SetAxisCam
连结轴并开始凸轮运动。
语法
KsCommandStatus SetAxisCam(
int Master,
int Slave,
BOOL Permanent,
double MasterOffset,
double SlaveOffset,
double MasterScaling,
double SlaveScaling,
McCamStartMode StartMode,
double StartParameter,
McSource MasterValueSource,
int Cam,
McBufferMode BufferMode
);
参数
Master [in]:主轴索引。索引以零为起点;别名将影响此参数。
Slave [in]:从轴索引。索引以零为起点;别名将影响此参数。从轴之最大数量为 32 轴。
Permanent [in]:决定马达停用后是否保留凸轮状态。
TRUE:马达停用但保留凸轮状态,例如当主轴启用时从轴也会跟著启用,而当主轴发生错误从轴也会发生错误。
FALSE:马达停用后不会保留凸轮状态。
MasterOffset [in]:凸轮表中主轴位置的偏移量。
SlaveOffset [in]:凸轮表中从轴位置的偏移量。
MasterScaling [in]:主设定档因子(预设值 = 1.0),以从轴的角度来看,该因子乘以整个主设定档。
SlaveScaling [in]:从设定档因子(预设值 = 1.0),该因子乘以整个从设定档。
StartMode [in]:从轴所用的凸轮模式。请见 McCamStartMode 类型
StartParameter [in]:依选择的斜坡而定,若为 camRampDistance
,StartParameter 即为从轴移动的距离,单位为计数;若为 camRampTime
,StartParameter 即为从轴移动的时间,每秒为一单位。该参数使用主轴的资讯来决定如何移动从轴,而距离取决于主轴移动的距离。
MasterValueSource [in]:定义同步的来源。请见 McSource 类型
- mcSetValue – 同步主轴设定值,建议使用此设定。
- mcActualValue-同步主轴实际值,此设定可能不稳定。
- mcSecondEncoderValue – 轴的第二编码器实际值。
注意:尚未支援 mcSecondEncoderValue。
Cam [in]:凸轮表的索引,连接到 SetCamTable 的输出。 .
BufferMode [in]:定义如何融合两功能的速度,请见 McBufferMode 类型
回传值
返回 KsCommandStatus 结构。
备注
- 此功能不与 SetCamTable 合并,因为这种分离可即时更改。
- 从轴偏移的机械类比是凸轮与额外的恒定层厚度焊接,如此从位置具有恒定的偏移量,若采用直线导向从动件,则该偏移量可表示主轴的轴偏移量。
- 欲分离从轴,请使用 ReleaseAxis。
- 当模数轴启用时,SetAxisCam 将不受影响,该轴不会将凸轮表中的位置视为模数位置。例如,假设主轴与从轴同步运行,且两者的模数值皆设定为 360。在凸轮表中,下一个 MasterPosition 和 SlavePosition 分别设定为 360 和 540。在此情况下,主轴将旋转 1 圈,而从轴将旋转 1.5 圈,以达到设定的位置。启用模数轴后,建议使用者:
- 使用 SetAxisPositionOffset 重设位置,以防止显示位置与内部位置不一致。例如,当模数值设为 360 时,使用者可能会看到位置为 0,而内部位置为 360000。
- 使用速度或距离 API 来移动主轴。
范例
KsCommandStatus AssignCamSlave(INT Master, INT Slave, INT Table) {
BOOL InSync = FALSE;
BOOL Busy = FALSE;
BOOL Active = FALSE;
BOOL CommandAborted = FALSE;
BOOL Error = FALSE;
WORD ErrorId = 0;
INT QueueIndex = -1;
BOOL EndOfProfile = FALSE;
KsCommandStatus cam = SetAxisCam(Master, Slave, FALSE,
0, //Master Offset. Offset to add to the master positions in the CAM table
0, //Slave Offset. Offset to add to the slave positions in the CAM table
1, /*Master Scaling. Ratio to apply to the distance between
the master positions and the original position*/
1, //Slave Scaling. Ratio to apply to the slave positions in the CAM table
camRelative, //StartMode.
/*Absolute: The slave axis will jump to its target in the table.
Alarms may be triggered if the position is too far.*/
//Relative: The current master/slave positions are used as origin for the CAM table.
/*Ramp Distance: The slave axis will ramp to its target position
while the master axis moves along the distance provided in StartParameter*/
/*Ramp Time: The slave axis will ramp to its target position
over the period of time provided in seconds in StartParameter*/
0, //Start Parameter
mcSetValue, /*Master Value Source. Value of the master position used.
Cam be the target position (commanded value and set value are identical)
or the actual position.*/
Table,
mcAborting
);
return cam;
}
使用需求
RT | Win32 | |
---|---|---|
最低支援版本 | 4.0 | 4.0 |
标头档 | ksmotion.h | ksmotion.h |
程式库 | KsApi_Rtss.lib | KsApi.lib |
参见