PDA

View Full Version : PIC Simulator to free up a serial port for wideband



daedalusjc
18-09-2010, 07:00 PM
Hi guys,

As you know the adaptronic sends an at command to the obdpro to remove and cel;s that may be current or pending. Now one downfall of this is not having the serial port free to run serial based widebands. So after alot of contemplation and research i've put together a very very simple PIC circuit based on the 16f628a to simply clear cel's every 5 minutes without hogging the CANBUS.

Parts required

1x PIC 16F628a
1x Max232 RS232 line converter
3x 1uF electrolic capacitors
1x 10uF electrolic capacitor
1x momentary switch (Handy for reset)
1x 100n MKT capacitor
1x 12k resistor

You will also need a 5v source such as the spare TPS +5v line or a 12 to 5v converter and also a Male DB9 connector.

<a href="http://s215.photobucket.com/albums/cc175/daedalusjc/?action=view&current=628uart.gif" target="_blank"><img src="http://i215.photobucket.com/albums/cc175/daedalusjc/628uart.gif" border="0" alt="Photobucket"></a>


All you need to do is compile the code with MPLAB or MPASMWIN and burn it to the PIC

Code

;************************************************* ******************
; Function: Sends ATZ 04 command to obdpro to clear cel's
; Processor: PIC16F628 at 4 MHz using internal RC oscillator
; Hardware: Cutsom breadboard. 628A + Max232
; Filename: 628uart.asm
; Author: Matt Abbott. Base code modified from Lars Peterson
; Email: daedalusjc@amnet.net.au
; Credit: Base code modified from Lars Peterson
;************************************************* ******************

LIST P=16F628, R=DEC ; Use the PIC16F628 and decimal system

#include "P16F628.INC" ; Include header file

__config _INTRC_OSC_NOCLKOUT & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON

CBLOCK 0x20 ; Declare variable addresses starting at 0x20
dataL
d1
d2
d3
d4
e1
e2
e3
ENDC

ORG 0x000
;
; --------------------------------
; SET ANALOG/DIGITAL INPUTS PORT A
; --------------------------------
;
movlw 7
movwf CMCON
;
; ----------------
; INITIALIZE PORTS
; ----------------
;
movlw b'00000000' ; set up portA
movwf PORTA

movlw b'00000100' ; RB2(TX)=1 others are 0
movwf PORTB

bsf STATUS,RP0 ; RAM PAGE 1

movlw 0xFF
movwf TRISA ; portA all pins input

movlw b'11110010' ; RB7-RB4 and RB1(RX)=input, others output
movwf TRISB

; ------------------------------------
; SET BAUD RATE TO COMMUNICATE WITH ADAPTRONIC SERIAL PORT
; ------------------------------------
; Boot Baud Rate = 9600, No Parity, 1 Stop Bit
;
movlw 0x19 ; 0x19=9600 bps (0x0C=19200 bps)
movwf SPBRG
movlw b'00100100' ; brgh = high (2)
movwf TXSTA ; enable Async Transmission, set brgh

bcf STATUS,RP0 ; RAM PAGE 0

movlw b'10010000' ; enable Async Reception
movwf RCSTA
;
; ------------------------------------
; START UP SETTLE DELAY AND FLUSH
; ------------------------------------
;
clrf dataL
settle decfsz dataL,F
goto settle

movf RCREG,W
movf RCREG,W
movf RCREG,W ; flush receive buffer
;
; ---------
; MAIN LOOP
; ---------
;



call Delay3 ; Initial 5 second delay
nop ; internal delay
call message ; Send ATZ to wake up obdpro in first startup
call Delay3 ; Another 5 second delay
nop ; Loop delay
call message2 ; Send 04 to clear CEL
loop call Delay3 ; send "ATZ" to initialize obd adaptor
call message ; send ATZ once car is running
call Delay ; 5 minute delay to avoid congesting CANBUS
call message2 ; send 04 to clear any pending CEL's
goto loop ; return to start of loop. process duration 5 min 5 seconds

Delay
;299999995 cycles
movlw 0x54
movwf d1
movlw 0xA1
movwf d2
movlw 0xFD
movwf d3
movlw 0x02
movwf d4
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto $+2
decfsz d4, f
goto Delay_0

;1 cycle
nop

;4 cycles (including call)
return


Delay3
;4999993 cycles
movlw 0x2C
movwf e1
movlw 0xE7
movwf e2
movlw 0x0B
movwf e3
Delay3_0
decfsz e1, f
goto $+2
decfsz e2, f
goto $+2
decfsz e3, f
goto Delay3_0

;3 cycles
goto $+1
nop

;4 cycles (including call)
return


;
; -------------------------------------------------------------
; SEND CHARACTER IN W VIA RS232 AND WAIT UNTIL FINISHED SENDING
; -------------------------------------------------------------
;
send movwf TXREG ; send data in W

TransWt bsf STATUS,RP0 ; RAM PAGE 1
WtHere btfss TXSTA,TRMT ; (1) transmission is complete if hi
goto WtHere

bcf STATUS,RP0 ; RAM PAGE 0
return
;
; -------
; MESSAGE
; -------
;
message movlw 'A'
call send
movlw 'T'
call send
movlw 'Z'
call send
movlw 0x0D ; CR
call send
movlw 0x0A ; LF
call send
return

message2 movlw '0'
call send
movlw '4'
call send
movlw 0x0D ; CR
call send
movlw 0x0A ; LF
call send
return

END

fauxpas
18-09-2010, 07:18 PM
I was going to work on that very thing last week but you beat me to it... Nice work...

daedalusjc
18-09-2010, 09:05 PM
yeah i will mail ya one over faux once i finish the basic pcb. means we can use serial data input on the ecu for the wideband

0dd0ne
18-09-2010, 09:12 PM
i love how you said "very very simple". Right. simple. hahah

benefits of using the serial port for the wide band?

actually can you be more specific on benefits cause i cant see how i'd need to use this (excuse my automotive ignorance)

steel
18-09-2010, 09:13 PM
Interesting. Is there any advantage to using the serial for the wideband over the current setup?

Jemjem
18-09-2010, 09:32 PM
Lost me!!!!!

Ayu452
19-09-2010, 03:47 AM
i will make sweet love to the schematic because the that assembly stuff went straight over my head

daedalusjc
19-09-2010, 01:28 PM
ah it also helps for emissions cel's. every 5 minutes it will clear all the cels present in the system so like the having no cat cel for example. the benefit of using widebands over serial is pretty trivial. i've got a techedge 2j2 with serial output so its more a case of "because i can". i love rs232 stuff. hey ayu i will chuck my phone on charge in a sec. come up today if your free

0dd0ne
19-09-2010, 01:43 PM
wonder if it will help my asc issue. I'm doubting it. Either way when that pops cels after it does its asc thing it could be handy. Hey matt whats one of these worth for you to build for me?

Ayu452
19-09-2010, 02:57 PM
odd one what asc issues u getting?
the light coming on and stuff?
i get that sometimes...i think its due to the obd connector, i use to get it with the scangauge 2 and sometimes get it with the obdpro
i think the obd pro kinda corrupts the bus, having a device in general on the bus...try unplug plug it back in...dirty contacts i dunno...do it while the engine is off though

-matt i dont think i can make it today...when u free next?

0dd0ne
19-09-2010, 04:07 PM
nah it actually has a physical effect on the car. you know when you run into a deep puddle of water and the car physically slows down? thats what it feels like.

happens randomly and not every drive (longer drives = higher chance). after it happens the ASC and traction light stay lit, then CELS pop up and i lose gauges like revs and temp. the Cels will clear but the ASC wont go off till i restart the car. same shit happens even if i hold the ASC button for 3 secs and disable it.

Ayu452
20-09-2010, 01:30 AM
fuk i had that a few times...i go for a squirt...then suddenly it feels bogged...and lights come on...and gauges die...have to restart a few times to get it going
had a few times that it just started reving...and rev kept climbing for no reason...hd to hit the kill switch...
as if the ecu crashed or soemthing @_@
happen to matt car once when i took it for a drive...
i see how it goes...its completely random though...dun about 500km since the last time it happened...and i do 30min/20km drives to work everyday...
might keep an eye on the weather though...think it happened when it was gettin hot and i gave it a squirt...like 25ish

0dd0ne
20-09-2010, 12:42 PM
shit hey. So i'm not the only one. Wonder if matt has any theories on it.

Ayu452
20-09-2010, 03:09 PM
worst case scenario i do full time logs until it occurs again and send it to adaptronic?
maybe that will help them...but yeh completely random...
especially when daed and i did like 100km plus of thrashing all in one day...then the next day i was 10km from the city and it happened @_@

0dd0ne
22-09-2010, 04:15 PM
yeah see that would be a fucking pain to try find in the log. when mine was doing its stupid popping thing cause of the bad ground it was hard enough to find in the log and that was constantly happening over 10 mins.

trying to find this in a log would be like looking for a needle in a stack of needles.