Towards Industry 4.0 — #3 PLC Programming, A Mixer Use Case with Ladder Logic Diagram

Andi Sama
12 min readNov 1, 2022

--

The Digital Transformation Journey to Industry 4.0 starts by understanding Industry 3.0

Andi Sama CIO, Sinergi Wahana Gemilang with Cahyati S. Sangaji

In Summary

- Implementation of one of PLC's programming languages: Ladder Logic Diagram. Applied in a use case for controlling the mixing of fluids in a mixer.
- This article's supporting files (open plc source files) are available on Github.

The Industry 4.0 initiative has been driving the need for OT & IT convergence for more than a decade to modernize Operational Technology (OT) by leveraging Information Technology (IT). Industry 4.0 promotes end-to-end digitization of manufacturing and other industrial processes by monitoring and acting on real-time data as they occur.

In the journey towards Industry 4.0, OT can leverage IT such as Cloud Computing, the Internet of Things (IoT), and Artificial Intelligence (AI). Blockchain technology will play an important role when moving to Industry 5.0 later.

Understanding existing technologies in Industry 3.0 (at the Operational Technologies level or OT) would be the foundation for transforming into Industry 4.0.

Industrial Automation

There are two types of industrial automation: discrete and analog. We can identify the difference in the finished products, whether they can be easily quantified or not.

Manufacturing cars, bottled water, and shoes are discrete automation as the finished product can easily be quantified. In contrast, generating household gas, manufacturing cakes or ice cream, and producing oil are analog automation examples, as the finished products are not easily quantified.

Operational Technologies

In most Industry applications (including factories), OT infrastructure has been designed for 24x7 operation and generates a lot of data. The design is for the components to be operational for a long lifespan, like 20, 40, or 50 years.

It is not uncommon for factory operations, for example, to run continuously for weeks, months, or even years. Similarly, it reminds us of the 24x7 Information Technology (IT) operation in Banks or Telecommunication Providers.

OT includes software and hardware devices (controllers, sensors, and actuators). Some hardware devices are configurable. OT includes software such as Enterprise Resource Planning (ERP), primarily for accounting purposes. Advanced OT has additional software like Manufacturing Execution System (MES) and Customer Relationship Management (CRM).

Please see more discussion on Operational Technology in (Andi Sama, Cahyati S. Sangaji) “Towards Industry 4.0 — #1 IT/OT Convergence, A Digital Transformation Journey.”

For this article, let’s focus on the Programmable Logic Controller (PLC) and the implementation of the mixer use case.

PLC

A production line in a factory consists of several different machines. One PLC controls multiple field devices of one or several machines. It may also control and monitor machines across several production lines. From PLC to field devices, there are complex and various interfaces. Another challenge is properly integrating different PLC brands to acquire aggregated production data.

PLC as the Modern Logic Controller replacing the Relay Systems

In the early days of Industry 3.0 in the 1970s, PLC with solid-state relay systems started to replace mechanical relays. Mechanical relays were the foundation of automation technology in Industry 2.0.

Other supporting automation components in Industry 2.0 were mechanical counters and mechanical timers. They became programmable since the introduction of PLC. These technological advancements have significantly increased the reliability and maintainability of modern Industry 3.0-based automation systems for the last five decades (50 years).

The mechanical relay could easily handle a high current, such as over 2A (two Ampere); however, the mechanical contact within the relay has a slow response time (about 10ms), and the physical-mechanical connection tends to wear faster.

Although the solid state relay system in PLC has many advantages (i.e., physically compact and fast switching time), it has its limitations.

In PLC, there is a digital output and analog output, for example, that are designed with different solid-state components. The digital output typically consists of a Transistor for DC load only. In contrast, the analog output consists of a Triac for low-powered AC load, such as for a motor starter with a current load not exceeding 1A.

A Siemens PLC with a photoelectric sensor as the input switch (+24VDC) controls a relay as the output (+24VDC) to start or stop a high-voltage 3-phase AC motor (Realpars, 2022). For example, the photoelectric sensor can sense an object on the moving conveyor belt. PLC will then start or stop the motor by sending a signal (e.g., raising the voltage to +24VDC) to the motor starter, triggered by the object's presence (Realpars, 2022).

PLC to Field Devices (Sensors & Actuators) Integration

Physical interfaces from PLC to field devices can range from a slow RS-232 cable or RS-485 twisted two-pairs cable to high-speed Ethernet.

In Industrial networks, there are two types of communication protocols: master-slave and producer-consumer.

  • Actuator Sensor Interface (AS-I), Modbus, and Process Field Bus (Profibus) are master-slave protocols commonly used for factory automation.
  • For producer-consumer, a commonly used protocol is Profinet.

A different protocol known as Highway Addressable Remote Transducer (HART) is for HART-enabled smart devices. Another one is the multi-master Controller Area Network (CAN) that we can easily find in the automotive industry, including the implementation of networking to monitor and control various sensors in a car through multiple Engine Control Units (ECU).

Communication speed can range from as low as 1.2kbps (HART) or 9.6kbps (Modbus with RS-485) to 1Mbps (CAN),12Mbps (Profibus with RS-485), and 1Gbps (Profinet with Ethernet).

Additionally, signaling can be digital or analog with different voltage (commonly used: 24V) and current (commonly used: 4–20mA) specifications.

A PLC acts as a gateway to the field devices. PLC creates physical communication and controls these variations of physical interface and communication protocols to enable data exchange.

PLC Programming Languages

In PLC, there are variations of programming languages to do automation. The five common programming languages are Ladder Logic Diagram (LAD), Function Block Diagram (FBD), Sequential Function Chart (SFC), Instruction List (IL), and Structured Text (ST).

This article implements a use case for mixer control with the most popular programming language, the ladder logic diagram.

Why is LAD the most popular programming language? LAD naturally follows the technological advancements of the physical-mechanical relay logic to a digital relay logic in PLC. When things break, LAD is also the easiest to debug during troubleshooting.

A Quick Refresh on Technical Background

Programming with a ladder logic diagram is programming graphically by having certain technical knowledge of electronics such as power, ground, switches, latch, flip-flops, and motors.

PLC has I/O (Input/Output) that can be digital or analog. Enterprise-level PLC can have a lot of I/IO locally (hundreds or thousands of I/O) or remotely (remote I/O). When a PLC gets an analog reading from the outside world, such as from a sensor, it has to be converted to digital values according to a certain mapping (e.g., the analog to digital value mappings from the sensor documentation).

Digital input can be as simple as a start or stop push button or other things like a photo-electric sensor mentioned above. The digital output can be like an on-off relay to trigger a high-powered 3-phase motor starter through a motor driver or a simple lamp.

Analog input can be temperature or humidity readings, for example. It can also be an electrical current, commonly implemented for better signal stability over the long range.

Digital I/O comes in discrete values of either 0 or 24VDC electrical voltage. Analog I/O has continuous values of, e.g., from -20V to +20V or 4 to 20mA.

Examples of analog inputs and outputs in Siemens PLC. Inputs are on the left of the PLC, outputs are on the right of the PLC (Realpars, 2022).

Implementing a Use Case in PLC

A Mixer Use Case

Let’s look at a Mixer mixing fluids in a tank. The fluids come from two different sources in a tank. The mixed fluids are then routed to another process through a controlled valve.

A Mixer mixes fluids in a tank. The fluids come from two different sources in a tank. The mixed fluids are then channeled to another process.
A PLC with a set of inputs and a set of outputs controls the mixing process.

The two different fluids come to a tank controlled through two pumps: PUMP_1 and PUMP_2. If pumps are active, fluids fill the tank. There are two level sensors within the tank for detecting whether the tank is low on fluid (L_LEVEL sensor) or full (H_LEVEL sensor). Once the tank is full, the MIXER will start for a predefined time to mix the two fluids automatically. Following the completion of the mixer, the drain VALVE opens to drain the mixed fluids to be processed further. Then the cycle can repeat.

Note that the opening of VALVE can be combined with the readiness of the next process to receive the mixed fluids.

An example of a conductive level switch sensor (type MLR430–3) for detecting liquids. Provided by GHM Messtechnik GmbH. This level sensor has an operating temperature from -20C to 140C. Output is programmable and can be set to either NO or NC (Normally Open or Normally Closed).

Programming the PLC using Ladder Logic Diagram

Download Open PLC Editor for Windows here.

We use Open PLC Editor software on Microsoft Windows (Open Source PLC Software, 2022). Open PLC is an open-source PLC application that complies with IEC 61131–3, in which we can design Ladder Logic, Structured Text, Instruction List, Function Block Diagram, or Sequential Function Chart.

a. First Ladder Logic Diagram

Let’s start with our first section of the ladder diagram that turns ON PUMP_1 and PUMP-2 when the L_LEVEL sensor is activated (ON).

We implement this using the SR flip-flop function block with two input pins (S and R) and one output pin (Q). SR flip-flow is the Set-Reset flip flop where R dominates (meaning if both are 1, R will be in effect, meaning the output will be reset). In contrast with the RS flip-flop, S dominates (meaning if both are 1, S will be in effect, meaning the output will be set).

S, R, and Q pins are Boolean, meaning it has only two possibilities, 0 or 1.

When the START push button is ON, our program starts.

Power rails (the black thick line on the left, with +24VDC voltage) energize the rungs. The black thick line on the right is the ground. A rung is a line in which we design our logic graphically in the ladder logic diagram. The rungs (lines) that are energized turn from BLACK to GREEN.

Typical PLC has three steps during its execution:

  • Scan the input image table (input memory) to get all the states of inputs.
  • Execute our program. In this article, this is our ladder diagram.
  • Write the output into the output image table (output memory).

PLC executes our ladder diagram from left to right, then from top to bottom.

Note that this is a live simulation within the Open PLC application where our program runs as if it is in the real PLC hardware.

For the program to run on the real PLC, the specific I/O addresses need to be specified. E.g., I0.0, I0.1, I0.2, and I0.3 for the START push button, STOP push button, L_LEVEL sensor, and H_LEVEL sensor for the inputs. Also, Q0.0, Q0.1, Q0.2 for the PUMP_1, PUMP_2, and MIXER_MOTOR for the outputs. The actual assignment of I/O addresses may differ among different PLCs.

L_LEVEL sensor triggers the S-pin on the SR0 flip-flop to ON (changing the value from 0 to 1). As a result, Q output is ON, activating both PUMP_1 and PUMP_2. PUMP_1 and PUMP_2 are running now.

Note that the R-pin is controlled by both the H_LEVEL sensor and the STOP push button. R-pin will be set to ON if H_LEVEL rises from 0 to 1 or the STOP push button is 1. When R-pin is ON, the Q output will be reset to 0, meaning both PUMP_1 and PUMP_2 will be OFF.

b. Second Ladder Logic Diagram

The second section of the ladder diagram monitors the H_LEVEL sensor, then starts the MIXER_MOTOR for a predefined preset time to mix the fluids. One more time, we use SR flip-flop for this.

Likewise, power rails energize the rungs when the START push button is ON.

When the H_LEVEL sensor is triggered (rises from 0 to 1, indicating the tank is full of fluids), it triggers TP0 (a timer with a preset time of 8 seconds), which then activates the S-pin in SR1 to ON, causing MIXER_MOTOR to be active (ON).

After 8 seconds, the Q output on TP0 (timer) changed from 1 to 0, causing S-pin on SR1 to be 0, deactivating the Q output on SR1 (changes from 1 to 0). This turn the MIXER_MOTOR OFF. The VALVE is automatically ON as it is activated by the third ladder diagram when detecting MIXER_MOTOR in the OFF state (see discussion on the third section of the ladder diagram below).

c. Third Ladder Logic Diagram

Likewise, power rails energize the rungs when the START push button is ON.

Nothing happens when L_LEVEL is ON.

When H_LEVEL is ON and MIXER_MOTOR is OFF, S-pin on RS0 changes from 0 to 1, causing Q output on RS0 to be active (ON), activating the VALVE (VALVE is in an OPEN state).

Note that we use RS flip-flop instead of SR flip-flop. In RS flip-flop, Set dominates.

When L_LEVEL is OFF (changes from 1 to 0, indicating the tank is empty), the R-pin is activated (changes from 0 to 1) as L_LEVEL connected to the R-pin is a negated L_LEVEL (meaning activated by 0 instead of 1), causing Q output on RS0 to be deactivated. VALVE is in a CLOSED state.

When the VALVE is in a CLOSED state, the state of both PUMP_1 and PUMP_2 is also OFF. MIXER_MOTOR is also OFF.

At this point, the program has completed its full cycle. It may start from the beginning, either manually triggered by activating L_LEVEL with a parallel push button in the first rung (or automated, if required).

A Completed Ladder Logic Diagram

The following shows a complete implementation of the ladder logic diagram for executing the mixer use case (the layout is slightly modified for compact printing).

A Mixer Use-Case: A completed ladder logic diagram to design the desired program to be executed in PLC.

Looking Forward

The (R)evolution, the transformation from Industry 3.0 to Industry 4.0, is happening now. IT and OT teams need to work together, internally or externally.

As in many technological revolutions, people often become the main bottleneck for change as the new technology may affect their jobs and comfort zone. Top Management will play a key role in managing the transformation.

Understanding the driving technologies in Industry 3.0 is important for transforming into Industry 4.0. This article discussed the most popular programming language for PLC, i.e., Ladder Logic Diagram. Though, there are many areas of technological advancements in Industry 3.0. Some of them are field devices (sensors & actuators), other programming languages for PLC, and robotics, including key applications like Manufacturing Execution Systems (MES) and Enterprise Resource Planning (ERP).

The transition to Industry 4.0 may not be straightforward at once as in one multi-years turn-key project. The iteration approach could be the best to follow. Transforming one area of focus at a time, moving on to the next iteration as business values emerge as previous iteration(s) starts to produce tangible benefits.

References

--

--

No responses yet