Im doing some work on getting a servo (say for a camera “pan”) to face the forward direction of a robot as it walk around.
Using the idea of leg control i thought that maybe adding servos and code for the Z and X axis i could also add other servos eg, Tibia + Femur on Z axis and a Coxa on X axis.
[code]Coxa_PulseMin con 600
Coxa_PulseMax con 2400
Femur_PulseMin con 600
Femur_PulseMax con 2400
Tibia_PulseMin con 600
Tibia_PulseMax con 2400
Coxa con P1
Femur con P2
Tibia con P2
CoxaAngle_Min con 108 ;numbers to be confirmed in setup.
CoxaAngle_Max con 108
FemurAngle_Min con 108
FemurAngle_Max con 108
TibiaAngle_Min con 108
TibiaAngle_Max con 108
Coxa_Pulse var word
Femur_Pulse var word
Tibia_Pulse var word
TravelLengthX var sword
TravelLengthZ var sword
:-------------------------------------------------------------
Coxa= (((Coxa_PulseMax - Coxa_PulseMin) * ((TravelLengthZ + 64 ) & $7F) |
/ 127 + Coxa_PulseMax) min Coxa_PulseMin) max Coxa_PulseMax
Femur= (((Femur_PulseMax - Femur_PulseMin) * ((TravelLengthX + 64 ) & $7F) |
/ 127 + Femur_PulseMax) min Femur_PulseMin) max Femur_PulseMax
Tibia= (((Tibia_PulseMax - Tibia_PulseMin) * ((TravelLengthX + 64 ) & $7F) |
/ 127 + Tibia_PulseMax) min Tibia_PulseMin) max Tibia_PulseMax[/code]
would this work just the same…?