for the past days i have struggled with a power controller, the functions are:
1. when pin 3 goes high it checks if its still high after 3 secs, if that is the case it activates relay 1 after another 5 secs and relay 2 after 5 more secs
2. when pin 3 goes low it shuld hold the relays for 20 secs.
there are also a rutine to check for battery voltage.
the setup is used to power up a car pc when acc lines goes high and to cut power 20 secs after acc line goes low.
the power up sequence is spot on as i want it, but power is cut as soon as acc goes low.
my schematic are below (disregard the programmng connector), the program in the picaxe:
Strange enough it works in simulator but not in real life...
1. when pin 3 goes high it checks if its still high after 3 secs, if that is the case it activates relay 1 after another 5 secs and relay 2 after 5 more secs
2. when pin 3 goes low it shuld hold the relays for 20 secs.
there are also a rutine to check for battery voltage.
the setup is used to power up a car pc when acc lines goes high and to cut power 20 secs after acc line goes low.
the power up sequence is spot on as i want it, but power is cut as soon as acc goes low.
my schematic are below (disregard the programmng connector), the program in the picaxe:
Code:
boot:
Symbol Whole_2 = B11
Symbol Fract_2 = B12
Symbol C = B3 ;Var used to detect if the initial 3 sec acc line check has been done
Symbol T = B0 ;Counter used in for next loop
C = 0 ;Reset C
T = 0 ;Reset T
Low 1 ;Turn off AMP
Low 2 ;Turn off PC
ReadADC 4 , B1 ;Read the battery voltage and store it in B1
Whole_2 = B1 * 5 * 4 / 255 'Whole number
Fract_2 = B1 * 5 * 4 * 100 / 255 // 100 'Digits
SerTxD ("Battery: ",#Whole_2, ".", #Fract_2)
If B1 < 141 Then battlow ;Battery voltage is too low - Adjust value after < to fit your needs, if voltage is ok program will just continue on next line. Otherwise it will jump to battlow section
B2 = Pin3 ;Store status of ACC Line in B2
If B2 = 1 Then boot ;Go to start of boot section
If B2 = 0 Then ignon ;Go to ignon section
main:
ReadADC 4, B1 ;Read the battery voltage and store it in B1
Whole_2 = B1 * 5 * 4 / 255 'Whole number
Fract_2 = B1 * 5 * 4 * 100 / 255 // 100 'Digits
SerTxD ("Battery: ",#Whole_2, ".", #Fract_2)
B2 = Pin3 ;Store status of ACC Line in B2
If B1 < 141 Then battlow ;Battery voltage is too low - Adjust value after < to fit your needs
If B2 = 1 Then ignoff ;Go to IgnOff Section
If B2 = 0 Then ignon ;Go to IgnOn section
ignoff:
Pause 20000 ;Wait for 20 seconds
low 2 ;Turn off PC
low 1 ;Turn off AMP
Goto boot ;Got to the boot section
ignon:
If C > 0 Then main ;Jump to main section if the acc line has been on for at least 3 sec's without interrupt ie crank engine
For T = 0 to 3 ;The next 3 lines put 3 sec wait in to the loop
Pause 1000
Next
B2 = Pin3 ;Store status of ACC Line in B2
If B2 = 1 Then boot ;If Acc line is low then go to boot, this will reset C and we start over, otherwise the program will continue
C = C + 1 ;Add 1 to C, once this is done it will skip the the ignon part because the first line will kick it back the main section
Pause 5000 ;Wait for 5 seconds, adjust as needed
High 1 ;Turn on PC
Pause 5000 ;Wait for 5 seconds, adjust as needed
High 2 ;Turn on AMP
Goto main
battlow:
Low 2 ;Turn off PC
Low 1 ;Turn off AMP
ReadADC 4, B1 ;Read the battery voltage and store it in B1
Whole_2 = B1 * 5 * 4 / 255 'Whole number
Fract_2 = B1 * 5 * 4 * 100 / 255 // 100 'Digits
SerTxD ("Battery: ",#Whole_2, ".", #Fract_2)
If B1 > 166 Then boot ;Adjust value after > to fit your needs - Tells when its ok to return to normal, until the voltage goes over this value the program will stay here. Once voltage is ok it will start from the boot section
Goto battlow
Attachments
-
43.7 KB Views: 48
Last edited: