Create Boolean members in DB_Input_Map using the names shown in the conveyor workbook.
Paste the code below into the implementation area.
Compile the FC and call it before all logic-development blocks in OB1.
Use a watch table to monitor both the physical address and mapped DB member.
Force only during PLCSIM testing; remove all forces before real-machine operation.
2. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Day 11 SCL source
IF %I10.0 THEN
"DB_Input_Map".Emergency_Stop := TRUE;
ELSE
"DB_Input_Map".Emergency_Stop := FALSE;
END_IF;
IF %I10.1 THEN
"DB_Input_Map".Auto_Manual_Selector_Switch := TRUE;
ELSE
"DB_Input_Map".Auto_Manual_Selector_Switch := FALSE;
END_IF;
IF %I10.2 THEN
"DB_Input_Map".System_Auto_Start_Push_Button := TRUE;
ELSE
"DB_Input_Map".System_Auto_Start_Push_Button := FALSE;
END_IF;
IF %I10.3 THEN
"DB_Input_Map".System_Auto_Stop_Push_Button := TRUE;
ELSE
"DB_Input_Map".System_Auto_Stop_Push_Button := FALSE;
END_IF;
IF %I10.4 THEN
"DB_Input_Map".System_Fault_Reset_Push_Button := TRUE;
ELSE
"DB_Input_Map".System_Fault_Reset_Push_Button := FALSE;
END_IF;
IF %I10.5 THEN
"DB_Input_Map".System_Fault_Acknowledge_Push_Button := TRUE;
ELSE
"DB_Input_Map".System_Fault_Acknowledge_Push_Button := FALSE;
END_IF;
IF %I10.6 THEN
"DB_Input_Map".Entry_Sensor := TRUE;
ELSE
"DB_Input_Map".Entry_Sensor := FALSE;
END_IF;
IF %I10.7 THEN
"DB_Input_Map".Exit_Sensor := TRUE;
ELSE
"DB_Input_Map".Exit_Sensor := FALSE;
END_IF;
3. Verification checklist
□ Block created and compiled
□ Required DB members created
□ OB1 call added
□ PLCSIM/watch-table test completed
Topic: Extended Input Mapping: Conveyor, Safety and Feedback
4. TIA Portal procedure
Continue in FC_Input_Mapping below the first-byte mappings.
Create the required members in DB_Input_Map before compiling.
Keep normally-closed field-device meaning clearly documented.
For Emergency Healthy signals, invert only when the electrical drawing confirms NC logic.
Test every input individually in PLCSIM or with the disconnected machine.
5. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Day 11 SCL source
IF %I11.0 THEN
"DB_Input_Map".Conveyor_Forward_Push_Button := TRUE;
ELSE
"DB_Input_Map".Conveyor_Forward_Push_Button := FALSE;
END_IF;
IF %I11.1 THEN
"DB_Input_Map".Conveyor_Reverse_Push_Button := TRUE;
ELSE
"DB_Input_Map".Conveyor_Reverse_Push_Button := FALSE;
END_IF;
IF %I11.2 THEN
"DB_Input_Map".Forward_Position_Sensor := TRUE;
ELSE
"DB_Input_Map".Forward_Position_Sensor := FALSE;
END_IF;
IF %I11.3 THEN
"DB_Input_Map".Reverse_Position_Sensor := TRUE;
ELSE
"DB_Input_Map".Reverse_Position_Sensor := FALSE;
END_IF;
IF %I11.4 THEN
"DB_Input_Map".VFD_Healthy := TRUE;
ELSE
"DB_Input_Map".VFD_Healthy := FALSE;
END_IF;
IF %I11.5 THEN
"DB_Input_Map".VFD_Fault := TRUE;
ELSE
"DB_Input_Map".VFD_Fault := FALSE;
END_IF;
IF %I11.6 THEN
"DB_Input_Map".Safety_Relay_Healthy := TRUE;
ELSE
"DB_Input_Map".Safety_Relay_Healthy := FALSE;
END_IF;
IF %I11.7 THEN
"DB_Input_Map".Main_Contactor_On_Feedback := TRUE;
ELSE
"DB_Input_Map".Main_Contactor_On_Feedback := FALSE;
END_IF;
6. Verification checklist
□ Block created and compiled
□ Required DB members created
□ OB1 call added
□ PLCSIM/watch-table test completed
12
Day 12 · Advanced Project
Digital Output and Analog Mapping
Map %Q6.0 to %Q7.7, %IW0 to %IW8 and %QW0 to %QW2 with clear global tags.
Place output mapping after all command and alarm logic in OB1.
Never write the same physical output from another FC, FB or OB.
Test each output with the power circuit safely isolated.
2. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Day 12 SCL source
IF "DB_Output_Map".Conveyor_Forward_Command THEN
%Q6.0 := TRUE;
ELSE
%Q6.0 := FALSE;
END_IF;
IF "DB_Output_Map".Conveyor_Reverse_Command THEN
%Q6.1 := TRUE;
ELSE
%Q6.1 := FALSE;
END_IF;
IF "DB_Output_Map".Brake_Contactor_Command THEN
%Q6.2 := TRUE;
ELSE
%Q6.2 := FALSE;
END_IF;
IF "DB_Output_Map".Green_Lamp_Command THEN
%Q6.3 := TRUE;
ELSE
%Q6.3 := FALSE;
END_IF;
IF "DB_Output_Map".Yellow_Lamp_Command THEN
%Q6.4 := TRUE;
ELSE
%Q6.4 := FALSE;
END_IF;
IF "DB_Output_Map".Red_Lamp_Command THEN
%Q6.5 := TRUE;
ELSE
%Q6.5 := FALSE;
END_IF;
IF "DB_Output_Map".Blue_Lamp_Command THEN
%Q6.6 := TRUE;
ELSE
%Q6.6 := FALSE;
END_IF;
IF "DB_Output_Map".Hooter_Command THEN
%Q6.7 := TRUE;
ELSE
%Q6.7 := FALSE;
END_IF;
3. Verification checklist
□ Block created and compiled
□ Required DB members created
□ OB1 call added
□ PLCSIM/watch-table test completed
Topic: Analog Input and Output Mapping
4. TIA Portal procedure
Create FC_Analog_Mapping in SCL.
Create INT members AI_0_Raw through AI_8_Raw in DB_Analog_Map.
Create INT members AO_0_Raw and AO_2_Raw in DB_Analog_Map.
Paste the direct mappings.
Add scaling only after confirming each module measurement range and raw-value format.
5. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Create alarm Boolean members and Alarm_Code in DB_Alarm_Map.
Create Reset_Alarms and Fault_Acknowledge commands in DB_Project.
Place alarm logic before tower-lamp logic.
Test one alarm at a time and verify common alarm and first-fault code.
2. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Day 13 SCL source
IF NOT "DB_Input_Map".Emergency_Stop THEN
"DB_Alarm_Map".Emergency_Stop_Alarm := TRUE;
ELSE
"DB_Alarm_Map".Emergency_Stop_Alarm := FALSE;
END_IF;
IF NOT "DB_Input_Map".Safety_Relay_Healthy THEN
"DB_Alarm_Map".Safety_Relay_Alarm := TRUE;
ELSE
"DB_Alarm_Map".Safety_Relay_Alarm := FALSE;
END_IF;
IF "DB_Input_Map".VFD_Fault THEN
"DB_Alarm_Map".VFD_Fault_Alarm := TRUE;
ELSE
"DB_Alarm_Map".VFD_Fault_Alarm := FALSE;
END_IF;
IF NOT "DB_Network_Map".VFD_Communication_OK THEN
"DB_Alarm_Map".VFD_Communication_Alarm := TRUE;
ELSE
"DB_Alarm_Map".VFD_Communication_Alarm := FALSE;
END_IF;
"DB_Alarm_Map".Alarm_Present :=
"DB_Alarm_Map".Emergency_Stop_Alarm OR
"DB_Alarm_Map".Safety_Relay_Alarm OR
"DB_Alarm_Map".VFD_Fault_Alarm OR
"DB_Alarm_Map".VFD_Communication_Alarm;
IF "DB_Alarm_Map".Emergency_Stop_Alarm THEN
"DB_Alarm_Map".Alarm_Code := 1;
ELSIF "DB_Alarm_Map".Safety_Relay_Alarm THEN
"DB_Alarm_Map".Alarm_Code := 2;
ELSIF "DB_Alarm_Map".VFD_Fault_Alarm THEN
"DB_Alarm_Map".Alarm_Code := 3;
ELSIF "DB_Alarm_Map".VFD_Communication_Alarm THEN
"DB_Alarm_Map".Alarm_Code := 4;
ELSE
"DB_Alarm_Map".Alarm_Code := 0;
END_IF;
3. Verification checklist
□ Block created and compiled
□ Required DB members created
□ OB1 call added
□ PLCSIM/watch-table test completed
14
Day 14 · Advanced Project
Network and Tower-Lamp Mapping
Map PLC, HMI, RIO and VFD communication status and drive the tower lamp and hooter.
Create Boolean members in DB_Network_Map for HMI, RIO and VFD status.
Map device status from the actual hardware/system tags generated by TIA Portal.
Use the simulation switches shown below only for offline training.
Replace simulation members with real diagnostic tags before commissioning.
2. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Day 14 SCL source
// Training simulation mapping
IF "DB_Project".Sim_HMI_Online THEN
"DB_Network_Map".HMI_Communication_OK := TRUE;
ELSE
"DB_Network_Map".HMI_Communication_OK := FALSE;
END_IF;
IF "DB_Project".Sim_RIO_01_Online THEN
"DB_Network_Map".RIO_01_Communication_OK := TRUE;
ELSE
"DB_Network_Map".RIO_01_Communication_OK := FALSE;
END_IF;
IF "DB_Project".Sim_RIO_02_Online THEN
"DB_Network_Map".RIO_02_Communication_OK := TRUE;
ELSE
"DB_Network_Map".RIO_02_Communication_OK := FALSE;
END_IF;
IF "DB_Project".Sim_VFD_Online THEN
"DB_Network_Map".VFD_Communication_OK := TRUE;
ELSE
"DB_Network_Map".VFD_Communication_OK := FALSE;
END_IF;
"DB_Network_Map".All_Networks_OK :=
"DB_Network_Map".HMI_Communication_OK AND
"DB_Network_Map".RIO_01_Communication_OK AND
"DB_Network_Map".RIO_02_Communication_OK AND
"DB_Network_Map".VFD_Communication_OK;
3. Verification checklist
□ Block created and compiled
□ Required DB members created
□ OB1 call added
□ PLCSIM/watch-table test completed
Topic: Tower Lamp and Hooter Mapping
4. TIA Portal procedure
Create FC_Tower_Mapping.
Create status members in DB_Tower_Map.
Use alarm priority: red overrides yellow and green.
Use the system clock memory or a cyclic clock tag for flashing.
Pass the final tower commands to DB_Output_Map.
5. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Use the mapped selector-switch state to determine Manual and Auto mode.
Combine emergency, safety, VFD health and network health into Basic_Permission.
Use Basic_Permission in every motor command.
Display each permission individually on the HMI for troubleshooting.
2. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Day 15 SCL source
IF "DB_Input_Map".Auto_Manual_Selector_Switch THEN
"DB_Project".Auto_Mode_Selected := TRUE;
"DB_Project".Manual_Mode_Selected := FALSE;
ELSE
"DB_Project".Auto_Mode_Selected := FALSE;
"DB_Project".Manual_Mode_Selected := TRUE;
END_IF;
IF "DB_Input_Map".Emergency_Stop AND
"DB_Input_Map".Safety_Relay_Healthy AND
"DB_Input_Map".VFD_Healthy AND
NOT "DB_Input_Map".VFD_Fault AND
"DB_Network_Map".VFD_Communication_OK THEN
"DB_Project".Basic_Permission := TRUE;
ELSE
"DB_Project".Basic_Permission := FALSE;
END_IF;
IF "DB_Project".Manual_Mode_Selected AND
"DB_Project".Basic_Permission THEN
"DB_Project".Manual_Permission := TRUE;
ELSE
"DB_Project".Manual_Permission := FALSE;
END_IF;
3. Verification checklist
□ Block created and compiled
□ Required DB members created
□ OB1 call added
□ PLCSIM/watch-table test completed
Topic: Manual Conveyor Forward and Reverse Logic
4. TIA Portal procedure
Create FC_Manual_Mode.
Use the mapped forward and reverse push buttons.
Prevent simultaneous forward and reverse commands.
Stop at the corresponding position/over-travel sensor.
Drop both commands immediately when Basic_Permission becomes false.
5. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Day 15 SCL source
IF "DB_Project".Manual_Permission AND
"DB_Input_Map".Conveyor_Forward_Push_Button AND
NOT "DB_Input_Map".Conveyor_Reverse_Push_Button AND
NOT "DB_Input_Map".Forward_Position_Sensor THEN
"DB_Project".Manual_Forward_Command := TRUE;
ELSE
"DB_Project".Manual_Forward_Command := FALSE;
END_IF;
IF "DB_Project".Manual_Permission AND
"DB_Input_Map".Conveyor_Reverse_Push_Button AND
NOT "DB_Input_Map".Conveyor_Forward_Push_Button AND
NOT "DB_Input_Map".Reverse_Position_Sensor THEN
"DB_Project".Manual_Reverse_Command := TRUE;
ELSE
"DB_Project".Manual_Reverse_Command := FALSE;
END_IF;
"DB_Output_Map".Conveyor_Forward_Command :=
"DB_Project".Manual_Forward_Command AND
NOT "DB_Project".Manual_Reverse_Command;
"DB_Output_Map".Conveyor_Reverse_Command :=
"DB_Project".Manual_Reverse_Command AND
NOT "DB_Project".Manual_Forward_Command;
6. Verification checklist
□ Block created and compiled
□ Required DB members created
□ OB1 call added
□ PLCSIM/watch-table test completed
16
Day 16 · Advanced Project
SINAMICS G120 PROFINET Setup, Control and Status
Configure the G120 telegram, write control word/speed setpoint and read status/fault feedback.
Topic: SINAMICS G120 PROFINET Hardware and Telegram Setup
1. TIA Portal procedure
Add the SINAMICS G120 device or GSDML device in Network view.
Connect the PLC and drive to the same PROFINET network.
Assign unique device name and IP address to the drive.
Select the required standard telegram; this manual uses a 2-word command and 6-word status concept.
Record the PLC input and output start addresses assigned to the telegram.
Create DB_G120_PN with Control_Word_1, Speed_Setpoint, Status_Word_1, Actual_Speed, Current, Torque, Power and Spare_Status.
Do not run the motor until motor data identification and safety checks are complete.
2. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Day 16 SCL source
// Example cyclic telegram mapping.
// Replace %QW20/%QW22 and %IW20... with actual assigned addresses.
%QW20 := "DB_G120_PN".Control_Word_1;
%QW22 := "DB_G120_PN".Speed_Setpoint_Word;
"DB_G120_PN".Status_Word_1 := %IW20;
"DB_G120_PN".Actual_Speed_Word := %IW22;
"DB_G120_PN".Current_Word := %IW24;
"DB_G120_PN".Torque_Word := %IW26;
"DB_G120_PN".Power_Word := %IW28;
"DB_G120_PN".Spare_Status_Word := %IW30;
3. Verification checklist
□ Block created and compiled
□ Required DB members created
□ OB1 call added
□ PLCSIM/watch-table test completed
Topic: G120 PROFINET Control Word and Speed Setpoint
4. TIA Portal procedure
Create FC_G120_PN_Command.
Confirm the exact bit definition from the selected SINAMICS telegram manual.
Initialize the control word before setting individual bits.
Use DB_Project commands and permissions, not direct HMI-to-drive control.
Limit the speed setpoint to the permitted engineering range.
5. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Day 16 SCL source
"DB_G120_PN".Control_Word_1 := WORD#16#0000;
IF "DB_Project".Basic_Permission THEN
"DB_G120_PN".Control_Word_1.%X0 := TRUE; // ON/OFF1
"DB_G120_PN".Control_Word_1.%X1 := TRUE; // OFF2 released
"DB_G120_PN".Control_Word_1.%X2 := TRUE; // OFF3 released
"DB_G120_PN".Control_Word_1.%X3 := TRUE; // Operation enabled
ELSE
"DB_G120_PN".Control_Word_1.%X0 := FALSE;
END_IF;
IF "DB_Project".Manual_Forward_Command OR "DB_Project".Auto_Forward_Command THEN
"DB_G120_PN".Control_Word_1.%X11 := FALSE; // Forward
ELSIF "DB_Project".Manual_Reverse_Command OR "DB_Project".Auto_Reverse_Command THEN
"DB_G120_PN".Control_Word_1.%X11 := TRUE; // Reverse
END_IF;
IF "DB_Input_Map".System_Fault_Reset_Push_Button THEN
"DB_G120_PN".Control_Word_1.%X7 := TRUE; // Fault acknowledge pulse
ELSE
"DB_G120_PN".Control_Word_1.%X7 := FALSE;
END_IF;
"DB_G120_PN".Speed_Setpoint_Word :=
REAL_TO_INT(LIMIT(MN := 0.0,
IN := "DB_Project".Speed_Setpoint_Percent,
MX := 100.0) * 16384.0 / 100.0);
6. Verification checklist
□ Block created and compiled
□ Required DB members created
□ OB1 call added
□ PLCSIM/watch-table test completed
Topic: G120 PROFINET Status, Feedback and Fault Mapping
7. TIA Portal procedure
Create FC_G120_PN_Status.
Use the selected telegram documentation to verify each status bit.
Map ready, operation enabled, fault and warning states.
Convert the actual-speed word into percent or engineering units.
Use the decoded status in DB_Network_Map and DB_Alarm_Map.
8. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Day 16 SCL source
IF "DB_G120_PN".Status_Word_1.%X0 THEN
"DB_G120_PN".Ready_To_Switch_On := TRUE;
ELSE
"DB_G120_PN".Ready_To_Switch_On := FALSE;
END_IF;
IF "DB_G120_PN".Status_Word_1.%X2 THEN
"DB_G120_PN".Operation_Enabled := TRUE;
ELSE
"DB_G120_PN".Operation_Enabled := FALSE;
END_IF;
IF "DB_G120_PN".Status_Word_1.%X3 THEN
"DB_G120_PN".Fault_Active := TRUE;
ELSE
"DB_G120_PN".Fault_Active := FALSE;
END_IF;
IF "DB_G120_PN".Status_Word_1.%X7 THEN
"DB_G120_PN".Warning_Active := TRUE;
ELSE
"DB_G120_PN".Warning_Active := FALSE;
END_IF;
"DB_G120_PN".Actual_Speed_Percent :=
INT_TO_REAL("DB_G120_PN".Actual_Speed_Word) * 100.0 / 16384.0;
"DB_Network_Map".VFD_Communication_OK :=
"DB_G120_PN".Ready_To_Switch_On OR
"DB_G120_PN".Operation_Enabled;
"DB_Input_Map".VFD_Fault := "DB_G120_PN".Fault_Active;
9. Verification checklist
□ Block created and compiled
□ Required DB members created
□ OB1 call added
□ PLCSIM/watch-table test completed
17
Day 17 · Advanced Project
Reusable PLC–G120 PROFINET Function Block
Build and call a reusable G120 PROFINET control block for project logic.
Use global DB members shown below for this training version.
Call the FB once per drive from OB1.
Keep all physical telegram addresses in one mapping region.
Commission at zero or low speed with the machine mechanically safe.
2. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Day 17 SCL source
REGION Telegram_Read
"DB_G120_PN".Status_Word_1 := %IW20;
"DB_G120_PN".Actual_Speed_Word := %IW22;
"DB_G120_PN".Current_Word := %IW24;
END_REGION
REGION Permission_and_Command
IF "DB_Project".Basic_Permission AND
NOT "DB_G120_PN".Fault_Active THEN
"DB_G120_PN".Control_Word_1 := WORD#16#047F;
ELSE
"DB_G120_PN".Control_Word_1 := WORD#16#0000;
END_IF;
IF "DB_Output_Map".Conveyor_Reverse_Command THEN
"DB_G120_PN".Control_Word_1.%X11 := TRUE;
ELSE
"DB_G120_PN".Control_Word_1.%X11 := FALSE;
END_IF;
END_REGION
REGION Telegram_Write
%QW20 := "DB_G120_PN".Control_Word_1;
%QW22 := "DB_G120_PN".Speed_Setpoint_Word;
END_REGION
3. Verification checklist
□ Block created and compiled
□ Required DB members created
□ OB1 call added
□ PLCSIM/watch-table test completed
18
Day 18 · Advanced Project
SINAMICS G120 Modbus RTU Communication
Configure Modbus RTU and develop the cyclic read/write sequence in SCL.
Topic: SINAMICS G120 Modbus RTU Hardware and Parameters
1. TIA Portal procedure
Install and configure the S7-1500 communication module supported by the project.
Use RS-485 wiring with correct polarity, shield and termination.
Configure identical baud rate, parity, stop bits and slave address in PLC and G120.
Set the drive command source and setpoint source to fieldbus/Modbus as required.
Create DB_G120_MB for request, response, control word, status word, speed and diagnostics.
Use Siemens MB_COMM_LOAD and MB_MASTER instructions according to the installed module version.
Perform one request at a time and wait for DONE or ERROR before the next request.
2. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Day 18 SCL source
// Call once at startup or when communication parameters change
"MB_COMM_LOAD_DB"(
REQ := "DB_G120_MB".Load_Request,
PORT := "Local~CM_PtP_1",
BAUD := 19200,
PARITY := 2,
MB_DB := "MB_MASTER_DB",
DONE => "DB_G120_MB".Load_Done,
ERROR => "DB_G120_MB".Load_Error,
STATUS => "DB_G120_MB".Load_Status);
// Replace PORT and parameter values with the actual hardware configuration.
3. Verification checklist
□ Block created and compiled
□ Required DB members created
□ OB1 call added
□ PLCSIM/watch-table test completed
Topic: G120 Modbus RTU Read/Write Sequence in SCL
4. TIA Portal procedure
Create FC_G120_Modbus_Sequence.
Use one sequence step for write control word/speed and another for read status/actual speed.
Trigger MB_MASTER only with a one-scan request pulse.
Advance the step only after DONE; record ERROR and STATUS on failure.
Confirm Modbus register numbers and zero/one-based addressing from the G120 manual.
5. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Day 18 SCL source
CASE "DB_G120_MB".Comm_Step OF
0:
"DB_G120_MB".Request := FALSE;
"DB_G120_MB".Comm_Step := 10;
10: // Write control word and speed setpoint
"DB_G120_MB".Mode := 1;
"DB_G120_MB".Start_Address := 40100; // Example only
"DB_G120_MB".Data_Length := 2;
"DB_G120_MB".Request := TRUE;
"DB_G120_MB".Comm_Step := 11;
11:
"DB_G120_MB".Request := FALSE;
IF "DB_G120_MB".Done THEN
"DB_G120_MB".Comm_Step := 20;
ELSIF "DB_G120_MB".Error THEN
"DB_G120_MB".Comm_Step := 900;
END_IF;
20: // Read status word and actual speed
"DB_G120_MB".Mode := 0;
"DB_G120_MB".Start_Address := 40110; // Example only
"DB_G120_MB".Data_Length := 2;
"DB_G120_MB".Request := TRUE;
"DB_G120_MB".Comm_Step := 21;
21:
"DB_G120_MB".Request := FALSE;
IF "DB_G120_MB".Done THEN
"DB_G120_MB".Comm_Step := 10;
ELSIF "DB_G120_MB".Error THEN
"DB_G120_MB".Comm_Step := 900;
END_IF;
900:
"DB_G120_MB".Communication_Fault := TRUE;
IF "DB_Input_Map".System_Fault_Reset_Push_Button THEN
"DB_G120_MB".Communication_Fault := FALSE;
"DB_G120_MB".Comm_Step := 0;
END_IF;
END_CASE;
6. Verification checklist
□ Block created and compiled
□ Required DB members created
□ OB1 call added
□ PLCSIM/watch-table test completed
19
Day 19 · Advanced Project
Conveyor Project: Manual and Auto Modes
Develop manual movement, auto sequence, permissions, sensors and step transitions from the tag workbook.
Topic: Conveyor Project Manual Mode from the Tag Workbook
1. TIA Portal procedure
Create FC_Conveyor_Manual_Project.
Use the workbook concepts Manual_Forward_Push_Button, Manual_Reverse_Push_Button, Forward_Position, Reverse_Position and VFD_Healthy.
Generate Brake_Contactor_Command before motor run.
Prevent a direction change until both drive commands are off.
Create feedback timeout alarms as the next extension.
2. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Day 19 SCL source
IF "DB_Project".Manual_Mode_Selected AND
"DB_Project".Basic_Permission THEN
"DB_Project".Manual_Mode_Healthy := TRUE;
ELSE
"DB_Project".Manual_Mode_Healthy := FALSE;
END_IF;
IF "DB_Project".Manual_Mode_Healthy AND
("DB_Input_Map".Conveyor_Forward_Push_Button OR
"DB_Project".HMI_Manual_Forward_Push_Button) AND
NOT "DB_Input_Map".Forward_Position_Sensor AND
NOT "DB_Output_Map".Conveyor_Reverse_Command THEN
"DB_Output_Map".Brake_Contactor_Command := TRUE;
"DB_Output_Map".Conveyor_Forward_Command := TRUE;
ELSE
"DB_Output_Map".Conveyor_Forward_Command := FALSE;
END_IF;
IF "DB_Project".Manual_Mode_Healthy AND
("DB_Input_Map".Conveyor_Reverse_Push_Button OR
"DB_Project".HMI_Manual_Reverse_Push_Button) AND
NOT "DB_Input_Map".Reverse_Position_Sensor AND
NOT "DB_Output_Map".Conveyor_Forward_Command THEN
"DB_Output_Map".Brake_Contactor_Command := TRUE;
"DB_Output_Map".Conveyor_Reverse_Command := TRUE;
ELSE
"DB_Output_Map".Conveyor_Reverse_Command := FALSE;
END_IF;
IF NOT "DB_Output_Map".Conveyor_Forward_Command AND
NOT "DB_Output_Map".Conveyor_Reverse_Command THEN
"DB_Output_Map".Brake_Contactor_Command := FALSE;
END_IF;
3. Verification checklist
□ Block created and compiled
□ Required DB members created
□ OB1 call added
□ PLCSIM/watch-table test completed
Topic: Conveyor Project Auto Mode and Step Sequence
4. TIA Portal procedure
Create FC_Conveyor_Auto_Project.
Latch Auto_Cycle_On from Start and Stop commands.
Use an integer Auto_Step in DB_Project.
Keep command outputs assigned in one CASE statement.
Reset the sequence immediately on loss of permission, stop command or alarm.
Adapt the sensor order to the actual conveyor sequence in the attached workbook and machine drawings.
5. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Day 19 SCL source
IF "DB_Input_Map".System_Auto_Start_Push_Button AND
"DB_Project".Auto_Mode_Selected AND
"DB_Project".Basic_Permission AND
NOT "DB_Alarm_Map".Alarm_Present THEN
"DB_Project".Auto_Cycle_On := TRUE;
END_IF;
IF "DB_Input_Map".System_Auto_Stop_Push_Button OR
NOT "DB_Project".Basic_Permission OR
"DB_Alarm_Map".Alarm_Present THEN
"DB_Project".Auto_Cycle_On := FALSE;
"DB_Project".Auto_Step := 0;
END_IF;
"DB_Project".Auto_Forward_Command := FALSE;
"DB_Project".Auto_Reverse_Command := FALSE;
CASE "DB_Project".Auto_Step OF
0:
IF "DB_Project".Auto_Cycle_On AND
"DB_Input_Map".Entry_Sensor THEN
"DB_Project".Auto_Step := 10;
END_IF;
10: // Move conveyor forward
"DB_Project".Auto_Forward_Command := TRUE;
IF "DB_Input_Map".Forward_Position_Sensor OR
"DB_Input_Map".Exit_Sensor THEN
"DB_Project".Auto_Step := 20;
END_IF;
20: // Wait for delivery permission
IF "DB_Project".Delivery_Permission THEN
"DB_Project".Auto_Step := 30;
END_IF;
30: // Return conveyor
"DB_Project".Auto_Reverse_Command := TRUE;
IF "DB_Input_Map".Reverse_Position_Sensor THEN
"DB_Project".Auto_Step := 0;
END_IF;
ELSE
"DB_Project".Auto_Step := 0;
END_CASE;
IF "DB_Project".Auto_Cycle_On THEN
"DB_Output_Map".Conveyor_Forward_Command := "DB_Project".Auto_Forward_Command;
"DB_Output_Map".Conveyor_Reverse_Command := "DB_Project".Auto_Reverse_Command;
END_IF;
6. Verification checklist
□ Block created and compiled
□ Required DB members created
□ OB1 call added
□ PLCSIM/watch-table test completed
20
Day 20 · Advanced Project
Final Integration, Faults and Commissioning
Integrate mapping, alarms, network, tower, VFD and conveyor logic; test with PLCSIM and commission safely.
Topic: Integrated Faults, Timeouts, Network and Tower Logic
1. TIA Portal procedure
Create FB_Project_Diagnostics with an instance DB for timers.
Use TON timers for forward and reverse travel timeout.
Generate first-out fault codes and common alarm.
Stop all motion on any active critical fault.
Use the tower and hooter mapping from Day 20.
Display fault code, fault text, network states and current sequence step on the HMI.
2. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Day 20 SCL source
"DB_Diagnostics".Forward_Timeout_Timer(
IN := "DB_Output_Map".Conveyor_Forward_Command AND
NOT "DB_Input_Map".Forward_Position_Sensor,
PT := T#10s);
"DB_Diagnostics".Reverse_Timeout_Timer(
IN := "DB_Output_Map".Conveyor_Reverse_Command AND
NOT "DB_Input_Map".Reverse_Position_Sensor,
PT := T#10s);
IF "DB_Diagnostics".Forward_Timeout_Timer.Q THEN
"DB_Alarm_Map".Forward_Travel_Timeout_Alarm := TRUE;
END_IF;
IF "DB_Diagnostics".Reverse_Timeout_Timer.Q THEN
"DB_Alarm_Map".Reverse_Travel_Timeout_Alarm := TRUE;
END_IF;
IF "DB_Input_Map".System_Fault_Reset_Push_Button AND
NOT "DB_Output_Map".Conveyor_Forward_Command AND
NOT "DB_Output_Map".Conveyor_Reverse_Command THEN
"DB_Alarm_Map".Forward_Travel_Timeout_Alarm := FALSE;
"DB_Alarm_Map".Reverse_Travel_Timeout_Alarm := FALSE;
END_IF;
IF "DB_Alarm_Map".Alarm_Present OR
"DB_Alarm_Map".Forward_Travel_Timeout_Alarm OR
"DB_Alarm_Map".Reverse_Travel_Timeout_Alarm THEN
"DB_Output_Map".Conveyor_Forward_Command := FALSE;
"DB_Output_Map".Conveyor_Reverse_Command := FALSE;
END_IF;
3. Verification checklist
□ Block created and compiled
□ Required DB members created
□ OB1 call added
□ PLCSIM/watch-table test completed
Topic: Complete Project Integration, PLCSIM and Commissioning
4. TIA Portal procedure
Use the exact OB1 execution order shown below.
Compile software and hardware completely.
Run PLCSIM tests for every physical input, output command, alarm and sequence transition.
Test manual forward and reverse at a low speed.
Test Auto mode one transition at a time using a watch table.
Confirm loss of emergency, safety, VFD health and communication stops the conveyor.
Confirm fault reset works only after the fault cause is removed.
Back up the commissioned project and export PLC tag tables and block sources.
5. Copy-paste SCL code
Important: This manual intentionally avoids local # tags. Create the quoted global DB members exactly as shown, then paste the code into the SCL implementation area. Addresses shown for drive telegrams and Modbus registers are examples and must be replaced by the actual configured values.
Day 20 SCL source
// Recommended OB1 call order
"FC_Input_Mapping"();
"FC_Analog_Mapping"();
"FC_Network_Mapping"();
"FC_Mode_and_Permission"();
// Choose one drive communication method for the machine
"FB_G120_PROFINET_DB"();
// OR call Modbus communication blocks and FC_G120_Modbus_Sequence
"FC_Conveyor_Manual_Project"();
"FC_Conveyor_Auto_Project"();
"FB_Project_Diagnostics_DB"();
"FC_Alarm_Mapping"();
"FC_Tower_Mapping"();
"FC_Output_Mapping"();
// Final safety rule:
// No physical output is written anywhere except FC_Output_Mapping.