How are PLC Timers Used in Timed Switch Operations?

Learn about the functions and applications of PLC timers.
PLC Timers - thumbnail
Listen to this article

Timers are one of the most often-used functions in PLC programming, and for good reason.

Timers allow the programmer to delay taking action for a period of time, to allow actions to proceed only for a set period of time, or to allow actions to continue for a total amount of time, even if the time is accumulated over several distinct periods.

These actions make advanced alarming strategies possible and allow the transfer of operation from a primary pump to a secondary pump after the primary pump has been in service for a set period of time.

Timers are pre-defined functions. They are added to a PLC program as an instruction block, with parameters such as Enable, Accumulated Time, and Timer Reset built into the timer function.

While there are several libraries of timers available, I will concentrate on IEC timers in this article, since most current PLC programming tools use this set of timers.

Timers are used throughout the courses available at realpars.com, but several courses, such as the PLC Programming Made Easy and CODESYS course series can help you master the use of timer functions. Check it out!

Importance of timers

We are all familiar with how timers impact our daily lives. Whether it is the time left in a sporting event, the time we set on the microwave to heat our food, or the alarm we set every night to get up in the morning at the right time, timers provide an essential function.

In a PLC program, timers do very much the same thing — they let us know how much more time is left in the current operational step, and they indicate how long to wait when a valve is told to open to evaluate if the valve did open.

Can you name other functions timers perform in PLC programs you may have written?

For example, many industrial processes involve sequential operations that must occur at specific intervals or durations. Timing functions enable programmers to precisely control the timing of these operations, ensuring that they occur in the correct sequence and at the right times.

In complex systems with multiple actuators, sensors, and processes, timing functions help synchronize the actions of different components.

For example, in a conveyor belt system, timing functions can ensure that items are moved at the right speed and that loading and unloading occur at the appropriate times.

As you can see, timers are critical in many industries such as manufacturing assembly lines, chemical processing, batch operations such as paint manufacture, and others.

In this article, I will describe various timer types and functions, giving examples of each as I go. So strap in, and let’s get started!

Structure of timers

Timers all have a basic structure. I will illustrate this using an IEC on-delay timer.

Timers all have a memory address. In this example, the address is T4:0. Depending on the PLC model, this address can be a file number and element, as shown here, a simple timer number, such as T12, or a numeric address.

The Time Base is the smallest unit of time tracked by the timer, such as 1.0 sec, 0.1 sec, or 0.01 seconds.

The Preset is the timer setpoint.

The Accumulated value is the elapsed time.

All of these parameters are built into the timer function. I just need to provide the correct timer type, add the correct values to support my application, and then let the timer do its thing!

When the accumulated time reaches the preset, the time is done, and the DN bit is set.

During the time that the timer is enabled and timing up to the preset value, the enable, or EN bit, and timing, or TT bit, is set.

These bits can be used in other rungs of the logic to allow downstream logic to execute.

For example, we may want to switch a conveyor gate once boxes have been traveling down one conveyor for 1 minute. The timer preset may be 60 with a time base of 1 second, so after 1 minute, when the done bit is set, the conveyor gate switches to the opposite side.

Types of timers

On-Delay Timer

The timer just illustrated is called an on-delay timer. When the logic upstream of the timer on the same rung is true, the timer is enabled. The timer times until the preset is reached, and the done bit is set.

If the timer input is no longer enabled, the timer resets.

Once set, the done bit stays true until the rung goes false.

Off-Delay Timer

An off-delay timer acts somewhat in the reverse of an on-delay timer.

Once the time rung goes true, the done bit is set immediately. When the timer input goes false, the timer begins to time and after the preset is reached, the done bit turns off.

This type of timer is useful for delaying an action until a certain time period has elapsed.

When transferring operation from a primary feed pump to a secondary feed pump, an off-delay timer can be used to delay off the primary while the secondary has a chance to ramp up to speed.

This keeps the primary pump on for the preset time, preventing a loss of flow during the transition period.

Retentive Timer

This type of timer is like the on-delay timer, except the timer does not reset when the timer input goes false.

The accumulated time is preserved, and when the timer is enabled again, it continues to accumulate time until the preset time is reached. At that point, the done bit is set.

With a retentive timer, a reset instruction must be executed to reset the timer.

A typical use of retentive timers is to track run time on a piece of equipment so that the optimal time for maintenance can be determined.

In this case, the timer runs as long as the machine is running. Once the machine stops, the timer stops but starts again once the machine starts back up.

The retentive timer tracks total run time, and once the preset has been reached, a maintenance flag is set, indicating it is time to change a roll of labels on a packing line, for example.

Best practices for timer usage

Setting appropriate timer presets is very important. If I am trying to delay the evaluation of a valve position alarm when a change of state is requested, I would want to set the timer to a reasonable value, such as 3 seconds.

This allows enough time for the valve to change state without an excessive delay before an alarm condition is checked.

Waiting 30 seconds might sound good, but if a fault occurs because the valve did not switch states, then the process may be affected for over 25 seconds.

When setting timer presets, I need to consider the system and process response times as well as any natural variations in these response times.

Whenever configuring a timer in the PLC, I should add comments to document the use of the timer and what actions will be taken when the timer expires.

Timers are also an excellent way to help with troubleshooting. Timers can temporarily be inserted in PLC logic to hold up the execution of logic long enough to be able to diagnose problems.

Advanced timer functions

Timers can be used for executing complex logic sequences. Timing functions can be cascaded to control the alternating addition of two feed streams into a mixing vessel for a specific period of time.

The master timer is set up for the overall addition time. A secondary timer controls the alternating opening and closing of the two ingredient valves.

Timers can be used to provide de-bouncing of an alarm condition. If the level in a tank is at the high level switch point, the resulting alarm may chatter, turning on and off repeatedly as the level bounces around the alarm point.

If I put an on-delay timer in the logic so that the alarm condition must be present for a period of time before triggering, I can reduce the chatter in the alarm.

Conclusion

I have presented a number of different timer functions along with practical examples of each. It should be clear that timers have a very important function in a wide array of applications.

Timers are one of the most widely used PLC instructions, and automation engineers are continuously coming up with new ways to use timers to create complex logic to coordinate operations on the plant floor.

If you want to learn more about using timers and programming PLCs, you should check out the wide selection of courses at realpars.com.

Join the Top 1% of Automation Engineers

Start your 7-day free trial

Learn from Industry Experts

Start your learning journey today!
With a 7-day trial, then 25/month
Join for Free