Hi, Shirleyzzzzzzzz ...
that's it !
Find here an application ...
Code:
'****************************************************************
'* Name : Glow Driver with Fail Safe - 1 *
'* Author : Ironsides *
'* Notice : Copyright (c) 2004 C *
'* : All Rights Reserved *
'* Date : 24 Feb 2004 *
'* Version : 1.0 *
'* Notes : Turns on glow driver to glow plug at low throttle *
'* If sigal is lost for 5 secs, engine is killed and *
'* glow power turned off *
'* ; An N Channel MOSFET is needed to carry the current*
'* ; See the circuit diagram for details *
'* Caution : Should have a safety cut off switch in the pits *
'* : For PIC 12F675 *
'****************************************************************
;The 12F675 has both analog converters and analog comparators.
;You must disable both to use the I/O pins for digital functions.
;In addition, the register that controls the analog converters
;has been named ANSEL, and it has a different format that the ADCON1
;register found on most PICmicro MCUs
PCON.3 = 1
ANSEL = 0 ;needed as as above
CMCON = 7
ASM
errorlevel -302 ; Suppress message 302
bcf STATUS,RP0 ; Bank 0
clrf GPIO ; Init GPIO
movlw 07h ; Set GP<2:0> to
movwf CMCON ; digital IO
bsf STATUS,RP0 ; Bank 1
clrf ANSEL ; Digital IO
movlw 0Ch ; Set GP<3:2> as inputs
movwf TRISIO ; and set up GP<5:4,1:0> as outputs
endasm
DEFINE OSC4 ;sets up 4 meg internal oscillator
THROTTLE VAR GPIO.1 ;Outputs to throttle servo - Pin 6
GLOW VAR GPIO.2 ;Output to MOSFET driving glow driver - Pin 5
RADIO VAR GPIO.3 ;Input from receiver - Pin 4
TEST VAR WORD ; Used to test for loss of signal
P VAR WORD ; This stores the PULSIN value
N VAR WORD ; Loop counter
;*********************************************************************
TEST = 0
RX: ; This is where we wait for a signal from the Tx
PULSIN RADIO,1,P ; With 4 meg oscillator, PULSIN measures at 10 millisecs
IF (P < 50) and (test = 0) then GOsub LOS ; Loss of signal
PULSIN RADIO,1,P ; Check to see if signal re-established
if (P < 50) and (test = 1) then goto kill_glow
; There is loss of signal - kill the engine
IF (P > 100) and (P < 130) THEN GOSUB SW_ON ; Turn on glow
IF (P > 130) THEN GOSUB SW_OFF ; Turn off glow
goto RX
;********************************************************************
SW_ON:
HIGH GLOW ; This tunrs on the glow signal on Pin 5
PULSOUT THROTTLE, p ; send the normal signal to the throttle servo
RETURN
SW_OFF:
LOW GLOW ; This turns off the glow signal on Pin 5
PULSOUT THROTTLE, p ; send the normal signal to the throttle servo
RETURN
LOS:
TEST = 1 ; Set for loss of signal
For N = 1 to 5
Pause 1000 ; one second - 5 secs total
NEXT n
return
KILL_GLOW:
low glow ; Turn off the glow plug
KILL_ENGINE:
PULSOUT throttle, 101 ; Kill engine - adjust this value to get the
; carb closed to prevent dirt from entering
pause 50 ; Needs a pause to stop servo hum
goto KILL_ENGINE ; Keep in loop to stop spurious signals
;********************************************************************
END ;Terminate the program
Alain
Bookmarks