RetCode result;
int exit_cmd = 0;
//库加载
result = YKM_LoadLib();
YKM_BusInfo busInfo;
//等待系统初始化完成
while (!exit_cmd)
{
result = YKM_GetBusInfo(&busInfo);
if (busInfo.running)
break;
Sleep(100);
}
UINT32 groupIndex = 0;
//速度/加速度配置
YKM_GroupProfile profile;
profile.max_velocity = 500;
profile.start_velocity = 1;
profile.stop_dec_emg = 10000;
profile.stop_dec_smooth = 1000;
profile.stop_dec_jerk = 10000;
YKM_SetGroupProfile(groupIndex, profile);
//轴绑定
YKM_GroupConfig config;
config.System = YKM_COORDINATE_ACS;
config.axisNum = 2;
config.axisIndex0 = 0;
config.axisIndex1 = 1;
YKM_InitGroup(groupIndex, config);
//等待绑定完成
YKM_GroupStatus status;
while (!exit_cmd)
{
result = YKM_GetGroupStatus(groupIndex, &status);
print(result);
if (status.Inited)
break;
Sleep(1);
}
//直线插补,绝对模式
YKM_MoveLinearAbsoluteConfig absConfig;
absConfig.position.x = 1000;
absConfig.position.y = 500;
absConfig.position.z = 0;
absConfig.velocity = 100;
absConfig.acceleration = 1000;
absConfig.deceleration = 1000;
absConfig.jerk = 5000;
absConfig.bufferMode = YKM_BLENDING_LOW;
absConfig.transMode = YKM_CORNER_DISTANCE;
absConfig.transPara.x = 1.0;
absConfig.transPara.y = 0;
absConfig.transPara.z = 0;
YKM_MoveLinearAbsolute(groupIndex, absConfig);
//直线插补,相对模式
YKM_MoveLinearRelativeConfig relConfig;
relConfig.distance.x = 100;
relConfig.distance.y = 500;
relConfig.distance.z = 0;
relConfig.velocity = 100;
relConfig.acceleration = 1000;
relConfig.deceleration = 1000;
relConfig.jerk = 5000;
relConfig.bufferMode = YKM_BLENDING_LOW;
relConfig.transMode = YKM_CORNER_DISTANCE;
relConfig.transPara.x = 1.0;
relConfig.transPara.y = 0;
relConfig.transPara.z = 0;
YKM_MoveLinearRelative(groupIndex, relConfig);
YKM_StartGroup(groupIndex);
//等待目标位置到达
YKM_GroupStatus status;
while (!exit_cmd)
{
result = YKM_GroupStatus(groupIndex, &status);
if (0 != status.Done)
break;
Sleep(1);
}
|