EnableAxisUnitConversion
Enables the axis to use a real-world unit. Changing the unit affects the position and velocity. You need to update MinimumFollowingError
, MaximumFollowingError
in McProfileSettings and MinimumOutput
, MaximumOutput
in McPidSettings.
Syntax
KsError EnableAxisUnitConversion(
int Index,
BOOL Active
);
Parameters
Index: the index of an axis. Indexes are zero based. Aliases affect this parameter.
Active: TRUE: use a real-world unit. FALSE: use the count unit.
Return value
If the function succeeds, it returns errNoError
, otherwise an error code. For more information about the error code, see the KsError list.
Remarks
- The default is the count (pulse) system. In the count system, the position unit is count and the velocity unit is count per second.
- In the real-world system, KINGSTAR Subsystem converts the functions to count units using the conversion ratio defined in SetAxisCountsPerUnit and SetAxisSecondEncoderCountsPerUnit.
- To use this function, first you need to change the numerator and denominator. Second, you need to update the PID gain values and motion interpolation parameters to match the user-defined unit. This can only be done when the axis is disabled.
Example
VOID ConfigureUnit(INT Index) {
SlaveStatus moduleStatus = { 0 };
int resolution = 0;
KsError nRet = GetAxisByIndex(Index, &moduleStatus, &resolution, NULL, NULL);
nRet = SetAxisCountsPerUnit(Index, resolution, UNITS_PER_REVOLUTION, FALSE);
nRet = EnableAxisUnitConversion(Index, TRUE);
}
Requirements
RT | Win32 | |
---|---|---|
Minimum supported version | 4.0 | 4.0 |
Header | ksmotion.h | ksmotion.h |
Library | KsApi_Rtss.lib | KsApi.lib |
See also