Shop OBEX P1 Docs P2 Docs Learn Events
controlling servo — Parallax Forums

controlling servo

Whats the best way to control a 180 degrees servo to move to certain positions such as 0, 45, 90 and 180 degrees? Is it by using pwm, frequency-out, or pulse out command? Could someone please illustrate a simple project? Thanks

Comments

  • Click this link https://learn.parallax.com/tutorials/robot/scribbler-robot/hacker-port-expansion/controlling-standard-servo for an example of working with servos using blocklyprop. It may not be exactly your setup, but it should give you some ideas...
  • bluejay,

    When you say 180-degree servo do you have a Parallax standard servo?
    https://www.parallax.com/product/900-00005
    https://www.parallax.com/downloads/standard-servo-product-documentation
    http://learn.parallax.com/tutorials/language/propeller-c/propeller-c-simple-devices/standard-servo

    If you look at the documentation you will see that the width of the repeating pulse controls the servo position, but there is a C function that takes in an angle and sends the needed width.
    https://cdn.rawgit.com/parallaxinc/propsideworkspace/master/Learn/Simple Libraries/Motor/libservo/Documentation servo Library.html
  • My servo is the standard Parallax 180 deg., type . How do I interpret code in BlocklyProp ?
  • bluejay,

    The Propeller doesn't actually use the BlockyProp program.
    BlockyProp blocks are turned into C code that runs on the Propeller.

    Start with the link that Francis Bauer provided which is a simple BlockyProp program.
    Instead of P0 use whatever pin you have your servo connected to.
    The first angle is already 0 so change the 2nd from 90 to 45.
    Change the 3rd angle from 180 to 90.
    Now add a 4th 'set angle' block and use 180.
    Also add a 4th 'wait' block.
  • I don;t understand "change these leds to this color" code. Using color is included in BlockyProp code?
  • I have not seen color block functions in BlocklyProp language.
  • bluejay wrote: »
    I don;t understand "change these leds to this color" code. Using color is included in BlockyProp code?

    The tutorial that was given by Francis Bauer, refers to BlocklyProp code that is specific to the Parallax S3 Robot. Unless you are running this code on an S3 Robot, just ignore the "Change these LEDs to these colors" blocks. Leave those out of the program and it should work!

    dgately

  • My servo code does not work properly. Can someone please give me coding in blocklyprop that I can rotate my Parallax 180 deg servo to positions 180, 90, 45, and 0 deg.? Thanks
  • How do you have your servo wired?
  • The flat 3-wire cable is wired as follows. Black to gnd, red to 5v, white to control pin of Flip.
    Vdd source is from usb.
  • I assume your control pin is P3. If so, the program you posted should work. It should go to zero unless it is already there, then to 90 and then to 180 and then stop. Did you get any motion at all or any error message?

    Try turning the servo by hand (unpowered), in case it jammed at one of the stops. You can also try changing 0 to 10 deg and 180 to 170 deg in case the servo is off slightly and jams at the stops. (That happened to me with an off brand servo).
  • bluejay wrote: »
    My servo code does not work properly. Can someone please give me coding in blocklyprop that I can rotate my Parallax 180 deg servo to positions 180, 90, 45, and 0 deg.? Thanks

    Your code ran servos on my Activity Bot when I changed the pin to 12 or 13! There must be something about your hardware setup. 5 volts (and low current from USB) may be a little low for the servos. I used the VIN input from 2x3.7 volt lithium batteries to run the servos at 7.4 volts rather than the USB's 5 volts.

    dgately

  • PublisonPublison Posts: 12,366
    edited 2019-10-25 19:35
    A picture of your setup would be a great help at this point.
    bluejay wrote: »
    The flat 3-wire cable is wired as follows. Black to gnd, red to 5v, white to control pin of Flip.
    Vdd source is from usb.

    A picture of your setup would be a great help at this point.
    I am also concerned that your 5V to the servo will not supply enough current if you are relying on the onboard FLIP supply voltage. That voltage comes directly from the USB port which may not be able to supply the 500mA that the specification states. Are you driving anything else from the FLIP 5V ? LED's, etc.
  • bluejay,

    Does your servo vibrate, make noise, or get warm when you run your code?
  • The servo usually goes to 90 deg position the 0 deg position , then stops and moves a little, then repeats, even though there is no repeat block in program.
  • PublisonPublison Posts: 12,366
    edited 2019-10-26 17:54
    I have closed your other recent thread. You started another thread on the same subject. That is against Forum rules, and it just confuses people as to which thread to respond to. Please keep your questions in this thread.
  • Thanks. How do I post a picture on this forum?
  • PublisonPublison Posts: 12,366
    edited 2019-10-26 18:41
    bluejay wrote: »
    Thanks. How do I post a picture on this forum?

    Use the "Attach a File" at the bottom left in your new post. A .jpeg would be fine.
  • I solved my servo problem by instead of using the USB Vdd (+5v) power source, I am using an external 5v 1a walwart, which is working fine.
  • bluejay wrote: »
    I solved my servo problem by instead of using the USB Vdd (+5v) power source, I am using an external 5v 1a walwart, which is working fine.

    That's great news. Time to play.
Sign In or Register to comment.