|
|
Jan 12, 2012 19:38:38 GMT
|
Another present from Autofive, I have been given an Amstrad NC100 notepad computer which otherwise would have gone straight to the tip. It is 20 years old, has a 4mhz Z80 processor, OS and software on a 256K ROM and a whopping 64K of RAM. So what would it be useful for? I already have a doorstop! Well, my main interest is that there is a proper RS232 serial port and a programming language built in (BBC Basic!) Also, it's light, robust, runs on 4 AA batteries and boots instantly when you press the power button. I think these qualities will make it ideal for use as an OBD diagnostic trouble code reader - I have several ELM23x interfaces but I don't want to leave a laptop at the garage just to read and clear codes with. I have tested it using the built in serial terminal (another bonus) and it does work, but it would be nice to have some software instead of typing the commands into a terminal and interpreting the response in my head so that's what I'm going to try. I haven't written anything in BBC Basic for over 25 years...... No power supply, but one was found in the box of power supplies and adapted to suit - it has -ve to the centre pin on the socket and all my supplies are +ve pin so I cut the lead and swapped the wires around. So there you go. I'm off to try some programming.
|
|
To get a standard A40 this low, you'd have to dig a hole to put it in
|
|
|
rysz
Club Retro Rides Member
Posts: 2,554
|
|
Jan 12, 2012 19:50:42 GMT
|
YAY! Another SOC tech post! I love these! Lordy, BBC Basic, that is going back a bit from when I used to code text adventures and demos from magazines! I still have an Archimedes A3010 that still works with the GUI far more advanced than whatever MS had at the time! On another home tech note, have you seen these? www.raspberrypi.org/ I am sure you would have a few uses for one of them! Rysz.
|
|
|
|
markbognor
South East
Posts: 9,969
Club RR Member Number: 56
|
New use for Old Techmarkbognor
@markbognor
Club Retro Rides Member 56
|
Jan 12, 2012 21:00:50 GMT
|
I love Basic. I did a computer studies a'level on BBC Micros, a long time ago. Good luck with it - not that you need that! Looking forwards to the updates.
|
|
|
|
|
|
Jan 12, 2012 22:53:24 GMT
|
Found a BBC basic tutorial site www.bbcbasic.co.uk/bbcbasic/mancpm/index.htmlI'm starting at the beginning because it's so long since I used BASIC I had forgotten how to declare a variable (LET ) and I made a null-modem lead so I can test the com port routines without going and sitting in the car (and save stuff off the notepad) I've tested it between terminal programs, and it works. That's all the hardware side done, rest is just software.
|
|
To get a standard A40 this low, you'd have to dig a hole to put it in
|
|
|
|
|
10 ser=OPENUP("COM:") 20 PRINT#ser, "HELLO WORLD" 30 GOTO 20 Ok, it's starting to come back to me. ;D
|
|
To get a standard A40 this low, you'd have to dig a hole to put it in
|
|
|
|
|
10 REM simple serial comms 20 ser=OPENUP("COM:") 25 query$="0101" 30 PRINT#ser, query$ 35 REPEAT 40 INPUT#ser, reply$ 50 PRINT reply$ 60 check$=LEFT$(reply$,2) 70 UNTIL check$ = "41" OR reply$="NO DATA" 80 IF reply$="NO DATA" THEN PRINT "Comm error" : STOP 90 pid$=MID$(reply$,4,2) 100 pid=EVAL ("&"+pid$) 110 IF pid>127 THEN mil=1 ELSE mil=0 120 IF mil=1 THEN pid=pid-128 130 IF mil=1 THEN PRINT "MIL ON" ELSE PRINT "MIL OFF" 140 PRINT "Stored DTCs =";pid 150 END
Right, that's enough for tonight! (2 in the morning ) The above code *SHOULD* request the number of stored codes and MIL status (0101) and decode the reply. I'll try it out on a vehicle sometime tomorrow.
|
|
To get a standard A40 this low, you'd have to dig a hole to put it in
|
|
MiataMark
Club Retro Rides Member
Posts: 2,963
Club RR Member Number: 29
|
New use for Old TechMiataMark
@garra
Club Retro Rides Member 29
|
|
|
|
1990 Mazda MX-52012 BMW 118i (170bhp) - white appliance 2011 Land Rover Freelander 2 TD4 2003 Land Rover Discovery II TD52007 Alfa Romeo 159 Sportwagon JTDm
|
|
|
|
|
I have an arduino - it's a useful little thing and the raspberry Pi looks pretty good too but neither of them come cased up with a screen and a keyboard.....
|
|
To get a standard A40 this low, you'd have to dig a hole to put it in
|
|
Nathan
Club Retro Rides Member
Posts: 5,627
Club RR Member Number: 1
|
New use for Old TechNathan
@bgtmidget7476
Club Retro Rides Member 1
|
Jan 13, 2012 16:47:17 GMT
|
I owe BBCBasic alot, if it were not for that I don't think I would be in this IT profession. Excellent keep the updates coming mate.
Thats PI is excellent, I noticed it from a post Rysz made.....I don't do enough Home programming anymore (TBH sick to death of looking at SQL code at work), But I should get back into it really and I think the PI is the device for me.
|
|
Last Edit: Jan 13, 2012 16:54:48 GMT by Nathan
|
|
|
|
Jan 13, 2012 18:51:20 GMT
|
Live test with actual car... comms works fine but DTC report is wrong (should be a zero). Thought for a sec, then realized that I'd forgotten that as well as a reply identifier byte (41) the ECU sends back the PID byte (01) and my program is reading this byte as though it is data byte A (00) containing mil status and stored codes. Line 90 is now ammended to 90 pid$ = MID$(reply$,7,2) which has fixed it. Now reporting correctly (for a car with the mil off and no codes stored) - next live test is to cause a fault and read it, but I need to write the code reading and clearing routines first.
|
|
To get a standard A40 this low, you'd have to dig a hole to put it in
|
|
|
MiataMark
Club Retro Rides Member
Posts: 2,963
Club RR Member Number: 29
|
New use for Old TechMiataMark
@garra
Club Retro Rides Member 29
|
Jan 13, 2012 22:27:38 GMT
|
Just remembered got an Acorm Atom in the loft, wonder if it still works....
|
|
1990 Mazda MX-52012 BMW 118i (170bhp) - white appliance 2011 Land Rover Freelander 2 TD4 2003 Land Rover Discovery II TD52007 Alfa Romeo 159 Sportwagon JTDm
|
|
|
|
|
Well, it's been a few years since I sat up all night writing Basic! I now have a working code scanner that checks for codes, reads and translates them, then offers to clear them before checking again. The routines are written as PROC calls so I can easily re-write the UI (which so far just calls them all in turn then quits). There is even "some" error handling! Trouble is, all that code is trapped on the Amstrad and I can't figure out (because I'm tired) how to send a listing to the serial port so I can capture it on the laptop and cut and paste it rather than typing in a couple of hundred lines again! Anyone remember how it's done?
|
|
To get a standard A40 this low, you'd have to dig a hole to put it in
|
|
|
|
Jan 14, 2012 13:34:01 GMT
|
Ha! What you do is *SPOOL <filename> LIST *SPOOL
then open the word processor, select document <filename> and print it.
On the other end, all you need is cat /dev/ttyUSB0 > /home/andy/filename
10 REM OBD scanner program V1
20 err_FLAG=0 : mil=0 : pid=-1 : pid$="null"
30 ser=OPENUP("COM:")
40 PROC_pidstate
50 IF err_FLAG=1 PRINT reply$ : STOP
60 PROC_readdtc(pid)
70 IF err_FLAG=1 PRINT reply$ : STOP
80 PROC_clear
90 END
500 DEF PROC_serial(query$,response$)
510 PRINT#ser, query$
520 REPEAT
530 INPUT#ser, reply$
540 REM PRINT reply$
550 chars=LENresponse$
560 check$=LEFT$(reply$,chars)
570 UNTIL check$=response$ OR reply$="?" OR reply$="NO DATA"
580 ENDPROC
600 DEF PROC_pidstate
610 query$="0101" : response$="41 01"
630 PROC_serial(query$,response$)
640 IF check$<>response$ THEN err_FLAG=1 : ENDPROC
650 pid$ = MID$(reply$,7,2) : pid = EVAL("&"+pid$)
660 IF pid>127 THEN mil=1 ELSE mil=0
670 IF mil=1 THEN pid=pid-128
680 IF mil=1 PRINT "CHECK ENGINE"
690 PRINT "Stored DTCs = ";pid
695 ENDPROC
700 DEF PROC_readdtc(pid)
710 IF pid=0 PRINT "NOTHING TO DO HERE" : ENDPROC
715 IF pid=-1 PRINT "Must SCAN first!" : ENDPROC
720 DIM code$(pid-1)
730 query$="03" : response$="43"
740 count=0
750 REPEAT
760 PROC_serial(query$,response$)
770 IF check$<>response$ THEN count=pid : 830
780 code$(count)= MID$(reply$,4,5)
790 count=count+1
800 IF count<pid THEN code$(count)= MID$(reply$,10,5)
810 count=count+1
820 IF count<pid THEN code$(count)= MID$(reply$,16,5)
825 count=count+1
830 UNTIL count>=pid
840 FOR loop=0 TO pid-1
850 byte1$=LEFT$(code$(loop),1)
860 PROC_process(byte1$)
870 rest$=MID$(code$(loop),2,1)+RIGHT$(code$(loop),2)
880 PRINT PID$+rest$
890 NEXT
900 ENDPROC
1000 DEF PROC_process(byte1$)
1010 IF byte1$="0" PID$="P0"
1020 IF byte1$="1" PID$="P1"
1025 IF byte1$="2" PID$="P2"
1030 IF byte1$="3" PID$="P3"
1040 IF byte1$="4" PID$="C0"
1050 IF byte1$="5" PID$="C1"
1060 IF byte1$="6" PID$="C2"
1070 IF byte1$="7" PID$="C3"
1080 IF byte1$="8" PID$="B0"
1090 IF byte1$="9" PID$="B1"
1100 IF byte1$="A" PID$="B2"
1110 IF byte1$="B" PID$="B3"
1120 IF byte1$="C" PID$="U0"
1130 IF byte1$="D" PID$="U1"
1140 IF byte1$="E" PID$="U2"
1150 IF byte1$="F" PID$="U3"
1160 ENDPROC
1200 DEF PROC_clear
1210 PRINT "Erase all codes and data?"
1220 PRINT "Are you sure you want to do this?"
1230 INPUT "Type YES to continue", yes$
1240 IF yes$<>"YES" PRINT "Aborting" : ENDPROC
1250 PROC_serial("04","44")
1260 PROC_pidstate
1270 ENDPROC
I've spotted (and corrected) a couple of errors that weren't apparant last night - It's so much easier when you can look at the whole listing at once and don't have to rely on LIST and EDIT. I also didn't realize how much I've got used to having autocomplete, cut and paste etc....
|
|
To get a standard A40 this low, you'd have to dig a hole to put it in
|
|
|
|
Jan 14, 2012 18:17:18 GMT
|
Some more live car testing (I have to wait for my daughter to visit, I haven't actually got a car with an OBD port :x ) line 30 (ser=OPENUP("COM:") has been moved to line 505 (inside the PROC_serial routine) because with it outside the subroutine only worked once. (worked ok with a computer "pretending" to be a car...) .....and a new line 30 has been added to call PROC_serial with the arguments "atz,ELM" to reset the adapter between attempts. This is because turning the ignition sometimes crashes the adapter causing it to reply with "?". Attempting to clear codes on a running engine gives "NO DATA" as expected. Trying to read codes when none are stored gives the "NOTHING TO DO HERE" message instead of falling into divide by zero hell. Unpluging the Lambda sensor puts the MIL on and records a code of P0134 (O2 sensor circuit no activity bank1,sensor1), replying YES at the prompt clears the code and puts the MIL back out. All working as expected. Might have to try a different car next time
|
|
To get a standard A40 this low, you'd have to dig a hole to put it in
|
|
|
|
|
Jan 14, 2012 19:15:08 GMT
|
TBH, I was thinking that there isn't a huge difference between BASIC and languages like Java and Python (or even Bash script..) so once I've got it hammered out here it won't be a big job to port it to a modern laptop (or smartphone..) and use bluetooth_serial instead of RS232. Then you all can go buy a £10 chinese bluetooth OBD adapter on eBay and download an app to read your own car.
Sound useful?
|
|
To get a standard A40 this low, you'd have to dig a hole to put it in
|
|
|
|
Jan 14, 2012 19:48:52 GMT
|
You can do that anyway. TBH a 30 quid code reader off ebay does the same job and is probably more reliable. Hats off to you though mate. I take it this is just reading EOBD codes though.
|
|
R.S. Autotech. Servicing/Repairs/Diagnostics.
|
|
|
|
Jan 14, 2012 20:10:58 GMT
|
Good point.... although I get irritated with the cheap readers because you can't break out of the software into a terminal and look at the data yourself. Also, I noticed there is NO diagnostics software available on GNU/Linux so I might write it and GPL it anyway. For now, this just does mode 03 EOBD codes (and won't filter out the non-P codes like the cheap readers do), but the interface is capable of anything I have the access codes for
|
|
To get a standard A40 this low, you'd have to dig a hole to put it in
|
|
|
|
Jan 14, 2012 20:42:12 GMT
|
Non P codes? You mean you can read driveline and bus faults or do you mean manufacture specific powertrain faults?
|
|
R.S. Autotech. Servicing/Repairs/Diagnostics.
|
|
|
|
Jan 14, 2012 20:54:54 GMT
|
I can read anything the ECU sends on mode 03. This could be powertrain, chassis, body or network. The hard bit is finding out what non-obd codes mean! I can read C0324 (for example) but I can't necessarily interpret it. Sometimes Google hits lucky, other times I'm phoning someone at a main dealers to find out
|
|
To get a standard A40 this low, you'd have to dig a hole to put it in
|
|
|