Reader small image

You're reading from  Industrial Automation from Scratch

Product typeBook
Published inJun 2023
PublisherPackt
ISBN-139781800569386
Edition1st Edition
Right arrow
Author (1)
Olushola Akande
Olushola Akande
author image
Olushola Akande

Olushola Akande is an industrial automation and robotics expert with over 10 years of experience in the design and development of automation and robotics-related projects. He is an industrial automation trainer and consultant with a passion for driving industries to achieve greater results by doing work more accurately with less effort of human control. He is the chief executive officer (CEO) of Showlight Technologies Limited, an industrial automation, robotics, artificial intelligence (AI), and machine learning (ML) training and servicing company in Lagos, Nigeria. He is a member of the Schneider Electric team involved in the installation of Integrated Control and Safety Systems (ICSSs), which includes high-integrity PLCs, supervisory control and data acquisition (SCADA) systems, and distributed control systems (DCSs) at the largest oil refinery in Africa (Dangote Oil Refinery) at Lekki Free Zone, Lagos, Nigeria.
Read more about Olushola Akande

Right arrow

Deep Dive into PLC Programming with TIA Portal

In the previous chapter, we learned the fundamentals of PLC programming, which include PLC programming languages, PLC programming devices, PLC programming software, Ladder Diagram basics, elements of Ladder Diagrams (ladder logic programs), rules for Ladder Diagram programming, downloading and installing TIA Portal V13 Professional and PLCSIM, and how to create a project and write some programs with the programming software (TIA Portal).

In this chapter, you will dive deeper by practicing how to use the programming software you downloaded and installed in the previous chapter. This chapter also includes a simulation of programs, which will enable you to see the result of the programs you have written right there on your PC or laptop even when you don’t have the real PLC to test or practice.

We are going to cover the following main topics in this chapter:

  • Opening a saved program
  • Simulating programs with Siemens...

Technical requirements

While every part of this book is valuable, Chapter 2, Switches and Sensors – Working Principles, Applications, and Wiring, Chapter 3, Actuators and Their Applications in Industrial Automation, and Chapter 7, Understanding PLC Hardware and Wiring, as well as Chapter 8, Understanding PLC Software and Programming with TIA Portal, are very important to have a better understanding of this chapter.

This chapter is actually a continuation of the previous chapter. Hence, you must have familiarized yourself with the necessary terms and the programming software (TIA Portal) and also practiced the programs explained using the necessary instructions before reading this chapter.

Opening a saved program

We will continue learning the programming of PLC here by opening the project/program we saved in the previous chapter:

  1. Start the TIA Portal application.
  2. Click on Open existing project, select the project, and then click Open:
Figure 9.1 – Opening a saved program – recently used project

Figure 9.1 – Opening a saved program – recently used project

  1. Upon clicking Open, you should see the following screen. Click on Open the project view:
Figure 9.2 – Opening a saved program – Open the project view

Figure 9.2 – Opening a saved program – Open the project view

  1. Double-click the PLC folder (PLC_1) on the left-hand side, and then double-click Program blocks:
Figure 9.3 – Opening a saved program – PLC_1 [CPU 1211C AC/DC/Rly]

Figure 9.3 – Opening a saved program – PLC_1 [CPU 1211C AC/DC/Rly]

  1. Double-click Main [OB1]:
Figure 9.4 – Opening a saved program – Main [OB1]

Figure 9.4 – Opening a saved program – Main [OB1]

The program will be opened showing the ladder diagram, as shown in the following...

Simulating programs with Siemens TIA Portal using PLCSIM

We will now learn how to simulate a program using Siemens TIA Portal. We will use the program written in the previous chapter as an example:

  1. Open the project/program using the steps in the previous section. You should have what looks like the following screenshot. Click on the Compile icon and ensure there is no error in your program.
Figure 9.6 – Opened project showing the Compile button (red arrow)

Figure 9.6 – Opened project showing the Compile button (red arrow)

  1. Click on the Start simulation icon, as indicated in the following screenshot:
Figure 9.7 – Compiled program showing no error, that is 0 errors

Figure 9.7 – Compiled program showing no error, that is 0 errors

  1. A warning message shown as follows will appear. Click OK:
Figure 9.8 – Simulation – Warning message

Figure 9.8 – Simulation – Warning message

You should have what looks similar to the following screenshot:

Figure 9.9 – Simulation – Extended download to device dialog box

Figure 9.9 – Simulation – Extended download...

Latching and unlatching in PLC programming

Latching is a technique used to keep an output energized or activated even when the input ceases. Latching makes a momentary push-button act as a maintained switch; in other words, after the push button is pressed, the output is turned on to remain energized (ON) even when the button is released.

Unlatching is simply a method or technique used to de-energize a latched output.

A latch and unlatch program using normally open push buttons for both starting and stopping

Write the simple program in network 3 to see how latching and unlatching works with a normally open push button for starting and a normally open push button for stopping:

Figure 9.27 – A latch and unlatch program using normally open push buttons for both starting and stopping

Figure 9.27 – A latch and unlatch program using normally open push buttons for both starting and stopping

The PLC wiring for the program is as follows:

Figure 9.28 – Wiring to implement a latch and unlatch program using normally open push buttons for both starting and stopping

Figure 9.28 – Wiring to implement a latch and unlatch program using normally open...

Using an output address as an input in a program

In the previous chapter, we learned that an output address can be used as an input address (NC or NO contact) in the rules for ladder diagram programming.

The following example shows an output address (Q0.2) being used for an input. You can write the program in network 4 and simulate the program to see how it works.

Figure 9.31 – Output address (Q0.2) used for a normally open (NO) contact at the input

Figure 9.31 – Output address (Q0.2) used for a normally open (NO) contact at the input

The wiring diagram for the program is as follows:

Figure 9.32 – Wiring diagram to implement a program using an output address for input

Figure 9.32 – Wiring diagram to implement a program using an output address for input

Let’s say a pilot lamp (PL3) is connected to Q0.3, as shown in the preceding diagram.

Anytime Q0.2 is ON, the normally open contact with the address Q0.2 will be closed since the coil with the address Q0.2 is energized and PL3 connected to Q0.3 will be ON.

If we edit the program by replacing the normally open contact...

Using the SET and RESET instructions

The SET and RESET instructions are two important instructions used in ladder diagram programming. They are both output (coil/assignment) instructions.

The SET coil is energized when power is supplied to it via an input (switch, sensor, or push button) and it remains SET (ON) even when the switch, sensor, or push button that supplied power to it is OFF until it is reset.

The RESET coil is de-energized (OFF) when power is supplied to it via an input (switch, sensor, or push button) and it remains OFF even when the switch, sensor, or push button that supplied power to it is OFF until it is SET.

The sample program in the following screenshot shows the SET and RESET instructions in use:

Figure 9.34 – SET and RESET program

Figure 9.34 – SET and RESET program

Note

The set/reset instruction can be added to your rung using the following steps:

On the right-hand side of the programming environment, click Instructions | Bit Logic operation...

Using the timer instruction

The timer instruction is a delay instruction. It can be used to delay an operation. Several timers exist; the common ones are the ON-delay timer (TON) and the OFF-delay timer (TOF).

An ON-delay timer (TON) activates an output when the input is ON for a specified amount of time.

Let’s write a simple program to demonstrate the ON-delay timer using the following steps:

  1. On a new network, add a normally open instruction and specify an address, for example, I0.0.
  2. On the right-hand side of the programming environment, click Instructions | Timer operation, drag the TON (ON-delay timer) instruction to the rung/network, and type a name, for example, timer1, as shown in the following screenshot. Click OK:
Figure 9.36 – How to use the timer instruction – Call options dialog box

Figure 9.36 – How to use the timer instruction – Call options dialog box

  1. Double-click the question marks (???) at PT (programmed time) and type the time you want, Q (output), to become energized...

Using the counter instruction

This is an instruction that can either count up or down when its input is triggered, and an output is activated when the set value is reached. It can be used to determine the number of times an event has happened in a process. In this section, we will be looking at the common counter instructions, including counting up and counting down.

Count up (CTU)

The count up instruction will count up or increase by 1 each time its input is triggered (0 to 1); for example, when a button is pressed and released or when a sensor is activated. The counter’s output will be energized when the number of times the input is triggered (current value of the counter) is equal to, or greater than, the pre-set value (PV).

In this example, a pilot lamp (PL1) is connected to Q0.0. A PNP proximity sensor (NO) is connected to I0.0 and a normally open push button is connected to I0.1, as shown in the following wiring diagram:

Figure 9.41 – PLC wiring for using the counter instruction with a proximity sensor

Figure 9.41...

Using the move instruction

The move instruction moves a value from a source to a destination. There are various move operations in TIA Portal. In this book, we will learn how to use MOVE (the move value), which is the common move instruction.

Perform the following steps to write a simple program to move the value 20 to a register, MW0, when a push button connected to I0.0 is pressed:

  1. On a new network, add a normally open instruction and specify an address, I0.0.
  2. On the right-hand side of the programming environment, click Instructions | Move operation, and drag the MOVE (move value) instruction to the rung/network.
  3. Double-click ??? for IN and specify a value, for example, 20.
  4. Double-click ??? for OUT1 and specify the destination address, for example, MW0, as shown in the following screenshot:
Figure 9.46 – Using the move instruction

Figure 9.46 – Using the move instruction

When the push button connected to I0.0 is pressed, the normally open contact I0.0 in the...

Using the compare instructions

The compare instructions are used to test the relationship between two values from two sources.

The following table shows the compare instructions available in S7 1200:

Compare Instruction

Meaning

CMP ==

Equals

CMP <>

Not equal

CMP >=

Greater than or equal to

CMP <=

Lesser than or equal to

CMP <

Less than

CMP >

Greater than

Table 9.1 – The compare instructions and their meaning

We will learn how to use CMP > in this book. The same concept applies to other compare instructions.

Perform the following...

Level control using PLC

The following diagram shows a level control that can be used in the industry:

Figure 9.49 – Level control

Figure 9.49 – Level control

The tank has two level sensors (a high-level sensor and a low-level sensor). The low-level sensor is connected to I0.2, while the high-level sensor is connected to I0.3. A pump connected to Q0.0 via a contactor supplies liquid to the tank. The start push button (normally open) is connected to I0.0, while the stop push button (normally closed) is connected to I0.1. The pump ON indicator is connected to Q0.1. A manual discharge valve is used to discharge the liquid when required.

When the start push button is pressed and released and there is no liquid in the tank, in other words, the low-level sensor cannot detect liquid, the pump should start running until the liquid fills the tank, in other words, the high-level sensor detects liquid.

When the manual discharge valve is opened and the liquid falls below the high...

Automated filling, capping, and wrapping system using PLC

The following diagram shows another industrial application of PLC:

Figure 9.51 – Filling, capping, and wrapping

Figure 9.51 – Filling, capping, and wrapping

The start push button (normally open) is connected to I0.0, while the stop push button (normally closed) is connected to I0.1. A conveyor motor is connected to Q0.0, a fill valve is connected to Q0.1, a capping machine is connected to Q0.2, and a wrapping machine is connected to Q0.3. A fill position sensor is connected to I0.2 and a cap position sensor is connected to I0.3, while a job out sensor is connected to I0.4, as indicated in the preceding diagram.

When the start push button is pressed and released, the conveyor motor should start running until the bottle gets to the fill position sensor; in other words, the fill position sensor detects the bottle and the conveyor motor stops.

The fill valve should open as soon as the conveyor motor stops at the fill sensor for 10...

Summary

Congratulations! You have successfully completed another chapter of this book. Good job! PLC is the brain behind most modern automated machines and programming is key when automating a machine with PLC. You should now understand latching and unlatching, know how to use an output address as input, and be familiar with timer, counter, move, and compare instructions. You should also be able to write programs using the techniques and instructions explained in the chapter. Simulation, which is key, was also discussed. You should be able to simulate your program after writing to know whether it will work. The final two sections of this chapter were the most interesting, where we looked into some real-life applications of some of the techniques learned in the chapter (that is, level control using PLC and an automated filling, capping, and wrapping system using PLC). Try to get your hands dirty with them.

In the next chapter, we will learn about the Human Machine Interface (HMI...

Questions

The following are questions to test your understanding of this chapter. Ensure you have read and understood the topics in this chapter before attempting the questions:

  1. ________________ is a technique used to keep an output energized or activated even when the input ceases.
  2. A ______________ instruction can be used to delay an operation.
  3. A __________ instruction can be used to determine the number of times an event has happened in a process.
  4. ________________ instructions are used to test the relationship between two values from two sources.
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Industrial Automation from Scratch
Published in: Jun 2023Publisher: PacktISBN-13: 9781800569386
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Olushola Akande

Olushola Akande is an industrial automation and robotics expert with over 10 years of experience in the design and development of automation and robotics-related projects. He is an industrial automation trainer and consultant with a passion for driving industries to achieve greater results by doing work more accurately with less effort of human control. He is the chief executive officer (CEO) of Showlight Technologies Limited, an industrial automation, robotics, artificial intelligence (AI), and machine learning (ML) training and servicing company in Lagos, Nigeria. He is a member of the Schneider Electric team involved in the installation of Integrated Control and Safety Systems (ICSSs), which includes high-integrity PLCs, supervisory control and data acquisition (SCADA) systems, and distributed control systems (DCSs) at the largest oil refinery in Africa (Dangote Oil Refinery) at Lekki Free Zone, Lagos, Nigeria.
Read more about Olushola Akande