恭喜,你发布的帖子
发布于 2020-04-15 20:24:54
4楼
用循环中断ob中计数实现定时器功能,比如ob35中,中断周期是1s
timecounter:=timecounter+1;//计时器计时
if timecounter>=timecounter_sp1 then//计时器超过设定值1(30分钟,即1800)后归零重新计时
timecounter:=0;
end_if;
if timecounter "气动阀":=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;
太感谢啦。
但是你用定时中断的计时不准确呀!我看资料上说用IEC的定时器,时间最准确。
请填写推广理由:
分享
只看
楼主