PDA

View Full Version : control of servo position



panagiotis
01-13-2006, 05:09 PM
HELLO. I TRY TO IMPLEMENT A PROJECT RELATED TO A ROBOTIC ARM WITH 4 DEGREES OF FREEDOM.I USE THE BS/2 AND HITEC SERVOS.·MY QUESTION IS HOW (IN THE BS/2 PROGRAM) CONTROL THE POSITION OF 2 OR MORE SERVOS SIMULTANIOUSLY·TO PRESERVE THEIR POSITION WITH DO LOOPS E.G.IF I WANT TO MOVE·THE SHOULDER AT A DESIRED ANGLE A DO LOOP MUST EXIST IN ORDER·FOR THE THE SERVO TO KEEP THE POSITION CORRECT;. SO·CONSIDERING THAT IN ORDER·TO MOVE THEN THE ELBOW I NEED ANOTHER DO LOOP FOR THE OTHER SERVO. SO HOW CAN I MAKE BOTH LOOPS WORK SIMULTANIOUSLY;;http://forums.parallax.com/images/smilies/cry.gif··I WOULD APPRECIATE·ANY POSIBLE ANSWER..

Tronic (Greece)
01-13-2006, 06:21 PM
Take a look in the attached file that·for a 5-axis robotic arm·with Pots for position encoder.

It came from here:
http://users.thess.sch.gr/xrysoxoidou/e107/download.php?view.24

It would be easy to convert it for 4-axis you are·using.


Thanos



-----------------
www.greekbotics.tk (http://www.greekbotics.tk)

Paul Baker
01-13-2006, 09:01 PM
Its not as hard as you may think, a servo requires a 1-2ms pulse every 20ms, there is nothing stating that the pulses to different servos has to occur at the same time. So since you want to control 4 servos, you break the 20ms into 4 equal sections of 5ms each. Say the servo pulse width for each servo is given the variables A-D, the pseudocode for controlling all 4 would be:

pulseout servo1 duration A

pause 5ms-A

pulseout servo2 duration B

pause 5ms-B

pulseout servo3 duration C

pause 5ms-C

pulseout servo4 duration D

pause 5ms-D

loop back to servo1

You may need to adjust the timing to account for any additional computations you need to do within the servo control loop.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10

allanlane5
01-13-2006, 10:42 PM
Or even:

Servo1:
pulseout servo1 duration A
pulseout servo2 duration B
pulseout servo3 duration C
pulseout servo4 duration D

Pause 20-ms

loop back to servo1

This works because the servo refresh will work anywhere from 20 to 50 mSec -- so as long as your code runs in 30 mSec (a pretty safe assumption, if you don't put a large 'pause' anywhere) you'll be ok.

Tom Walker
01-13-2006, 11:14 PM
The easy answer is to get a servo controller to handle all of your servo needs. This would allow your program to simply tell the controller to "move servo 1 to position x" and "move servo 2 to position y", and the controller would do so (and hold them there) while the Stamp is off doing other things (checking sensors, receiving input, displaying information, etc...). Trying to accomplish this with a single-tasking Stamp would require some tricky programming to meet the timing requirements (if it was possible at all) and would likely not allow the Stamp to do anything else while it deals with the servos.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...

panagiotis
01-14-2006, 05:32 PM
thank you all about the answers