Using Siemens PLC to control 3D printers not only improves printing accuracy but also enables advanced features such as multi-material switching and self-diagnosis of faults. This article will detail how to achieve this.
1. Hardware Configuration
1. Selection of PLC and Expansion Modules
The 3D printing equipment mainly involves multi-axis motion control and temperature control. It is recommended to use:
Main Control PLC: S7-1215C DC/DC/DC (6ES7 215-1AG40-0XB0)
Expansion Module: SM1223 DC/RLY (8 inputs/8 outputs)
Communication Module: CM1241 RS232 (for communication with the printer motherboard)
2. I/O Point Allocation Table
Address Type Function Description Remarks
I0.0 DI Emergency Stop Button Normally closed contact
I0.1 DI X-axis Limit Switch Home position
I0.2 DI Y-axis Limit Switch Home position
I0.3 DI Z-axis Limit Switch Home position
I0.4 DI Filament Detection Photoelectric sensor
Q0.0 DO X-axis Stepper Motor Pulse High-speed output
Q0.1 DO X-axis Stepper Motor Direction Control direction
Q0.2 DO Y-axis Stepper Motor Pulse High-speed output
Q0.3 DO Y-axis Stepper Motor Direction Control direction
Q0.4 DO Z-axis Stepper Motor Pulse High-speed output
Q0.5 DO Z-axis Stepper Motor Direction Control direction
Q0.6 DO Extruder Motor Control PWM output
Q0.7 DO Heated Bed Control Solid-state relay
3. Selection of Peripheral Devices
Stepper Motor Driver: DM542 (set to 1600 pulses/revolution)
Temperature Sensor: PT100 with temperature transmitter, output 4-20mA
Solid-state Relay: 40A for heated bed, 10A for nozzle heating
Touch Screen: TP700 Comfort, 7-inch color screen
2. Control Program Design
1. Variable Definition Specification
Defined in DB1 “Machine_Data”:
TYPE “UDT_AxisControl”
Position : Real; // Current position (mm)
TargetPos : Real; // Target position (mm)
Speed : Real; // Running speed (mm/s)
Acceleration : Real; // Acceleration (mm/s²)
IsHomed : Bool; // Home flag
IsMoving : Bool; // Moving flag
Error : Bool; // Error flag
END_TYPE
TYPE “UDT_Temperature”
Actual : Real; // Actual temperature
Setpoint : Real; // Set temperature
Output : Real; // PID output
IsHeating : Bool; // Heating flag
IsReady : Bool; // Temperature reached flag
END_TYPE
2. Program Architecture Design
Using modular design, mainly includes the following function blocks:
FB1 “AxisControl” – Single-axis motion control
FB2 “TemperatureControl” – Temperature PID control
FB3 “PrintJobManager” – Print job management
FB4 “SafetyMonitor” – Safety monitoring
3. State Control Design
The main program uses a state machine design:
CASE #MachineState OF
0: // Initialization
IF #InitComplete THEN
#MachineState := 10;
END_IF;
10: // Standby
IF #StartButton AND #AllAxisHomed THEN
#MachineState := 20;
END_IF;
20: // Preheating
IF #ExtruderTemp.IsReady AND #BedTemp.IsReady THEN
#MachineState := 30;
END_IF;
30: // Printing
IF #PrintComplete OR #StopButton THEN
#MachineState := 40;
END_IF;
40: // Cooling
IF #ExtruderTemp.Actual < 50 THEN
#MachineState := 10;
END_IF;
99: // Fault
IF #ResetButton AND NOT #EmergencyStop THEN
#MachineState := 0;
END_IF;
END_CASE;
3. Data Management and Storage
1. Parameter Configuration Table
Stored in DB2 “PrintParameters”:
Parameter Name Data Type Description Default Value
LayerHeight Real Layer height 0.2mm
PrintSpeed Real Print speed 60mm/s
TravelSpeed Real Travel speed 120mm/s
ExtruderTemp Real Nozzle temperature 210°C
BedTemp Real Heated bed temperature 60°C
FillDensity Int Fill density 20%
2. Runtime Data Logging
Create a circular buffer to log key data:
TYPE “UDT_PrintLog”
TimeStamp : DTL; // Timestamp
LayerNumber : Int; // Current layer number
PrintProgress : Real; // Print progress
ExtruderTemp : Real; // Nozzle temperature
BedTemp : Real; // Heated bed temperature
FilamentUsed : Real; // Material usage
END_TYPE
// Define a circular buffer with 100 records in DB3
VAR_GLOBAL
PrintLog : ARRAY[0..99] OF “UDT_PrintLog”;
LogIndex : Int;
END_VAR
4. User Interface Design
1. Main Interface Layout
The touch screen main interface is divided into four areas:
Top: Status bar (displays machine status, temperature, progress)
Left: Function buttons (Start, Pause, Stop, Zeroing)
Middle: 3D preview area (displays print model and current layer)
Right: Parameter settings (speed, temperature, layer height, etc.)
2. Parameter Settings Interface
// Example configuration for parameter input field
Object: InputField_ExtruderTemp
Tag: DB2.ExtruderTemp
Min: 180
Max: 260
Format: ###.#
Unit: °C
3. Alarm Handling Interface
Establish an alarm text list:
Alarm ID Alarm Text Handling Suggestions
1001 Nozzle temperature too high Check temperature sensor, confirm heater power
1002 Filament exhausted Replace filament, check feeding mechanism
1003 Axis motion limit exceeded Check limit switches, re-zero
2001 Communication failure Check connection cables, restart system
5. Fault Diagnosis and Troubleshooting
1. Common Fault Analysis
Establish a fault diagnosis decision tree:
IF #ExtruderTemp.Error THEN
IF #ExtruderTemp.Actual > 300 THEN
// Sensor open circuit
#AlarmID := 1101;
ELSIF #ExtruderTemp.Actual < 10 THEN
// Sensor short circuit
#AlarmID := 1102;
ELSE
// PID control abnormal
#AlarmID := 1103;
END_IF;
END_IF;
2. Diagnostic Data Collection
// FB10 “DiagnosticCollector”
IF #TriggerDiagnostic THEN
#DiagData.Timestamp := DTL();
#DiagData.MachineState := #MachineState;
#DiagData.AxisPosition[0] := #XAxis.Position;
#DiagData.AxisPosition[1] := #YAxis.Position;
#DiagData.AxisPosition[2] := #ZAxis.Position;
#DiagData.Temperatures[0] := #ExtruderTemp.Actual;
#DiagData.Temperatures[1] := #BedTemp.Actual;
// Save to SD card
CALL “WriteCSV”(FileName := ‘Diagnostic.csv’,
Data := #DiagData);
END_IF;
3. Automatic Recovery Mechanism
// Power failure recovery function
IF #PowerFailureDetected THEN
// Save current print state
#RecoveryData.LayerNumber := #CurrentLayer;
#RecoveryData.Position := #CurrentPosition;
#RecoveryData.GCodeLine := #CurrentGCodeLine;
CALL “SaveToRetainMemory”(Data := #RecoveryData);
END_IF;
Conclusion
Through reasonable hardware selection and modular program design, we have achieved a fully functional 3D printing control system. The key points are precise motion control, stable temperature management, and a comprehensive fault handling mechanism. Feel free to leave comments for any specific questions!