Use ladder for mapping, interlocks, permissives and anything a technician will troubleshoot online, because live contact states make faults visible. Use SCL for calculations, loops, arrays, strings and complex state machines. Both compile to the same code and write the same DB members, so mix them per block.
- Interlocks in LAD: the open contact is the diagnosis.
- Maths, arrays and loops in SCL: ten lines instead of ten networks.
- Choose per block – both feed the same DBs and HMI.
What Each Language Is Good At
| Criterion | Ladder (LAD) | SCL |
|---|---|---|
| Online troubleshooting | Excellent – power flow visible | Good with monitoring, needs code reading |
| Interlocks and permissives | Natural | Possible, less visual |
| Maths and formulas | Clumsy boxes | Natural |
| Loops and arrays | Not practical | Natural |
| State machines | Readable up to a few steps | CASE statement scales well |
| Maintenance team skills | Widely known | Growing |
Lab Flow: One Pump Station, Two Languages
Every lesson in the Softwell PLC lab manual series follows the same six stages and the same address rule, so the code you write here plugs straight into the HMI lessons.
Stage 1Field Signals and PLC Tags
| PLC tag | Address | Type | Device / comment |
|---|---|---|---|
FT40_Raw | %IW104 | Int | Flow transmitter 4–20 mA = 0 – 20 m³/h |
LS40_Water | %I6.5 | Bool | Tank low-level switch, 1 = water present |
P40_Fault | %I6.6 | Bool | Pump MPCB trip, 1 = tripped |
P40_Run | %Q3.3 | Bool | Pump contactor |
Stage 2Input Mapping (LAD or SCL – both fine)
// FC_InputMapping "DB_IO".FT40_m3h := SCALE_X(MIN := 0.0, MAX := 20.0, VALUE := NORM_X(MIN := 0, VALUE := "FT40_Raw", MAX := 27648)); "DB_IO".LS40_OK := "LS40_Water"; "DB_IO".P40_Fault := "P40_Fault";
Stage 3Logic: Interlock in LAD, Calculation in SCL
| Block | Language | Why |
|---|---|---|
| FC_PumpInterlock | LAD | Maintenance sees the open contact online |
| FB_FlowCalc (OB30, 100 ms) | SCL | Array, loop and maths stay readable |
| FC_OutputMapping | LAD or SCL | One line per output |
// FC_PumpInterlock (LAD), one network:
// --| "DB_Pump".Run_Req |--| "DB_IO".LS40_OK |--|/ "DB_IO".P40_Fault |--( "DB_Pump".P40_Run )
// FB_FlowCalc (SCL) in OB30 – STAT: Idx : Int; TEMP: i : Int; sum : Real;
"DB_Flow".Buf[#Idx] := "DB_IO".FT40_m3h;
#Idx := (#Idx + 1) MOD 10;
#sum := 0.0;
FOR #i := 0 TO 9 DO
#sum := #sum + "DB_Flow".Buf[#i];
END_FOR;
"DB_Flow".Avg := #sum / 10.0;
"DB_Flow".Total := "DB_Flow".Total + "DB_Flow".Avg * 0.1 / 3600.0; // 100 ms in hoursThe averaging and totaliser run in a cyclic interrupt OB so the time base is constant – see the scan cycle lesson.
Stage 4Link PLC Tags to the HMI
| HMI tag | PLC member | Used by |
|---|---|---|
DB_Pump_P40_Run | "DB_Pump".P40_Run | Run lamp |
DB_Flow_Avg | "DB_Flow".Avg | Flow field |
DB_Flow_Total | "DB_Flow".Total | Total field |
Stage 5Link the Graphics
| # | Object | Properties | Tag / event |
|---|---|---|---|
| ① | Pump lamp | Appearance from P40_Run (or feedback) | DB_Pump_P40_Run |
| ② | Output field average flow | Format 99.9 m³/h | DB_Flow_Avg |
| ③ | Output field total | Format 99999.999 m³; consider logging it – see the trends lesson | DB_Flow_Total |
Logging the average flow is shown in HMI trends and data logs.
Stage 6Perform and Test: the Same Machine in LAD and SCL
The pump interlock runs as ladder, the flow averaging and totalising as SCL – exactly the split recommended above. Toggle the signals and compare how each language shows what is happening.
Troubleshooting
| Symptom | Likely cause | First check |
|---|---|---|
| Average jumps every 10 samples | Index not wrapped | MOD 10 on the index |
| Total grows with scan time | Totaliser in OB1 | Move to a cyclic interrupt OB |
| Technician cannot find why pump stops | Interlock buried in SCL | Move interlocks to LAD |
Hands-On Lab: One Pump Station in LAD and SCL
Hands-on- TIA Portal with an S7-1200 or PLCSIM
- Estimated time: 60 minutes
Wire and declare the pump signals
Declare FT40_Raw, LS40_Water, P40_Fault and P40_Run.
Map and scale into DB_IO
Scale the flow to m³/h and copy the switches in FC_InputMapping.
Write the interlock in LAD and the calculation in SCL
FC_PumpInterlock in LAD; FB_FlowCalc in SCL in OB30 with a 10-sample array and a totaliser.
Link HMI tags
Drag DB_Pump and DB_Flow into the HMI tag table.
Build the pump screen
Add the run lamp, raw and average flow and the total.
Compare online
Toggle the signals, watch the LAD rung and monitor the SCL block online.
The interlock is readable online in ladder, the calculation is clean in SCL, and both feed the same DBs and HMI.
Frequently asked questions
Is SCL faster than ladder logic on Siemens PLCs?
No meaningful difference. Both compile to the same machine code on S7-1200 and S7-1500. Choose on readability and maintainability, not speed.
Can I mix ladder and SCL in one project?
Yes, and you should. The language is chosen per block, so a single machine can have ladder interlocks calling SCL function blocks.
Which should a beginner learn first?
Ladder, because it maps onto the electrical drawing and makes online troubleshooting visual. Add SCL once you meet maths, loops or long sequences.
Why do OEMs often insist on ladder?
Because the end customer's maintenance team has to fault-find at night without the OEM present, and ladder shows the open contact on screen without any code reading.
Where should the language split be in a typical machine?
Mapping, interlocks and simple motor logic in LAD; calculations, arrays, loops, string handling and complex state machines in SCL; one block per job so each can be read in its best language.
Can the HMI tell which language produced a value?
No, and it does not need to. Both write the same DB members, so the HMI tags and screens are identical whichever language you choose.