PLC Program to Change Preset Value of Counter


This is a PLC Program to Change Preset Value of Counter According to Various Products.

Problem Description

Different objects are moving on a conveyor belt. Let’s say, circular balls, square blocks and rectangular blocks. All three types of objects are collected in the same sized box. As these types are different in size and shapes as well, number of objects to be placed are different for each type. Set counter value according to different sized objects’ detection. Implement automation of this in PLC using Ladder Diagram programming language.

Problem Diagram

Diagram showing counting process of different objectsplc-program-change-preset-value-counter-according-various-products-01

Problem Solution
  • Use three different proximity switches to detect all three different objects.
  • Mount these switches such that switches detect assigned object only. For example, mount Square detector proximity such that it neither detects Rectangular blocks nor Balls.
  • Load counter values in registers for different objects. And load this value as soon as a particular type of object is detected.
PLC Program

Here is PLC program to Change Preset Value of Counter According to Various Products, along with program explanation and run time test cases.

List of Inputs and Outputs
 I:1/14	= Start							(Input)
 I:1/15	= Stop							(Input)
 O:2/0	= Master Coil						(Output)
 O:2/1	= Conveyor motor					(Output)
 I:1/0	= Square block detector (Proximity)			(Input)
 I:1/1	= Ball detector Proximity				(Input)
 I:1/2	= Rectangle block detector Proximity			(Input)
 MOV	= To move corresponding source value to counter preset	(Logical)
 CTU	= Up Counter to count the number of objects		(Counter)
-(RES)-	= To reset counter accumulator value			(Reset)

Ladder Diagram to vary counter preset valueplc-program-change-preset-value-counter-according-various-products-02

Program Description
  • RUNG001 is to run conveyor motor when the process starts.
  • RUNG002 is to Move and Vary preset value of counter whenever a particular type of object is detected.
  • When I:1/0 goes high, a square is detected, box has a capacity to pack 15 square blocks, hence #15 is moved to the preset value of counter with address C5:0.PRE. Similarly the same box has capacity to fill 20 balls or 10 rectangular blocks.
  • When C5:0 is done counting and C5:0.PRE = C5:0.ACC, C5:0/DN goes high momentarily which resets counter immediately for next counting operation.
  • C5:0/DN bit can be used to take further actions such as moving filled box and packing it.
Runtime Test Cases
Inputs	        Outputs             Physical elements
I:1/14 = 1	O:2/0 = O:2/1 = 1   Start conveyor motor
I:1/0 = 1	C5:0.PRE = 15	    Collect 15 square objects
I:1/1 = 1	C5:0.PRE = 20	    Collect 20 balls
I:1/2 = 1	C5:0.PRE = 10	    Collect 10 rectangular blocks

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.