Connecting to a PLC A– 5 Connecting to a PLC If RS– 232C is used for panel/PLC connection, follow the same steps above, only set RS– 232C as the PLC and RS– 422 as Not Used. Connect the PLC to the panel through the proper cable below. For cable pinouts, see page A– 15. DirectTouch Cables Family PLC (or other device) Port Cable DirectLOGIC DL05.
How do timers work in PLC Structured Text (ST)? How do we declare them?
I've been studying a standard of PLC (IEC 61131-3), and they do not speak about timers in ST. I know the great majority of PLC programmers do them in ladder logic, but in this particular case I really need to declare timers in ST.
I am using a Rockwell PLC.
YoanribeiroYoanribeiro
5 Answers
You can find explanations about timers and how to use (declare) it in the help system of your IDE. For example, in the CODESYS help you can read about timers of the standard library.
In general, you can declare timer-delay (TON) as:
Then you can use it:
![Timer Timer](/uploads/1/2/4/8/124865917/132634778.png)
You can also use constants to set up your timer:
As a BOOL variable, the timer's output can be used in IF and WHILE statements:
All examples are run in CODESYS v3.5 SP5 and v2.3. For other IDEs there might be nuances.
nadeinnadein
I solved it like this in Gx-Works(Mitsubishi / FXCPU):
Remember to declare TON_1 :)
Richard87Richard87
The timer works so that
TON.Q
goes high only if TON.IN
is continuously high for at least the duration of TON.PT
.This makes sure that
TON.Q
only goes high if TON.IN
is in a stable high state.This could be useful for instance to ensure that the output is only enabled if a button is pressed for at least a duration of
TON.PT
.Adam.at.EpsilonAdam.at.Epsilon
Typically, you set a preset time and enable the timer. When it elapses, there will be done sort of done bit set true. When you reset the enable, the time will reset as well.
tkezytkezy
I have done this with an OMRON PLC which supports the ST language.
There's a timer interrupt in the PLC, and we used it to build our own timer in ST, and then we could skip out of the PLC limitations. When the PLC power on, the code inside the interrupt task is executed every interruption, and you can write 'A=A+1' inside the interrupt handler.
When you start to use the timer, just record the current data of A. Let's say A1; the interval is:
Then compare
Interval
to the time you want. If Interval
is bigger than the time you want, then execute the next code.![Ton timer on-delay Ton timer on-delay](http://www.thelearningpit.com/lp/doc/ntmr/tn5-500x350.gif)
Sunh HaoSunh Hao