HE351 code for me78569

Started by me78569, June 11, 2015, 09:38:57 AM

me78569

I got the OBD in, 

And ugh.

It doesn't like to connect to the truck, sometimes it does, others it doesn't.  Then when it does the obd read is slow enough to make the turbo cycle lol. 

Too cold out there for me to dig too much, but my code worked on the first try lol. 
2000 Dodge 2500 quad-cab 5.9 Cummins slt, homebuilt 47re revmax 3.5 messed with vb, Quad adr iquad, 4" tbe , pureflow 150 gph. he351ve in the works 100hp DFI inj

Rx7man

Well that kinda sucks... it's pretty cold out here too.. -16C or 5F.. sure don't like doing anything without gloves on!
'94 dually,  67/67 HE351VE, NV5600, ~600hp
'93 ECLB 47RH, new toy truck, H pump project, 1000hp goal, 300K miles
93 XCLB auto, bone stock, 350K miles
93 XCLB 5spd, bone stock, 100K miles

me78569

Yea I need to spend some time working through the example code and see if I can get it to read.
2000 Dodge 2500 quad-cab 5.9 Cummins slt, homebuilt 47re revmax 3.5 messed with vb, Quad adr iquad, 4" tbe , pureflow 150 gph. he351ve in the works 100hp DFI inj

me78569

Well I think I hit the wall.  While the obd reader does support the right buadrate it doesn't support j1939, ugh. 

I figured since it was built on the eml327 adapter that it would work for what I need since my cheapo eml 327 works fine.

Time to open up my eml327 and see if it has previsions on the board for serial tx/rx
2000 Dodge 2500 quad-cab 5.9 Cummins slt, homebuilt 47re revmax 3.5 messed with vb, Quad adr iquad, 4" tbe , pureflow 150 gph. he351ve in the works 100hp DFI inj

hakcenter

I'm confused. Does it use too many pins? You can't read can bus on and obd at the and time with multiple shields?
TS2009 Deḇarim 8:2
"And you shall remember that יהוה your Elohim led you all the way these forty years in the wilderness, to humble you, prove you, to know what is in your heart, whether you guard His commands or not.

me78569

the obd reader I bought that was built around arduino with a library etc does support the j1939 protocol for whatever reason ( I think the reader isn't speced for the right pins on the obd.

I am now just working through AT commands to read the obd data that is in serial form from my cheapo eml327.  I should be able to read the data directly using the Arduino without the obd library that the other reader uses.

hopefully since the em327 can read the PID's I want I can sniff it out of the data stream.
2000 Dodge 2500 quad-cab 5.9 Cummins slt, homebuilt 47re revmax 3.5 messed with vb, Quad adr iquad, 4" tbe , pureflow 150 gph. he351ve in the works 100hp DFI inj

me78569

#246
so I have been working through getting the OBD serial stuff coded. 

I am finding that there needs to be a delay between the serial.print and serial.read This could really throw a wrench in things.

Thoughts on doing something like
 
if(timer % 100) { serial.print("010c");

if timer % 200) { serial.readstring();}



or


adc_roll_over++;
// There functions will need to be calibrated to the sensor.
  if (adc_roll_over == 1) { serial.print("010c"); }
  if (adc_roll_over == 2) { engineRpm = serial.readstring(); }   Plus some math to convert from hex to decimal
  if (adc_roll_over == 3) { adc_roll_over = 0; }


or something similar to space the serial send and read?  I am assuming that since I am not using the serial section of your code that the serial message should sit in the buffer? 
2000 Dodge 2500 quad-cab 5.9 Cummins slt, homebuilt 47re revmax 3.5 messed with vb, Quad adr iquad, 4" tbe , pureflow 150 gph. he351ve in the works 100hp DFI inj

hakcenter

Well yeah there needs to be a delay because it takes time to process your request.

Alternate with a switching boolean
TS2009 Deḇarim 8:2
"And you shall remember that יהוה your Elohim led you all the way these forty years in the wilderness, to humble you, prove you, to know what is in your heart, whether you guard His commands or not.

me78569

Well I am not sure the truck can talk fast enough to work for what I need.

I am sending and receiving serial data via the elm327, but it is SLOW.    not sure where to go from here, I need a break from it for a bit lol. 
2000 Dodge 2500 quad-cab 5.9 Cummins slt, homebuilt 47re revmax 3.5 messed with vb, Quad adr iquad, 4" tbe , pureflow 150 gph. he351ve in the works 100hp DFI inj

hakcenter

Data rate should be around what 30-40hz ? Should be fast enough for basic sampling.
TS2009 Deḇarim 8:2
"And you shall remember that יהוה your Elohim led you all the way these forty years in the wilderness, to humble you, prove you, to know what is in your heart, whether you guard His commands or not.

me78569

38400 is supported,

My loop was taking 175ms to complete.   I am rewriting now without any 3rd party library and strictly serial commands.  I am gonna try again tomorrow and see what I can do with it.   I think if it is going to work I need to work through how much of a delay there is between the serial send and when the request comes back from the PCM.  If I can do other stuff in the code then go back and read the serial buffer it might work.   
2000 Dodge 2500 quad-cab 5.9 Cummins slt, homebuilt 47re revmax 3.5 messed with vb, Quad adr iquad, 4" tbe , pureflow 150 gph. he351ve in the works 100hp DFI inj

me78569

Alright I think I am gonna be able to make it work.   I am now not using any outside libraries to talk to the OBD.  I struggled most of the day because I forgot to use Serial.println(); instead of Serial.print();  The ELM327 wasn't reading the serial string due to the missing "\r" after the serial print. 
'
Now I need to figure out the rest.  I know all the commands I need to send via serial, but I am struggling with how to read a hex return and translate that to an usable int.  Biggest issue I have is I am not sure how to read the full return. 

If I send the command ("010c") for rpm request I am expecting to see something like "00 00" if engine off or 0 rpm. or any series of hex to signal the rpm

Back to reading and the endless google pit.
2000 Dodge 2500 quad-cab 5.9 Cummins slt, homebuilt 47re revmax 3.5 messed with vb, Quad adr iquad, 4" tbe , pureflow 150 gph. he351ve in the works 100hp DFI inj

hakcenter

I'm going to crudely reply.

if 2 bytes back

int value = 0;
if (Serial.available() > 1) {
    value = 0;
    value = (int) strtol(Serial.read(), 0, 16);
    value += (int) strtol(Serial.read(), 0, 16);
}
if (Serial.available() > 0) {
    value = 0;
    value = (int) strtol(Serial.read(), 0, 16);
}


No idea if you're receiving /r/n etc so you may want to catch those and discard.
TS2009 Deḇarim 8:2
"And you shall remember that יהוה your Elohim led you all the way these forty years in the wilderness, to humble you, prove you, to know what is in your heart, whether you guard His commands or not.

me78569

That's pretty similar to what I wrote, THANKS!!!! Your's , as normal, is less complicated than mine haha.  I felt like a blind man haha.   

I am unsure on the \r\n also.  I know when I talk to the elm327 via my laptop using terminal I don't get a \r or \n but I am unsure if the terminal program filters that.

question for you,  The hex sent by the computer is in form 00 00  I am guessing that 00 00 is considered 2 bytes? each one in it self is consider a byte correct?  So you need to combine both bytes into a string then convert to make it an usable integer? hence the need for the if statement >1 or >0? 

I just want to make sure I am not misunderstanding this whole thing.   
2000 Dodge 2500 quad-cab 5.9 Cummins slt, homebuilt 47re revmax 3.5 messed with vb, Quad adr iquad, 4" tbe , pureflow 150 gph. he351ve in the works 100hp DFI inj

Rx7man

00 00 can mean anything.. typically, if you're speaking HEX, you prefix it with '0x' to make it evident.. it takes 2 characters to display one byte in hex, so 0x00, 0x00 is indeed 2 bytes.

Isn't there something in the Arduino where you can specify "high byte" and "Low byte"? don't know if it takes hex, but might be worth checking out
'94 dually,  67/67 HE351VE, NV5600, ~600hp
'93 ECLB 47RH, new toy truck, H pump project, 1000hp goal, 300K miles
93 XCLB auto, bone stock, 350K miles
93 XCLB 5spd, bone stock, 100K miles