peterclones
New Member
I'm new to Picaxe and have built a 3 servo robotic arm with a 08M2. It works fine using a modified version of Erco's code from his 6 servo arm. It moves each servo 1 degree simultaneously with a nice subroutine. However, I'd like each servo to end up at the target, or "goal" as it's called in the code, at the same time for a smoother transition. Has anyone seen such a code here or know how to implement it? I'd imagine it would take a fair bit more complexity and math equations. Here's what I have now in my "move" subroutine for servos 1, 2 and 4:
Code:
move:' move subroutine move slowly to new goal coordinates
test1:
if servo1=goal1 then test2
if servo1<goal1 then inc servo1
elseif servo1>goal1 then dec servo1
endif
servopos 1,servo1 ' finger up down
test2:
if servo2=goal2 then test4
if servo2<goal2 then inc servo2
elseif servo2>goal2 then dec servo2
endif
servopos 2,servo2 ' elbow up down
test4:
if servo4=goal4 then test5
if servo4<goal4 then inc servo4
elseif servo4>goal4 then dec servo4
endif
servopos 4,servo4 ' shoulder rotate left right
test5:
pause delay
if servo1=goal1 and servo2=goal2 and servo4=goal4 then fin
goto test1 ' loop back until motion stops
fin: ' servos stopped, all goals reached
return