Synchronising Servos
oquiziohcha
Posts: 5
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
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
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
I will check it out, see how I get on with it
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
...and nobody likes a limp solar tracker!
Paul
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.
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
Some useful info at http://www.electro-tech-online.com/renewable-energy/40493-solar-tracker.html
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
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,
You need standard servos not RC servos. What is the brand name of the servos?
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.
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.
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?
I agree with stamtrol. A worm gear and standard DC motor are in order. No need to bring anymore smarts into it.
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.
Do an internet search for "How do servos work" and checkout the Parallax CR servo manual for more information.