Shop OBEX P1 Docs P2 Docs Learn Events
servos w/ pwm — Parallax Forums

servos w/ pwm

JiggsJiggs Posts: 26
edited 2004-07-31 19:22 in General Discussion
I have two continuous rotation servos (the ones sold from Parallax). I've been going crazy trying to get them to run properly. All I want to do is have them off initially, than have them rotate (at this point, I've stopped caring which direction they turn) for three seconds, then stop again. I would be truly grateful if someone could show me how to achieve this seemingly simple task.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
~Jiggs

Comments

  • JiggsJiggs Posts: 26
    edited 2004-07-30 19:08
    This is the code I've tried. It seems like it should work to me, but the servos do nothing but sputter on and off.

        rservo.start();
        lservo.start();
        rservo.update(220,2304);
        lservo.update(220,2304);
        CPU.delay(20000);
        rservo.stop();
        lservo.stop();
    
    



    Both servos are initialized with this line:

    static PWM lservo = new PWM(CPU.pin13,220,2304);
    



    Of course the variable name and pin number are changed for the right servo.
    Does anyone have any ideas?

    Thanks.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ~Jiggs
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2004-07-30 20:46
    Go here:
    http://groups.yahoo.com/group/javelinstamp/files/Jon%20Williams%20Class%20Files/

    and get file BOE-BOT line follow.
    It has some code to control servos that may
    be an example to you how to use pwm().

    regards peter
    ·
  • JiggsJiggs Posts: 26
    edited 2004-07-30 21:25
    Thanks Peter. I guess something must be wrong with either my servos or my Javelin, because they still sputter on and off. By sputter I mean on----on----on----on----on----on----on...
    I suppose I could hook an oscilliscope up to the PWM out pin on my javelin and see if it is sending correctly timed pulses.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ~Jiggs
  • JiggsJiggs Posts: 26
    edited 2004-07-30 22:22
    Hi again.
    While investigating my servo mystery, I made a rather unusual discover. See, after observing the behavior of the servo on a duty cycle of 220,2304 I though that perhaps the Javelin was constantly resetting itself, as if it were underpowered (ie. the servo drew more power than was available, which would cause the Javelin to reset). To test my theory, I wrote a very simple program to initialize the servo and print "hi" in the message window.
    public class ServoTest {
    
      static PWM servo = new PWM(CPU.pin13,220,2304);
    
      public static void main() {
        System.out.println("hi");
      }
    
    }
    


    The result was very interesting. The servo exhibited the same behavior of intermittent on-off, and the Javelin failed to write anything to the message window. However, I unplugged the servo with the Javelin on, and, low and behold, "hi" popped onto the screen. So, it seems to me that the power supply on my Demo Board is failing. Does anyone else have an idea as to what might be going on here?

    Thanks again.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ~Jiggs
  • JavalinJavalin Posts: 892
    edited 2004-07-31 17:29
    Hello,

    I dont know that I can help but I am having a similar experience!

    I too have two servo's to run a small robot.· The wiring is ok as it works perfectly with a Basic Stamp2.

    Using the ServoControl.java app which comes with the IDE, if I use "c" to center the servo, all is ok.· However when I use "r" or "l" to move forwards/backwards the javalin resets (the message window shows the help initial screen).

    I am using a 9V battery to the VDD pin.

    Only other bit of info is the javalin runs quite hot!

    Any help would be appriatated!!!!!

    smile.gif

    james
  • JavalinJavalin Posts: 892
    edited 2004-07-31 19:20
    Hello again!

    Solved it (at leased for me!).··Run the Javalin off one powersupply, I am now using a 12V supply - and the servo's from another - Im using 4 * AA Nicads.· Found the voltage drop when running one psu and splitting via regulator to include a 5v feed.

    Solves the problem.

    tongue.gif

    James
  • JiggsJiggs Posts: 26
    edited 2004-07-31 19:22
    That's exactly what I plan to do. Glad you got it to work.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ~Jiggs
Sign In or Register to comment.