The bear
Senior Member
Hello Everyone,
My project, is to motorise a garden awning, using a 12 volt car wiper motor.
I have a program, that uses two limit switches.
My friend JPB33 suggested using a counter instead, to simplify the wiring,
it made sense to me.
However, I'm stuck. I 've searched the forums but cannot find anything that works for me.
I would like to be able to count the revolutions of the motor shaft, e.g. say 50 then stop the
motor, awning now fully open. Likewise to close it. I have some sensors.
http://www.vishay.com/docs/83760/tcrt5000.pdf
Program attached. ( Note to Tex, I have used symbols, just hope they are meaningful).
My project, is to motorise a garden awning, using a 12 volt car wiper motor.
I have a program, that uses two limit switches.
My friend JPB33 suggested using a counter instead, to simplify the wiring,
it made sense to me.
However, I'm stuck. I 've searched the forums but cannot find anything that works for me.
I would like to be able to count the revolutions of the motor shaft, e.g. say 50 then stop the
motor, awning now fully open. Likewise to close it. I have some sensors.
http://www.vishay.com/docs/83760/tcrt5000.pdf
Program attached. ( Note to Tex, I have used symbols, just hope they are meaningful).
Code:
;Awning Project 3 (Limit Switches) 21.05.15 65 Bytes
#picaxe 14m2
#No_data
let dirsC = %000110
let dirsB = %0111001
symbol paus = 1000 ;mS
symbol open_switch = pinC.3 ;OPEN
symbol close_switch = pinC.0 ;CLOSEsymbol motor_on_open = C.1
symbol motor_close = C.2
symbol motor_open = C.1
symbol limit_switch1 = pinB.1 ;Open
symbol limit_switch2 = pinB.2 ;Close
low C.1:low C.2
main:
pause paus
if open_switch = 1 then ;OPEN switch
gosub open_awning
endif
if close_switch = 1 then ;CLOSE switch
gosub close_awning
endif
goto main
close_awning:
pause paus
high motor_close ;To transistor & relay 2 (Clockwise)
Do until limit_switch2 = 1 ; pinB.2 = 1
loop
low motor_close ;To transistor & relay 2 (Clockwise)
pause paus
return
open_awning:
pause paus
high motor_open ;To transistor & relay 1 (Anticlockwise)
Do until limit_switch1 = 1 ;pinB.1 = 1
loop
low motor_open ;To transistor & relay 1 (Anticlockwise)
pause paus
return