|
老外一般是不用定时器的,如遇到计时,他们是这么写的,先建立个100MS脉冲,程序如下:
A "m_pulse_100ms" //If flag set from last cycle
R "m_pulse_100ms" // -> reset flag
L "mw_100ms_pulse" //Load stored time value
L #OB1_PREV_CYCLE //and add last cycle time
+I
T "mw_100ms_pulse"
L 100
<I //Value smaller than 100ms?
JC l040 //yes -> go ahead
-I //no -> store difference to 100ms
T "mw_100ms_pulse" //as new initial value
SET
S "m_pulse_100ms"
比如要计时3S,先用传送指令 L 30 T MW100,然后每100MS减1,当MW100=0时,计时时间到。
本文转载自:西门子工业技术论坛
|
|