# PLC Ladder Logic Programming Examples with detailed explanation

## PLC Ladder Logic Programming Examples, Description:

If you are new to the PLC programming, then I highly recommend first read my previous two articles in which I have explained the very basics like for example

• Best PLC for beginners
• How to write your first PLC program
• How to run a PLC simulation
• Basic PLC gates etc

Without any further delay let’s get started!!!

Fatek PLC, FBs-14MAR2-AC (FBs-14MA):

Fatek PLC programming Cable:

IR adjustable infrared Proximity Sensor 2v to 24V:

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

DISCLAIMER:

Following are the PLC ladder logic programming examples. I will start with the very simple projects and I will try to keep things simple. After, I am sure I have explained enough things then I will start explaining some complex level projects.

## PLC based Load Management System:

This is the simplest beginner’s level project that I can think of. This project is very famous among the B-Tech students and in some engineering colleges this project if offered as the Final Year Engineering Project. In this project the electrical loads are controlled using the buttons.

## Circuit Diagram:

4 SPDT “Single Pole Double Throw” type relays are connected with the PLC output contacts Y0 to Y3. Different type of loads can be connected with these relays. As these relays need 12 volts, so, that’s why C0 and C1 are connected with the 12 volts. For 12 volts you can use a 12v adaptor or you can make your own power supply using LM7812 voltage regulator.

Four switches S1 to S4 are connected with the Fatek PLC inputs X0 to X3. So, currently, we can only control 4 loads using these 4 switches. The total numbers of inputs which are available are 8 and the total numbers of outputs which can be controlled using the Fatek FBS-14 are 6. FBS-14 means that this PLC has 8 inputs and 6 outputs. In Fatek PLC the inputs are represented by

X0,X1,X2,… Xn while the outputs are represented by Y0,Y1,Y2,…Yn.

Look at the ladder logic diagram, how simple it is. X0, X1, X2, and X3 are the open type Input contacts while Y0, Y1, Y2, and Y3 are the output contacts. Now, using this program any load can be turned ON and turned OFF. If you write the same program in Arduino, it will be a long program using multiple IF conditions and flags. But, in PLC it only consists of 4 lines. The PLC programming is extremely simple, if you know exactly how to use the different contacts, this all depends on your logic.

## PLC based Two Way Switch for a Staircase:

This is also one of the most frequency used projects in building management systems. In this project one light is controlled using two switches. One switch is installed at the lower side of the Staircase while the other switch is installed at the upper side of the Staircase. With the help of this project you can also save electricity and reduce your electric bill. This project can also be made fully automatic if you replace the switch with the ultrasonic sensor or PIR sensors or Laser etc. There are different types of the sensors available in the market. So first let’s start with the circuit diagram.

### Circuit Diagram of the PLC based Staircase Light Control System:

If you look closely, this circuit diagram is almost the same as the previous one. But this time I am using only two switches S1 and S2 and one Load which is going to be the 110/220Vac Light Bulb. The connections remain the same but this time the program will be a bit different. Let’s have a look at the ladder logic programming of the Staircase light control system.

### Ladder Logic Diagram of the Staircase Light Control System:

As you can see, this is just a one line program. But looks at bit confusing, am I right? For beginners this program can be a bit complex but trust me this is very simple. If you have checked my previous tutorial on the logic gates you will come to know that, this is basically an Exclusive OR gate. The two switches are used in parallel. You can see clearly I am using the same input contacts in normally open and normally closed configuration. The contacts with no lines are normally open type and the contacts with the line “with red color” are the normally closed type contacts.

When no switch is pressed the light remains OFF.

The time when you press the Switch connected with X0 input of the PLC the light is turned ON, which you can see in the picture below.

You can see clearly, the path is completed and that’s why the light is turned ON. Now let’s say you have climbed the stairs and now you press the Swtich2. This will turn OFF the light, as you can see in the picture below.

As you can see both the switches are pressed, which makes the other two switches open. But contacts with lines are active only if no switches are pressed, they look for 0. So, now if you press any of the switches the light will turn ON.

## PLC based Objects Counting System:

This project is very famous in industries. The PLC Ladder Logic programming example that I am about to share is used for the production monitoring. This project can be used in all those areas where you need to count the items. It can be used on conveyor belts for counting bottles, boxes, etc. As this project is based on the counting, so in this project the counter will be used. If you pay a full attention to what I am doing, I am sure you will master the counter, and in future you will be able to use counters in very complex projects.

In this project we are going to use one infrared sensor for counting boxes or anything you like. When the box is filled the buzzer will turn ON. The operator then press the button and re-set the counter.

### PLC based Objects Counting System Circuit Diagram:

As you can see the circuit diagram is very simple. An IR infrared sensor is connected with the X0 and a Pushbutton is connected with the input X1. A relay is connected with the output Y0 which will be used to control the Buzzer. You can use NPN type infrared sensor.

### PLC based Objects Counting System Ladder Logic Diagram:

As you can see the program is very simple. As you can see currently I have counted two objects and the pre-set “PV” value is 5. This means the box can have maximum 5 items in it. This pre-set value can be changed as per the requirement. Each time an item or object crosses the IR Sensor the value in C0 is incremented by 1. As you can see the counter has two inputs

PLS and

CLR

The PLS takes an input signal from a Sensor or button while, the CLR when given an input resets the counter or in simple words clears the counter. So when the counter reaches the pre-set value which in my case is 5. The C0 will get high which will activate the timer and turns on the buzzer for 10 seconds. This alerts the operator that the box is full. The operator comes and press the Pushbutton connected with X1. This resets the counter, this way the counting again starts from zero.

## PLC based Conveyor Belt / Grinder Protection System:

This one is very important. This is for the workers protection and I believe this piece of code should be used in all those projects in which moving parts are used, like for example conveyor belts, Grinder, chains, belts etc.

In this project when a conveyor belt or Grinder is turned ON, first of all a buzzer is activated for at least 5 seconds which alerts the workers to move away from the grinder or conveyor belt. After 5 seconds the buzzer is turned OFF and the conveyor belt or Grinder is started. It sounds great. Let’s do it.

### PLC based Conveyor Belt / Grinder Protection System Circuit Diagram:

The circuit diagram is very simple. As you can see there is only one switch connected on the input side and two relays are connected on the output side. One relay is used to control the buzzer while another relay is used to control the load which can be a motor, conveyor or grinder, etc.

### PLC based Conveyor Belt / Grinder Protection System Ladder Logic Diagram:

As you can see when the input switch X0 is ON the timer is activated and the buzzer connected with the output Y0 is turned ON while the Load connected with Y2 remains OFF.

When the preset time of 5 seconds is completed the buzzer turns OFF and the load connected with Y2 is turned ON. This load will remain ON until we turn OFF the switch connected with X0.

## PLC based Traffic Light Control System:

No matter we are learning Arduino or 8051 family microcontrollers, as a beginner we always wish to make traffic control system. In this small project I am going to write a very simple traffic light control system. I will turn ON each light for 5 seconds and then it repeats for ever unless you turn OFF the switch. Let’s start with the Circuit diagram.

### PLC based Traffic Light Control System Circuit Diagram:

Three lights RED, YELLOW, and GREEN are connected with outputs Y0, Y1, and Y2. One switch is connected with X0 to activate and deactivate the traffic control system. Now let’s have a look at the ladder logic diagram of the PLC based traffic control system.

### PLC based Traffic Light Control System Ladder Logic Diagram:

While the switch X0 is turned ON all the lights RED, YELLOW, and GREEN are turned on one by one. This cycle is repeated infinite times until and unless the switch is turned OFF.

So with this I am done with the PLC ladder logic programming examples article. Due to the size of the article

There are so many other projects which I will share in my upcoming articles. For more articles like this you can subscribe to my website, you can also follow me on Facebook and YouTube channel.