Show Posts
Pages: [1] 2 3 4
1  Using Arduino / Project Guidance / Re: Reading OBD(1) data from Toyota Corrola 1992 .... on: September 11, 2014, 08:33:45 am
Revised code smiley
2  Using Arduino / Project Guidance / Re: Reading OBD(1) data from Toyota Corrola 1992 .... on: September 11, 2014, 05:49:23 am
I thought of doing it this way, the #define was added after I done the first part of getdata smiley
I will make  the change its a good comment smiley

I'm waiting for the new screen to arrive, once its here I will make a video with the data output.

3  Using Arduino / Project Guidance / Re: Reading OBD(1) data from Toyota Corrola 1992 .... on: September 10, 2014, 04:29:33 am
Great day ...
Added a button on int1 (pin3) ...
Have 3 diffrent output on the screen:
SPEED / RPM
8 main data (1->smiley-cool
Flag as binary ...

Had to adjust the "lost connection" to 3500 ms to prevent the slight errors that happens at time when the button is pressed ..

I need to make some video of this .. the only problem is that the OLED I'm using got damaged (by me applying to much force trying to mount it) and its all messed up (still readable) ... will have to wait till the new one gets here smiley

Let me know what u think of the code ....
4  Using Arduino / Project Guidance / Re: Reading OBD(1) data from Toyota Corrola 1992 .... on: September 10, 2014, 12:32:44 am
Did some work on the code.
I think the datasheet I have on the output is a bit different then yours, or I'm not getting the math right.
I added this function
Code:

// GET DATA FROM OBD
float getOBDdata(int OBDdataIDX) {
 // define return value
  float returnValue;
  switch (OBDdataIDX) {
    case 0:// UNKNOWN
        returnValue = ToyotaData[0];
        break;
    case 1: //  Injector pulse width (INJ) - in milisec
        returnValue = ToyotaData[1]/10;
        break;
    case 2: // Ignition timing angle (IGN) - degree- BTDC
        returnValue = ToyotaData[2]-90;
        break;
    case 3: //Idle Air Control (IAC) - Step # X = 125 = open 100%
        returnValue = ToyotaData[3]/125*100;
         break;
     case 4: //Engine speed (RPM)
         returnValue = ToyotaData[4]*25;
         break;
     case 5: //Manifold Absolute Pressure (MAP) - kPa Abs
         returnValue = ToyotaData[5];
          break; 
    case 6: // Engine Coolant Temperature (ECT)
          if (ToyotaData[6] >= 244)
            returnValue = ((float)(ToyotaData[6] - 244) * 10.0) + 132.0;
          else if (ToyotaData[6] >= 238)
            returnValue = ((float)(ToyotaData[6] - 238) * 4.0) + 103.0;
          else if (ToyotaData[6] >= 228)
            returnValue = ((float)(ToyotaData[6] - 228) * 2.1) + 80.0;
          else if (ToyotaData[6] >= 210)
            returnValue = ((float)(ToyotaData[6] - 210) * 1.11) + 60.0;
          else if (ToyotaData[6] >= 180)
            returnValue = ((float)(ToyotaData[6] - 180) * 0.666) + 40.0;
          else if (ToyotaData[6] >= 135)
            returnValue = ((float)(ToyotaData[6] - 135) * 0.444) + 20.0;
          else if (ToyotaData[6] >= 82)
            returnValue = ((float)(ToyotaData[6] - 82) * 0.377) + 0.0;
          else if (ToyotaData[6] >= 39)
            returnValue = ((float)(ToyotaData[6] - 39) * 0.465) + (-20.0);
          else if (ToyotaData[6] >= 15)
            returnValue = ((float)(ToyotaData[6] - 15) * 0.833) + (-40.0);
          else
            returnValue = ((float)ToyotaData[6] * 2.0) + (-70.0);
       
         break; 
    case 7: // Throttle Position Sensor (TPS) - DEGREE
         returnValue = ToyotaData[7]/2;
         break;       
    case 8: // Speed (SPD) - km/h
         returnValue = ToyotaData[8];
         break;
    case 9:// UNKNOWN
        returnValue = ToyotaData[9];
        break;
    case 10:// UNKNOWN
        returnValue = ToyotaData[10];
        break;   
    case 11:// FLAG #1
        returnValue = ToyotaData[11];
        break;
    case 12:// FLAG # 2
        returnValue = ToyotaData[12];
        break;   
    default: // DEFAULT CASE (in no match to number)
      // send "error" value
      returnValue =  9999.99;
   } // end switch
  // send value back
  return returnValue;
} // end void getOBDdata

I used your great temp calc- which I could not figure out of the document I had.
Not sure which of he calculation is correct.
I also added this :

Code:


// "names" for the OND data to make life easier
#define OBD_INJ 1 //Injector pulse width (INJ)
#define OBD_IGN 2 //Ignition timing angle (IGN)
#define OBD_IAC 3 //Idle Air Control (IAC)
#define OBD_RPM 4 //Engine speed (RPM)
#define OBD_MAP 5 //Manifold Absolute Pressure (MAP)
#define OBD_ECT 6 //Engine Coolant Temperature (ECT)
#define OBD_TPS 7 // Throttle Position Sensor (TPS)
#define OBD_SPD 8 //Speed (SPD)

which then makes it much easier to read a code like this :


Code:
etOBDdata(OBD_SPD)

Also added

Code:
#define DEBUG_OUTPUT true

// dfeine connection flag and last success packet - for lost connection function.
boolean OBDConnected;
unsigned long OBDLastSuccessPacket;


// AND THIS IS LOOP NOW

// VOID LOOP
void loop() {
 
  // if found bytes
  if (ToyotaNumBytes > 0)  {
    if (DEBUG_OUTPUT) { debugdataoutput();  }
     // draw screen
     drawSpeedRpm();
     // set last success
     OBDLastSuccessPacket = millis();
     // set connected to true
     OBDConnected = true;
     // reset the counter.
     ToyotaNumBytes = 0;
  } // end if (ToyotaNumBytes > 0)
 
  // if found FAILBIT and dbug
  if (ToyotaFailBit > 0 && DEBUG_OUTPUT )  { debugfaildataoutput(); }
 
  //check for lost connection
  if (OBDLastSuccessPacket + 2000 < millis() && OBDConnected) {
    // show no connection
     displayNoConnection();
     // set OBDConnected to false.
     OBDConnected = false;
  } // end if loas conntcion
 
} // end void loop


Since now there is output in diaplay using the u8glib I need to know if the system lost connection .. IE the arduino is on but no signal from the car - it will not get "stuck" on the last display - so now it will just show the "no signal" display smiley


I attached the current version of the code I have.

Next on my list to add a button that will allow to toggle between different data output. the main one will stay the SPEED/RPM but on the immediate list is output of all available known values and an output of all the flags - and then try to find the rest the flags

Let me know what you think ... I will be happy to get any improvements to the code ... I'm not a C expert ... you seem to do a much better work smiley


5  Using Arduino / Project Guidance / Re: Reading OBD(1) data from Toyota Corrola 1992 .... on: September 09, 2014, 05:48:08 am
Good work on the temp ... I had no clue how to go about it. does it work well ?
Did you see the PDF I posted on this thread ?
It has some of the info of what each byte is and how to decode them.





6  Using Arduino / Project Guidance / Re: Reading OBD(1) data from Toyota Corrola 1992 .... on: September 09, 2014, 02:34:18 am
I got it to work perfectly with your code by adding a 100nf capacitor on the data line for debounce  smiley

I did spend good 3-4hrs till I got there.
For debug I output (serial) the BIT counted (and the millis passed) on the CHANGE and noted that once the engine is running there is a "noise" on the data line and no code can help with that... so after few trials (different value capacitors) I got it to work well. and since I already had the code for the output on the OLED I could see the output on the screen.

While working on this I also found out that only by luck my code was working (kinda ok) ... and the reason for that is that I had a VERY high value (24k+) on the delay micros and only today I noticed it (again since it was working ok)
at some point I thought "hey - so how the hell does it work ???" ....
Then when I outputted the micros() on each end of a line and it showed about 1.25 sec interval between each read ...  which blow my mind - I thought I was going crazy.
So I went to the code reference and found this : "Currently, the largest value that will produce an accurate delay is 16383. " - LOL .. in an "magical" way it brought it down to about 8000-9000 micros which is about right smiley

Learned a lot today about debounce  and digital comm.

I will work some more on the code and get it more organised and then I will upload it to here.
 
Thank you GadgetFreak  for the great code and for all the help.



7  Using Arduino / Project Guidance / Re: Reading OBD(1) data from Toyota Corrola 1992 .... on: September 08, 2014, 05:26:12 am
Thank you very much for the detailed answer.
I'm going to run some tests tomorrow and see if I can "adjust" it better.
Will let you know what I found out.
8  Using Arduino / Project Guidance / Re: Reading OBD(1) data from Toyota Corrola 1992 .... on: September 08, 2014, 12:05:47 am
Hi,

I tried the modified code and it worked well - as long as the car was not started. was the engine was running I had issues.
I use an opto coupler as well and as I mentioned with my code I had no issues like that.

I really like the fact that your code free time for other tasks and I can get it to work now with the u8glib lib which I could not before due to long processing time on the lib draw function.

Can you tell me how you connected the data line ?

I use 4n35 Optocoupler, I tried hoking the data out of the car directly to it, but it did not work, so had to use a 2n2222 to amplify the single.   

One more thing  I would love to add to the code is "lost connection" dedection, but I guess it can be added in the loop with a check to see when the last data update happened and if its longer then lets say 3sec. to show "lost connection" on  screen. I had it set up on my code for display purpuse

Thanks for all the help.
9  Using Arduino / Project Guidance / Re: Reading OBD(1) data from Toyota Corrola 1992 .... on: September 07, 2014, 05:06:00 am
Well the first 4bits on my car is "0110"
When the care is first start I get this unique string : "101111111110000000000000000"
then every line of data starts with (16x1 + 0110) "11111111111111110110" then the rest of the 13 words data parts....
And on top of that, word-0 (zero) actually starts with a 1 bit not 0 bit like the rest of the words ... to make it a bit harder smiley-wink
Is it the same on your car ?
10  Using Arduino / Project Guidance / Re: Reading OBD(1) data from Toyota Corrola 1992 .... on: September 06, 2014, 11:17:57 pm
Hi GadgetFreak,

I took your code and since my signal is not reversed and I'm using an UNO (I'm assuiming you are using DUO) I made the following changes in the code and added a 12K resistor between PIN-D2 with and ground (instead of the pull_up in the code).

#define ENGINE_DATA_PIN 2 // pin 2
#define ENGINE_DATA_INT 0  // for attachInterrupt
#define LED_PIN          13


// I have inverted the Eng line using an Opto-Coupler, if yours isn't then reverse these low & high defines.
#define  MY_HIGH HIGH //LOW
#define  MY_LOW   LOW //HIGH


#define  TOYOTA_MAX_BYTES  24
volatile uint8_t ToyotaNumBytes, ToyotaID;
volatile uint8_t ToyotaData[TOYOTA_MAX_BYTES];
volatile uint16_t ToyotaFailBit = 0;

void setup()
{
  Serial.begin(115200);
  Serial.print("system Started");
  pinMode(ENGINE_DATA_PIN, INPUT); // _PULLUP
  pinMode(LED_PIN, OUTPUT);
  attachInterrupt(ENGINE_DATA_INT, ChangeState, CHANGE);
}



But the only result I get is "Fail 4 firtbit" ....

I know my code is a mess ... but it never failed me yet ... and I just came back from a 20 min ride with an OLD screen display and the speed + rpm were showing normal reading all the way smiley
M ycode might have glitches and points when it lose data - but none that I have seen so far - for example strange spike in the speed or rpm value ....

If you have any suggestion on how to get your code working on none-reverse I would love to hear and test them out on my system.

Thanks
11  Using Arduino / Project Guidance / Re: Reading OBD(1) data from Toyota Corrola 1992 .... on: August 27, 2014, 01:17:25 am
I have attached the code, it is set to work I2C 16X2 LCD screen, but it outputs to the SERIAL as well.
The code it self is pretty simple and can be improved,  I might work on that later on, but for start all I wanted is to get the RPM and the SPEED which I did.
If you scroll in this post to the one starting with "After hours of reading and trial and error I..." you can see I attached a PDF that show how the output of the data looks like ..
I found few miss match to the data I sow on mine (long start string + different signuter string) , but in general its the same.

I'm not working on output on a 1.3" OLED screen and run a test on the car to see that I can read it from where its going to be mounted. once I get that done I will try to make a video and show all the connections as well.

If you need any help let me know.
12  Using Arduino / Project Guidance / Re: Reading OBD(1) data from Toyota Corrola 1992 .... on: August 18, 2014, 09:00:51 pm
I will be more then happy to share both the code and the setup I did.
Basically what I did is to amplify the pulse with a 2n222 and separated the 12V data from the 5V read of the arduino with an optocoupler.
I do not remember the list of things that the computer output - but I'm 99.9% sure that Km. done are not a part of it - so fuel consumption is not possible smiley
But temp of engine and speed/rmp exists .. I will add a file with the list I worked from.
I'm currently not home but once I get back home (in a week or so) I will post the code and take some photos of the setup.
Just know one thing, the data that is available is transmitted every 1.25SEC in one long string  .. so the data you can show will have a 1.25sec delay from its reading point .....
13  Using Arduino / Project Guidance / Re: Reading OBD(1) data from Toyota Corrola 1992 .... on: June 28, 2014, 02:08:51 am
It was not simple .... but I made it !!
I now have a big LCD screen and using the GLCD library I now output the RPM (tested) and SPEED (was not tested yet) on the screen.
Also, if the line is lost - like in the case of switching the car off - a "lost connection" alert will show... and the system will wait for the next set of data stream to be picked up.

I'm now trying to get it into the car, since the OBD is under the hood. I only need to run one wire to the car - the rest (5V + GND) I can get from the cigarette lighter connection ...

The only down side of it all .. the data get refreshed (or transmitted) only every 1.25 Seconds .... but better then nothing.

I will post some more info once I get it done and run a test ....


14  Using Arduino / Project Guidance / Re: Reading OBD(1) data from Toyota Corrola 1992 .... on: June 24, 2014, 10:27:01 pm
After hours of reading and trial and error I can tell for sure that the data is there ... now I'm trying to read it using an arduino mega.
But having some issues since they have a different pattern for the serial - then one that I could find on the begin command.
I know its baud 96 (100) ...
I made several attempts of reading the data (via Seral1 - baud 100 in all the 2 end bit options) and sending it to the computer via the Serial.
I get an output but can not make a pattern out of it - and I'm guessing it has to do with the starting 16bit + 4bit as shown in the PDF.
Any one can help me out with a code that might help me over come this issue ?

Any helps, tips, questions will be highly appropriated .. would love to be able to finish this project 
15  Using Arduino / Project Guidance / Re: Reading OBD(1) data from Toyota Corrola 1992 .... on: May 04, 2014, 03:17:39 am
Again, thanks for your reply smiley
Here (North of Thailand) thus tools are harder to come by smiley-wink
I think that even If I try to go to Toyota Main shop here - they might look at me like crazy smiley-wink

My hope will be that the combination of the OBDII 2 USB connector -which I'm guessing is some form of SERIAL TO USB connection - with the s/w I found on the web (that can communicate with com ports) will do the trick.

And for the trial of it I'm willing to spend the $16.

I'm flying soon to Israel (where I'm originally from) and I hope maybe to find the answer while I'm there - I know a few people that know few people smiley

Thanks a million for all the help, If I find any thing new, or works things out I will post them here smiley
Pages: [1] 2 3 4