
Hello everyone, I am Chen Yi. Today we will dive deep into the three major variable types in PLC: Digital Signals, Analog Signals, and Pulse Signals. These are the most fundamental and important types of signals in PLC control, and understanding them is crucial for mastering PLC programming. Let me help you thoroughly understand these three types of signals with vivid examples.
1. Digital Signals
1.1 What are Digital Signals?
Digital signals are like a light switch, with only ON and OFF states:
• Logic 1 (ON): Typically corresponds to 24V DC• Logic 0 (OFF): Typically corresponds to 0V DC
1.2 Digital Signal Wiring Method
// Input wiring exampleCOM ---|24V DC|---X0 ---|Button|---X1 ---|Limit Switch|---X2 ---|Photoelectric Switch|---
// Output wiring exampleCOM ---|24V DC|---Y0 ---|Relay|---Y1 ---|Indicator Light|---Y2 ---|Solenoid Valve|---
1.3 Digital Signal Programming Example
// Simple start-stop controlLD X0 // Start buttonAND NOT X1 // Not stop buttonOR M0 // Latching contactAND NOT X2 // Not emergency stop buttonOUT M0 // Running stateOUT Y0 // Output control
2. Analog Signals
2.1 What are Analog Signals?
Analog signals are continuously changing signals, like the temperature adjustment of an air conditioner, which can vary smoothly within a certain range.
2.2 Common Analog Signal Ranges
// Voltage types0-10V DC±10V DC0-5V DC
// Current types4-20mA0-20mA
2.3 Analog Signal Program Example
// Temperature control programPROGRAM Temperature_ControlVAR Temp_Input AT %IW0: INT; // Temperature input Heat_Output AT %QW0: INT; // Heating output Set_Point: INT := 500; // Set point (50.0℃) Dead_Band: INT := 5; // Dead band rangeEND_VAR
// Temperature control logicIF Temp_Input < (Set_Point - Dead_Band) THEN Heat_Output := 32767; // 100% heatingELSIF Temp_Input > (Set_Point + Dead_Band) THEN Heat_Output := 0; // Stop heatingEND_IF;
2.4 Analog Signal Calibration
// Linear calibration formulaReal_Value = (AD_Value * Scale) + Offset
Where:AD_Value: Analog input value (0-32767)Scale: Scale factorOffset: Zero offsetReal_Value: Actual physical quantity
3. Pulse Signals
3.1 What are Pulse Signals?
Pulse signals are high-speed changing digital signals, like the square wave signals output by encoders. They are mainly used for:
• High-speed counting• Position detection• Speed measurement
3.2 Pulse Signal Applications
// High-speed counter configurationHSC0( EN := TRUE, // Enable Reset := Reset_Cmd,// Reset CV => Count_Value, // Count value DIR := TRUE // Count direction); // Frequency calculationFrequency := Count_Value / Sample_Time;
3.3 Stepper Motor Control
// Position control programPROGRAM Pulse_ControlVAR Target_Position: DINT; // Target position Current_Position: DINT; // Current position Pulse_Output: BOOL; // Pulse output Direction: BOOL; // Motion directionEND_VAR
// Position control logicIF Target_Position > Current_Position THEN Direction := TRUE; Pulse_Output := TRUE;ELSIF Target_Position < Current_Position THEN Direction := FALSE; Pulse_Output := TRUE;ELSE Pulse_Output := FALSE;END_IF;
4. Signal Processing Techniques
4.1 Digital Signal Debouncing
// Digital signal debouncing|--[X0]--|[TON]--|[Y0]--| Input Delay Output
Timer_On( IN := Input_Signal, PT := T#20ms, // Debounce time Q => Stable_Signal);
4.2 Analog Signal Filtering
// Mean filtering programValue_Sum := Value_Sum - Value_Buffer[Buffer_Index];Value_Buffer[Buffer_Index] := Current_Value;Value_Sum := Value_Sum + Current_Value;Buffer_Index := Buffer_Index + 1;IF Buffer_Index >= 10 THEN Buffer_Index := 0;END_IF;Filtered_Value := Value_Sum / 10;
4.3 Pulse Signal Speed Measurement
// Speed calculation programSpeed_RPM := (Pulse_Count * 60) / (Pulses_Per_Rev * Sample_Time);
Where:Pulse_Count: Number of pulses during the sampling periodPulses_Per_Rev: Number of pulses per revolutionSample_Time: Sampling time (seconds)Speed_RPM: Speed (r/min)
5. Exercises
1.
Design a liquid level control system with analog signals:
•4-20mA liquid level sensor input•High and low liquid level alarms•PID control output
Implement an encoder speed measurement system:
•Forward and reverse rotation identification•Speed calculation•Data display
3.Comprehensively use the three types of signals to achieve temperature control:
•Thermocouple analog input•Digital alarm output•PWM pulse control for heating
Practical Tips:
1.
Signal selection recommendations:
• Use digital signals for simple control• Use analog signals for precise control• Use pulse signals for high-speed control
Interference prevention measures:
• Shielding of signal wires• Reasonable wiring• Software filtering
3.Tuning techniques:
• Online monitoring of signals• Data trend analysis• Parameter recording and archiving
4.Common problem-solving:
• Check wiring for signal mutation• Check grounding for value drift• Check filtering for slow response
Friends, today’s learning about the three major PLC variables ends here! These are the most commonly used knowledge points in practical work. I recommend everyone start practicing with a single type of signal, and gradually try to use multiple signals together. Feel free to ask questions in the comments section. I wish everyone happy learning and continuous improvement in industrial control skills!