Just started a few days ago, PBPro Compiler gives me a whole list of syntax errors etc.. Please let me know if what is wrong it.
[html]
' Set Internal Oscillator to 4MHz
' Pin 01 - V_DD - +5v
' Pin 08 - V_SS - GND
'
' GPIO.0 - GP0 - 07 - DIG - input for momentary button
' GPIO.1 - GP1 - 06 - DIG - output for op indicator LED
' GPIO.2 - GP2 - 05 - DIG - output to switch on sprayer
' GPIO.3 - GP3 - 04 - DIG - input to monitor fan op
' GPIO.4 - GP4 - 03 - DIG - NC
' GPIO.5 - GP5 - 02 - DIG - NC
'
'---------- Options ------------------------------------------------------------
define OSC $60 'Set oscillator (clk) to 4MHz
ANSEL = %000000 'Analog/Digital ports
INTCON = 'GPIO External interrupts
GPIO = %000000 'Set High/Low GPIO.5 -> GPIO.0 (all low)
TRISIO = %001001 'Set input/output GPIO.5 -> GPIO.0 (GP0 & 3 input)
'---------- Constants & Symbols/Variables --------------------------------------
M_BUT con GPIO.0 'Name bit 0 of GPIO to Momentary Button
LED con GPIO.1 'Name bit 1 of GPIO to LED
PUMP con GPIO.2 'Name bit 2 of GPIO to Pump
FAN con GPIO.3 'Name bit 3 of GPIO to Fan
symbol ON_OFF = 1
'---------- Subroutines & Loops ------------------------------------------------
PUMP_RUN: 'This is defined for the pump on/off
symbol X0 = 0 'X0 is the variable used in LED_F loop for counting
pump = 0 'Turn misting pump on
LED_RUN: 'LED Flash loop begins here
if X0 < 10 then
gosub LED_F
else
LED = 0 'Makes sure LED is off
pump = 0 'Turns relay controlling the pump off
return 'Returns to main code
LED_F:
LED 1 'Turns on the warning LED
pause 500 'Pause 500mS (1/2 second) with LED on
LED = 0 'Turns off warning LED
pause 500 'Pause 500mS (1/2 second) with LED off
X0 + 1 'This adds 1 to variable X0 each time it loops
goto LED_RUN 'Returns to begining of LED Flash loop
FAN_RUN:
if FAN = 1 then 'If cooling fans are on then...
gosub Pump_run 'Run pump sequence
pause 15000 'Pause for 15 seconds, no point in saturating
else
pause 5000 'Pause for 5 seconds
goto fan_run 'Returns to beginning to see if fan is running
ENDIF
'---------- Main Code ----------------------------------------------------------
if M_BUT = 1 then 'If the button is pressed then...
Pause 2000 'Wait 2 seconds before continuing
if M_BUT = 1 then 'If button is still pressed
gosub PUMP_RUN 'Then run the pump and flash LED
else
if ON_OFF = 1 then 'If auto-spray is on...
ON_OFF = 0 'Then turn it off
else 'Otherwise...
ON_OFF = 1 'Turn auto-spray on
ENdif
ENDIF
ENDIF
[/html]
Only other question with this is, do I need to use an interrupt for the button if the fan trig has turned on the pump, and running the LED Flash loop?
Bookmarks