Anyone interested in developing an OBD Arduino based fuel economy gauge should post here. So far, I have been working on one based around an ELM323 OBD to RS232 adapter. Some previous discussion on this was on the other thread (Any interest in developing an open source fuel economy gauge/computer?)
Currently, I was able to connect to the ELM and send it commands. However, when sending OBD commands (010c), the response is "ELM INIT:...>" without ERROR or OK and no real data is received.
I'm definately interested, but I have to wait. Just a couple thoughts in case this takes off w/out me.
There are so many things that you can display from the obd port that this probably would be a good 4x20 LCD candidate.
Since this is a "higher end" version than the injector based gauge, it's probably ok that it costs a little more (i.e. elm chips, bigger LCD, etc).
Also, I *think* all cars are coming out with the CAN bus now, don't know if that is just North America or what. I did see an atmel CAN processor recently (OBD support built in), but do not know how 'duino compatable that will be, if 'duino is even in the cards for the obd effort (would be nice to not have to learn another platform).
Anyway, there is a lot of interest in the obd approach. It can obviously be a useful tool for your average driver. I do hope something comes of it, at least for the hobby crowd who want complete control of the display AND mpg feedback. The scangauge is not terribly expensive though, so building your own obd mpg gauge will probably be even more of a niche than the injector based version.
New comer here, I wanted an SGII but I find it pricey, then I discovered your project, pretty cool!
I will have to buy a *duino kit to test, with an LCD screen. And I guess an ELM323 for my car. A few months ago I started to look at various obd2 solution including ELM, jeff interface, palm, 486 laptop, etc.
(I am currently working on a digital and analog I/O low level module on an Atmel AT91, an ARM 32bits RISC, so I know the stuff, and if I have time I will work on your code too).
Great project guys, continue!!
EDIT:
I am wondering if we really need an ELM chip, or if we just communicate directly in the OBD-II protocol, like the "Atmel AVR 2004 Design Contest Project" at http://www.circuitcellar.com/AVR2004/first.html
Maybe wait also for the Atmel 328P to have more RAM?
We should bring also the "xarias" guy here for some help.
EDIT2:
Here's how to connect the OBD-II connector directly to an Atmel: http://prj.perquin.com/obdii/
(see Microcontroller-OBD interface, second picture)
I doubt you need an ELM323, on AVRFreaks a couple of people did it without an ELM. Search "obd" on their forums, some people even give some C codes to do it. It seems the ELM is slow too.
I'm sure we can drop the ELM.
To init the OBDII you send 0x33 at 5 bauds then you switch to 10400 bauds and send some commands, plug the Atmel directly on the OBDII like this:
(ISO protocol only)
You could also switch to an AT90CAN128 to speak CAN to your car I guess?
Lightner's article, posted above by Magister, is very well written and in depth. He offers schematics to properly handle the vehicle's 12V power supply and an in depth examination of the J1850 VPW protocol. The end of his article claimed circuit cellar (magazine running the story) would cover all the protocols in the future, but I haven't been able to find them.
In any case, I found the calculations necessary to convert OBD-II PID's to MPG. The information is also posted in the main instrumentation forum. All from Bruce Lightner's mind:
The calculation depends on whether your car has a MAF sensor or not.
14.7 - grams of air to 1 gram of gasoline - ideal air/fuel ratio
6.17 - pounds per gallon - density of gasoline
4.54 - grams per pound - conversion
VSS - vehicle speed in kilometers per hour
0.621371 - miles per hour/kilometers per hour - conversion
3600 - seconds per hour - conversion
MAF - mass air flow rate in 100 grams per second
100 - to correct MAF to give grams per second
No MAF (Uses MAP and Intake Temp to approximate MAF):
MAP - Manifold Absolute Pressure in kPa
IAT - Intake Air Temperature in Kelvin
R - Specific Gas Constant (8.314 JM/K)
MM - Average molecular mass of air (28.97 g/M)
VE - volumetric efficiency measured in percent
ED - Engine Displacement in liters
This method requires tweaking of the VE for accuracy.
I have no idea if these are the methods the SGII uses. The accuracy will be off due to approximations (AFR ~14.7, etc). All the information is from the brilliant mind of Bruce Lightner.
Ok it seems we do not need a "jeff interface" or transistors to connect the K line to the TX/RX of the chip, a single Motorola/Freescale chip already exist that does everything: the MCZ33290EF
Quote:
The MC33290 is a serial link bus interface device designed to provide bi–directional half–duplex communication interfacing in automotive diagnostic applications. It is designed to interface between the vehicle’s on–board microcontroller and systems off–board the vehicle via the special ISO K line. The MC33290 is designed to meet the “Diagnostic Systems ISO9141” specification.
It's the chip used in the Blafusel "KL interface serial cable" and also a obd2-lcd device.
- a Freeduino serial V2.0 + LCD display at NKC ($17+$10)
- an OBD plug at CarPlugs.com ($5)
- a sample MCZ33290EF from Freescale ($0)
I should be in business, I will find a 510 ohms resistor somewhere here and some push buttons, it's the only component needed.
I even started to write some codes, I started with standard C but why re-invent the wheel to support digital I/O and all, it's in the Wiring/IDE already. So I went back to the standard IDE, and it will be easier to share with other people.
It compiles, obviously it's not tested, copy/paste in IDE
EDIT July 3rd: Maybe I will not update this post anymore, for all information go to the homepage of the project at http://code.google.com/p/opengauge/
Do not plug it into a PC!!! This goes to an interface only!!!
You can make it yourself with an OBD-II plug available at http://www.carplugs.com/ for $5+$3sh.
Use at least AWG24 wires especially for Battery and Chassis ground.
INTERFACE
-------
The cable goes into an interface to adapt the ISO signal for the Arduino input.
It concists of a small IC, a resistor, a DB9M that will be plugged with the cable mentionned above, and a few wires that connect to the Arduino board.
Schematic is like this:
all I gots to say is...AWESOME! I've been working on this exact thing off and on for a while and thought I was completely on my own, nice to know there's others more intelligent than I working on it as well. I built a usb-obdii interface using a pic and it works with pwm, which is what my car uses. I've got an extra set of chips from that project that I could use if it comes down to it, but I'd rather just use straight arduino if I can. Anyone seen any of the low-level info about pwm, besides the message formats and such? So far all I have is my 4x20 lcd hooked up and laid out, and the message frames all compiled, I just have to figure out how to get the right signals sent (whether I need to use a rs232 converter chip or if I could bit bang it or something).
Oh yeah, and another thing I learned from my last project is...SAMPLES!!!! I didn't have to pay for a single chip on that project, plus I have extras now to use if need be
I have an arduino board and I was looking into doing the same thing! I haven't started because I lacked the time... Untill now. I will place a sample order too, allthough it costs money for oversea sampling (6$), its still cheaper as at farnell (actually not, but i need to order 98 pcs at least over there)...
Well, I'm folowing this thread very closely, and I'll try to contribute some code
Thanks! well, from what I've gathered, and looking at the schematics from the usb adapter I built, there should be no extra hardware needed for pwm, as the pic on that board just drives 2 transistors for 5v (which I think is what the arduino digital pins are, no?). I've also gathered that pwm at the physical layer is a balanced bus of +/- 5v in reference to each other. I'm still trying to get my head wrapped around it, but it's comforting that we should be able to do it without extra hardware.
I have most of the parts on the way for the freeduino setup. I also have the chip and the LCD coming. Once I have everything connected, Im not sure how to do the programing for the device. If anyone can help me, it would be greatly welcome.
P.S. Sorry if i havent read enough of the other threads on this forum, But im new at this and need help.
Download the IDE from their web site and install it. Once you have a little program made, in the IDE you can compile it and send it to the board via Serial/USB.
Note that the "OBDuino" project is very very young for the moment, we have the hardware but no software
That helps out some. One big problem is that I know NOTHING about programming. And that being the case I should probably give up. If anyone has some code already written that I could use it would be greatly appreceated. Also is there anything else I need?
Current items on the way:
1 freeduino v2.0 board
1 2x16 LCD display
1 MCZ33290EF sample from freescale
1 serial to obdII cable
If there is anything else I need, please let me know.
I plan to plug the OBD2 signal (from the freescale chip) on pin 2 and 3 of the board, the RS232 on the board will be used to send debug message on a terminal screen, so you will have to either make an adapter or cut your obd2-serial cable to plug the right pins.
For the moment, no, there is absolutly no "OBDuino" code for the project!! I started to write some code, blindly, as I have no hardware to play with!
I will work on getting parts ordered tonight and start building, I might be able to help with the code once I get the hardware.
__________________
2007 Honda Civic Ex
Second Goal = 50mpg
First goal = 40mpg Goal Achieved 3 tank average over 40mpg
Starting point 30mpg ready...... GO.
hé, we're not that far, I go through Albany when I go in vacation
I continued my code to write a function to send an ISO string, a command is 7 bytes length maximum IIRC. The same function will return the response and the number of received bytes.
I plan to have four pointers to function to display the four info in the four corners, prototype something like
void (*topleft)(void);
void (*topright)(void);
void (*bottomleft)(void);
void (*bottomright)(void);
then in the config it will assign what you want, e.g. if you want to have the instant MPG in the top left, the config will assign the pointer of the function to the topleft() one. Let's assume a function cal_inst_mpg() calculate it, the config will just do:
topleft=cal_inst_mpg;
and in the loop() it will do:
loop()
{
// read a couple of value
iso_read_whatever