Shop OBEX P1 Docs P2 Docs Learn Events
Synchronising Servos — Parallax Forums

Synchronising Servos

oquiziohchaoquiziohcha Posts: 5
edited 2011-03-30 17:50 in BASIC Stamp
Edit: Moved the last post to the front, will seem a bit out of order but this post says what I need help with in the clearest terms

Reason I need to use the CR servos is that they can stay at the last position they were sent to without consuming power whereas standard servos constantly consume power to hold the position

Right as simple as it gets - I need 2 servos to move 12 times over 12 hours, servo 1 will move X amount each time, servo 2 will move X2 amount each time. After 12 hours they will move in reverse back to where they started and wait 12 hours before starting again.


Because servo 1 moves a differant amount each time from servo 2, I dont know how to get it so they both start moving at the same time. The only way I know to write the code would see servo 1 move 12 times "followed by" servo 2 move 12 times, both servos returning to start point together then waiting for 12 hours totalling 36hours.

How do I make 2 servos move together, once an hour, differant distances



Its not getting any signals from detectors or anything else that would justify the title of a "tracker", its basically a code that approximates tracking im after

Comments

  • doggiedocdoggiedoc Posts: 2,240
    edited 2011-03-28 14:03
    Welcome to the forums!

    A good place to start is with the BoeBot Text. It's a free download and contains a lot of examples on controlling continuous rotating servos. And it assumes no programming experience.

    Enjoy!

    Paul
  • oquiziohchaoquiziohcha Posts: 5
    edited 2011-03-28 14:07
    Thanks!

    I will check it out, see how I get on with it
  • Mike GMike G Posts: 2,702
    edited 2011-03-28 14:17
    Servos require a pulse every 20ms to hold position. If the pulses stop you might get some unexpected glitches and twitches or worse a limp solar tracker.
  • oquiziohchaoquiziohcha Posts: 5
    edited 2011-03-28 14:38
    Mike G: I thought the continuous rotation servos would just stop at the position the last set of pulses took them too?

    Mike G/DoggieDoc: From the guide you linked, about the most relevant part was the following;

    ' Robotics with the Boe-Bot - Ch02Prj02_4RotationCombinations.bs2
    ' Move servos through 4 clockwise/counterclockwise rotation
    ' combinations.
    '{$STAMP BS2}
    '{$PBASIC 2.5}
    DEBUG "Program Running!"

    counter VAR Word

    FOR counter = 1 TO 120 ' Loop for three seconds
    PULSOUT 13, 850 ' P13 servo counterclockwise
    PULSOUT 12, 850 ' P12 servo counterclockwise
    PAUSE 20
    NEXT

    FOR counter = 1 TO 124 ' Loop for three seconds
    PULSOUT 13, 650 ' P13 servo clockwise
    PULSOUT 12, 650 ' P12 servo clockwise
    PAUSE 20
    NEXT

    FOR counter = 1 TO 122 ' Loop for three seconds
    PULSOUT 13, 650 ' P13 servo clockwise
    PULSOUT 12, 850 ' P12 servo counterclockwise
    PAUSE 20
    NEXT

    FOR counter = 1 TO 122 ' Loop for three seconds
    PULSOUT 13, 850 ' P13 servo counterclockwise
    PULSOUT 12, 650 ' P12 servo clockwise
    PAUSE 20
    NEXT

    END


    Assume the above movements is what I want however, I want it to execute one movement per hour. So say it is idle for 12 hours with..

    For counter = 1 TO 720
    PAUSE 60000
    NEXT

    Then on the 13th hour it should execute one FOR/NEXT, wait for the 14th hour and execute the next one etc.

    If both servos take different amounts of time to perform their motion, they would be out of sync surely...

    So, do I need to calculate the time remaining (1 hour minus the time it takes to execute a movement) for each servo independantly...each time they move or can I set something to output high on the hour that the servos wait for before moving.


    Thanks again, and if I talk nonsense feel free to let me know
  • doggiedocdoggiedoc Posts: 2,240
    edited 2011-03-28 14:38
    @Mike G,
    ...and nobody likes a limp solar tracker! :D

    Paul
  • ercoerco Posts: 20,256
    edited 2011-03-28 15:22
    @oquiz...

    CR servos have no position control. They don't know where they are at, can't remember where they've been. You can't tell them to go to a certain position. They are simply a gearmotor with a non-precision speed control.

    Standard analog servos rotate 90-180 degrees only, they can be commanded to a certain position.
  • oquiziohchaoquiziohcha Posts: 5
    edited 2011-03-28 15:51
    sitting tryin to puzzle this out, On my actual code I think what I have done is try to write it so that they move to a specific position - the position changes everytime so a seperate section is needed for each position.

    All I think I need is how long they move for, that simplifies things as then its just a single command for each servo that needs to be issued once on the hour. In that case If I can just get them to wait till the end of the hour before they go I shouldnt need to worry about clocks and stuff

    So now I have this issue, I will need each servo to wait for a different amount of time until the hour is up. The only way I would know of to write it is...

    DO
    For 12 times (once every hour for 12 hours)
    servo 1 - move for time (X)
    pause for remainder of the hour (hour - X)
    Next

    For 12 times
    For/next servo 2 - move for time (X2)
    pause remainder of the hour (hour - X2)
    Next

    For counter = 1 TO 720 (wait 12 hours)
    Pause 60000
    Next
    LOOP


    With that surely one servo would move 12 times, then the second one would move 12 times
    I want them to both go together

    Im still sorta puzzling out what I need it to do as I go thats why lot of what im saying is pretty fragmented


    Thanks again to folk doing their best to help me


    Oquizi
  • ercoerco Posts: 20,256
    edited 2011-03-28 16:28
    Again, you need standard servos (not continuous rotation servos) if you want to send them to a specific, repeatable position. You just have to live with 180 degrees (or less) of rotation. Should not be a problem for a solar tracker.

    Some useful info at http://www.electro-tech-online.com/renewable-energy/40493-solar-tracker.html
  • oquiziohchaoquiziohcha Posts: 5
    edited 2011-03-28 17:11
    Reason I need to use the CR servos is that they can stay at the last position they were sent to without consuming power whereas standard servos constantly consume power to hold the position

    Right as simple as it gets - I need 2 servos to move 12 times over 12 hours, servo 1 will move X amount each time, servo 2 will move X2 amount each time. After 12 hours they will move in reverse back to where they started and wait 12 hours before starting again.


    Because servo 1 moves a differant amount each time from servo 2, I dont know how to get it so they both start moving at the same time. The only way I know to write the code would see servo 1 move 12 times "followed by" servo 2 move 12 times, both servos returning to start point together then waiting for 12 hours totalling 36hours.

    How do I make 2 servos move together, once an hour, differant distances



    Its not getting any signals from detectors or anything else that would justify the title of a "tracker", its basically a code that approximates tracking im after
  • ercoerco Posts: 20,256
    edited 2011-03-28 23:59
    Can't help you sync CR servos. You need motors & encoders.
  • stamptrolstamptrol Posts: 1,731
    edited 2011-03-29 04:59
    What's been said is that CR servos aren't really servos because they have had their feedback mechanism removed. As such they are a compact motor package with a control circuit.
    Without feedback, the best you can do is guess.

    For what you're doing, a small worm gearmotor will give you the holding feature you want. Solarbotics or Tamiya have several models.You need to get position information from both axes by attaching a pot or encoder or limit switches so the controller knows where the structures are. Then you'll have a controllable system.

    Cheers,
  • Mike GMike G Posts: 2,702
    edited 2011-03-29 07:20
    CR servo or standard servos require a pulse every 20ms to stay energized. You can build a solar tracker with CR servos but the servos require constant feedback. This is generally done with a light sensing circuits, and differential amplifiers, and DC motors. Using RC servos just make the whole project a 1000 times more difficult.
    Right as simple as it gets - I need 2 servos to move 12 times over 12 hours, servo 1 will move X amount each time, servo 2 will move X2 amount each time. After 12 hours they will move in reverse back to where they started and wait 12 hours before starting again.
    You need standard servos not RC servos. What is the brand name of the servos?
    How do I make 2 servos move together, once an hour, differant distances
    If you where using standard servos, trigonometry. It can NOT be done with RC servos without some kind of feedback.

    When you ask for help it is a good idea to listen. Erco and stamptrol gave you excellent advice.
  • CrazyMCrazyM Posts: 2
    edited 2011-03-29 13:10
    I'm assuming you are using Parallax continuous rotation servos - in that case, these do not require continuous pulses to maintain position and will work in this situation.

    As for your problem - since you didn't indicate how fast you want your servos to actually move into position and it doesn't seem critical in this case, it all comes down to simple arithmetic. If servo A moves at speed V, and servo B moves twice as fast as servo A (2*V), then servo B will travel twice the distance in the same amount of time. So to adapt the code from the book for this example:

    FOR counter = 1 TO 200 ' approximately 5s motion
    PULSOUT 13, 800 ' P13 servo A counterclockwise motion at half speed
    PULSOUT 12, 850 ' P12 servo B counterclockwise motion at full speed
    PAUSE 20
    NEXT

    So, both servos move at the same time and in the same direction but at two different speeds, thus covering different distance. You will need to determine the exact number for the end value in FOR ... TO statement so that the servos move the required distance.

    As for the issue of performing this movement every hour over 12 hours - use SLEEP 'duration' command. With this command, the BASIC Stamp will go into low-power mode for the specified amount of time, then awake to run through the sequence again. The 'duration' value is specified in seconds, and has a resolution of 2.304 seconds. As an example, if we performed movement for 5s in the above sequence, the remaining amount of time we need to sleep in the hour is 3595 seconds.
  • Mike GMike G Posts: 2,702
    edited 2011-03-29 14:16
    I'm assuming you are using Parallax continuous rotation servos - in that case, these do not require continuous pulses to maintain position and will work in this situation.

    Are you sure about that? Are you relying on mechanical resistance?
    http://www.parallax.com/Portals/0/Downloads/docs/prod/motors/900-00008-CRServo-v2.1.pdf

    The speed thing is true but if you don't know the current angular position how can you possibly know how long to move the servo?
  • PublisonPublison Posts: 12,366
    edited 2011-03-29 17:01
    This would work if you had a geared solution. The OP never said anything about gears. Without gears, the unit would revert to the start position, or wherever gravity brought it, , because no pulses are being applied to hold the servos steady..

    I agree with stamtrol. A worm gear and standard DC motor are in order. No need to bring anymore smarts into it.

    CrazyM wrote: »
    I'm assuming you are using Parallax continuous rotation servos - in that case, these do not require continuous pulses to maintain position and will work in this situation.

    As for your problem - since you didn't indicate how fast you want your servos to actually move into position and it doesn't seem critical in this case, it all comes down to simple arithmetic. If servo A moves at speed V, and servo B moves twice as fast as servo A (2*V), then servo B will travel twice the distance in the same amount of time. So to adapt the code from the book for this example:

    FOR counter = 1 TO 200 ' approximately 5s motion
    PULSOUT 13, 800 ' P13 servo A counterclockwise motion at half speed
    PULSOUT 12, 850 ' P12 servo B counterclockwise motion at full speed
    PAUSE 20
    NEXT

    So, both servos move at the same time and in the same direction but at two different speeds, thus covering different distance. You will need to determine the exact number for the end value in FOR ... TO statement so that the servos move the required distance.
  • CrazyMCrazyM Posts: 2
    edited 2011-03-29 21:25
    My experience with this servo is from pure personnal observation. If a set off pulses is sent to move the servo in clockwise direction for example, it will turn through the specified arc. When the pulses stop, the servo does not return to "zero position", it stays exactly where it stopped. When more pulses are sent, it will continue rotation from the last position on. Isn't that the main concept behind the continuous rotation servo, as opposed to the standard servo that will return to "zero position" when no pulses are sent?

    This was just a suggestion to try, because without knowing all the details of the particular design, it's hard to say what will work 100% with the conditions originally specified. In my use case, this servo behaves exactly as I suggested.
  • Mike GMike G Posts: 2,702
    edited 2011-03-30 06:26
    Isn't that the main concept behind the continuous rotation servo, as opposed to the standard servo that will return to "zero position" when no pulses are sent?
    Your understanding is not correct. Standard servos move to a position specified by a continuous (20ms) PWM control signal. Standard servos do not reset in the absence of a control signal. Continuous rotation servos move clockwise, counter clockwise, or neutral but can not be positioned absolutely. Both RC and standard servos require a continuous PWM signal to stay energized.

    Do an internet search for "How do servos work" and checkout the Parallax CR servo manual for more information.
  • ercoerco Posts: 20,256
    edited 2011-03-30 17:50
    oquizi: Besides the servo/motor issues you need to resolve, you may want to revisit your basic plan to move to a specified XY position each hour. First, there's no need to only move once per hour, you can do it continuously. Second, the sun's position at any given hour changes significantly each day throughout the year, moreso at the spring & autumnal equinoxes, less at summer & winter solstice. You actually want to use some sensors & smarts to track the sun accurately for best efficiency. It's not hard, you already have the uC working for you.
Sign In or Register to comment.