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