control of servo position
panagiotis
Posts: 14
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;;··I WOULD APPRECIATE·ANY POSIBLE ANSWER..
Comments
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
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
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.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...