servo control - need some help
daidalos62
Posts: 21
Heres my code for reference...
temp var word
main:
for temp = 0 to 200
pulsout 15, 750
pause 20
next
for temp = 0 to 200
pulsout 15, 900
pause 20
next
for temp = 0 to 200
pulsout 15, 600
pause 20
next
goto main
And so the servo doesn't move .............. just vibrates and makes some noise
I've got it wired through a breadboard as follows ...
red wire to the VDD on the stamp
black wire to the VSS on the stamp
white wire to PIN 15 on the stamp
im pretty sure I dont need a control module for this and it should work fine ....
anyone run servo's for prototyping like this?
please help im in a bit of a jam!
temp var word
main:
for temp = 0 to 200
pulsout 15, 750
pause 20
next
for temp = 0 to 200
pulsout 15, 900
pause 20
next
for temp = 0 to 200
pulsout 15, 600
pause 20
next
goto main
And so the servo doesn't move .............. just vibrates and makes some noise
I've got it wired through a breadboard as follows ...
red wire to the VDD on the stamp
black wire to the VSS on the stamp
white wire to PIN 15 on the stamp
im pretty sure I dont need a control module for this and it should work fine ....
anyone run servo's for prototyping like this?
please help im in a bit of a jam!
Comments
If you don't have an alternative power supply, sometimes you can add extra filtering to the existing supply. Use a 1000uF electrolytic capacitor between the red and black wires of the servo (with an adequate voltage rating on the capacitor). That may help.
I attempted another power supply giving the servo 5V without success. I happen to have one of those capacitors laying around somewhere .. I'll try that in the morning
hmmmm
SEROUT 16, 16468, [noparse][[/noparse]"BS2 Reset", 13]
at the front of your program. Then hang a PC off the programming port, running hyperterminal or something, to recieve this "Reset" signal. This will reveal if your program is having a 'brown out reset' when you control the Servo -- which would come from a "too small" power supply -- too little current available.
Apparently you're not using a BOE board -- if you were, we'd know what linear regulator you were using on your circuit. So the question remains -- what voltage and current 'wall-wart' are you using, if any, and what linear regulator are you using, and does it have any input or output capacitors.
Also, I assume this is a BS2 'plain' -- is that true?
It seems my problem was a very simple one.
The pause needed to be set to 10 rather than 20 within the code.
As soon as I did this, it ran fine, which is somewhat strange, given that most of my information has told me to send pulses every 20 ms.
cheers.
Post Edited (daidalos62) : 3/6/2007 1:28:13 PM GMT
Why do you use the "Next" statement? This should only be needed for Case structures within your code.
Try removing the Next statements and using a pause of 500 (1/2 second).
Hope this helps
i'm fairly new to BS2 so I was under the impression that when using the FOR statement, the NEXT was necessary.
I'm sure theres many ways to re-write that code, I'll give your suggestion a shot as well.
thanks!
daidalos62 is right, the NEXT statements are necessary. Every FOR statement has to have a matching NEXT statement and, if nested, they have to match up. Look at the PBasic manual section on the FOR statement (and look at the section for CASE statements ... they don't use NEXT statements). Also, servos have to get repeated pulses, normally once every 20ms or so. I don't know why daidalos62's servos seem to need them more often, but there it is.
I am working on a project that uses multiple servos. I like using the servo controller board as I don't have to worry about holding position after the initial command. Save a lot of code space too.
Next time, coffee before response!