Stiffness (K)

How to determine the stiffness of the servo when it is powered.

The Math Behind the Setup

The setup for these tests relies on the angular version of Hooke's law:

τ=kΔθ\tau=k\Delta\theta ----> k=τΔθk = \frac{\tau}{\Delta\theta}

Normally, Δθ\Delta\thetawould be the amount the element displaces given the applied torque. However, for the servo tests we will instead considerΔθ\Delta\thetaas the difference between the commanded position and the actual position.

One way to think about this is to consider the pendulum setup from the inertia/damping tests.

In this case, the gravitational torque is functionally creating stiffness by resisting the commanded motion, causing a difference between the actual position and commanded position. Thus, the "stiffness" in this case is:

k=mgLθcom−θactk = \frac{mgL}{\theta_{com}-\theta{act}}

However, this setup is hard on the servos, so we want to use an alternate setup. Instead, we will have the servo pressing down on a scale.

In this case, commanding a position that the servo cannot reach causes it to apply a force on the scale. That force can then be used to calculate kservok_{servo}. Alternatively, you can record several values for various commanded positions, then plot the Torque vs. Δθ\Delta\thetacurve. The slope of this line will be kservok_{servo}.

It's also crucial to consider how the servo actually produces stiffness. The Dynamixels in general produce stiffness artificially through the PID control loop in the servo. This stiffness can then be changed by altering different addresses in the servo related to the PID loop. In the case of the MX-28s, this address is the "P Gain." For other servos, the E-Manual for the servo should list the valid address to change. However, none of the manuals list how these gain values relate to Nm/rad stiffness, so the stiffness curve tests will need to be done for several Gain values to determine the relationship between them.

Testing Setup

The interfaces between the test setup and the MX-28 brackets have already been developed. The CAD files are included below.

To run the tests, the main 80-20 beam just needs to be clamped to the tabletop. Other considerations include:

  1. The place the servo pad presses down on the scale should be as close to the center as possible

  2. The fan should be blowing on the servo to help heat dissipation

See the page below for a guide on how to read data from the scale on the computer.

OHAUS Ranger 3000 Scalechevron-right

CAD Files

file-archive
2MB
All files for the MX-28 K setup, as well as the full setup assembly.

Taking Data

The Arduino code for this setup is pasted below:

Essentially, the code cycles through attempting to reach each of the positions defined in one of the arrays in lines 33-40 (only one should be uncommented at a time) on each button press for 5 seconds, then goes back to the resting position. After each press on the scale ends, the code prints the commanded position and actual position. Once all positions have been attempted, the code disables the servo torque, prints the current temperature, then ends.

The positions listed in the arrays range from the minimum position to create good contact with the scale, and the approximate position at which the servo will produce max force. This helps ensure that the resulting torque-displacement curve will be linear. The data collection is randomized between these two extremes, to help ensure there isn't fatigue over the test decreasing the stiffness slope. In the past, I've selected an array order from some sort of online randomizer.

All of the position values in the base code are tuned for the stall torque of the MX-28s. If you are using other servos, experiment to find the right ranges. Some considerations for this are:

  • The minimum to ensure good contact with the scale seems to be around 2040-2045. This will likely not change unless the setup is modified

  • The difference between successive commanded positions should be≥\geq6 bits, otherwise data points will not chart well on theΔθ\Delta\thetaaxis later on.

  • Try to aim for around 10 data points for each test. This may not become feasible for higher stiffnesses to keep the difference between successive positions great enough, which is fine.

For an undetermined reason, the scale will not reach equilibrium with the servo pressing on it. Instead, it will slowly decay over time as the servo presses. However, because it decays so slowly, we can consider the value it reaches after the impulse of hitting the scale as the defacto force value. I have tuned the code to stop pressing down on the scale around the time the value will really reach equilibrium (5 s). Thus, you can use the value right before the servo stops pressing as F.

The curve generated by the servo pressing on the scale.

The steps for data collection are as follows:

  1. Open the ComDebug Logger software

  2. Upload the code to the board or restart the board. Open the Serial Monitor to begin the code.

  3. Start the Logger, then press the circle button on the board to begin a press down.

  4. Once the servo stops pressing down, pause the Logger and note down the final value before it begins to rapidly decay back to zero.

  5. Resume the logger and press the button again

  6. Repeat steps 3-5 until the code is finished.

Processing Data

The code I used to parse the MX-28 trials is presented above. The code:

  1. Converts the provided bit displacement values in bits and force values in kgs into deg/rad values and torque values, respectively.

  2. Plots the torque vs. displacement curve for each trial in a figure

  3. Finds the line of best fit for each trial and takes the slope as a possible value of kservok_{servo}

  4. Averages the trials for a value of kservok_{servo}for the value of P Gain

  5. Plots kservok_{servo}vs. P Gain to highlight the relationship between them

kServoDegAvg and kServoRadAvg are the end variables that store the values for kservok_{servo} in Nm/deg and Nm/rad, respectively.

The program imports data from files named with the convention, "<servo type> k=<p gain>" from within the same folder as the program. For example, the MX-28 files were named, "mx-28 k=16", "mx-28 k=32", etc. The files themselves should only have numbers in them. The first row should be the commanded position, the second row the actual position, and then the following rows each of the trials themselves. For example, here is the contents of the "mx-28 k=16" file:

While parsing the data, check each stiffness' figures to see if data points from the end need to be pruned. As you reach the maximum force the servo can apply, the τ\tau vs. Δθ\Delta\theta will begin to taper to an equilibrium, and the method the program uses to find the line of best fit is very sensitive to these points. For best results, ensure that any sort of tapering is removed.

Data points and line of best fit before pruning the data (left) and after (right).

Ideally the final plot will be roughly linear. For reference, here is the data for the MX-28s:

The K_servo vs. K_p graph for the MX-28s

Last updated

Was this helpful?