Best Practices for Seamless Integration of Siemens PLC and Sensor Networks

Follow Us | Discover More Exciting Content

With the wave of intelligent manufacturing, the collection of sensor data on production lines has become increasingly important. Today, I will share a practical case to show how to build a stable and reliable sensor data acquisition system using the Siemens S7-1200 PLC. This solution has been successfully deployed in multiple factories with excellent results.

Hardware Selection Issues

Selecting the right hardware is half the battle won. This project uses the Siemens S7-1200 1214C DC/DC/DC model, equipped with two analog expansion modules SM1231 AI. Why choose this model? Because it comes with an Ethernet port for easy data upload, is cost-effective, and has adequate performance.

The following sensors were selected:

  • Temperature: PT100 temperature sensor (4-20mA output)

  • Pressure: SICK pressure transmitter (4-20mA output)

  • Vibration: IFM vibration sensor (4-20mA output)

Key Point: All sensors use a unified 4-20mA current signal, which has strong anti-interference capability and is easy to debug.

Key Points for System Wiring

Wiring in the electrical cabinet is a technical job; here are some practical experiences:

  1. Analog signal wires must use shielded cables and should run in separate conduits, away from power lines

  2. Sensor power supply should be independently powered with a 24V switching power supply

  3. Each signal should have a surge protector added, as industrial sites often have lightning strikes

  4. Grounding must be standardized, with all shielding layers grounded at a single point

Here is a wiring diagram:

Sensor --> Surge Protector --> Terminal Block --> PLC Analog Module
   |          |           |           |
   +----------+-----------+-----------+---> Ground Bar

PLC Program Design

The program architecture is divided into three functional blocks:

  • Data Acquisition (FC1)

  • Data Processing (FC2)

  • Data Upload (FC3)

Focus on the code for the data acquisition part:

//Temperature Acquisition Function Block
FUNCTION "FC_TEMP_ACQ": VOID
BEGIN
    //Read analog channel value
    "MD_TEMP" := NORM_X(MIN := 0,
                        VALUE := "IW64",  //Analog input address
                        MAX := 27648);
    //Convert to actual temperature value
    "REAL_TEMP" := "MD_TEMP" * 100.0;  //4-20mA corresponds to 0-100 degrees
    //Over-limit alarm detection
    IF "REAL_TEMP" > 80.0 THEN
        SET "TEMP_ALARM";
    END_IF;
END_FUNCTION

The acquisition program has a key point: the NORM_X instruction automatically converts the PLC’s analog value (0-27648) into a 0-1 ratio value for easy subsequent calculations.

Data Processing Optimization

Using raw data directly has significant issues; some processing is necessary:

  1. Sliding average filtering to remove spikes

  2. Dead zone setting to prevent data jitter

  3. Extreme value exclusion to rule out sensor faults

  4. Data compression to reduce storage space

Code example:

//Sliding Average Filtering
FOR #i := 1 TO 9 DO
    #Temp_Buff[#i] := #Temp_Buff[#i + 1];
END_FOR;
#Temp_Buff[10] := "REAL_TEMP";
#Sum := 0;
FOR #i := 1 TO 10 DO
    #Sum := #Sum + #Temp_Buff[#i];
END_FOR;
"AVG_TEMP" := #Sum / 10.0;

Common Problem Solutions

During project implementation, the most common issues encountered are:

  1. Signal drift causes: often due to poor grounding or unstable sensor power supply. Solution: Check grounding and install signal isolators.

  2. Data break causes: usually due to communication interruptions. Solution: Add a watchdog program for automatic reset.

  3. Insufficient accuracy causes: limited by AD conversion resolution. Solution: Use a 16-bit high-precision module or implement software compensation.

Practical Recommendations

  1. Conduct signal simulation tests before powering on

  2. Prepare a set of backup sensors

  3. Regular calibration and maintenance

  4. Establish a data anomaly warning mechanism

  5. Implement lightning protection and anti-interference measures

This system has been running for over a year with high reliability. The most important experience is: it’s better to spend more time on early planning and testing than to rush into the system.

Remember this: details determine success or failure; there is no room for carelessness in the industrial field.

If you need practical exercises, it is recommended to start with a simple temperature acquisition system to get familiar before gradually increasing the types and quantities of sensors.

Leave a Comment