Air Ride controller

ol boy

Member
I have the idea for several years but could never get the project started. I then found this website and downloaded the code editer and manuals. After 2 days of tinkering on my down time I was able to write some code to control ride hieght based on vehical speed.

I want to use the 20M IC and us the 4 adc channels to control 5 output pins. Everything works as I like on the simulator. Trying to design a PCB to house the processor and a freq to volt converter for vehicle speed and other hardware.

Can someone read through my code to see if there is anyway improve it? Any feed back on the project as a whole would be great.

The idea is to use 2 TPS type sencors, one placed on each axle and a pressure sender on the air tank, based on adc counts I can turn on or off 5 relay inputs. Compressor relay, front up, front down, rear up and rear down.

All the adc counts listed in the code will have to change once installed in the car of course. Any advise would be great Thanks Ryan

'airride based on veh speed 4 ride hights for 4 different speed zones 233 byts. PIX 20M
main:
readadc 1,b1 'read adc count at adc1
if b1 < 220 then high 1 'turn on compressor when below adc count 220
elseif b1 > 230 then low 1 'turn off compressor when above adc count 230
endif

if b1 < 180 then flash_1 'if tank below 180 adc all output will stay low
'and code skips to flash1 below
readadc 2, b2 'read adc count at adc2 front height input
readadc 3, b3 'read adc count at adc3 rear height input
readadc 7, b7 'read adc count at adc4 speed input

if b7 > 125 then flash_4 'when speed is above 125 skip to flash4 settings >75mph
if b7 > 110 then flash_3 'when speed is above 110 skip to flash3 settings >60mph
if b7 > 80 then flash_2 'when speed is above 80 skip to flash2 settings >40mph

if b2 < 170 then high 2 'if adc is below 170 turn output 2 on
elseif b2 > 180 then low 2 'adc count above 180 turn output 2 off
endif

if b3 < 170 then high 4 'if adc is below 170 turn output 4 on
elseif b3 > 180 then low 4 'adc count above 180 turn output 4 off
endif

if b2 > 180 then high 3 'when adc reaches above 180 turn output 3 on
pause 1000 'pause 1 second to deflate
switch off 3 'turn off output 3
endif 'ride height below 40mph

if b3 > 180 then high 5 'when adc reaches above 180 turn on ouput 5
pause 1000 'pause 1 second to deflate
switch off 5 'turn off output 5
endif 'ride height below 40mph
goto main 'start over

flash_1: 'from above
low 2 'output 2 low
low 3 'output 3 low
low 4 'output 4 low
low 5 'output 5 low
goto main 'start over

flash_2: 'from above
if b2 < 150 then high 2 'if adc is below 150 turn output 2 on
elseif b2 > 160 then low 2 'adc count above 160 turn output 2 off
endif

if b3 < 150 then high 4 'if adc is below 150 turn output 4 on
elseif b3 > 160 then low 4 'adc count above 160 turn output 4 off
endif

if b2 > 160 then high 3 'when adc reaches above 160 turn output 3 on
pause 1000 'pause 1 second to deflate
switch off 3 'turn off output 3
endif 'ride height above 40mph

if b3 > 160 then high 5 'when adc reaches above 160 turn on ouput 5
pause 1000 'pause 1 second to deflate
switch off 5 'turn off output 5
endif 'ride height above 40mph
goto main

flash_3: 'from above
if b2 < 130 then high 2 'if adc is below 130 turn output 2 on
elseif b2 > 140 then low 2 'adc count above 140 turn output 2 off
endif

if b3 < 130 then high 4 'if adc is below 130 turn output 4 on
elseif b3 > 140 then low 4 'adc count above 140 turn output 4 off
endif

if b2 > 140 then high 3 'when adc reaches above 140 turn output 3 on
pause 1000 'pause 1 second to deflate
switch off 3 'turn off output 3
endif 'ride height above 60mph

if b3 > 140 then high 5 'when adc reaches above 140 turn on ouput 5
pause 1000 'pause 1 second to deflate
switch off 5 'turn off output 5
endif 'ride height above 60mph
goto main

flash_4: 'from above
if b2 > 125 then high 3 'when adc reaches above 125 turn output 3 on
pause 1000 'pause 1 second to deflate
switch off 3 'turn off output 3
endif 'ride height above 75mph

if b3 > 125 then high 5 'when adc reaches above 125 turn on ouput 5
pause 1000 'pause 1 second to deflate
switch off 5 'turn off output 5
endif 'ride height above 75mph
goto main
 
Top