2024年3月24日发(作者:)
开 篇
本文以Beckhoff公司PLC通过CANOpen协议控制路斯特ServerC plus驱动器驱
动phase伺服电机系统为实验背景给出的。下文控制字为PLC扫描上来的驱动器(BOXx,
其中x代表站号)的RxPDO1中的变量1(Var-0),状态字为PLC扫描上来的驱动器(BOXx)
的TxPDO1中的变量1(Var-0)。控制字和状态字均为16字节。详情请参照文档
“EK1100+EL6751连路斯特ServerC plus 驱动路斯特400w电机”。
第一章 控制字
控制字为16字节,常用的仅为0~8字节。控制字的各字节定义如下:
设备控制命令将有控制字的下列组合所触发,其中4-6和8字节根据当前运行模式有
关。
☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞
☞☞
读上面表格总结控制字如下:
① control word=6 (Quick Stop=1,Enable voltage=1,其它=0)
开始时电机驱动器的状态为Switch on disable,此时会切换到状态ready to switch
on ,在这种状态下应该能进行模式切换了。
② control word=F (Enable Operation=1,Quick Stop=1,Enable voltage=1,
Switch on=1,其它=0)
此时会给上了使能。如果选择的是速度模式(Modes of operation=3)且速度不为
0(target velocity≠0),则电动机应开始转动。
③ 在给上使能且模式为Profile position mode(通过DriverManager在驱动器中设
定)前提下,control word=1F (New setpoint=1,Enable Operation=1,Quick
Stop=1,Enable voltage=1,Switch on=1,其它=0)
如果是位置模式(Modes of operation=1)且速度不为0(profile velocity≠0),则电
动机开始相对转动。
④ 在给上使能且模式为Profile position mode(通过DriverManager在驱动器中设
定)前提下,control word=5F (abs/rel=1,New setpoint=1,Enable Operation=1,
Quick Stop=1,Enable voltage=1,Switch on=1,其它=0)
如果是位置模式(Modes of operation=1)且速度不为0(profile velocity≠0),则电
动机开始绝对转动。
⑤ 先control_word.7=0,后control_word.7=1,即Fault reset: 0→1
此时会完成复位错误。
☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜
☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜
第二章 状态字
状态字的个字节定义如下:
Bit 4 :Voltage enable
电源已连接。
Bit 5:Quick Stop
这一字节为低电平时表示控制器正在执行“Quick-Stop”。当驱动器为“ready for
operation”(即Operation Enable)时状态字的bit 0,bit 1和bit 2 被设定为1。其它
字节代表驱动器的附加状态,例如正在执行“Quick-Stop”。当产生一个错误时,Fault字
节被设定。
Bit 7:Warning
警告,例如温度限制等。当警告发生时,电动机状态不能进行切换。关于警告的更多
信息,参考FAULT CODE。
Bit 8:
生产厂商指定,当前未被应用。
Bit 9:
当前未被应用。
Bit 10:Target reached
当SetPoint到达时,这一位会自动被置1。而SetPoint基于运行模式(Operation
mode)。SetPoint改变将会影响这一字节。
对于stop命令,这一字节会保持原状态不变。
Bit 11:Internal Limit active
当内部限制到达的时候这一字节被设定。这一字节是基于OPERATION MODE的。
Bit 12和13:
这一字节基于OPERATION MODE。
这两个字节是对生产厂家特定生效的,在各种运行模式的章节给出了其注释说明。
☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞
☞☞
由上述内容我们可以看出,我们只需要读状态字的某些特定位就能判断出电机当前的
工作状态,例如:status_word.10=1或status_word.10=0,即可完成实现对电机当前是
否已Target reached进行判断。
☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜
☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜
第三章 编程实例
一、速度模式运行(完全状态字判断方式)
确认target_velocity是否为0,velocitystart表示速度模式的启动开关,velocityflag
表示速度模式运行的标志。
IF velocitystart AND (NOT velocityflag) THEN
modes_of_operation:=3;
END_IF
//将运行模式设定为速度模式
IF modes_of_operation_display =3 AND velocitystart AND
THEN
control_word:=0;
velocityflag:=TRUE;
END_IF
IF status_word=16#5670 OR status_word=16#5270
THEN
control_word:=6;
END_IF
IF status_word=16#5631 OR status_word=16#5231
THEN
NOT velocityflag
AND velocitystart
AND velocitystart
control_word:=F;
END_IF
//以上部分实现控制字依此给定0,6,F,实现速度模式运行
IF status_word=16#5637 AND velocitystart THEN
velocitystart :=FALSE;
END_IF
二、绝对位置模式运行(状态字按位判断方式)
确认profile_velocity是否为0,absolutestart表示绝对位置模式的启动开关,后面
对absolutestart的置false可避免重复发控制字0.
IF absolutestart THEN
modes_of_operation:=1;
END_IF
//将运行模式设定为位置模式
IF modes_of_operation_display =1 AND relativestart THEN
control_word:=0;
absolutestart :=FALSE;
END_IF
(* IF modes_of_operation_display =1 AND status_word=16#4670 THEN*)
IF modes_of_operation_display
AND
=1
AND
AND
status_word.6=1
status_word.2=0
AND
AND status_word.0=0 status_word.1=0
status_word.3=0 THEN
(即:)
control_word:=6;
END_IF
(* IF modes_of_operation_display =1 AND status_word=16#4631 THEN*)
IF modes_of_operation_display
AND
=1 AND
AND
status_word.6=0
status_word.1=0
AND
AND status_word.5=1 status_word.0=1
status_word.2=0 AND status_word.3=0 THEN
(即:)
control_word:=15;
END_IF
//以上部分实现控制字依此给定0,6,F,实现位置模式使能
IF modes_of_operation_display =1 AND start AND status_word.6=0 AND
status_word.5=1 AND status_word.0=1 AND status_word.1=1 AND
status_word.2=1 AND status_word.3=0 THEN
(即:)
control_word:=31;
start:=FALSE;
END_IF
//控制字给定1F,实现绝对位置动
三、相对位置模式运行(完全状态字判断方式)
确认profile_velocity是否为0,relativestart表示相对位置模式的启动开关,后面对
relativestart的置false可避免重复发控制字0.
IF relativestart THEN
modes_of_operation:=1;
END_IF
//将运行模式设定为位置模式
IF modes_of_operation_display =1 AND relativestart THEN
control_word:=0;
relativestart:=FALSE;
END_IF
IF status_word=16#4670 (* AND control_word=0*) THEN
control_word:=6;
END_IF
IF status_word=16#4631 (*AND control_word=6*) THEN
control_word:=15;
END_IF
//以上部分实现控制字依此给定0,6,F,实现位置模式使能
IF status_word=16#4637 (*AND control_word=15*) THEN
control_word:=95;
END_IF
IF (status_word=16#1237(* OR status_word=16#5637*)) AND relativestart
THEN
(*modes_of_operation:=1;*)
stop:=FALSE;
relativestart :=FALSE;
(*velocityflag:=TRUE;*)
END_IF
//控制字给定5F,实现相对位置动
三、紧急停止并去掉使能,停止结束不再运动(位置模式和位置模式均有效)
IF emergency_stop_edge THEN
control_word:=0;
modes_of_operation:=0;
emergency_stop_edge:=FALSE;
END_IF
四、紧急停止并使能不改变,停止结束可能会继续运动(位置模式和位置模式均有效)
IF emergency_stop_edge THEN
control_word.8:=1;
END_IF
注:对于位置模式,该指令类似于暂停指令,其只会停顿很短的时间(10
-1
秒级时间),
然后control_word.8会自动复位为0,若未到达设定位置,电动机会继续向目标位置运动。
所以,我们若要实现停住应每个PLC周期都要执行control_word.8:=1指令,即持续将
control_word.8置1。
五、错误报告
其中,faultflag为BOOL型错误标志变量;令control_word.7:=0是为错误复位时产
生上升沿做准备。
IF ( status_word.3) AND (NOT status_word.2) AND (NOT status_word.1)
AND (NOT status_word.0) AND (NOT status_word.6) THEN
faultflag:=TRUE;
control_word.7:=0;
ELSE
faultflag:=FALSE;
END_IF
注:由表格 我们可以通过判断状态字的特定位来检
测是否报错,即:status_word.6=0,status_word.3=1,status_word.2=0,
status_word.1=0,status_word.0=0。
六、错误复位
其中,faultflag为BOOL型错误标志变量;faultreset为BOOL型错误复位指令。
IF faultflag AND faultreset THEN
control_word.7:=1;
faultreset:=FALSE;
END_IF
注:由
保control_word.7=0,以产生上升沿。
我们可以看出:令control_word.7:=1之前要确
六、运动完成报告
其中doneflag是运动完成标志。
IF status_word=16#5637 OR status_word=16#4637 THEN
doneflag:=TRUE;
ELSE
doneflag:=FALSE;
END_IF
注:其中status_word=16#5637是速度模式的完成,status_word=16#4637是位
置模式的完成。
七、运动中报告(位置模式)
其中doingflag是运动中标志。
IF status_word=16#1237 THEN
doingflag:=TRUE;
ELSE
doingflag:=FALSE;
END_IF
注:速度模式应该也有类似的模式,本人未做实验。
第四章 常见状态字对照
☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞☞
☞☞
注:以下状态字的附录仅针对Profile Velocity模式
① status_word=16#5270
解析:二进制表示为 xx01 00xx x1xx 0000
表示:追踪无误,设定点已确认(此时为速度模式),未到达内部限制,目标未到达,
Switch on disable。
② status_word=16#5670
解析:二进制表示为 xx01 01xx x1xx 0000
表示:追踪无误,设定点已确认(此时为速度模式),未到达内部限制,目标已到达,
Switch on disable。
③ status_word=16#5631
解析:二进制表示为 xx01 01xx x01x 0001
表示:追踪无误,设定点已确认(此时为速度模式),未到达内部限制,目标已到达,
ready to switch on。
④ status_word=16#5231
解析:二进制表示为 xx01 00xx x01x 0001
表示:追踪无误,设定点已确认(此时为速度模式),未到达内部限制,目标未到达,
ready to switch on。
⑤ status_word=16#5637
解析:二进制表示为 xx01 01xx x01x 0111
表示:追踪无误,设定点已确认(此时为速度模式),未到达内部限制,目标已到达,
operation enable。
⑥ status_word=16#4670
解析:二进制表示为 xx00 01xx x1xx 0000
表示:追踪无误,设定点未确认(此时为位置模式),未到达内部限制,目标已到达,
Switch on disable。
⑦ status_word=16#4631
解析:二进制表示为 xx00 01xx x01x 0001
表示:追踪无误,设定点未确认(此时为位置模式),未到达内部限制,目标已到达,
ready to switch on。
⑧ status_word=16#4637
解析:二进制表示为 xx00 01xx x01x 0111
表示:追踪无误,设定点未确认(此时为位置模式),未到达内部限制,目标已到达,
operation enable。
⑨ status_word=16#1237
解析:二进制表示为 xx01 00xx x01x 0111
表示:追踪无误,设定点已确认(此时为位置模式),未到达内部限制,目标未到达,
operation enable。(此时在位置模式下向目标位置运动的过程中)
⑩
☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜
☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜☜
☜


发布评论