the old fart
Senior Member
Hi Guys,
I have 3 electronic beams around my Koi Pond. The idea is that if any of the beams are broken, ie by a heron, then a water spray starts up to scare off the heron.
The water spray is from a pump mounted near the surface.
The system is working, using stripboard and relays, but I want to 'PIC' it.
I also have auto fill using another PIC, but thats another project.
I have programmed this to Picaxe 20m2.
I have 2 questions.
1/ is there a better way to transfer inputs 0-7 directly into b0-b7?
2/ main3: program I tried was: if (beam1=1 or switch1=1) and (beam2=1 or switch2=1) and (beam3=1 or switch3=1) then relay=1:else:relay=0:endif
is this possible as a single line command?
Cheers
Dave
I have 3 electronic beams around my Koi Pond. The idea is that if any of the beams are broken, ie by a heron, then a water spray starts up to scare off the heron.
The water spray is from a pump mounted near the surface.
The system is working, using stripboard and relays, but I want to 'PIC' it.
I also have auto fill using another PIC, but thats another project.
I have programmed this to Picaxe 20m2.
Code:
; pond beam control
; Picaxe-20M2
; input
;0 stop spray
;1 beam 1
;2 beam 2
;3 beam 3
;4 dil 1 overide beam1
;5 dil 2 overide beam2
;6 dil 3 overide beam3
;7 dil 4 stop buzz
;output
;o
;1 timed relay delay off 24vdc
;2 timed relay delay off 24vdc
;3 relay 24vdc
;4 relay 24vdc
;5 buzzer 24vdc
;6 buzzer 24vdc
;7 watchdog 4vdc
;inputs
symbol nospray = b0 ; disable spray
symbol beam1 = b1 ;beam1 good
symbol beam2 = b2 ;beam2 good
symbol beam3 = b3 ;beam3 good
symbol switch1 = b4 ;overide beam1
symbol switch2 = b5 ;overide beam2
symbol switch3 = b6 ;overide beam3
symbol nobuzz = b7 ;disable buzzer
;outputs
symbol drelay = b16
symbol relay = b17
symbol buzzer = b18
start:
main:
if pin0=1 then let nospray=1:else:nospray=0:endif
if pin1=1 then let beam1=1: else: beam1=0:endif
if pin2=1 then let beam2=1: else: beam2=0:endif
if pin3=1 then let beam3=1: else: beam3=0:endif
if pin4=1 then let switch1=1:else:switch1=0:endif
if pin5=1 then let switch2=1:else:switch2=0:endif
if pin6=1 then let switch3=1:else:switch3=0:endif
if pin7=1 then let nobuzz=1:else:nobuzz=0:endif
if drelay=1 then high 1,2:else:low 1,2:endif ; output 1 and 2 linked
if relay=1 then high 4,3: else: low 4,3: endif ;output 3 and 4 linked
if buzzer=1 and nobuzz=0 then high 6,5: else: low 6,5: endif ;output 5 and 6 linked
goto main
start1:
;watchdog
main1:
high 7
pause 300
low 7
pause 300
goto main1
start2:
main2:
if buzzer=0 or nospray=1 then goto end3
drelay=1
pause 7000
goto main2
end3:
drelay=0
goto main2
start3:
main3:
lab1:
if beam1=1 then lab3
if switch1=1 then lab3
lab6:
let relay=0
let buzzer=1
goto lab1
lab3:
if beam2=1 then lab4
if switch2=1 then lab4
goto lab6
lab4:
if beam3=1 then lab5
if switch3=1 then lab5
goto lab6
lab5:
let relay=1
let buzzer=0
goto lab1
goto main3
I have 2 questions.
1/ is there a better way to transfer inputs 0-7 directly into b0-b7?
2/ main3: program I tried was: if (beam1=1 or switch1=1) and (beam2=1 or switch2=1) and (beam3=1 or switch3=1) then relay=1:else:relay=0:endif
is this possible as a single line command?
Cheers
Dave