SetAxisCountsPerUnit

将使用者定义的位置单位转换为轴使用的计数(脉冲)单位的转换比率。

语法

KsError SetAxisCountsPerUnit(
     int Index,
     double Numerator,
     double Denominator,
     BOOL Reverse
);

参数

Index:轴的索引。索引以零为起点;别名将影响此参数。

Numerator:将驱动器单位转换为使用者单位。例如,若装置为编码器,则通常分子是编码器的解析度。

Denominator:将驱动器单位转换为使用者单位。例如,若使用度数,则分母将为 360,因一旋转为 360 度。

以下为单位转换的范例:

angle:需要的角度。

resolution:编码器解析度。

360:旋转的角度。

position:位置。

Reverse:反转轴的方向。

回传值

如果此函式执行成功,会回传 errNoError,否则会传回错误码。如需更多有关错误码的资讯,请参阅 KsError 清单。

备注

范例

复制
#define UNITS_PER_REVOLUTION 360
SlaveStatus slaveStatus = { 0 };
int resolution = 0;
DWORD InputVar = 0, OutputVar = 0;

KsError nRetGetAxisByIndex = GetAxisByIndex(0, &slaveStatus, &resolution, &InputVar, &OutputVar);
KsError nRetSetAxisCountsPerUnit = SetAxisCountsPerUnit(0, resolution, UNITS_PER_REVOLUTION, FALSE);

使用需求

  RT Win32
最低支援版本 4.0 4.0
标头档 ksmotion.h ksmotion.h
程式库 KsApi_Rtss.lib KsApi.lib

参见

EnableAxisUnitConversion

SetAxisSecondEncoderCountsPerUnit