Tutorial 4-3: User units

The axis coordinates have units of user units. By default, the user units are pulses, so a position command of 10000 will cause the servo to be commanded a movement of 10000 pulses.

To adjust the user units to a different unit (such as micrometers), set the Gear Ratio Numerator and Gear Ratio Denominator parameters to the ratio between the desired user unit and one pulse.

For example, if the servo encoder resolution is 2^20 pulses per revolution, the distance per encoder revolution is 10mm, and the desired user unit is 1um (micrometer), the Gear Ratio Numerator and Gear Ratio Denominator can be set as follows:

2^20 * 1um / 10mm = 1048576 / 10000

Gear Ratio Numerator = 1048576

Gear Ratio Denominator = 10000

After setting the gear ratio parameters as above, a position command of 10000 will cause the servo to be commanded a movement of 10000um.

The following code sets the user units to micrometers assuming the pulses per revolution and distance per encoder revolution in the above example.

double encoderPulsesPerRevolution = 1048576;
double encoderUserUnitsPerRevolution = 10000;

//Set the gear ratio
err = wmxlib_cm.config->SetGearRatio(0, encoderPulsesPerRevolution, encoderUserUnitsPerRevolution);
if (err != ErrorCode::None) {
    wmxlib_cm.ErrorToString(err, errString, sizeof(errString));
    printf("Failed to set gear ratio. Error=%d (%s)\n", err, errString);
    goto exit;
}