APIs, concepts, guides, and more
Counts Per Unit (User Units)

Convert raw encoder counts into meaningful units like inches, centimeters, or degrees for practical application in motion control systems.

🔹 What are Counts Per Unit (User Units)?

User Units are a way to format the values you work with into something more meaningful than raw counts. They are often used to change counts to distance (cm, inch, etc), degree, full rotation, etc.

🔹 How to Use Counts Per Unit?

Image

Many people like to use linear units such as inches or centimeters. In this case you need to calculate how many motor revolutions there are in a centimeter then multiply that number by the motor resolution. See examples below.

Warning
User Units are a RapidCode Axis class member variable. It is not written or stored to the drives/controller memory. Gearing and other Controller operations will not apply User Unit scaling/inversion for you.

🔹 RapidSetup Parameters Scaled by Counts Per Unit

Motion and Tuning Tab

  • Velocity, Acceleration, Deceleration, Motion Profile Positions 1 and 2, and Relative Increment.

Limits and Actions Tab

  • Position error Trigger value, Positive and Negative Software trigger values.

Configuration Tab

  • Fine and Coarse Position tolerances, Velocity tolerance, and Estop modify deceleration rate.

🔹 Examples - Calculate Counts per Unit

Note
If you have an AKD drive, a free-spinning motor that is not connected to anything, and you want to work in Degrees.
Resolution$$= 2^{20} = 1048576 Counts/MtrRev$$ (set by AKD drive)
Counts Per Unit
$$= (1048576 Counts/MtrRev) * (0.002777... MtrRevs/Degree) = 2912.7111... Counts/Degree$$

Image

Example 2

If you have an AKD drive, a motor hooked up to a 5mm/rev ball screw, with a 2:1 timing belt and you want to work in Inches.

Helpful hints: There are 25.4mm in 1 Inch. The actuator travels 5mm in 1 ball screw revolution. The motor needs to turn 2 revs to turn the ball screw 1 rev.

Image

Resolution = 2^20 = 1048576 Counts/MtrRev (set by AKD drive)

Counts per Unit = 1048576 Counts/MtrRev x 10.16 MtrRevs/Inch = 10653532.16 Counts/Inch

Example 3

If you have an S300 drive with PRBASE set to 16, a motor hooked up to a conveyor belt that has a 5-in-diameter roller, a 25:1 gearhead and you want to work in meters.

Helpful hints: There are 0.0254 meters in 1 Inch. The linear distance that the belt travels in one roller revolution is the same as the roller circumference. The motor needs to turn 25 revs to turn the roller 1 rev.

Roller Circumference = 5in x pi = 15.707 inches

Image

Resolution = 2^16 = 65536 Counts/MtrRev (set by PRBASE in S300 drive)

Counts per Unit = 65536 Counts/MtrRev x 62.663 MtrRevs/meter = 4106700 Counts/meter

Example 4

If you have an AKD drive, a free-spinning motor that is not connected to anything, and you want to work in Revolutions.

Helpful hints: The AKD drive uses 1048576 Counts/MtrRev regardless of the motor feedback device.

Resolution = 2^20 = 1048576 Counts/MtrRev (set by AKD drive)

Counts per Unit = 1048576 Counts/MtrRev

Example 5

If the drive resolution is 24 bits and you want to work in Revolutions.

Resolution = 2^24 = 16777216 Counts/MtrRev (set by drive)

Counts per Unit = 16777216 Counts/MtrRev

📜 Sample Code

  • C#

    const int ENCODER_RESOLUTION_BITS = 20; // The number of bits defining the encoder resolution
    // Specify your counts per unit/user units. (the motor used in this sample app has 1048576 encoder pulses per revolution)
    // 1048576 Setting the user units to this value will result in a commanded position of 1 spinning the motor 1 full revolution
    double USER_UNITS = Math.Pow(2, ENCODER_RESOLUTION_BITS);
    // SET
    axis.UserUnitsSet(USER_UNITS);
    axis.ErrorLimitTriggerValueSet(1); // Specify the position error limit trigger. (Learn more about this on our support page)
    // GET
    var userUnits = axis.UserUnitsGet();

  • C++

    // Parameters
    const int ENCODER_RESOLUTION_BITS = 20; // The number of bits defining the encoder resolution
    const double USER_UNITS = std::pow(2, ENCODER_RESOLUTION_BITS); // The number of user units per revolution
    // (2^20 = 1,048,576 user units per revolution)
    // SET
    axis->UserUnitsSet(USER_UNITS);
    // GET
    double userUnits = axis->UserUnitsGet();