Docstoc

VSS-and-ECT-conversion1

Document Sample
VSS-and-ECT-conversion1 Powered By Docstoc
					           How to convert VSS and ECT signals for an ap1 S2000 Cluster
VSS

If you have a reed style VSS sensor, use a pullup to 5V and connect the reed switch to ground. You’ll get a
very noisy 5V square wave with lots of noise that you remove with the debouncing and Schmitt trigger
circuits. The Schmitt trigger is probably not needed anyway.
If you have a ‘normal’ 2 or 3 wire VSS sensor, you don’t need the circuits.




Fuel sender:
S2000
full : 11 - 13 ohm
empty 130 - 132 ohm

NB miata
full : 5 ohm
empty: 185 ohm
Device 16F628A
Config INTRC_OSC_NOCLKOUT, WDT_OFF, PWRTE_ON, LVP_OFF, MCLRE_ON
'B0 = VSS input signal = input (pin 6)
'B3 = VSS output signal = output (pin 9)

Dim tm As Word
Dim ttm As DWord
Dim Fout As Word
Dim ovf As Word

tm = 0 ; set counter to 0
ttm = 0
Fout = 0 ; output frequency - 245Hz is lowest possible
ovf = 0
;76543210
PORTB = %00000000 ; all low
TRISB = %00000001 ; 7, 6, 5, 4, 3, 2, 1 en 0 are input (1) or output (0)
INTCON = %11010000 ; Enable interrupts (GIE, PIE, RB0)
T1CON = %00110000 ; setup timer1 with 1:8 prescale (1:2 and 1:4)
PIE1.0 = 1 ; enable tmr1 interrupt

on_interrupt GoTo interrupt_handler

While 1=1

Wend

interrupt_handler:
If INTCON.1 = 1 Then ; VSS pulse came in
T1CON.0 = 0 ; stop counter
tm.LowByte = TMR1L ; read and save counter
tm.HighByte = TMR1H
TMR1H = 0 ; reset counter to 0
TMR1L = 0
T1CON.0 = 1 ; (re)start counter
ttm = tm + (ovf * 65535)
ovf = 0
If ttm > 0 Then
; Fout = 39000000 /(ttm * 8) ; Fout[p/s] = (multiplier / divider[at output]) * 1000000 [us/s] / (cc [p] * 8[p/us])
Fout = 39000000 /(ttm * 2) ; Fout[p/s] = (multiplier / divider[at output]) * 1000000 [us/s] / (cc [p] * 8[p/us]) [with 4 multiplier at output]
If Fout > 245 Then HPWM 1, 127, Fout
EndIf
EndIf

If PIR1.0 = 1 Then ;timer1 interrupt
If ovf < 2 Then ;Because the timer counts a bit fast (thus accurate) we also need to count the overflows
ovf = ovf + 1
Else
T1CON.0 = 0 ;stop counter as the car has stopped (no input VSS pulse within 1,5 seconds)
TMR1H = 0
TMR1L = 0
Fout = 0
ovf =0;
T2CON=%0000000 ; stop hpwm
EndIf
PIR1.0 = 0 ; reset timer interupt flag
EndIf
INTCON = %11010000 ; Reset all interrupt flags
Return
ECT


Conversion values to program the Modifry module:

[738] millivolts - 2nd bar lights at 71°C
[600] millivolts - 3rd bar lights at 79°C
[478] millivolts - 4th bar lights at 88°C
[389] millivolts - 5th bar lights at 96°C
[297] millivolts - 6th bar lights at 104 °C estimated value - verify
[229] millivolts - red bar lights at 110 °C estimated value - verify
[297] millivolts - POYM! alarm on at 104 °C estimated value – verify


Code to program your own module instead o f the Modifry module:
Device 12F675
Config INTRC_OSC_NOCLKOUT, WDT_OFF, MCLRE_ON
'AN3 = ECT input signal = input (pin 3)
'GP5 = ECT output signal = output (pin 2)

TRISIO = %00011111 'all ports inputs
ANSEL = %00001000 'AN3 (GP4) is analog input
CMCON = %00000111 'Shut down the comparator
ADCON0 = %10000000 'right justify the A/D result

Dim adc As Word
Dim temp As Word
Dim i As Word
Dim ht As Word
Dim lt As Word

adc = 0
temp = 0
i=0
ht = 30 ; high level is always 30ms
lt = 0


GPIO.5 = 0

DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 0
DEFINE ADC_SAMPLEUS 10
While 1=1

adc = ADIn 3 ; Read channel AN3
; adc = adc / 2 ; To have a full scale reading during tests.

For i = 0 To 6
; in celsius: [ 113, 104, 96, 88, 79, 71, cold]
temp = LookUpL i, [ 71, 87, 106, 131, 161, 200, 1024]
If adc > temp Then
i=i
Else
; in bars/segments: [ 7, 6, 5, 4, 3, 2, 1]
lt = LookUpL i, [ 150, 220, 300, 400, 700, 1100, 1500]
i=7
EndIf
Next

GPIO.5 = 1
DelayMS ht
GPIO.5 = 0
DelayMS lt
Wend
End

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:0
posted:3/2/2013
language:English
pages:4