topleft
topright
ECU Reader
Sunday, 08 July 2007
This ECU Reader is based on a Microchip PIC16F877 microcontroller.


ECU Reader / Data Logger

      

This ECU Reader is based on a Microchip PIC16F877 microcontroller. Basic functions include reading and clearing of DTC. Reading measurement groups. The data logging stores the data in a 32k byte eeproms. A battery backed real time clock can date stamp the stored data.


The stored data can later be uploaded to a PC via the debug port.

     
  

Front view of PCB.                                                                    Back view of PCB

 

Si9241AEY

ISO K Line driver IC with short circuit protection and line fault output, manufactured by Vishay. Datasheet
£2.60

 

MC33290D

ISO K Line driver IC with short circuit protection, manufactured by Motorola. Datasheet
£2.50

 

  
  

Talking to the ecu is fairly simple if you understand initialization sequence. The protocol implemented is the KWP-1281.
It involves setting the serial port to 5 baud.
Send out a 0x01, this is done by bit bashing the Tx line.
Set serial port 10400 baud straight away and listen for 0x55 0x01 0x0a from the ecu.
Then you need to sent an acknowledge message of 0x03 0x02 0x09 0x03. The ecu will then sent the ecu id back like 1 . 8 L R 4 / 5 V T after another ack you are ready to sent to the ecu some real request.
A message of say 0x04 0xd0 0x29 0x75 0x03 request a block read of group 117 (0x75) which is engine speed, throttle position and throttle drive. All you have to do is parse the returned message.
Most people would be interested in the boost pressure so that is what I will do next.

Sample data read from the ecu and decoded information
F C1 E7 1 C8 0 21 FF A 21 FF 7 12 FA 68 3
>Engine Speed 0rpm
>Throttle Position 3.0%
>Throttle Drive 2.0%

>Tx message
4 C2 29 73 3

>Rx message
F C3 E7 1 C8 0 21 85 85 12 FA 73 12 FA 63 3

>Tx message
4 C4 29 75 3

>Rx message
F C5 E7 1 C8 0 21 FF 1E 21 FF 5 12 FA 75 3
>Engine Speed 0rpm
>Throttle Position 11.0%
>Throttle Drive 1.0%

>Tx message
4 C6 29 73 3

>Rx message
F C7 E7 1 C8 0 21 85 85 12 FA 77 12 FA 63 3

SOFTWARE IMPLEMENTATION
The software is implemented on an embedded system using the Microchip PIC16F876 in C. The data is displayed on a 100 x 64 pixals back lit LCD screen. A bargraph is drawn to enable easy reading of the data.

The 5 baud is done using bit bashing technique. A 0x01 is required and each bit is 1/5 second long (200mS). Here is the function :-

char diag_l0_initbus(void)
{

     TRISC6 = 0; //Set RC6 as output
     //Now we need to sent address of 0x01 at 5 baud

     OBD_K_LINE = 0;

     DelayMs(200);

     OBD_K_LINE = 1;

     DelayMs(200);

     OBD_K_LINE = 0;

     DelayMs(200); //A high of 1400mS
     DelayMs(200);
     DelayMs(200);
     DelayMs(200);
     DelayMs(200);
     DelayMs(200);
     DelayMs(200);

     OBD_K_LINE = 1;

     //Now config serial port
     SPBRG=29; // data rate for sending/receiving @ 10400 baud
     BRGH=0; // data rate for sending/receiving
     SYNC=0; // asynchronous
     SPEN=1; // enable serial port pins
     CREN=1; // enable reception
     SREN=0; // no effect
     TXIE=0; // disable tx interrupts
     RCIE=0; // disable rx interrupts
     TX9=0; // 8-bit transmission
     RX9=0; // 8-bit reception
     TXEN=1; // enable the transmitter

}

   
  

U1 is a Microchip PIC a 8k flash device. Just need to fit all the code in that space. JP2 is a header
for a lcd. P1 sets the contrast. A backlit lcd can also be used. The power for the back light is on pin 15 and 16 via R9.

U5 is a RTC use for datalogger. Battery BT1 supplies the backup power for the RTC. U7 and U6 is the
eeprom. At the moment Farnell only do the 24LC256, that is 8 x 32 kbytes with two devices that gives
64kBytes. Also these two ic is socketed and when the 512 becomes available it can be replace with
the new device which will give 64k x 2 = 128kByte. Should be large enough for most datalogger apps.
If that is still not enough because of the 3 address bus A0, A1, A3 more can be added with a piggy
back daughter board. See how it goes.

JP4 is a 7x2 header for user interface, switches and LEDS.

U4 is a MAX232, mainly use for debug to connect to a terminal. As the UART is already used for the comms to the ecu. I need to implement bit bashing in software for this. R14 and R13 is a DO NOT FIT
for ecu reader project. It is connected straight to PIC's UART. The reason I've designed like this is that if this PCB is not used for a ecu reader project it can be use for other projects that need a UART.

U2 is the SI9241EY driver IC, the CS and FAULT is connected to the PIC as I want to know when a fault
has occurred.

U3 is a 5V 1A voltage regulator. The reason for 1A is that if a backlit LCD is used then it could take 200mA or more at 5v
of power. R12 just drop some of the voltage before it gets to U3.

 
 

Displays reading of Group 4. Showing engine rpm, battery voltage, coolant and intatake temperature. Note the car has just started from cold.

  
 

Displays reading of Group 115. Showing engine load, spec boost, actual boost. Note the car is idle when the photo is taken. The pressure in mBar has been subtract by 900mbar of atmospheric pressure.

  
  

Displays reading of Group 117. Showing engine speed, throttle position and throttle drive.

 
          
 

Recommended books on OBDII
Amazon delivers worldwide.

cover cover

 

 

The ISO-9141 connector is available here.

 

    
 

Last update : 24-Apr-2005 10:11

Design subject to change without notice.

 

 

       
           
              
             
    
 
< Prev
Joomla Templates by JoomlaShack Joomla Templates