' {$STAMP BS2}
'Transmission shifting program for a 1991 Toyota Corolla
speed VAR Byte
lastspeed VAR Byte
performance VAR Bit
overdrive VAR Bit
brakes VAR Bit
tpswot VAR Bit
tpsidle VAR Bit
pulses VAR Word
newpulses VAR Word
pulses=0 'initializes the variable "pulses"
INPUT 0 'speed sensor input
INPUT 1 'performance switch input
INPUT 2 'O/D switch input
INPUT 3 'brake switch input
INPUT 4 'TPS WOT input
INPUT 5 'TPS idle input
OUTPUT 8 'output to solenoid 1
OUTPUT 9 'output to solenoid 2
OUTPUT 10 'output to lockup solenoid
mainloop:
performanceswitch:
IF IN1=0 THEN performanceon 'sets status of performance switch to ON
IF IN1=1 THEN performanceoff 'sets status of performance switch to OFF
performanceon:performance=1
GOTO overdriveswitch
performanceoff:performance=0
overdriveswitch:
IF IN2=0 THEN overdriveoff 'sets status of overdrive switch to O/D OFF (down position)
IF IN2=1 THEN overdriveon 'sets status of overdrive switch to O/D ON (up position)
overdriveoff:overdrive=0
GOTO brakestatus
overdriveon:overdrive=1
brakestatus:
IF IN3=0 THEN brakesoff 'sets status of brakes to OFF (brakes not applied)
IF IN3=1 THEN brakeson 'sets status of brakes to ON (brakes applied)
brakesoff:brakes=0
GOTO tpswotstatus
brakeson:brakes=1
tpswotstatus:
IF IN4=0 THEN tpswotoff 'sets status of tpswot to OFF (throttle is not WOT)
IF IN4=1 THEN tpswoton 'sets status of tpswot to ON (throttle is WOT)
tpswotoff:tpswot=0
GOTO tpsidlestatus
tpswoton:tpswot=1
tpsidlestatus:
IF IN5=0 THEN tpsidleoff 'sets status of tpsidle to OFF (throttle is not at idle)
IF IN5=1 THEN tpsidleon 'sets status of tpsidle to ON (throttle is at idle)
tpsidleoff:tpsidle=0
GOTO speedsensing
tpsidleon:tpsidle=1
speedsensing:
COUNT 0, 500, newpulses 'retrieves speed sensor info
pulses=(pulses + newpulses)/2 'averages the count to smooth it out
speed = pulses/2
'IF tpswot=1 THEN accel
'IF tpsidle=1 THEN decel
normal:
'IF lastspeed > speed THEN mainloop 'keeps trasmission from downshifting in normal mode
'lastspeed=speed
'IF performance=0 THEN normalgearselect
'IF performance=1 THEN speedmodify 'modifies speed value if performance switch is on
'speedmodify:
'speed = speed - 5
normalgearselect:
IF speed < 15 THEN firstgear
IF speed >=15 AND speed < 25 THEN secondgear
IF speed >=25 AND speed < 40 THEN thirdgear
'IF overdrive = 0 THEN thirdgear
IF speed >= 40 THEN fourthgear
'accel: 'acceleration shift pattern
'IF speed < 30 THEN firstgear
'IF 30 <= speed < 60 THEN secondgear
'IF 60 <= speed < 80 THEN thirdgear
'IF overdrive = 0 THEN thirdgear
'IF speed >= 80 THEN fourthgear
'decel: 'deceleration shift pattern
'LOW 10 'turns off Lock up solenoid
'IF performance=0 THEN normaldecel
'IF performance=1 THEN perfdecel
'normaldecel: 'normal deceleration pattern
'IF speed < 10 THEN firstgear
'GOTO mainloop
'perfdecel: 'performance deceleration pattern
'IF speed < 10 THEN firstgear
'IF 10 <= speed < 20 THEN secondgear
'IF 20 <= speed < 30 THEN thirdgear
'GOTO mainloop
firstgear: 'First gear solenoid activation
HIGH 8
LOW 9
LOW 10
GOTO mainloop
secondgear: 'Second gear solenoid activation
HIGH 8
HIGH 9
LOW 10
GOTO mainloop
thirdgear: 'Third gear solenoid activation
LOW 8
HIGH 9
LOW 10
GOTO mainloop
fourthgear: 'Fourth gear (O/D) solenoid activation
LOW 8
LOW 9
LOW 10
'IF speed < 45 THEN mainloop
'IF speed >= 45 THEN brakeidlecheck
'brakeidlecheck:
'IF brakes=1 THEN mainloop
'IF tpsidle=1 THEN mainloop
'lockup:
'HIGH 10
GOTO mainloop