oldcarguy85
- 1st August 2007, 00:53
Hey there,
I'm very new at this basic programming stuff, but here is my question. im working on an lcd project for my car that interfaces with the ECU. there is a data port on teh ecu to connect to. The ECU program has been modified such that you can send a byte and receive a byte back. depending on what i send i should get info about different sensor readings. This is a basic TTL interface and should not be too difficult. i am able to send data and recieve data with a laptop and a serial->TTL converter. However, my pic16f877 seems to be having issues with the communication
here is the pertinent code:
SERIN2 in_pin,ser_baud,[tempval] 'get input from computer
serout2 me_out,6,[tempval] 'send this data to the ecu
serin2 me_in,6,4000,loop,[test2] 'get the response from the ECU
serout2 out_pin,ser_baud,[test2] 'spit it back to the PC
this is basically whats in my main loop.
i am able to communicate correctly with two computers hooked up with two ttl converters. So i know the communication should work. I think it has something to do with timing, such that possibly the PIC is recieving the data from the ECU before it gets to the serin2 command. im not sure. any help would be greatly appreciated. o btw the ECU operates at 38400 baud rate thast why theres a 6 there.
thanks,
Jordan Cary
I'm very new at this basic programming stuff, but here is my question. im working on an lcd project for my car that interfaces with the ECU. there is a data port on teh ecu to connect to. The ECU program has been modified such that you can send a byte and receive a byte back. depending on what i send i should get info about different sensor readings. This is a basic TTL interface and should not be too difficult. i am able to send data and recieve data with a laptop and a serial->TTL converter. However, my pic16f877 seems to be having issues with the communication
here is the pertinent code:
SERIN2 in_pin,ser_baud,[tempval] 'get input from computer
serout2 me_out,6,[tempval] 'send this data to the ecu
serin2 me_in,6,4000,loop,[test2] 'get the response from the ECU
serout2 out_pin,ser_baud,[test2] 'spit it back to the PC
this is basically whats in my main loop.
i am able to communicate correctly with two computers hooked up with two ttl converters. So i know the communication should work. I think it has something to do with timing, such that possibly the PIC is recieving the data from the ECU before it gets to the serin2 command. im not sure. any help would be greatly appreciated. o btw the ECU operates at 38400 baud rate thast why theres a 6 there.
thanks,
Jordan Cary