Hi All,
First the disclaimer: While I've been working with servos for 30+ years in R/C aircraft, this is my first attempt to integrate them with picaxe......
I thought that since one of my hobbies is R/C aircraft, and I love clocks, it would be appropriate to construct a clock using servos - with the final product having maybe R/C airplane props as hands to complete the theme.
Anyway, I designed a basic setup with three servos, one for hours, one for '10s' of minutes and the third for minutes.
Initially, I had the whole mess on the AXE091 board using the same 5V supply to power everything. I experienced nothing but resets - which I thought might happen given that I know servos are very noisy (electrically). I re-designed my setup on a larger breadboard with twin 7805 regulator based power supplies fed from a dual secondary transformer. One supplies the 1307 RTC and the 28X1picaxe and the other supplies the three servos (diagram attached).
Even with dual supplies, filtering caps and bypass caps on the 1307, the 28X1 and even on the 28X1's reset pin, I still got nothing but resets - evidenced by the three servos executing their start of program sweep test per the code:
I tried a few things and came upon my particular solution quite by accident. If I put a 2 second (or more) delay after the inital servo sweep test AND a debug statement just after the readi2c line, the clock works perfectly and does not reset. If I shorten the delay to anything less than two seconds OR remove / remark-out the debug statement, it will continually reset. When it resets, it also resets ALL the DS1307 registers (see attached screenshot of debug screen)
Looking in the manual under the servo command I see reference to not being unable to use the servo command at the same time as timer or pwmout/hpwm. I'm not using these - unless timer is somehow a part of pause or wait ??
I get the same result whether the servos are connected or not. I've physically disconnected the three servos and it still resets.
As long as I have the 2 sec or longer delay and the debug statement, the clock works flawlessly even after I disconnect the pogramming cable. I've let it run for hours beside me while I'm on the computer and t never resets once....
Any thoughts because I'm stumped
Regards, John.
First the disclaimer: While I've been working with servos for 30+ years in R/C aircraft, this is my first attempt to integrate them with picaxe......
I thought that since one of my hobbies is R/C aircraft, and I love clocks, it would be appropriate to construct a clock using servos - with the final product having maybe R/C airplane props as hands to complete the theme.
Anyway, I designed a basic setup with three servos, one for hours, one for '10s' of minutes and the third for minutes.
Initially, I had the whole mess on the AXE091 board using the same 5V supply to power everything. I experienced nothing but resets - which I thought might happen given that I know servos are very noisy (electrically). I re-designed my setup on a larger breadboard with twin 7805 regulator based power supplies fed from a dual secondary transformer. One supplies the 1307 RTC and the 28X1picaxe and the other supplies the three servos (diagram attached).
Even with dual supplies, filtering caps and bypass caps on the 1307, the 28X1 and even on the 28X1's reset pin, I still got nothing but resets - evidenced by the three servos executing their start of program sweep test per the code:
Code:
'Servo connections:
'Hours on Out0 (Pin 21)
'10's of minutes on Out1 (Pin 22)
'Minutes on Out2 (Pin 23)
'All servo signal feeds through 330 ohm series resistor.
wait 2 'wait 2 seconds for settling
setfreq m8 'sets operating frequency at power-on
i2cslave %11010000, i2cslow, i2cbyte 'initiates and sets DS1307 slave address
'Initialize servos '225 is full CCW, 75 is full CW
servo 0,210
servo 1,210
servo 2,210
'Cycle test servos clockwise
b0 = 10 'step delay (Max 255)
for b1 = 218 to 97 step - 1
servopos 0, b1
pause b0
next
for b2 = 220 to 110 step -1
servopos 1, b2
pause b0
next
for b3 = 220 to 103 step - 1
servopos 2, b3
pause b0
next
'Return servos to home position
for b3 = 103 to 220
servopos 2, b3
pause b0
next
for b2 = 110 to 220
servopos 1, b2
pause b0
next
for b1 = 97 to 218
servopos 0, b1
pause b0
next
wait 2 'if delay is <2, then picaxe continually resets
'and debug screen never populates (remains blank)
'wait 1 'delay can be wait 1 and pause 1000 - as long as
'pause 1000 'it totals 2 or more seconds
b3 = 60 'ensure b3 can't be same as b1
'Read RTC
read_rtc:
readi2c 0, (b0, b1, b2) 'reads RTC values (sec, min & hrs)
debug 'resets occur if debug remarked out ??
pause 500
if b3 = b1 then
goto read_rtc
endif
'Set hands
gosub conv_hrs
servopos 0, b12
gosub conv_ten_min
servopos 1, b13
gosub conv_min
servopos 2, b14
b3 = b1
goto read_rtc
'Convert Hours
conv_hrs:
b10 = b2 and %00010000 / 16 'set b10 to the number of 10's hours (bit4)
b11 = b2 and %00001111 'set b11 to the number of 1's hours
b12 = b10 * 10
b12 = b12 + b11 - 1 '-1 since hours scale starts at 1 not 0
b12 = b12 * 11
b12 = 218 - b12
return
'Convert 10's Minutes
conv_ten_min:
b13 = b1 / 16
b13 = b13 * 22
b13 = 220 - b13
return
'Convert Minutes
conv_min:
b14 = b1 and %00001111
b14 = b14 * 13
b14 = 220 - b14
return
Looking in the manual under the servo command I see reference to not being unable to use the servo command at the same time as timer or pwmout/hpwm. I'm not using these - unless timer is somehow a part of pause or wait ??
I get the same result whether the servos are connected or not. I've physically disconnected the three servos and it still resets.
As long as I have the 2 sec or longer delay and the debug statement, the clock works flawlessly even after I disconnect the pogramming cable. I've let it run for hours beside me while I'm on the computer and t never resets once....
Any thoughts because I'm stumped
Regards, John.
Attachments
-
59.7 KB Views: 14
-
86.7 KB Views: 12
Last edited: