New Project-Automotive. Need a little help

Have questions about a SparkFun product or board? This is the place to be.

Moderators: phalanx, TS-Tim

Post Reply
CMS
Posts: 10
Joined: Mon Oct 19, 2009 4:59 pm
Location: Daytona Beach, FL

New Project-Automotive. Need a little help

Post by CMS » Mon Aug 16, 2010 4:36 pm

Hopefully someone can get me pointed in the right direction for this project. I've been reading so much my mind is spinning!

What I want to build is a 3 digit (7 sement) digit LCD display for a 0-5v input signal scaled from 0% to 100%.
It's an automotive application where I want to have a universal box that I can connect to a throttle position sensor output (0-5v) and be able to use a switch to set 0% at one voltage and then use another switch to to set 100% at a different voltage. Once set, the box would display 0-100% of the throttle position depending on the voltage.

It's a linear a/x+b scaling on one analog input driving a display with user set offsets.

If this were your project where would you start? Any tips/pointers would be much appreciated.

Thanks!

bill190
Posts: 101
Joined: Sat May 01, 2010 8:03 am
Location: Oregon

Re: New Project-Automotive. Need a little help

Post by bill190 » Mon Aug 16, 2010 7:02 pm

If you are not familiar with programming microcontrollers, the easiest to start with is the Parallax Basic Stamp. They sell those here. EZ, excellent documentation, and support.

Their forum at the following link has excellent advice and even an electrical engineer who answers questions. Post on the Basic Stamp forum (same question)...
(Click on forums...)
http://www.parallax.com

60amp_relay
Posts: 44
Joined: Fri Feb 26, 2010 12:12 pm

Re: New Project-Automotive. Need a little help

Post by 60amp_relay » Mon Aug 16, 2010 7:25 pm

The Parallax Basic Stamp is an easy way to get started with microcontrollers (which is eventually what you want here) The trouble is I don't know of a direct way to read an analog voltage using the Stamp. I suppose you could use a discrete ADC, like an ADC0831CCN or something similar, but in that case you might be better off jumping in with both feet and using a PIC or AVR that has a built-in ADC.

Are you new to electronics? I couldn't tell from your post if you're just getting started, or an old hand, so the following may not be applicable, but it might help to start off with a proof-of-concept design. Just an idea for the sake of design simplicity, you could build a 5-LED bar graph from a single quad voltage comparator (like an LM339N) and a handful of resistors. Two green LEDs, one yellow LED, and one red LED connected to the 4 outputs of a quad comparator through 1K resistors would make up your display. The inverting (-) inputs of the comparator could be connected to a voltage divider at +1, +2, +3, and +4 volts, or so. Potentiometers at both ends of the divider would allow you to adjust the scale. All four non-inverting (+) inputs of the comparator would be connected to the throttle position sensor. The 5th (bottom) green LED would always be lit.

bill190
Posts: 101
Joined: Sat May 01, 2010 8:03 am
Location: Oregon

Re: New Project-Automotive. Need a little help

Post by bill190 » Mon Aug 16, 2010 8:06 pm

Again, excellent documentation. Here is one on A/D...
http://www.parallax.com/Portals/0/Downl ... l-v1.4.pdf

esklar81
Support Volunteer
Posts: 839
Joined: Thu Jan 21, 2010 10:53 pm
Location: San Francisco, CA, USA
Contact:

Re: New Project-Automotive. Need a little help

Post by esklar81 » Mon Aug 16, 2010 8:53 pm

CMS,
I suggest you have a look at Arduino. Although I haven't tried the Parallax Basic Stamp, it's hard to believe it would be significantly easier to use than the Arduino (both in terms of hardware and the development environment). Furthermore, Arduino gives you on-board analog-to-digital conversion (ADC).

It would be relatively easy to set it up so that you have a pushbutton to set each end of the range and a software mapping of the measured voltage to 0 - 100% of the difference between the setpoints. With a bit more work, you could have it display actual voltage until/unless the setpoints were entered.

The only concern I have is: It's not obvious to me how (without external, durable memory) you could have the device remember the setpoints when it's powered down. Of course, if you're willing to re-set the setpoints about as frequently as you need to re-set the clock in the vehicle, you could just wire this to have power from the car battery at all times.

Good Luck,
Eric

JonChandler
Posts: 226
Joined: Fri Jun 17, 2005 1:05 pm
Contact:

Re: New Project-Automotive. Need a little help

Post by JonChandler » Mon Aug 16, 2010 10:06 pm

This would be a simple project using either the free Amicus Compiler for a PIC18F25k20 or using free Swordfish Special Edition with a PIC18F2520 or similar chip with on-board EEPROM to store set points. Amicus and Swordfish are Basic compilers that are simple to use.

Either of these would be a great combination with the low-cost TAP-28 PIC application board. It's set up with dedicated connectors for real-world functions like reading analog sensors and sensors and connecting to display boards. The TAP-28 supports many PIC18F-series 28 pin parts.

Amicus: http://www.myamicus.co.uk/

Swordfish: http://www.sfcompiler.co.uk/swordfish/

TAP-28: http://www.clever4hire.com/throwawaypic/

Also, a lot of good references to using any of the above is:

http://digital-diy.com/
Jon

User avatar
thebecwar
Posts: 260
Joined: Sat Aug 14, 2010 8:48 am
Location: New Haven, CT

Re: New Project-Automotive. Need a little help

Post by thebecwar » Mon Aug 16, 2010 10:26 pm

I'd also go to the SAE's electronics page and buy the OBD-II specification document. TPS is a code you can pull from the ECM, plus you don't have to tune the min/max values for each vehicle you want to use it on.
~tB~

bill190
Posts: 101
Joined: Sat May 01, 2010 8:03 am
Location: Oregon

Re: New Project-Automotive. Need a little help

Post by bill190 » Mon Aug 16, 2010 11:20 pm

thebecwar wrote:I'd also go to the SAE's electronics page and buy the OBD-II specification document. TPS is a code you can pull from the ECM, plus you don't have to tune the min/max values for each vehicle you want to use it on.
That sounds like the most "fun" to me, but I am quite the programmer/geek type!

FYI - OBD II is on vehicles 1996 and later. Vehicles prior to that would not have this. Also I've read there is an OBD III coming out?

Is your device for just one vehicle? Or for any fuel injected vehicle new/old?

If you do want to go the OBD route, Microchip which makes Pic microcontrollers has a "CAN" topic on their forums. (CAN is an automotive networking protocol as well as others.) And they have certain microcontrollers with CAN functionality built in. If you have never programmed a microcontroller before, I would suggest getting your "feet wet" with something more simple first though.

Here is the Microchip forum...
(Scroll down to CAN about 1/3 of the way down)
http://www.microchip.com/forums/default.aspx

About CAN...
http://en.wikipedia.org/wiki/Controller_area_network

FYI GM uses CAN and GMLAN...
http://en.wikipedia.org/wiki/GMLAN

User avatar
thebecwar
Posts: 260
Joined: Sat Aug 14, 2010 8:48 am
Location: New Haven, CT

Re: New Project-Automotive. Need a little help

Post by thebecwar » Tue Aug 17, 2010 1:00 am

bill190 wrote:
thebecwar wrote:I'd also go to the SAE's electronics page and buy the OBD-II specification document. TPS is a code you can pull from the ECM, plus you don't have to tune the min/max values for each vehicle you want to use it on.
That sounds like the most "fun" to me, but I am quite the programmer/geek type!

FYI - OBD II is on vehicles 1996 and later. Vehicles prior to that would not have this. Also I've read there is an OBD III coming out?

Is your device for just one vehicle? Or for any fuel injected vehicle new/old?

If you do want to go the OBD route, Microchip which makes Pic microcontrollers has a "CAN" topic on their forums. (CAN is an automotive networking protocol as well as others.) And they have certain microcontrollers with CAN functionality built in. If you have never programmed a microcontroller before, I would suggest getting your "feet wet" with something more simple first though.
[...snip...]
You might consider the ELM327 instead, since different manufacturers/models use differing standards. The ELM chip supports AT commands, and all of the major bus topologies for OBD-II (J1939 PWM & VPW, CAN, ISO, J1850) and converts the data to RS-232 for your use. It internally handles the protocol, and allows you to send messages using ASCII characters (much easier to troubleshoot). This is the cheapest/easiest solution I've found so far for interfacing with a wide variety of vehicles, without having to figure out the bus topology manually, and manually pack data behind the connection specific headers.
~tB~

CMS
Posts: 10
Joined: Mon Oct 19, 2009 4:59 pm
Location: Daytona Beach, FL

Re: New Project-Automotive. Need a little help

Post by CMS » Tue Aug 17, 2010 4:40 am

Now that's a support community! Thanks everyone! :D

I'll start researching some of the chips and solutions that you've all given me, and come back with some questions when I get myself a little deeper into this project. In the mean time, Let's see if I can fill in some blanks for some of the responses here:
60amp_relay wrote:Are you new to electronics? I couldn't tell from your post if you're just getting started, or an old hand,
Quite familiar with electronics, but just getting started with designing my own devices. But I like the idea of the bar graph proof of concept, that sounds like a good starting point.
esklar81 wrote:I suggest you have a look at Arduino
I have an Arduino dev kit on the bench, and it seemed to be "overkill" for the application to me. I was going to start there, but if there was a simpler approach then I would take a look at that.
esklar81 wrote:The only concern I have is: It's not obvious to me how (without external, durable memory) you could have the device remember the setpoints when it's powered down. Of course, if you're willing to re-set the setpoints about as frequently as you need to re-set the clock in the vehicle, you could just wire this to have power from the car battery at all times.
Good point, I'm not sure if that would make it a pain or not, but I would think I could solve this with a lithium backup battery on the board and some memory. It's something I need to look into as most of the newer "drive by wire" vehicles won't go to 100% until the ECU decides that's OK, so setting the high point can't happen in the driveway.
JonChandler wrote:This would be a simple project using either the free Amicus Compiler for a PIC18F25k20 or using free Swordfish Special Edition with a PIC18F2520 or similar chip with on-board EEPROM to store set points. Amicus and Swordfish are Basic compilers that are simple to use.

Either of these would be a great combination with the low-cost TAP-28 PIC application board. It's set up with dedicated connectors for real-world functions like reading analog sensors and sensors and connecting to display boards. The TAP-28 supports many PIC18F-series 28 pin parts.
Jon, thanks for these suggestions, I didn't have this route on my radar, until now...

thebecwar wrote:I'd also go to the SAE's electronics page and buy the OBD-II specification document. TPS is a code you can pull from the ECM, plus you don't have to tune the min/max values for each vehicle you want to use it on.
I started to wanter down the OBDII path, but there's a few challenges with it that make reading the raw voltage a better solution. Plus the response time of OBD can be an issue.
bill190 wrote:If you do want to go the OBD route, Microchip which makes Pic microcontrollers has a "CAN" topic on their forums
I'm very familiar CAN, use it almost everyday. The challenge here would be getting the CAN address for throttle position for each and every ECU out there. Not to mention that most of the manufacturers use 29bit CAN address format, which would take forever to crack. The OBD-CAN protocol that has become more common now, but it's not on motorcyles yet.

coyote20000
Posts: 339
Joined: Mon Jun 07, 2010 12:27 pm
Location: Rahway, NJ

Re: New Project-Automotive. Need a little help

Post by coyote20000 » Tue Aug 17, 2010 7:12 am

I personally would use an arduino.
Feed the signal to the ADC. Throttle low, press a 'Min' button, store Min value into EEPROM. Throttle High, press a 'Max' button, store Max value in EEPROM.
((Throttle value - Min)*100)/(Max - Min) = %Throttle (If my math is correct.. lol)

Convert %Throttle to a string and send it to a serial display.

Dave

User avatar
thebecwar
Posts: 260
Joined: Sat Aug 14, 2010 8:48 am
Location: New Haven, CT

Re: New Project-Automotive. Need a little help

Post by thebecwar » Tue Aug 17, 2010 8:22 am

CMS wrote: I'm very familiar CAN, use it almost everyday. The challenge here would be getting the CAN address for throttle position for each and every ECU out there. Not to mention that most of the manufacturers use 29bit CAN address format, which would take forever to crack. The OBD-CAN protocol that has become more common now, but it's not on motorcyles yet.
As far as CAN address of the sensor, you don't need to know it to read the TPS. You request it by sending the OBD-II request at mode 0x01 for PID 0x11. It's defined by the standard as one of the required mode 1 sensors. The request returns only 1 byte (which on some implementations returns 8 bytes anyway) so it's actually farily fast to send, even at the 10400 baud of some of the ISO connections.

But like you said, OBD is not on motorcycles, and if that's your target application, you probably have no choice but to tap the sensor directly. Of course this adds in overhead for different designs of TPS, if you want to make the part removable. Another question, is the voltage change across the sweep of the sensor linear, or logarithmic?
~tB~

anhingus
Posts: 35
Joined: Sun Aug 22, 2010 10:48 pm

Re: New Project-Automotive. Need a little help

Post by anhingus » Mon Aug 23, 2010 4:06 am

what's with the arduino stuff?

you can get an intersil ICL7106, ICL7107, ICL 7135 [my choice] for $3 and no code.

7-segment drivers and displays and you are in business.

just enter the chip number as a web search for application data.

jrsimma
Posts: 6
Joined: Sun Sep 19, 2010 7:36 pm

Re: New Project-Automotive. Need a little help

Post by jrsimma » Mon Oct 10, 2011 7:49 pm

Guys, we also have J1939/CAN/J1587/J1708 adapters. Wireless, USB, RS-232, and UART.

J1939 to RS-232
J1939 to USB
J1939 to WiFi
J1939 to UART

Thanks,

JR

Post Reply