Timer and Counter PLC Instructions
16 March, 2021.
In this
post, we will write a program using timer and counter. If a programmer
understands these basic concepts, he will then be able to write and understand complex programs further.
Every new programmer in industrial automation must understand the basic
principle of writing a PLC program. Without it, he cannot be able
to further troubleshoot or understand complex automation systems. As the logic
is the heart of the system and the machine operates according to it, properly
writing and understanding a program is an important aspect for a programmer.
This post is intended to tell a new programmer how to write a PLC logic. As the
post is divided in two parts, the second part will cover the use of timers and
counters and try to write a program using it. Refer the first part which
covered the very basic topics of writing a PLC program.
Basically, timers and counters
are the basic libraries used in a code. If you remember earlier times when
PLC’s were not much in use; hardwire timers were used to start a motor after a
delay in the control panel. With advances of PLC, hardwire electrical logic
became of no use. If you take any application, virtually, it is impossible that
there will not be a timer or counter in the logic. It is required in some or
the other way to either start an output after a delay, control a process after
a delay or stop a process after a delay. Not everything can be started in one
go. That’s why, I considered this as a must for fresh learners to get a general
idea of timers and counters.
Timers in PLC:
Let us first start with timers. A timer is a library or function which is used to start something after a delay or stop something after a delay. It is the most commonly used ones of functions in a PLC program. There are three types of timers used in PLC – TON, TOFF and TP. Let us have a look at each one of these.
TON stands for On-Delay Timer. It starts the output
after a delay. In this block, as long as the input of timer is on, the timer
will run in it’s set time. When the set time elapses, it turns on the output.
Refer the below image. When the start input is on, the timer starts running and
it will run for 5 seconds as long as this input is on. If the input is on and
the timer elapses (means set time equals current time), then the motor output
will turn on. Anytime, the input turns off, the timer turns off immediately and
the motor variable will also turn off. Timer turning off means the current time
will become zero. TON is the simplest ones available in timer family.
TOF stands for Off-Delay Timer. It stops the output
after a delay. Refer the below image. By default, the current time of timer
will be 5 seconds (equal to set value).
When the stop input turns on,
the motor variable turns on immediately. Refer the below image.
As soon as the input turns off,
the timer starts to run. As the timer is running, the timer output is still on.
After the timer elapses, the motor turns off. In between, if the input turns on
again, then the timer output again goes on immediately and the situation becomes
same as the default one (current value is equal to set value).
TP stands for Pulse Timer. It keeps the output on for
set time, as soon as it receives a pulse in the input side. The pulse can be
positive edge or negative edge. Refer the below image.
As soon as the start input pulse
is received, the timer starts to run. Irrespective of the input received, whether
input remains on or off; it just needs a pulse. As long as the timer is
running, the motor output will remain on. When the timer elapses, motor
variable turns off.
Counters in PLC:
A counter is a library which
counts the inputs received and then turns on the output. There are two types of
counters used in PLC programming – CTU
and CTD. Let us have a look at each one of these.
CTU stands for up counter. It
counts the inputs received and then turns on the output. Refer the below image.
When a positive peak is detected
at PB_1 variable or a negative peak is detected at PB_2 variable, the count is
incremented by 1. The counter counts only pulses. Suppose if a normal open contact
was used in place of these peak types as shown above; then, when the variable
value would have changed from 0 to 1, then the count would have incremented.
When the variable value would have again gone back to 0, then the count would
not have incremented. It will increment in the next rising edge. So, it is one
and the same; the concept is that the counter counts peaks – positive or
negative.
When the counter current value
reaches 5 after each increment, then the counter output turns on; powering the
motor variable. Now, if still the pulses are received at input, then only the
current value will increment. The output will remain on because the current
value is more than or equal to set value.
Once a pulse is applied at reset
variable, then the counter will reset and the output will turn off; because the
current value becomes zero. It is important to note that if the reset variable
is continuously high and still the pulses are applied at input, then too the
counter will not increment. It’s current value will remain at zero. Once the
reset input goes off, then you can increment the counter by applying pulses.
CTD stands for down counter.
It’s functioning is same as up counter; the difference being that this counter
counts in down direction. Refer the below image.
In the up counter, the default
current value is zero. In the down counter, the default current value is equal
to set value. When the pulse is applied to input, the counter starts
decrementing. When the counter current value becomes less than or equal to
zero, then the output of counter remains on. When the reset input is applied,
the counter current value again becomes equal to set value and the output turns
off. As discussed earlier, if the reset input is continuously on, then the
counter won’t decrement; irrespective of the pulse applied at input.
Now, it depends on how you use
these timers and counters in your logic. If you are clear with the basic and if
you have read the first post clearly, then you will be more familiar with
normal contacts, coils, timers and counters.
I have covered the general programming example of PLC. I have
also not attempted to cover every theory of these design deeply; you can learn
it easily once you get familiar with them. I have just given you an insight of
these types of controls. Once you are done with these, I am hopeful you will be
easily able to understand any logic properly. Learn the basics and explore a
new type of study in this type of automation. It will take some practice and as
you go on developing logic, you will become more familiar with it.
Thank you guys; I hope you enjoyed reading the
practices normally used for this type of study in industrial automation.
Comments
Post a Comment
If you have any queries, please let me know