恭喜,你发布的帖子
发布于 2020-04-15 17:22:52
3楼
用循环中断ob中计数实现定时器功能,比如ob35中,中断周期是1s
timecounter:=timecounter+1;//计时器计时
if timecounter>=timecounter_sp1 then//计时器超过设定值1(30分钟,即1800)后归零重新计时
timecounter:=0;
end_if;
if timecounter<imecounter_sp2 then//计时值小于设定值2(10分钟,即600)气动阀开,否则气动阀关
"气动阀":=1;
else
"气动阀":=0;
end_if;
if timecounter>=timecounter_sp1 and timecounter_sav<=timecounter_sp1 then//计时器第一次大于设定值,则电机选择切换一次
motor_select:=1-motor_select;
end_if;
timecounter_sav:=timecounter;//保存计时值
if timecounter>=timecounter_sp1 then//计时大于10分钟则
if motor_select then//如果motor_select为1,启动电机1,否则启动电机2
motor1:=1;
else
motor2:=1;
end_if;
else//如果计时小于设定值(10分钟)则电机1和2都关闭
motor1:=0;
motor2:=0;
end if;
请填写推广理由:
分享
只看
楼主