Application of Siemens PLC in Industrial IoT: From Traditional Automation to Smart Manufacturing

Application of Siemens PLC in Industrial IoT: From Traditional Automation to Smart Manufacturing

In the wave of Industry 4.0, traditional PLCs are evolving towards intelligence. This article will introduce how to utilize Siemens S7-1200/1500 series PLCs to achieve industrial IoT applications, including data acquisition, network communication, remote monitoring, and more, aiding production lines in their digital transformation.

Basic Network Configuration

Hardware Selection

  • CPU: S7-1215C DC/DC/DC

  • Communication Module: CM 1241 (RS485)

  • Ethernet Switch: SCALANCE XB008

  • Note: The CPU must have firmware version V4.0 or higher to support MQTT functionality

PLC Network Settings

  1. IP Address Configuration:

Device IP: 192.168.0.1
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.0.254
  1. Communication Ports:

  • S7 Communication: TCP Port 102

  • Modbus TCP: TCP Port 502

  • MQTT: TCP Port 1883 (standard) or 8883 (encrypted)

Data Acquisition Scheme

Local Data Storage

Establish data structure using data blocks (DB):

// Production Data DB
DATA_BLOCK "ProductionData"
VERSION 1.0
NON_RETAIN
STRUCT
Temperature: REAL; // Temperature value
Pressure: REAL; // Pressure value
Speed: INT; // Motor speed
Status: BOOL; // Device status
Timestamp: DTL; // Timestamp
END_STRUCT;
BEGIN
Temperature := 0.0;
Pressure := 0.0;
Speed := 0;
Status := FALSE;
END_DATA_BLOCK

MQTT Communication Configuration

// MQTT Connection Parameters
"MQTT_CLIENT_CONNECT_V4"(
REQ := %M0.0,
BROKER := 'mqtt.server.com',
PORT := 1883,
CLIENT_ID := 'PLC_001',
USERNAME := 'user',
PASSWORD := 'pass',
KEEP_ALIVE := 60,
DONE => %M0.1,
BUSY => %M0.2,
ERROR => %M0.3,
STATUS := %MW10
);

Practical Application Case: Injection Molding Machine Monitoring System

System Architecture

  1. Field Layer:

  • Temperature Sensor (PT100) → AI Module

  • Pressure Sensor (4-20mA) → AI Module

  • Main Motor Inverter → PROFINET Communication

  1. Control Layer:

  • S7-1215C PLC

  • Local HMI Panel

  1. Management Layer:

  • MQTT Broker (Message Server)

  • Database Server

  • Web Monitoring Interface

Key Code Snippet

// Data Acquisition and Upload Program
FUNCTION "DataAcquisition": VOID
VAR_TEMP
SendBuf: ARRAY[0..255] OF BYTE;
RetVal: INT;
END_VAR
BEGIN
// Collect data
"ProductionData".Temperature := "AI_Temperature";
"ProductionData".Pressure := "AI_Pressure";
"ProductionData".Speed := "VFD_Speed";
"ProductionData".Status := "Machine_Running";
// Get timestamp
RD_SYS_T("ProductionData".Timestamp);
// MQTT publish data
#RetVal := MQTT_PUBLISH(
TOPIC := 'factory/machine1/data',
DATA := "ProductionData",
QOS := 1
);
END_FUNCTION

Common Issues and Solutions

1. Communication Interruption Issues

Fault Phenomenon: MQTT connection frequently disconnects. Solutions:

  • Check network stability

  • Increase KEEP_ALIVE time

  • Implement reconnection mechanism

2. Data Anomaly Issues

Fault Phenomenon: Data collection shows jumps. Solutions:

  • Add data filtering algorithms

  • Check sensor wiring and shielding

  • Increase sampling times to take the average

Precautions

  1. Network Security:

  • Change default passwords

  • Enable access control lists

  • Use VPN if necessary

  1. Data Backup:

  • Regularly backup PLC programs

  • Store important data locally

  • Establish data recovery mechanisms

Practical Suggestions

Hardware Preparation:

  1. S7-1200 PLC practice kit

  2. MQTT server (can use free cloud services)

  3. Network testing tools

Basic Exercises:

  1. Basic PLC network configuration

  2. MQTT communication testing

  3. Simple data acquisition program

Advanced Practice:

  1. Complete monitoring system setup

  2. Data visualization development

  3. Alarm system implementation

This solution has been implemented in multiple factories and can be optimized and expanded according to actual needs. Further discussions can be held regarding specific implementation details and extended functions.

Leave a Comment