picbasic ISO 14230 5-baud init
Can anyone assist me with how to get a PIC to perform a 5-baud init please? I'm using picbasic & can't work out how to enable the K and L lines at 5 baud during initialisation then disable the L and dynamically change the baudrate to 10400 on the K line.
PS - I can't use ELM32x for this project, as once initialised I need to communicate with the ECU in a non-standard ISO way.
Do not know the PIC you are using but...
briefly -- this from memory so double check it before you implement it -- you need the ability to time up to 300+ milliseconds.
Originally Posted by chrisall
Sample the bus until you find it idle and then sample it continuously for 300mS to ensure it stays idle.
If idle at the end of 300mS then you need a way to time at least 200mS to send the 0x33 at 5 baud.
Then once that is out, look for a start bit and using a high resolution timer measure the time from the leading edge of the start bit to the falling edge of the 1st bit in the reply, the 1 of the 0x55 (sent in LSB/MSB order).
Then divide elapsed time between the starting edge of teh start bit and the falling edge of the 1st data bit by two and this is the bit time. Divide by 2 again and this is one half bit time and this is the amount of time by the processor's timer you are using you wait until you sample the data line for the next incoming bit.
Once you have that bit, the second bit of the 0x55 response, then use the whole bit time to sample what should be the middle of the next data bit, and so on.
If you receive the 0x55 ok then you have not only the bit time of the OBD2 bus and the engine controller but you have established communication with the ecu.