Shop OBEX P1 Docs P2 Docs Learn Events
URGENT HELP with PARALLAX continuous rotation servo and PIC microcontroller — Parallax Forums

URGENT HELP with PARALLAX continuous rotation servo and PIC microcontroller

Goat KurryGoat Kurry Posts: 2
edited 2013-02-22 22:29 in General Discussion
Hi all,

I'm relatively new here and am having serious trouble with the motor. I accidentally cut off the wire (ground, voltage, pin) right before the connector in hopes of soldering it to another wire, which I can then connect to a solderless breadboard. I was basically following these instructions (http://www.instructables.com/id/Breadboard-Servo/).

I figured out that my soldering technique was horrible, and now when I run this calibration program (basically calling a 1.5 ms pulse, then a 20 ms delay, repeated over), I get the servo rotating only in one direction (CCW) even when I try to manually calibrate it by turning the potentiometer. Since I don't get my servo to go in 2 direction at 1.5 ms, I get a fast speed CCW when I turn the potentiometer all the way to the left and a slow speed CCW (same direction) when I turn all the way to the right (no change in direction in between). Could this be because of my connection or my program?

PROGRAM:​ (B1 is the pin on my PIC)

int halt (void)
{
output_low (B1);
delay_us (1500);
output_high (B1);
delay_ms (20);
}


void main (void)
{
while (TRUE)
{
halt();
}
}

Again, I am using a PIC18F4520 microcontroller with a PARALLAX Continuous Rotation Servo Motor (http://www.parallax.com/Portals/0/Downloads/docs/prod/motors/900-00008-CRServo-v2.2.pdf).

Comments

  • ercoerco Posts: 20,256
    edited 2013-02-22 20:33
    A couple things:

    1) Aren't you sending an inverted pulse, going low, pause 1.5 ms, high, pause 20 ms? Switch that to high, pause 1.5 ms, low, pause 20
    2) Servo speed is controlled by pulsewidth, always 1.5 ms in your program, so it will always be the same speed.

    Dunno nothing about your potentiometer setup, but it's not being read anywhere in your program. BTW, it should not be connected to any of the servo wires, that's not how it works.

    BTW, your servo should be nulled (zero speed) at 1.5 ms, using the adjustment pot. Then you can test your program by modifying it to send a 1.0 ms pulses, and then 2.0 ms pulses, which will drive the servo in opposite directions.

    See http://www.societyofrobots.com/actuators_servos.shtml
  • W9GFOW9GFO Posts: 4,010
    edited 2013-02-22 20:44
    It sounds like the potentiometer he's referring to is the one for trimming the continuous rotation servo.

    Try reversing the outputs (like erco said)
    [COLOR=#333333]int halt (void)[/COLOR]
    [COLOR=#333333]{[/COLOR]
    [COLOR=#333333]output_high (B1);[/COLOR]
    [COLOR=#333333]delay_us (1500);[/COLOR]
    [COLOR=#333333]output_low (B1);[/COLOR]
    [COLOR=#333333]delay_ms (20);[/COLOR]
    [COLOR=#333333]}[/COLOR]
    
  • Goat KurryGoat Kurry Posts: 2
    edited 2013-02-22 22:29
    Wow, can't believe I overlooked that. Simple Fix.

    THANKS
Sign In or Register to comment.