'Code by Charles R. Hampton
'Written for PICAXE-08M, but should run (with mods) on any PICAXE with at least 4 outputs.
'Drives 1.8 degree unipolar stepper motor in single 10 ms. steps with increased torque.
'Turns motor clockwise 60 turns, which takes 2 minutes and 11 seconds.
'Removes power from motor.
'Waits 5 hours, 57 minutes, and 49 seconds.
'Turns motor counter clockwise 60 turns, which takes 2 minutes and 11 seconds.
'Removes power from motor.
'Waits 5 hours, 57 minutes, and 49 seconds.
'Repeats.
'One complete cycle through "main" should take 12 hours, 0 minutes, and 0 seconds.
symbol delay = 10 'pause duration (must be at least 1 ms. or motor will not turn)
' 10 ms. pauses results in 60 revolutions taking 2 minutes and 11 seconds
let dirs = %10110 'sets pins 4, 2, and 1 as outputs
'pin 3 is always an input; pin 0 is always an output
main:
for b1 = 1 to 60 'sets number of complete revolutions clockwise
for b0 = 1 to 50 '50 loops = 200 steps = 360 degrees clockwise
let pins = %10001 'windings 2b and 1a
pause delay
let pins = %00011 'windings 2a and 1a
pause delay
let pins = %00110 'windings 1b and 2a
pause delay
let pins = %10100 'windings 2b and 1b
pause delay
next b0
next b1
let pins = %00000 'removes power from motor
for b1 = 1 to 6 'sets number of "adjusted" hours motor stopped
for b0 = 1 to 60 'sets number of "adjusted" minutes motor stopped
pause 59625 'stops motor for 59.636 seconds (- .011 sec. clock adjustment)
next b0 'See Egg Turner Controller.xls for calculation details.
next b1
for b1 = 1 to 60 'sets number of complete revolutions counter clockwise
for b0 = 1 to 50 '50 loops = 200 steps = 360 degrees counter clockwise
let pins = %10100 'windings 2b and 1b
pause delay
let pins = %00110 'windings 1b and 2a
pause delay
let pins = %00011 'windings 2a and 1a
pause delay
let pins = %10001 'windings 2b and 1a
pause delay
next b0
next b1
let pins = %00000 'removes power from motor
for b1 = 1 to 6 'sets number of "adjusted" hours motor stopped
for b0 = 1 to 60 'sets number of "adjusted" minutes motor stopped
pause 59625 'stops motor for 59.636 seconds (- .011 sec. clock adjustment)
next b0 'See Egg Turner Controller.xls for calculation details.
next b1
goto main