bigal_scorpio
Active Member
Hi to all,
Thanks to a discussion on general I have been pointed in the right direction to get my project running.
I want to run a Laptop PC in the back of the car and need it to go into standby when the ignition is off and awake when ignition turned on. This seems simple just to send a pulse to a relay that shorts out the switch on the lappy.
I got that far but then got bogged down with the problem as you need to send a pulse to turn on and off according to the ignition position.
I have got as far as the pulse circuit and it was ok, but could get out of sync with a quick on off of the key so I asked the forum for ideas and a member gave me the idea of using the power led for feedback (on steady is on and flashing is standby, so I wrote a bit more code to implement it but it doesn't work as I expected!
GPIO.0 is the ignition feed and GPIO.1 is the feed from the power LED.
Turning on is fine with power to GPIO.0 and all is ok when GPIO.1 is constant.
The problem occurs when I switch off ignition ie GPIO.0 = 0 and GPIO.1 is on, it does send the off pulse needed but then after the delay it goes on sending it even though the ignition is off and the Power LED is only pulsing at about 1hZ.
What am I doing wrong here? I have tried various ways and thought I had it a few times but it just keeps on sending the pulse when it shouldn't.
I must be nearing the flashing limit of the pic now!
The PIC is a 12F629 and the code is below, please have a look.
Al
Thanks to a discussion on general I have been pointed in the right direction to get my project running.
I want to run a Laptop PC in the back of the car and need it to go into standby when the ignition is off and awake when ignition turned on. This seems simple just to send a pulse to a relay that shorts out the switch on the lappy.
I got that far but then got bogged down with the problem as you need to send a pulse to turn on and off according to the ignition position.
I have got as far as the pulse circuit and it was ok, but could get out of sync with a quick on off of the key so I asked the forum for ideas and a member gave me the idea of using the power led for feedback (on steady is on and flashing is standby, so I wrote a bit more code to implement it but it doesn't work as I expected!
GPIO.0 is the ignition feed and GPIO.1 is the feed from the power LED.
Turning on is fine with power to GPIO.0 and all is ok when GPIO.1 is constant.
The problem occurs when I switch off ignition ie GPIO.0 = 0 and GPIO.1 is on, it does send the off pulse needed but then after the delay it goes on sending it even though the ignition is off and the Power LED is only pulsing at about 1hZ.
What am I doing wrong here? I have tried various ways and thought I had it a few times but it just keeps on sending the pulse when it shouldn't.
I must be nearing the flashing limit of the pic now!
The PIC is a 12F629 and the code is below, please have a look.
Code:
program PCtimer
DIM fla as byte
DIM lamp as byte
DIM b as byte
DIM i as byte
CMCON = 07
TRISIO = %00000011
GPIO = %00000000
main:
lamp = 0 'reset lamp count
For b = 1 to 10
delay_ms(200)
fla = (GPIO.1)
lamp = lamp + fla
next b
IF (GPIO.0 = 1) and lamp <9 THEN 'on criteria
goto pulse
End if
IF (GPIO.0 = 0) and lamp >7 THEN 'off criteria
goto pulse
End if
GOTO main
PULSE:
GPIO.2 = 1 'set pulse on GPIO.2 for 1 sec
DELAY_MS(1000)
GPIO.2 = 0
GPIO.4 = 1 'show by LED on GPIO.4 that delay is working
For i = 1 to 5 'set period to wait before checking status again
DELAY_MS(1000)
NEXT i
GPIO.4 = 0 'turn off delay LED
GOTO main
End.
Al