Shop OBEX P1 Docs P2 Docs Learn Events
CR Servo Doesn't Move, Only Buzzes — Parallax Forums

CR Servo Doesn't Move, Only Buzzes

MinitelMinitel Posts: 4
edited 2012-05-07 11:38 in BASIC Stamp
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.

Comments

  • W9GFOW9GFO Posts: 4,010
    edited 2012-05-06 18:18
    Do you have any other servos that you can test the code with? Some digital servos are very picky about the timing of the signals whereas analog servos are very forgiving.
  • MinitelMinitel Posts: 4
    edited 2012-05-06 18:33
    No I don't, but it's good to now have the differences between analog and digital servos in mind, as I would never have guessed that. Thanks! How should I go about getting the right timing? Is it a matter of changing the pause or FOR or pulseout until it works?
  • W9GFOW9GFO Posts: 4,010
    edited 2012-05-06 18:35
    Well, I don't know if that is the problem for sure, but it wouldn't hurt to try reducing the PAUSE.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-05-06 19:10
    Often times problems like this is caused by batteries not being powerful enough. How are you powering both the BS1 and servo?
  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-06 20:16
    Where's the NEXT statement for the last FOR loop in your program?
  • MinitelMinitel Posts: 4
    edited 2012-05-06 22:53
    W9GFO wrote:
    Well, I don't know if that is the problem for sure, but it wouldn't hurt to try reducing the PAUSE.

    Ok, I tried reducing the PAUSE by increments of 5, no change, though it was worth a shot!
    Duane Degn wrote:
    Often times problems like this is caused by batteries not being powerful enough. How are you powering both the BS1 and servo?

    I am using a fresh 9v battery to power both.
    Mike Green wrote:
    Where's the NEXT statement for the last FOR loop in your program?

    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.
  • W9GFOW9GFO Posts: 4,010
    edited 2012-05-06 23:37
    Minitel wrote: »
    Ok, I tried reducing the PAUSE by increments of 5, no change, though it was worth a shot!

    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.
  • MinitelMinitel Posts: 4
    edited 2012-05-07 11:38
    Ah, I see. I have now tried reducing the pauses one by one from 20, but no dice. If the source of my problem is the current draw of my servo then I'm out of luck for now, but at least it's not the code that I'm using I hope? Also if my BS1 itself is the problem then I'm really out of luck haha. I'll see if I can wire up a few batteries in series.
Sign In or Register to comment.