ConfigureAxis
配置模拟轴的设定。
语法
KsError ConfigureAxis(
int Index,
SlaveStatus Details,
int Resolution
);
参数
Index:模拟轴的索引。索引以零为起点;别名将影响此参数。
Details: 含资讯的 SlaveStatus 结构,用以配置伺服驱动器的设定。
Resolution:预设订至轴的编码器解析度。
回传值
如果此函式执行成功,会回传 errNoError,否则会传回错误码。如需更多有关错误码的资讯,请参阅 KsError 清单。
备注
在使用模拟轴时允许预期的模拟行为。
可用的 EtherCAT 状态
ecatOffline, ecatOP
范例
复制
/////////////////////////////////////////////////////////////////////////
//
// This code snippet demonstrates how to configure simulated hardware
// in KINGSTAR subsystem. Please be aware that if any actual hardware
// detected in the bus scan procedure the configuration will be replaced
// by automated configuration.
//
/////////////////////////////////////////////////////////////////////////
#define AXIS_COUNT 2
#define IO_COUNT 3
// Variable declaration
KsError nRet = errNoError;
KsCommandStatus Command = { 0 };
SubsystemStatus Subsystem = { ecatOffline, ecatOffline, 0, 0, 0, {ecatOffline}, {ecatOffline}, {axisOffline} };
int axesCount = 0, ioCount = 0;
// Link to the KINGSTAR subsystem
nRet = Create(0, 0);
nRet = SetConfiguredAxesCount(AXIS_COUNT);
nRet = SetConfiguredIoCount(IO_COUNT);
for (int i = 0; i < AXIS_COUNT; i++)
{
SlaveStatus axisDefinition = { "Simulated Axis", 0 };
// Assign resolution for the simulated axes
nRet = ConfigureAxis(0, axisDefinition, 131072);
}
for (int i = 0; i < IO_COUNT; i++)
{
SlaveStatus simulatedIo = { "Simulated IO", 0 };
// Assign input length for the simulated IOs
simulatedIo.InputLength = 32;
nRet = ConfigureIo(i, simulatedIo);
}
// By setting the timeout to a short interval and abort Start() on timeout,
// KINGSTAR subsystem will stop scanning for real hardware and start with
// the simulated hardware instead.
Command = WaitForCommand(2, TRUE, Start());
// Get the configured hardware count. It can be used by another KINGSTAR application process.
nRet = GetConfiguredAxesCount(&axesCount);
nRet = GetConfiguredIoCount(&ioCount);
使用需求
| RT | Win32 | |
|---|---|---|
| 最低支援版本 | 4.0 | 4.0 |
| 标头档 | ksapi.h | ksapi.h |
| 程式库 | KsApi_Rtss.lib | KsApi.lib |
参见