Inst ToolsInst ToolsInst Tools
  • Courses
  • Automation
    • PLC
    • Control System
    • Safety System
    • Communication
    • Fire & Gas System
  • Instrumentation
    • Design
    • Pressure
    • Temperature
    • Flow
    • Level
    • Vibration
    • Analyzer
    • Control Valve
    • Switch
    • Calibration
    • Erection & Commissioning
  • Interview
    • Instrumentation
    • Electrical
    • Electronics
    • Practical
  • Q&A
    • Instrumentation
    • Control System
    • Electrical
    • Electronics
    • Analog Electronics
    • Digital Electronics
    • Power Electronics
    • Microprocessor
  • Request
Search
  • Books
  • Software
  • Projects
  • Process
  • Tools
  • Basics
  • Formula
  • Power Plant
  • Root Cause Analysis
  • Electrical Basics
  • Animation
  • Standards
  • 4-20 mA Course
  • Siemens PLC Course
Reading: Structured Text PLC Program for Measuring Event Duration
Share
Font ResizerAa
Inst ToolsInst Tools
Font ResizerAa
  • Courses
  • Design
  • PLC
  • Interview
  • Control System
Search
  • Courses
  • Automation
    • PLC
    • Control System
    • Safety System
    • Communication
    • Fire & Gas System
  • Instrumentation
    • Design
    • Pressure
    • Temperature
    • Flow
    • Level
    • Vibration
    • Analyzer
    • Control Valve
    • Switch
    • Calibration
    • Erection & Commissioning
  • Interview
    • Instrumentation
    • Electrical
    • Electronics
    • Practical
  • Q&A
    • Instrumentation
    • Control System
    • Electrical
    • Electronics
    • Analog Electronics
    • Digital Electronics
    • Power Electronics
    • Microprocessor
  • Request
Follow US
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Inst Tools > Blog > PLC Tutorials > Structured Text PLC Program for Measuring Event Duration

Structured Text PLC Program for Measuring Event Duration

Learn how to create a Structured Text PLC program to measure the time taken by an event between two sensors.

Last updated: September 13, 2024 3:05 pm
Viral Nagda
PLC Tutorials
No Comments
Share
5 Min Read
SHARE

In industrial automation, there arises an occasion where you are required to measure the time taken for a particular event and show it to the operator. This helps in realizing how a process is working and how much time it is taking.

Contents
PLC Program for Measuring Event DurationStructured Text PLC Program

Troubleshooting improves a lot due to this logic. In PLC programming, structured text is a language which is used in many applications for high-level troubleshooting and ease of writing. In this post, we will learn how to write a PLC program for measuring the time taken by an event using structured text.

PLC Program for Measuring Event Duration

Let us understand the case scenario first. There are two sensors on a conveyor, one mounted on the left and the other on the right.

When an object passes the first sensor, it means the timer should start to count. When that object passes the second sensor, it means the timer should stop to count, as the object has passed now. The time taken to travel from sensor-1 to sensor-2 is the event to be measured.

Structured Text PLC Program

Now, let us write the PLC program. Refer to the below image. There are only two PLC digital inputs – sensor-1 and sensor-2.

Structured Text PLC Program for Measuring Event Duration

When sensor-1 is sensed, we set a bit named Start_Timing by moving value 1. We will now require two elements – one timer for giving one second pulse and one counter for counting the time traveled. The timer will give one second pulse to the counter, so that it can count the timing in seconds.

For this, we first write the timer logic in the third part as shown. The timer input will be the negate of the timer done bit. The timer set value will be 1 second. Due to this, the timer will continuously be on and off for every 1 second. We can then use it’s output for our next part.

In the fourth part, we write the counter logic. The counter input will be the done bit of the timer and start_timing bit. Means, the counter will start counting only when this bit is set first.

The counter set value will be 32767 (based on our conveyor design which will not go beyond this much time as per sensor positioning). It means as per our design example, the travel time will not be more than 32767 seconds. As long as the bit is set, the counter will increment every second.

Now, coming to our most important part of counting the counter value. As you can see, we have written this part in the second block, above timer and counter logic. When sensor-2 is sensed, we reset the bit of Start_Timing by moving value 0.

But before that, we move the counter current value in the register where we show the accumulated value. This is because if this line is written afterward, then the counter would have been reset already and we will not get the value. So, in the third line, we reset the counter at last by sensor-2. So, the sequence goes as – first we move accumulated value, then stop counting, and then reset counting.

As sensor-2 will come in a pulse, the counter accumulated value will be holded in the register and not become zero. Due to this, the operator can every time view the last traveled time.

It is thus important to note that the sequence of lines is written properly for timely execution. Any mistake in ordering cannot run the logic properly.

In this way, we saw how to write a PLC program for measuring the time taken by an event using structured text,

Read Next:

  • Traffic Lights Ladder Diagram using Timers
  • PLC Programming With a Move Instructions
  • PID Controllers in Closed Loop Control Systems
  • Motion Detection based Street Light PLC Logic
  • PLC Programming for Pumping and Draining System

Don't Miss Our Updates
Be the first to get exclusive content straight to your email.
We promise not to spam you. You can unsubscribe at any time.
Invalid email address
You've successfully subscribed !

Continue Reading

Difference between PLC and HMI
Auto Sugar Bag Filling Station
Compare Online and Offline PLC Programs
How to Add Security in InTouch SCADA?
PLC Programming for Fan Control Unit System for Industry
PLC Programming Example on Bottle Line Control
Share This Article
Facebook Whatsapp Whatsapp LinkedIn Copy Link
Share
Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

128.3kFollowersLike
69.1kFollowersFollow
210kSubscribersSubscribe
38kFollowersFollow

Categories

Explore More

Edge Detection in PLC Programming
Network Switch Port Allocation Details
PLC Automatic Door Control System – Programming Example
Basics of Loop Checks
SCADA Interview Questions and Answers
Advanced PLC Conveyor Control: Forward and Reverse Rotation
PLC Program to Control Gas Pressure using Closed-Loop
Which Language is Best for PLC Programming?

Keep Learning

Compare DCS, PLC, RTU

Difference between DCS, PLC, and RTU ?

Code Simulation of Safety Circuit

Feedback Monitoring in Safety PLC

Mixing Tank Relay Circuit

PLC Program for Mixing Tank

How to Safely Design Automation System for Hazardous Environments?

Automation System for Hazardous Environments

PLC-Complete-Training-Package

Free PLC Training Software Download

Grounding Electronic Equipment

Importance of Grounding Electronic Equipment

Ladder Diagram PLC program

PLC Counter Instructions

PLC Program for Counting Objects on Conveyor

PLC Program for Counting Moving Objects on Conveyor

Learn More

PLC Batch System for 4 Tanks Mixing using CX-Programmer

PLC Batch System for 4 Tanks Mixing using CX-Programmer

Electrical Drives and Controls Interview Questions

Electrical Drives and Controls Interview Questions

What is Instrument Air Manifold

What is Instrument Air Manifold ?

Electrical Machines Questions and Answers

Induction Motors Operating Characteristics Questions

Difference between RCCB and RCBO

Difference between RCCB and RCBO

Instrumentation loop Diagram

Instrumentation Loop Diagrams

Corona-Ring-on-Surge-Arresters

Corona Ring on Surge Arresters and other EHV equipment

DDE Protocol

What is the DDE Protocol?

Menu

  • About
  • Privacy Policy
  • Copyright

Quick Links

  • Learn PLC
  • Helping Hand
  • Part Time Job

YouTube Subscribe

Follow US
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?