# Smoothing out movement of SSC-32U

I have a robot leg in two sections, femur and tibia, with two gearservos. I have a sequence of angles I want the sections to move through. The angles change in amounts from 1 degree to something like 12 degrees. I want a constant time between each movement although the two servos usually are moving a different number of degrees. My SSC-32U is working and things move to the correct angles I want but the motion is jerky.

I am using a Teensy 3.5 microcontroller and sending commands to the SSC-32U by serial 115200 bps.

What is the way to get this to smooth out. Below is some pseudocode.

float heron_femur[10] = {18.7, 24.47, 30.83, 39.73, 48.63, 56.93, 65.22, 74.4, 83.59, 88.94};
float heron_tibia[10] = {49.75, 37.41, 25.07, 16.49, 7.91, 3.95, 2.0, 2.03, 3.06, 4.64};
int heron_femur_usec[10];
int heron_tibia_usec[10];

void setup()
{
// Heron angles to uSec
for (int i = 0; i < 10; i++)
{
if (heron_femur[i] <= 90.0)
{
heron_femur_usec[i] = 1500 - int((90.0 - heron_femur[i]) * 3.0 + 0.5); // 3 uSec per degree to turn servo
}
else
{
heron_femur_usec[i] = 1500 + int((heron_femur[i] - 90.0) * 3.0 + 0.5);
}

``````  // Tibia angles to uSec
heron_tibia[i] = 180.0 - heron_tibia[i];
if (heron_tibia[i] <= 90.0)
{
// signs are reversed from femur because tibia motor is mounted 180 deg from femur
heron_tibia_usec[i] = 1500 + int((90.0 - heron_tibia[i]) * 3.0 + 0.5);
}
else
{
heron_tibia_usec[i] = 1500 - int((heron_tibia[i] - 90.0) * 3.0 + 0.5);
}

// Deal with angle of femur
if (heron_femur_usec[i] <= 1500)
{
heron_tibia_usec[i] -= 1500 - heron_femur_usec[i];
}
else
{
heron_tibia_usec[i] += heron_femur_usec[i] - 1500;
}
``````

}

void loop()
{
for (int i = 0; i < 10; i++)
{
String s = â€ś#0Pâ€ť + String(heron_femur_usec[i]) + â€ś#1Pâ€ť + String(heron_tibia_usec[i]);
Serial3.println(s);
delay(40);
}
}

1 Like

Hey @twiereng,

Welcome to the RobotShop community!

Thereâ€™s a few things to unpack hereâ€¦ letâ€™s get started!

Thatâ€™s a small amount of degrees. Also, over how long exactly?

Sounds good.

Well, since you are using a SSC-32U, I strongly recommend you use group move commands instead of sending motions yourself. Hereâ€™s an example where RC servomotors on channels 0 & 1 are moved to new positions over 2 seconds:
#0P2000 #1P800 T2000**\r**, where T determines the duration of the move in ms (milliseconds).

You can read more about basic move commands on pages 24-26 of the SSC-32U manual (PDF).

So, basically, using the SSC-32U to coordinate the move of 2 (or more) servos is probably a better idea since it has the capability of taking care of it on its own. That being said moving RC servomotors small distances at slow speeds is likely to be jerky regardless of how you tell it where to move.

As you may already know, DC motors (such as the ones used in RC servomotors) have a speed proportional to the voltage used (and indirectly, torque). When you make a motor move slowly, you also inadvertently lower its ability to move a load. This can be also compounded by the fact that the RC servomotorâ€™s internal position sensor might not be sensitive enough to allow fine grained control of the position at very low speeds, therefore seemingly jumping between positions (worse at lower speeds, higher loads or both together).

I hope this info helps! Good luck with your project!

Sincerely,

1 Like