;Beta v0.1
;Mattstrikes TCC controller for turbo K2500 3.8l v6
;Primary sensor inputs as follows
;
;Digital Inputs:
;
; MAP sensor:
; Information copied from https://www.robietherobot.com/storm/mapsensor.htm
; TPS sensor:
; Engine Coolant Temperature Sensor
; Information from http://wps.prenhall.com/wps/media/objects/6955/7122251/ppts/Chapter30.ppt
;
;Analog inputs:
; PCM VSS output
;
;lockup with 0% throttle is intentional.
;Wait until ECT is above 140F (Given the lack of information, this will have to be monitored and adjusted, and may be PCM and sensor specific)
;25mph...less than 7% throttle...no MAP input
;30mph...less than 10% throttle...no MAP input
;35mph...less than 12% throttle...no MAP input
;40mph...less than 14% throttle...no MAP input
;45mph...less than 15% throttle...no MAP input
;50mph...less than 16% throttle...less than 0.5psi
;55mph...less than 17% throttle...less than 1psi
;60mph...less than 18% throttle...less than 1.5psi
;65mph...less than 19% throttle...less than 2psi
;70+mph..less than 20% throttle...less than 2.5psi
;
;PICAXE 08M pin assignments
;pin 1 = +5v
;pin 2 = C.5
;pin 3 = C.4 ADC/IN/OUT 4.............ECT digital input 0-5v
;pin 4 = C.3 IN 3.....................VSS analog input (switched ground)
;pin 5 = C.2 ADC/IN/OUT/PWM 2.........MAP digital input 0-5v
;pin 6 = C.1 ADC/IN/OUT 1.............TPS digital input 0-5v
;pin 7 = C.0 OUT/SERIALOUT/INFRAOUT...TCC analog output to transistor circuit to control a relay
;pin 8 = GND
;
#picaxe 08m ;Identify PICAXE used is the 08M
;assign input/output names
symbol TCC = C.0
symbol TPS = pinC.1
symbol MAP = pinC.2
symbol MPH = pinC.3
symbol ECT = pinC.4
;assign general purpose memory
symbol temp = b0
symbol speed = b1
symbol throttle = b2
symbol boost = b3
symbol tccstate = b4
;assign VSS ranges
symbol v_0 = 28
symbol v_1 = 33
symbol v_2 = 39
symbol v_3 = 44
symbol v_4 = 50
symbol v_5 = 56
symbol v_6 = 61
symbol v_7 = 66
symbol v_8 = 72
symbol v_9 = 78
;Program initialize;
Init0: ;Label Init0.
Low TCC ;TCC off
wait 20 ;wait 20 seconds. This sequence is to protect against bucking from emergency engine re-start while vehicle is moving.
;provided that circuit is only powered during key on, and not when key is in start position
goto ECT0
;poll ECT sensor every 10 seconds until coolant reaches 140F.
ECT0: ;Label ECT0.
ReadADC ECT, temp ;Read sensor, output variable named temp
If temp > 76.5 ;if engine coolant less than 140F
then wait 10 ;wait 10 seconds
end if
If temp <= 76.5 ;if engine coolant 140F or more
Goto Input0 ;jump to TCC program start
end if
goto ETC0 ;loop ECT check
;Begin TCC Logic program
;Read Sensors
Input0: ;Label Input0 - read sensors
pause 500 ;wait 500ms
Count C.3, 1000, speed ;VSS - Count pulses over 1 second, output variable is named speed
ReadADC C.1, throttle ;TPS - Read sensor, output throttle variable named TPS
ReadADC C.2, boost ;MAP - Read sensor, output variable named MAP
goto Main0
;Current state variables defined. Begin Logic
Main0: ;Label Main0.
if speed < v_0 then ;If speed is less than 25mph
goto TCC1
end if
if speed > v_9 then ;if speed is greater than 70mph
if throttle < 51 and boost < 147 then ;if throttle is less than 20% and boost less than 2.5psi
goto TCC0
end if
goto TCC1
end if
select speed
case v_0 to v_1 ;when vehicle speed is between 25 and 30
if throttle < 17.75 then ;if throttle is less than 7%
goto TCC0
end if
goto TCC1
case v_1 to v_2 ;vehicle speed 30-35
if throttle < 25.5 then ;throttle under 10%
goto TCC0
end if
goto TCC1
case v_2 to v_3 ;vehicle speed 35-40
if throttle < 30.6 then ;throttle under 12%
goto TCC0
end if
goto TCC1
case v_4 to v_5 ;speed 40-45
if throttle < 35.7 then ;throttle under 14%
goto TCC0
end if
goto TCC1
case v_5 to v_6 ;speed 45-50
if throttle < 38.25 then ;throttle under 15%
goto TCC0
end if
goto TCC1
case v_5 to v_6 ;speed 50-55
if throttle < 40.8 and boost < 129 then ;throttle under 16% and boost under 0.5psi
goto TCC0
end if
goto TCC1
case v_6 to v_7 ;speed 55-60
if throttle < 43.35 and boost < 134 then ;throttle under 17% and boost under 1psi
goto TCC0
end if
goto TCC1
case v_7 to v_8 ;speed 60-65
if throttle < 45.9 and boost < 138 then ;throttle under 18% and boost under 1.5psi
goto TCC0
end if
goto TCC1
case v_8 to v_9 ;speed 65-70
if throttle < 48.5 and boost < 142 then ;throttle under 19% and boost under 2.0psi
goto TCC0
end if
goto TCC1
endselect
;TCC processes
TCC0: ;label TCC0
readoutputs tccstate ;check if TCC is already on
if tccstate < 1 then ;if TCC is off
high TCC ;turn on TCC
goto Input0 ;loop back to sensor read
end if
goto Input0
TCC1: ;label TCC1
readoutputs TCCstate ;check if TCC is already off
if tccstate > 0 then ;if TCC is on
low TCC ;Turn off TCC
goto Input0 ;Loop back to sensor read
end if
goto Input0