Shop OBEX P1 Docs P2 Docs Learn Events
Servo continuous rotation — Parallax Forums

Servo continuous rotation

bxgirtenbxgirten Posts: 79
edited 2006-10-18 00:06 in General Discussion
I can get a servo to rotate continuously. I add a second servo, they both pulse instead of continuously rotating.

Do I have to code-up some special CPU delay. They continously rotate on their own but when they're put together, it seems like they're attempting to share the same HIGH on separate pins.

Any ideas?

Post Edited (bxgirten) : 7/21/2005 9:53:29 PM GMT

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-22 01:05
    Please post the code you're using.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • bxgirtenbxgirten Posts: 79
    edited 2005-07-22 10:41
    import stamp.core.*;

    /**
    * Drives both servo at high speed
    *
    * @version 1.0 5/7/02
    * @author Parallax, Inc.
    */

    public class JBotServo4 {
    static PWM pwmR = new PWM(CPU.pin12); // create right servo
    static PWM pwmL = new PWM(CPU.pin13); // create left servo

    public static void main() {
    pwmR.update( 110, 255 ) ;
    pwmL.update( 240, 255 ) ;
    pwmR.start () ;
    pwmL.start () ;

    CPU.delay(10000); // run for one second

    pwmR.stop () ;
    pwmL.stop () ;
    }
    }
  • Kevin B SlaterKevin B Slater Posts: 49
    edited 2005-07-22 14:19
    Hey bx,
    · This sounds like a classic example of inadequate power.· First thing to do is try this code, the servos should run for one second then stop.· If you keep getting a '1' in the debug window then the Javelin is resetting most likely do to brownout.
    · Also it looks like the code you are using is from the JavelinBOT book.· Some of the classes have changed since the book was written, notice the change in the PWM class declaration.· Also you do not need to start the PWM, with the new classes it is started when it is declared and issuing a start actually has an adverse effect.· Here is the code.

    import stamp.core.*;
    
    [color=green]/**
    * Outputs '1' to debug window, drives both servos for one second *
    * @version 1.1 7/22/2005
    * @author Parallax, Inc.
    */[/color]
    
    public class JBotServoTest {
      static PWM pwmR = new PWM(CPU.pin12,[color=blue]173[/color],[color=blue]2304[/color]); [color=gray]// create right servo[/color]
      static PWM pwmL = new PWM(CPU.pin13,[color=blue]173[/color],[color=blue]2304[/color]); [color=gray]// create left servo[/color]
      static int testvalue = [color=blue]1[/color];
    
    public static void main() {
      System.out.println(testvalue); [color=gray]// Print out the value of testvalue to the Debug window[/color]
    
      pwmR.update ( [color=blue]110[color=black],[/color] 2304[/color] ) ;
      pwmL.update ( [color=blue]240[color=black],[/color] 2304[/color] ) ;
    
      CPU.delay([color=blue]10000[/color]); [color=gray]// run for one second[/color]
    
      pwmR.stop();
      pwmL.stop();
    
      }
    }
    

    ·A couple of things to try if you Javelin is resetting.· Depending on the kits you may have received, you should have a 3300uF capacitor, connect this across Vin and Vss, with the negative lead going to Vss.· The AppMod header is the best place to connect this.
    · If you don't have that, then do what in my opinion is the best option,·use a separate power supply for the servos.· The negative would go to·Vss and the positive would go to Vm if you have the Javelin Stamp Demo Board.· I use a R/C system receiver pack as that is what it is designed for.· I actually use both the separate power supply and the capacitor on my JBOT.
    · In addition when you get to one of the later chapters it discusses ramping code this will also additionally help in this situation.

    Kevin

    Post Edited (Kevin B Slater) : 7/22/2005 2:23:00 PM GMT
  • serverside6serverside6 Posts: 1
    edited 2006-10-18 00:06
    I had similar problem and the 3300uf cap suggestion worked like a charm!· Awsome!· Thanks!!!!
Sign In or Register to comment.