CR Servo Doesn't Move, Only Buzzes
Minitel
Posts: 4
I've been having this issue with programming a CR servo and I was hoping I could get some help with it.
I have connected an EXI-D226F continuous rotation servo to a Basic Stamp 1 carrier board and module, and tried to use the example code in the manual to see if my CR would do anything. Here is the code:
' {$STAMP BS1}
' {$PBASIC 1.0}
SYMBOL temp = W0 'Work space for FOR NEXT
SYMBOL Servo_pin = 0 'I/O pin that is connected to servo
Main:
FOR temp = 0 TO 200
PULSOUT Servo_pin,100
PAUSE 20
NEXT
FOR temp = 0 TO 200
PULSOUT Servo_pin,200
PAUSE 20
NEXT
FOR temp = 0 TO 200
PULSOUT Servo_pin,100
PAUSE 20
GOTO Main
What happens is when everything gets plugged in, the servo just buzzes for as long as until I pull a wire or the battery, even though the manual says that the code should make the servo rotate one way, then another way, and then back the other way.
I have connected an EXI-D226F continuous rotation servo to a Basic Stamp 1 carrier board and module, and tried to use the example code in the manual to see if my CR would do anything. Here is the code:
' {$STAMP BS1}
' {$PBASIC 1.0}
SYMBOL temp = W0 'Work space for FOR NEXT
SYMBOL Servo_pin = 0 'I/O pin that is connected to servo
Main:
FOR temp = 0 TO 200
PULSOUT Servo_pin,100
PAUSE 20
NEXT
FOR temp = 0 TO 200
PULSOUT Servo_pin,200
PAUSE 20
NEXT
FOR temp = 0 TO 200
PULSOUT Servo_pin,100
PAUSE 20
GOTO Main
What happens is when everything gets plugged in, the servo just buzzes for as long as until I pull a wire or the battery, even though the manual says that the code should make the servo rotate one way, then another way, and then back the other way.
Comments
Ok, I tried reducing the PAUSE by increments of 5, no change, though it was worth a shot!
I am using a fresh 9v battery to power both.
Whoops, in modifying the example code from the manual I forgot to add a NEXT. It originally had a STOP statement but I wanted it to execute the code over and over. I have added the NEXT after the FOR loop, right before the GOTO.
If the timing was really the problem then reducing in increments of five might shoot right past the optimum timing. I don't know the BS1 but I would guess that the sweet spot would be between 15 and 20. The goal is to have the pulses reach the servo at 50 times a second or once every 20 milliseconds. The pulse itself takes time and so does the FOR..NEXT code. A PAUSE 20 guarantees that the frequency of pulses will be greater than 20 milliseconds - which is usually not a problem.
PULSOUT 100 is a one millisecond pulse so a PAUSE 19 would be perfect. But.. the other lines of code takes a bit of time too, I don't know how much, maybe another millisecond - so PAUSE 18 might be right.
When you PULSOUT 200 then that is a two millisecond pulse so you would reduce the PAUSE to 17 to compensate.
Again, this may not be what is causing your problem.
Digital servos generally require more current to run. Their advantage is that they drive the motor at a higher frequency than analog servos and that will put higher demands on your power supply. A 9 Volt battery, even fully charged cannot supply much current at all. You would be much better off using four AA cells.
If you add some code to blink an led for a second at the beginning of your program you can use that to determine if the BS1 is constantly resetting.