PLC Program to Measure the Scan Cycle of PLC


This is a PLC Program to Measure the Scan Cycle of PLC.

Problem Description

Measure the scan cycle of a PLC using Ladder Diagram programming language.

Problem Solution
  • Use toggling output which toggles every time scan cycle is completed.
  • This can be done by connecting an XIO contact and an output in series with the same addresses.
  • Use this toggling bit as an input to up counter to increment number of times the bit toggles.
  • Use 1sec timer to stop the counter from counting, because the bit is toggling continuously and it might unnecessarily increment counter value even after 1sec is over.
  • Reset counter to clear the accumulator data to measure the scan cycle again.
PLC Program

Here is PLC program to Measure the Scan Cycle of PLC, along with program explanation and run time test cases.

List of Inputs and Outputs
 O:2/0	 = Toggling output			(Output)
 B3:0/0	 = Latching Bit				(Bit)
 I:1/0	 = Start measurement PB		        (Input)
 I:1/1	 = Reset Counter PB     		(Input)
 T4:1	 = 1sec time delay			(Timer)
 C5:0	 = Up counter to increment each toggle	(Counter)
 O:6	 = Display address			(Output)
 TOD	 = Hex to BCD conversion		(Compute)
 T4:0/DN = Stop counting			(Timer)
 -(RES)- = Reset Counter coil			(Output)

Ladder Diagram to measure scan cycleplc-program-measure-scan-cycle-plc-01

Program Description
  • When this program is Run, during first scan cycle, output image table memory bit O:2/0 is detected as 0 hence it allows the current through RUNG000 and updates output image table memory bit O:2/0 to 1. During the second scan cycle, O:2/0 is detected 1, hence it blocks current flow through the RUNG000 and output image table memory bit O:2/0 is reset to 0. This process continues till it is stopped manually.
  • This toggling of a memory bit is fed to Up Counter with address C5:0 and every time the bit toggles, counter is incremented by 1.
  • Scan cycle is defined as the Scans per second (Scans/Sec).
  • To fulfill this definition requirement, 1sec timer is added in this program to stop the incrementing of Counter after 1sec when Star PB is pressed which is done by placing XIO of T4:0/DN in series with Up Counter CTU.
  • Accumulator value is converted into BCD and fed to Display with address O:6.
Runtime Test Cases

Average value of scan cycle in LogixPro simulation software was detected 16 when it was set to Minimum Scans.plc-program-measure-scan-cycle-plc-02
Average value of scan cycle in LogixPro simulation software was detected 235 when it was set to Maximum Scans.plc-program-measure-scan-cycle-plc-03


Sanfoundry Global Education & Learning Series – PLC Algorithms.
To practice all PLC programs, here is complete set of 100+ PLC Problems and Solutions.

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.