Trying to prime the pump

Developer topics relating to hardware that interfaces PCs to ECUs

Moderator: Freon

Postby Visceral » Thu Jan 06, 2005 10:33 pm

Ok, you'll have to forgive me, as I'm new to OBD-II and serial programming. The OBD-II 5 baud code is not required -- there was an issue with the serial comms that this was masking.

Nemis, I took your code and worked on it a bit to make the parameter lookup file driven. It's a hack at the moment, as I was having trouble declaring array variables to be global (been a very long time since I programmed BASIC).

Code: Select all
REM Code initiated by Nemis
REM thank you colby for start tread on nasioc
REM thank you Visceral for help in programming
REM thank you numbles for find file subaruecu.htm

DEF SEG = 0
REM address of COM port (p)
REM Typical address
REM &H3F8 = COM1
REM &H2F8 = COM2

DIM response(100)

SUB LookupLabel(index, value)
  PRINT "In LookupLabel "; index; " " ;value
  DIM labels$(100)
  k = 0
  WHILE NOT EOF(1)
    INPUT #1, labels$(k)
    REM PRINT "Read: "; labels$(k)
    k = k + 1
  WEND
  CLOSE #1

  lindex = 0
  WHILE lindex < 8
       IF value MOD 2 = 1 THEN
      REM PRINT "1"
       value = (value-1)/2
       ELSE
       REM PRINT "0"
       value = value/2
       END IF
       lindex = lindex + 1
  WEND
END SUB

PRINT "Begin"

p = &H3F8

dllb = p + 0
dlhb = p + 1
ier = p + 1
fcr = p + 2
lcr = p + 3
mcr = p + 4
lsr = p + 5
REM clear buffers & enable FIFO
OUT fcr, 7
REM cancel interupts
OUT ier, 0
REM set MCR  rts low(on logic 1 -v), dtr-high(off logic 0 +V)
OUT mcr, 1



REM set baud rate 4800
PRINT "Changing to 4800 baud"
OUT lcr, (INP(lcr) OR 128)
OUT dllb, &H18
OUT dlhb, 0
OUT lcr, (INP(lcr) AND 127)
REM set 8bit no parity
lcrbits = INP(lcr)
        REM set 8 data bits xxxxxx11
        lcrbits = lcrbits OR 3
        REM set None parity xxxx0xxx
        lcrbits = lcrbits AND (255 - 8)
        REM set 1 Stop bit xxxxx0xx
        lcrbits = lcrbits AND (255 - 4)
        REM set 0 (off) Break Enable x0xxxxxx
        lcrbits = lcrbits AND (255 - 64)
OUT lcr, lcrbits

PRINT "Clear buffer"
DO
       c = INP(lsr) AND 1
       DELAY 1
LOOP WHILE c > 0
PRINT "Done"

REM send initialization string
REM 80 10(suby ecu)  f0(diagnostic) 01(1 byte data) bf(euc init) 40(chksum)

OUT p, &H80
OUT p, &H10
OUT p, &HF0
OUT p, &H01
OUT p, &HBF
OUT p, &H40


i = 0
ecuid$ = ""

PRINT "Reading response"
DO
     c = INP(lsr) AND 1
     IF c > 0 THEN
      abyte = INP(p)
      PRINT HEX$(abyte)
           IF (i > 13) AND (i < 19) THEN
       ecuid$ = ecuid$ + " " + HEX$(abyte)
           END IF
      response(i) = abyte
      i = i + 1
     END IF
REM Increase this value to process more data (when LookupLabel
REM   is called in a loop).
LOOP UNTIL i > 21


PRINT "ECU ID:"; ecuid$;
COLOR (9)
IF ecuid$ = " 54 53 52 51 50" THEN
     PRINT " OlŠ (r) by Nemis"
ELSEIF ecuid$ = " 16 44 50 3 5" THEN
     PRINT " turbo/wrx/gt 99/00 ae800/780"
ELSEIF ecuid$ = " 16 4 69 4 5" THEN
     PRINT " STI5/6 99/00 af040"
ELSEIF ecuid$ = " 16 4 96 6 5" THEN
     PRINT " P1ag340"
ELSEIF ecuid$ = " 1b 44 58 5 5" THEN
     PRINT " wrx 01/02 af531 7555"
ELSEIF ecuid$ = " 29 44 59 41 5" THEN
     PRINT " sti uk 01/02 ag820 2591"
ELSEIF ecuid$ = " 18 42 10 7 5" THEN
     PRINT " legacy 2.5gx 02"
ELSEIF ecuid$ = " 18 44 10 8 5" THEN
     PRINT " legacy 2.0gl 02"
ELSEIF ecuid$ = " d 4 68 8 5" THEN
     PRINT " legacy b4 tt"
ELSEIF ecuid$ = " 19 44 58 5 5" THEN
     PRINT " forester turbo S/gt00 ag050"
ELSEIF ecuid$ = " 23 44 10 8 5" THEN
     PRINT " forester 2.0 gls 02"
ELSEIF ecuid$ = " 1b 14 40 5 5" THEN
     PRINT " US wrx 01/02 af423"
ELSEIF ecuid$ = " 1e 12 0 7 5" THEN
     PRINT " 2,5 rs af581"
ELSEIF ecuid$ = " 26 54 78 61 5" THEN
     PRINT " libetry b4 tt ag850 3382"
ELSEIF ecuid$ = " 36 14 48 61 5" THEN
     PRINT " us wrx manual 03 aj030 5692"
ELSEIF ecuid$ = " 29 44 59 61 5" THEN
     PRINT " STI uk 01/02   ag820/ag821"
ELSEIF ecuid$ = " 2e 44 59 41 5" THEN
     PRINT " STI uk 03 ah990 5512"
ELSEIF ecuid$ = " 23 12 49 51 6" THEN
     PRINT " us 2,5 sti 04 aj241"
ELSEIF ecuid$ = " 2f 4 78 52 6" THEN
     PRINT " leg jap twins ah111 5646"
ELSEIF ecuid$ = " 2E 12 49 51 6" THEN
     PRINT " 2004 USDM WRX STi"
END IF

REM The 19th byte in the ECU response is the first parameter set
REM Calls to LookupLabel will be put in a loop at some future point.
offset = 19
CALL LookupLabel(offset, response(offset))

DO
LOOP UNTIL INKEY$ = CHR$(27)
END


The labels.txt file looks like this. I just entered in the first set as an example.
Code: Select all
Engine speed
Manifold Absolute Pressure
Air/Fuel Learning #2
Air/Fuel Correction #2
Air/fuel Learning #1
Air Fuel Correction #1
Coolant Temperature
Engine load
Visceral
 
Posts: 23
Joined: Thu Dec 30, 2004 10:21 am

Postby Visceral » Thu Jan 06, 2005 11:04 pm

After REM PRINT "1" should be
PRINT labels$(lindex)
Visceral
 
Posts: 23
Joined: Thu Dec 30, 2004 10:21 am

Postby Nemis » Fri Jan 07, 2005 4:10 am

i will try to understand your hack :D


basic is simple but don't have an GUI.

so if we change from basic to some other ?
Nemis
 
Posts: 66
Joined: Thu Dec 30, 2004 3:58 am
Location: italy

Postby Imp Guerra » Fri Jan 07, 2005 9:55 pm

ELM323 based tools like scantool, digimoto, scanmaster and others are of no use if u want to remap subaruECU or diag Subaru with SSM protocol tool like DeltaDash.

ELM is useful for generic scanning via obd-2. can read and erase DTC, log some data but it is rather slow.

we sell such ELM-sanners for a year and even translate scantool.net soft into russian

www.minsk555.narod.ru/scantool.htm
(free download and use).

maybe we translate in future DeltaDash and DeltaFlash free ProDrive versions :)

DigiMoto37 (for ELMbased scanner) has nice feature of
1/4 mile time and speed
and 0 - 100 km/h time
and the soft is "free" already, or "nearly free" ;)
User avatar
Imp Guerra
 
Posts: 73
Joined: Thu Jan 06, 2005 3:31 pm
Location: Minsk Soviet Union

Postby Nemis » Sat Jan 08, 2005 10:20 am

Nemis wrote:i will try to understand your hack :D



8) i have add "open "labels.txt" for imput as #1 " and now work better :D

so have do a little mod like:
ordinate output by ecu
add some color
now not display 0, 1,2,3 ... but 00,01,02,03 that's more beauty :D
cange clear buffer (now for me work ever, not only sometime)


file here:
http://marco1044.supereva.it/SSM/subby.bas


more work to do
Nemis
 
Posts: 66
Joined: Thu Dec 30, 2004 3:58 am
Location: italy

Postby Visceral » Sat Jan 08, 2005 11:42 am

Nemis wrote: 8) i have add "open "labels.txt" for imput as #1 " and now work better :D


Sorry about that, I must have missed that line in the copy/paste.


I started rewriting the code in C. Hopefully should have it logging a parameter (like ignition timing) in a few days.
Visceral
 
Posts: 23
Joined: Thu Dec 30, 2004 10:21 am

Postby Nemis » Sat Jan 08, 2005 11:47 am

Visceral wrote:
Nemis wrote: 8) i have add "open "labels.txt" for imput as #1 " and now work better :D


Sorry about that, I must have missed that line in the copy/paste.


I started rewriting the code in C. Hopefully should have it logging a parameter (like ignition timing) in a few days.



i dont know "C" but i can learn :D
so it have an gui that run under win ?
Nemis
 
Posts: 66
Joined: Thu Dec 30, 2004 3:58 am
Location: italy

Postby Visceral » Sat Jan 08, 2005 2:28 pm

Well, I have it logging at about 22 samples per second. Not too bad, limited by the 4800 baud.

I've developed the program on Windows with gcc (using Cygwin). There isn't any gui yet, I'll add that later once I've got the base logging portion stable.
Visceral
 
Posts: 23
Joined: Thu Dec 30, 2004 10:21 am

Postby Nemis » Thu Jan 13, 2005 1:19 am

i'm working on
write all label.txt (but i don't like external file)
make LookupLabel working with all offset
add some ID ecu
add calc checkum function (idea from visceral simple logger but i dont understand C :-( )

re-add logging data and make it working
Nemis
 
Posts: 66
Joined: Thu Dec 30, 2004 3:58 am
Location: italy

Postby Nemis » Fri Jan 14, 2005 3:27 am

labels file here http://marco1044.supereva.it/SSM/labels.txt


mod code
Code: Select all
DIM response(56)

SUB LookupLabel(index, value)
open "labels.txt" for input as #1
  PRINT "In LookupLabel "; index; " " ;value
  print
  DIM labels$(384)
  k = 0
   WHILE NOT EOF(1)
    INPUT #1, labels$(k)
    k = k + 1
   WEND
  lindex = 8
   WHILE lindex > 0
      IF value MOD 2 = 1 THEN
       PRINT labels$(lindex+(index-9)*8-1)
       value = (value-1)/2
      ELSE
       value = value/2
      END IF
    lindex = lindex - 1
   WEND
close #1
END SUB



now like subaruecu.htm when CALL LookupLabel(offset, response(offset))
offset go from byte 9 to byte 56
if byte 9 or response = ff call LookupLabel(offset,response(offset)) will print all parameter:
Engine Load
Coolant Temperature
Air/Fuel Correction #1
Air/Fuel Learning #1
Air/Fuel Correction #2
Air/Fuel Learning #2
Manifold Absolute Pressure
Engine Speed

call LookupLabel(9,1) print only engine speed active

call LookupLabel(56,ff) print
Roughness Monitor Cylinder #1
Roughness Monitor Cylinder #2
Roughness Monitor Cylinder #3
Roughness Monitor Cylinder #4
?
?
?
?
Nemis
 
Posts: 66
Joined: Thu Dec 30, 2004 3:58 am
Location: italy

Postby tones111 » Tue Mar 22, 2005 3:27 pm

Visceral wrote:Well, I have it logging at about 22 samples per second. Not too bad, limited by the 4800 baud.

I've developed the program on Windows with gcc (using Cygwin). There isn't any gui yet, I'll add that later once I've got the base logging portion stable.


Visceral,
I think it's a great idea to port the working basic code to C. I think writing the code in C or C++ will be a great benefit down the road as it's a more common and powerfull language to work with. I just stumbled across the openecu concept yesterday, and am really excited about the direction things are going, and the progress that's been made so far. I've had plans to make my own OBD-II datalogging tool even before I got my Subie, but am thrilled that some of the SSM protocol has made itself available. I hope to help in any way I can. My main skill set is embedded microcontroller programming, but I also enjoy the HW / SW interface issues that always arise when doing these sorts of projects. I'm waiting for the cboles cables to come to light, and then I will be able to help more on the software end. I was wondering if you might be able to email or post your C source so I can start getting familiar with it. I think this is a great project and has the potential for great things to come for all the subaru enthusiats out there.
tones111
 
Posts: 7
Joined: Tue Mar 22, 2005 3:04 pm

Previous

Return to Interface Hardware

Who is online

Users browsing this forum: No registered users and 6 guests