Towards Industry 4.0 — #6 Field Devices, Processing Analog Inputs with Siemens S7–1200

Andi Sama
14 min readApr 8, 2023

--

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 "Processing Analog Input" in Industrial Automation using Programmable Logic Controller (PLC).
- Two types of analog inputs: 0-10VDC, 0/4-20mA.
- PLC Hardware: Siemens compact PLC S7-1200 DC/DC/DC.
- Software tools: Siemens TIA Portal on Windows.
- Programming Language: Ladder Logic Diagram.
- PLC supporting files (Siemens S7-200) are available on Github:
* 0-10VDC, https://github.com/andisama/PLC-Analog-Input-Processing--0-10VDC
* 0/4-20mA, https://github.com/andisama/PLC-Analog-Input-Processing--0-4-20mA

In our first series of "Towards Industry 4.0" (late 2022–early 2023), we discussed various things covering some of the technological developments on the journey towards Industry 4.0, the convergence of Information Technology (IT), and Operational Technology (OT).

In those five articles (six, including a summary) — listed in the reference section in this article, we discussed the industrial automation technology driven primarily by Programmable Logic Controllers (PLC) since the beginning of Industry 3.0, along with its surrounding technologies. Field devices such as various sensors and actuators like pneumatic, hydraulic, and motors are examples of that surrounding technologies.

A few working examples were also presented, such as the typical "Hello World" program in PLC, including the mixer, traffic light, and box sorting using conveyor use cases. It covered PLC programming with a ladder logic diagram and SFC (Sequential Function Chart), as well as visualizing PLC data by SCADA (Supervisory Control and Data Acquisition) using Open PLC Simulator software, ScadaBR software, Siemens PLC Simulator software, Siemens TIA Portal (Total Integrated Automation) software, and the actual hardware of Siemens PLC S7–1200.

In this article, we introduce how Siemens compact PLC S7-1200 processes analog input — specifically processing the 0–10 voltage and 0–20mA or 4–20mA (0/4–20mA) current, both in DC (direct current). In contrast with digital values, which can only have two possible logic values: '0' (0VDC) and '1' (24VDC), analog values are continuous such as 0.0–10.0VDC for voltage and 0.0–20.0mA for current.

A. PLC, Processing Analog Input — Hardware and Wiring Configuration

Field Devices, such as sensors and actuators, have a variety of ways to connect to PLC. This is a big challenge in the field since there are a lot of variations.

Sensors can measure pressure, temperature, and level, among many things. Measurement methods can be by pressure, electric, or mechanical and transmit the measured values to PLC. Pressure measurement can be pneumatic (air-based) or hydraulic (oil-based) — measured in PSI (pounds per square inch). Electrical measurement can be in voltage or current, or other (such as in Watt, the combination of voltage and current). Mechanical devices can be measured in weight, for example.

The measurement, an analog signal, is then transmitted to the PLC after being converted to a certain standard by the transmitter. Along with other modern ways of transmitting the measured values to PLC, 0–10VDC and 4–20mA are commonly implemented.

Modern transmitters can use Modbus protocol or a LAN-based approach, even with a wireless or remote controller (Remote Terminal Unit, RTU). Even the recent ones can transmit data using Modbus TCP over the TCP/IP (Transmission Control Protocol/Internet Protocol) network or publish/subscribe protocols such as MQTT (Message Queue Telemetry Transport) over TCP/IP network.

Although others may still exist, like the legacy 3–15PSI, -10–+10VDC, and 0–20mA. Physically, even the transmission using the legacy serial technologies (e.g., RS-485) with Modbus protocol may still be some number there on the field. RS-485 with two twisted-pair cables has its benefit, e.g., it can transmit over long distances (at 100kpbs over up to 1.2 kilometers) with low noise.

In previous articles (Andi Sama, Cahyati S. Sangaji, 2023a), the examples were presented only based on digital Input/Output (I/O), like a push button switch for a digital input and a lamp for a digital output. These digital I/Os are also known as discrete I/Os.

We will discuss processing analog inputs for 0–10VDC and 0/4–20mA in sequence. First, let's look at the Siemens PLC S7–1200 series.

A.1. Siemens Compact PLC S7–1200, DC/DC/DC

We use Siemens PLC "Siemens compact PLC CPU 1214C DC/DC/DC, 6ES7214–1AG40–0XB0" for this experiment. The PLC has 14 digital inputs (24CDC), ten digital outputs (24VDC), and two analog inputs supporting 0–10VDC only (not directly supporting 0/4–20mA).

Siemens compact PLC CPU 1214C DC/DC/DC, 6ES7214–1AG40–0XB0, with SITOP PSU Power Supply.

The term "compact" means that the CPU with its I/O is integrated into a compact housing.

The configuration of Siemens PLC: SIMATIC S7-1200 Compact PLC, DC/DC/DC

- CPU 1214C, compact CPU
- DC/DC/DC
- Onboard I/O: 14 DI 24 V DC; 10 DO 24 V DC; 2 AI 0-10 V DC
- Power supply: DC 20.4-28.8V DC
- Program/data memory 100 KB

The DC/DC/DC notation refers to external Power Supply/Digital Input /Digital Output. In this case, the external power supply is DC 24VDC, the digital input is at 24VDC, and the digital output is also at 24VDC. Other combinations are possible, such as DC/DC/Rly, AC/DC/DC, AC/DC/Rly, etc.

Siemens compact PLC, I/O — input area.
Siemens compact PLC, I/O — output area, including RJ-45 (LAN Profinet port).

We have two wiring configurations for processing analog signals.

  • Wiring for analog signals with 0–10VDC.
  • Wiring for analog signals with 0–20mA.

In this case, the analog signals come from a signal generator, not the sensor. The USB-powered signal generator can generate either 0–10VDC voltage or 0–20mA current.

A 0.0–10.0VDC Signal Generator, currently showing 7.60VDC wired to PLC analog input Ch0. Note that the output (yellow cable) comes from AVo (voltage output).

Wiring Configuration, Processing Analog Voltage, 0–10VDC

The following details the configuration (hardware, software, wiring) for the first experiment, "Processing Analog Input, 0–10VDC."

WIRING CONFIGURATION for this Experiment "Processing Analog Input, 0-10VDC"

Hardware
- Power Supply
* 1x External Siemens PSU (Input 220VAC 1 Phase, Output 24VDC).
- CPU
* 1x Siemens Compact PLC 1200 DC/DC/DC.
- Digital Input
* 1x Start Push Button(NO) %I0.1.
* 1x STOP Push Button (NC) %I0.0.
- Analog Input
* channel 0, %IW64.
- Signal Generator
* 1x Signal Generator to Analog Input Channel 0.
* only use signal ground (GND) and AVo (output, voltage).
* powered by an external USB cable.
* set the mode on Signal Generator to Voltage (press the mode button to switch between voltage & current).
- Digital Output
* 5x 24VDC Lamps %Q0.0 (Blue), %Q0.4 (Red), %Q0.5 (Yellow), %Q0.6 (Green), %Q0.7 (White).
- Cabling
* AWG 16 with ferrules.
- Cabling (color)
* 220VAC Live: brown, 220VC Neutral: blue.
* 24VDC+: red, 24VDC common: black.
* 24VDC Digital Input: white.
* 24VDC Digital Output: orange.
* 24VDC Common: black.
* Analog Input: yellow.
- PLC Firmware level (updated from base 4.5)
* 4.6.0.
Hardware Configuration change in PLC
- Utilize Realtime Clock (RTC).
* through TIA portal, devices & network -> system & clock memory -> enable the use of clock memory byte.
* download to PLC (hardware configuration).
Connectivity
- Laptop to PLC
* RJ45.
* straight cable wiring as Siemens 1200 PLC can autocross on the ethernet cable.
Application Software
- Siemens TIA Portal v17 on Windows 11.

The overall wiring configuration looks like the following.

The Siemens PLC S7–1200 wiring configuration with a signal generator (0.0–10.0VDC). The signal generator shows 4.70 voltage, giving 4.70VDC to the PLC analog input channel 0 (address: %IW64). This PLC can accept 0.0–10.0VDC signal through its analog input channel. PLC is active — running, in RUN mode. Note that this configuration does not use the DC power supply on the far left (blue) and the ethernet switch (black).

220V AC input power (1-phase with two wires: L1 and N) enters a double pole MCB (Miniature Circuit Breaker) before being distributed to the workloads. In this case, there are two workloads in the system:

  • Siemens PSU 100S with output: +24VDC/2A. The PSU then supplies the regulated power supply to the PLC (24VDC, GND).
  • A volt meter that measures the input power supply continuously. Referring to the illustration, it indicates 226VAC.

There are 5 x 24VDC lamps to indicate PLC digital outputs. The assignment is as follows.

  • PLC digital output port: %Q0.0, color: blue.
  • PLC digital output port: %Q0.4, color: red.
  • PLC digital output port: %Q0.5, color: yellow.
  • PLC digital output port: %Q0.6, color green.
  • PLC digital output port: %Q0.7, color: white.

Also, we use one analog input. The assignment is as follows.

  • PLC analog output port: %IW64, connected to a signal generator.

There are two Push Buttons: Start Push Button and Stop Push Button:

  • Start Push Button (NO) input port: %I0.1.
  • Stop Push Button (NC) input port: %I0.0.

Note that the Stop Push Button is NO (Normally Open) in the program but NC (Normally Closed) in the hardware wiring for safety purposes.

A.2. Wiring Configuration, Processing Analog Voltage, 0/4–20mA

The following is the configuration change for the second experiment, "Processing Analog Input, 0/4–20mA." (configuration change refers to the first experiment — "Processing Analog Input, 0–10VDC").

Since the type of Siemens PLC we use does not support 0/4–20mA in its analog input, we need to slightly modify the configuration when accepting a 0/ 4–20mA analog signal. Note that we can directly process 0–10VDC analog signal since the PLC's hardware supports it.

We use a practical approach, the 500 Ohm resistor (Siemens AG, 2013), installed parallel to the PLC's analog input channel 0. As we could not find the 0.1% tolerance resistor on the market when we experimented, we used two 250 Ohm, 2 Watt with 1% tolerance resistors (measured as 496 Ohm in total when in series configuration — not energized). It's better than having a 2% or 5% tolerance.

A 500 Ohm resistor is installed parallel to the PLC's analog input channel 0.

Note that a more proper approach is using a signal conditioner device to transform various signals.

WIRING CONFIGURATION CHANGE for this Experiment "Processing Analog Input, 0/4-20mA"

Hardware
- Analog Input
* wire 500 ohm resistor (low resistance, such as 0.1%) in paralel between analog input channel 0 and GND.
- Signal Generator
* set mode on Signal Generator to: Current(press the mode button to switch between voltage & current).
A 0–20.0mA Signal Generator currently shows 4.40mA wired to PLC analog input Ch0. Note that the label indicates that it can generate 0–22mA; however, it can only generate 0–20mA. Note that the output (yellow cable) comes from AIo (current output) instead of AVo (voltage output).

A 0–20.0mA Signal Generator currently shows 4.40mA wired to PLC analog input Ch0. Note that the label shows that it can generate 0–22mA; however, it can only generate 0–20mA.

B. PLC, Processing Analog Input — Programming: Getting Analog Input, Normalizing & Scaling, and Energizing Select Lamps

B.1. PLC Programming

  • Use: Ladder Logic Diagram (LLD) with Function Block (FB).

B.2. Programming logic

  • If the Start Push Button (NO) is pressed, the program runs, and the Start Push Button is latched.
  • The program runs. It continuously monitors the analog input, normalizes and scales the analog input appropriately, and energizes the programmed output ports based on the normalized and scaled values.
  • If the Stop Push Button (NC) is pressed, the Start Push Button is un-latched, and the program stops.
TIA Portal: Initialization, just run once.
TIA Portal: The main program (network 1) — is not in an active state. Not in run mode.
TIA Portal: The main program (network 2) — is not in an active state. Not in run mode (1 of 2).
TIA Portal: The main program (network 2) — is not in an active state. Not in run mode (cont., 2 of 2).
TIA Portal: The custom function block — is not in an active state. To convert analog values to normalized and scaled values.

We implement the program for the PLC in Siemens TIA Portal software using the most popular programming language, the ladder logic diagram, in combination with the function block to do the normalization and scaling for the analog value received from the PLC's analog input channel 0.

The ladder Logic Diagram follows the technological advancements by transforming the physical-mechanical relay, physical timer, and physical counter to digital solid-state relay logic, digital timer, and digital counter. When things break, LAD is also the easiest to debug during troubleshooting.

  • Use the NORM_X function to normalize this range to 0–100% (input: integer, output: real).
  • Use the SCALE_X function to scale the normalized numbers to 0–10VDC (input: real, output: real).
  • Energize the appropriate lamp accordingly.

* Red: if the analog signal is between 0.0–2.5VDC.
* Yellow: if the analog signal is between 2.5–5VDC.
* Green: if the analog signal is between 5–7.5VDC.
* White: if the analog signal is between 7.5–10.0VDC.

Before running our program, it needs to be compiled with no errors.

TIA Portal: A good compilation result. No error. No warning.
TIA Portal: Connected to the PLC through Profinet (RJ-45 cable).

B.3. Operation

When the source program has been compiled through Siemens TIA Portal, it can be downloaded to PLC and runs inside the PPLC hardware. The source program can consist of a ladder logic diagram and function block, among others.

  • When the Start Push Button is pressed, the program starts.
  • Using the signal generator, manually by using hand, rotate the button. The display on the signal generator will indicate a value between 0.0–10.0 VDC.
  • Observe the corresponding lamp output (colored).
  • When the Stop Push Button is pressed, the program stops.

When the 220 AC Power is applied, the program runs.

When power is applied — The voltage meter shows the incoming AC power voltage value.

When power is applied, the program runs. The networks within the program (rungs) are energized.

First, the initialization organization block (OB100) runs once. Then, quickly the main program, the main organization block (OB1), runs.

TIA Portal: The main program (network 1) — Active, and PLC is in RUN mode.
TIA Portal: The main program (network 2) — Active, and PLC is in RUN mode (1 of 2).
TIA Portal: The main program (network 2) — Active, and PLC is in RUN mode (1 of 2).
TIA Portal: The custom function block — Is active, and PLC is in RUN mode.

Then, when the GREEN Start Push Button is pressed, the program starts.

When Powered ON and Start Push Button is pressed. The voltage meter shows the incoming AC power voltage value.

The analog values from the analog input channel 0 are continuously assigned to the 16-bits (word) AI_Buffer in the Main_DB data block.

The blue lamp is energized (blinking) with a frequency of 2 Hertz.

TIA Portal: The main program (network 1) — Running.

The incoming 0–10VDC analog input from the signal generator is automatically converted by the ADC, Analog to Digital Converter (within the PLC), to an integer value, 0–27648 (Siemens AG, 2021).

TIA Portal: The custom function block — Running.

The analog values in the AI_Buffer variable are continuously monitored, activating select digital outputs (connected to lamps) according to the current value.

TIA Portal: The main program (network 2) — Running (1 of 2).
TIA Portal: The main program (network 2) — Running (1 of 2).

When the analog value from the signal generator is set to 6.9VDC, for example, the green lamp is energized as the value falls within the range of 5.0–7.5VDC.

The energized lamp is GREEN when the signal generator value is set to 6.9VDC.
TIA Portal: The main program (network 2) when the value from the signal generator is 6.9VDC.
TIA Portal: The custom function block when the value from the signal generator is 6.9VDC.

Likewise, if the signal generator value is set to 2.6VDC, the yellow lamp is energized as the value falls within 2.5–5.0VDC.

The energized lamp is YELLOW when the signal generator value is set to 2.6VDC.
TIA Portal: The main program (network 2) when the value from the signal generator is 2.6VDC.
TIA Portal: The custom function block when the value from the signal generator is 2.6VDC.

When the RED Stop Push Button is pressed, the program stops. It will start again when the GREEN Start Push Button is pressed.

B.4. Processing Analog Current, 0/4–20mA

The program structure is the same as before. The only difference is that we are now monitoring current instead of voltage.

  • When the Start Push Button is pressed, the program starts.
  • Using the signal generator, manually by using hand, rotate the button. The display on the signal generator will indicate a value between 0.0–20.0mA.
  • Observe the corresponding lamp output (colored).
  • When the Stop Push Button is pressed, the program stops.

When 220 AC power is applied, the program runs. The networks within the program (rungs) are energized.

First, the initialization organization block (OB100) runs once, the same as before. Then, quickly the main program, the main organization block (OB1), runs.

Note that the logic flow in the main organization block is the same. The only difference is as follows (note the four In_Range function blocks following the Norm_Scale function block):

  • To energize red_light, change the In_Range Min — Max values from 0.0–2.5VDC to 4.0–8.0mA.
  • To energize yellow_light, change the In_Range Min — Max values from 2.5–5.0VDC to 8.0–12.0mA.
  • To energize green_light, change the In_Range Min — Max values from 5.0–7.5VDC to 12.0–16.0mA.
  • To energize white_light, change the In_Range Min — Max values from 7.5–10.0VDC to 16.0–20.0mA.

There are no changes to the OB100 (initialization organization block) and NORM_SCALE function block.

TIA Portal: The main program (network 2) — Active, and PLC is in RUN mode (1 of 2).
TIA Portal: The main program (network 2) — Active, and PLC is in RUN mode (2 of 2).

When the GREEN Start Push Button is pressed, the program starts.

Initially, we set the signal generator to 4.1mA.

The output fluctuates between 3.7–3.9mA. It's more frequently stable around 3.7mA. Is it the impact from the installed 2 x 250 Ohm resistors? — The resistors in series, installed parallel on the analog input channel 0 have only 1% tolerance. Well, it could be.

TIA Portal: When the signal generator is set at 4.0mA, the output fluctuates between 3.7–3.9mA (1 of 2).
TIA Portal: When the signal generator is set at 4.0mA, the output fluctuates between 3.7–3.9mA (2 of 2).

We do another experiment. The signal generator is now set to 12.4mA. The output fluctuates between 11.5–12.2mA. It's more frequently stable around 11.9mA.

When the value is below 12.0, the yellow lamp is energized. However, the green lamp is energized when the value is above 12.0.

Most likely, this is the impact of high tolerance (1%) on the resistor installed parallel to analog input channel 0.

When the signal generator is set to 12.4mA, the output fluctuates between 11.5–12.2mA. Now the program is energizing the Yellow lamp as the normalized and scaled value is 11.7mA (1 of 2).
TIA Portal: When the signal generator is set to 12.4mA, the output fluctuates between 11.5–12.2mA. Now the program is energizing the Yellow lamp as the normalized and scaled value is 11.7mA (2 of 2).
When the signal generator is set to 12.4mA, the output fluctuates between 11.5–12.2mA. Now the program is energizing the Green lamp as the normalized and scaled value is 12.0mA (1 of 2).
TIA Portal: When the signal generator is set to 12.4mA, the output fluctuates between 11.5–12.2mA. Now the program is energizing the Green lamp as the normalized and scaled value is 12.0mA (2 of 2).

When the RED Stop Push Button is pressed, the program stops. It will start again when the GREEN Start Push Button is pressed.

Summary and Moving Forward

In this article, we demonstrate and experiment with analog signal processing using Siemens compact PLC S7–1200. Analog signal is processed differently as it is a continuous value. A different perspective from just processing a discrete signal, the digital I/O with only two possible states: '0' and '1'.

We process the analog signals in two ways: voltage signal (0–10VDC) and current signal (4–20mA). The analog signal does not come from an actual sensor; it is simulated. The analog signal comes from a signal generator, simulating the analog signal as if it is received from the actual field devices (sensors).

The processing is done using a ladder diagram and function block, part of supported programming languages in the PLC.

More experiments are being planned for the future.

References

--

--