flex_load_counts_steps_rev

NI-Motion Functions

flex_load_counts_steps_rev

Device Compatibility

Device Compatibility
7330
Y
7340
Y
7344
Y
7350
Y
7390
Y
NI SoftMotion Controller for CANopen—Xenus
Y
NI SoftMotion Controller for CANopen—Accelnet
Y

Load Counts/Steps per Revolution

Usage

status = flex_load_counts_steps_rev(u8 boardID, u8 axis, u16 unitType, u32 countsOrSteps);

Purpose

Loads the quadrature counts or steps per revolution for an axis.

Tip  Refer to the Remarks section for information about how the behavior of this function differs between controllers.

Parameters

Name Type Description
boardID u8 assigned by Measurement & Automation Explorer (MAX)
axis u8 axis to control
unitType u16 type of information, counts or steps, to load
countsOrSteps u32 quadrature counts or steps per revolution

Parameter Discussion

axis is the axis to control. Valid values are NIMC_AXIS1 through NIMC_AXIS30. On motion controllers that support fewer than thirty axes, configuring non-existent axes returns error –70006 (NIMC_badResourceIDOrAxisError). Refer to Axes for axis resource IDs.

unitType is the type of information, counts or steps, to load. The following are valid values:

unitType Constant unitType Value Action
NIMC_COUNTS 0 Use to define counts/revolution for a quadrature encoder.
NIMC_STEPS 1 Use to define steps/revolution for a stepper motor.

countsOrSteps is either the quadrature counts per revolution for the encoder mapped to the axis or the number of steps (full, half, or microstep) per motor revolution.

Using This Function

Use this function to load any feedback value (counts or volts) per unit of measure or to load the number of steps per motor revolution. For encoders, this is typically in units of quadrature counts per motor revolution, but can be counts per inch, per cm, or per any unit of measure. For analog feedback, it can be in units of scaled voltage. Steps can be full steps, half steps, or microsteps depending upon how you have the external stepper driver and motor configured.

This parameter must be correctly loaded before you call the Load Velocity in RPM, Load Accel/Decel in RPS/sec, Load Velocity Threshold in RPM, Read Velocity in RPM, Load Move Constraints, or Find Reference functions.

The Find Reference function searches for the encoder index for one revolution as defined by this function. Therefore, another useful unit of measure is counts per index period. Linear encoders often have indexes every inch or every centimeter.

Closed-loop stepper functionality relies on the ratio of counts to steps and not on the absolute values of counts or steps per revolution. For closed-loop operation, any unit of measure (UOM) that allows you to enter both counts per UOM and steps per UOM that are within their valid ranges work. Notice that this function must be called twice: one time to set up the stepper motor steps/rev, and again to set up the quadrature encoder counts/rev.

Caution  For closed-loop stepper controllers, steps per revolution/counts per revolution must be in the range of 1/32,767 < steps/counts < 32,767.

This function loads a scale factor that affects subsequently loaded and read back values of velocity and acceleration.

Remarks

This section includes information about how the behavior of this function differs among the controllers that support it.

NI 73xx Controller Considerations

The following list includes considerations you must make when you are using this function with a 73xx controller:

  • countsOrSteps is interpreted as number of encoder counts per revolution for encoder feedback or number of ADC codes (LSBs) per revolution for analog feedback.
  • The range for the countsOrSteps parameter is 2 to 228–1 with a default value of 2,000.

NI SoftMotion Controller Considerations

The following list includes considerations you must make when you are using this function with the NI SoftMotion Controller:

  • The range for the countsOrSteps parameter is 1 to 231–1 with a default value of 1.
    Note  This parameter must be correctly loaded before you load target positions or write contour position information to the controller or camming table.
  • This function determines the unit used when loading velocity. You must set the countsOrSteps value to 1 to use this function to load velocity values in counts/sec and load acceleration values in counts/sec2. If you set countsOrSteps to any value other than 1, you must use the Load Move Constraints function to load velocity and acceleration in counts.