PC to ecu Interface software

From: ianmacnor <ian@...>
Date: Wed Oct 01 2003 - 21:39:10 CEST

Sirs

I have been investigating custom baud rates on a PC to talk to the
ecu in my car using a "Jeff Noxon" interface.
I am using Delphi and many of the Serial Port components will not
allow non-standard baud rates. I found a couple of components which
would allow them and tried TComPort - available from
http://comport.sf.net/
It was a bit fiddly to install but worked well. The COM port is set
up as follows:

procedure SetUpCOMPort;
var
COM: TComPort;
begin
with COM do
begin
Port := 'COM1';
Open;
Baudrate := brCustom;
CustomBaudRate := 10400;
DataBits := dbEight;
Parity.Bits := prNone;
StopBits := sbOneStopBit;
FlowControl.ControlDTR := dtrDisable;
FlowControl.ControlRTS := rtsDisable;
FlowControl.FlowControl := fcNone;
ClearBuffer(TRUE, TRUE); //input,output
SetDTR(FALSE);
SetRTS(TRUE);
delay(300);
end;
end;

It would also work at 5 baud but did some funny things to the PC
timing. The main problem being that it took about 10 seconds to
switch from 5 baud to 10400 baud. As most ecu's will start
transmitting at 10400 baud almost immediately on receipt of the 5
baud "wake-up", this method is impractical for ecu communication. As
has been discussed elsewhere, the "bit-bang" method works well. In
Delphi the COM port is setup as above and then the 5 baud wake-up is
sent as follows:

function wakeup: Boolean;
var
S: string;
X: Integer;
begin
S := '00110011' ;// if $33 is used for the wake-up
COM.SetBreak(TRUE); // Send Start
Delay(200);
for X := 8 downto 1 do // Because LSB is sent first
begin
if S[Y] = '0' then
COM.SetBreak(TRUE) // Send Zero
else
COM.SetBreak(FALSE); // Send One;
Delay(200);
end;
end;

This gives an accurate output at 5 baud if the delay is generated
using QueryPerformanceCounter as below:

procedure Delay(mS: Integer);
var
startT, endT, freq: Int64;
begin
QueryPerformanceFrequency(freq);
QueryPerformanceCounter(startT);
repeat
QueryPerformanceCounter(endT);
until ((endT - startT) * 1000 div freq) >= mS
end;

After sending the wake-up code, the PC is then ready to read
characters at 10400 baud immediately.

Regards

Ian McFarlane

 
Received on Wed Oct 01 12:39:14 2003

This archive was generated by hypermail 2.1.8 : Wed Jan 02 2008 - 00:56:01 CET