Siemens S7-1500 series · Part 5 · SCL

PLC Data Types and Memory in SCL (Siemens S7-1500)

The SCL view of data: where every variable you declare in a block actually lives, what survives a scan or a power cycle, and how to convert, slice and loop over data on an S7-1500. Built on the conveyor project from Parts 2 to 4.

SCL editor › FB_PRB [FB1]

Instance DB · DB_PRB_1 kept between calls

Temp · local data stack exists only during the call

Constant · compiled into the code no runtime memory

VAR_INPUTVAR_OUTPUTVAR (Static)VAR_TEMPVAR CONSTANT

Each variable drops into the memory its section decides. Watch the Temp value: it disappears after every call, while everything in the instance DB stays.

2,500+ engineers trained 4.9/5 Google rating 21+ years, Chinchwad, Pune Next batch: contact for dates
Quick answer

In SCL every variable is declared in a section that decides where it lives. Input, Output, InOut and Static variables of an FB are stored in its instance DB and keep their values between calls; Temp variables exist only while the block runs; Constants are compiled into the code. The CPU keeps the project in load memory (memory card), runs it from work memory, and keeps Retain values in retentive memory through a power cycle.

  • Static = the block's memory (instance DB); Temp = scratch space for one call; Constant = no runtime memory
  • Mark only values that must survive a power cycle as Retain; everything else returns to its start value
  • Convert explicitly (NORM_X, SCALE_X, TRUNC, ROUND), read bits with slices like #ZSW1.%X2, and loop over arrays with FOR

Part 3 showed addresses and data types from the PLC tag table. This part looks at the same data the way an SCL programmer does: as declarations inside blocks. Every tool below uses the conveyor project: FB_PRB from Part 4, the G120 drive from Part 2 and the Motor_UDT array from Part 3.

01

SCL Declaration Sections: Input, Output, InOut, Static, Temp, Constant

The section you declare a variable in decides where it is stored and whether it survives the next scan.

FB_PRB › block interface
Reference: declaration sections in an FB and an FC
SectionFBFC
VAR_INPUT / VAR_OUTPUTStored in the instance DBParameters of the call, no instance DB
VAR_IN_OUTCopy (elementary) or reference (structured)Passed from the caller
VAR (Static)Instance DB, kept between callsNot available
VAR_TEMPLocal data stack, only during the callLocal data stack, only during the call
VAR CONSTANTCompiled into the codeCompiled into the code
02

PLC Memory: Load Memory, Work Memory and Retentive Memory

The project sits on the memory card; the CPU runs it from work memory; only values marked Retain survive a power cycle.

CPU 1511-1 PN › memory
Load memory
SMC
SIMATIC Memory Card: the whole project, code and start values.
Work memory: codeRuntime-relevant code blocks
Work memory: dataDBs and instance DBs with actual values
Retentive memoryValues marked Retain, kept through power OFF
Download → load memory. Startup → work memory. Power OFF → only retentive data is kept. Process images (I, Q) and bit memory (M) sit in system memory.
DB_PRB_1 memberTypeStart valueActual valueRetain column

POWER OFF

In an optimized FB you set retentivity per variable in the interface's Retain column (Non-retain, Retain or Set in IDB). Keep the list short: retentive memory is much smaller than work memory.

Want to write SCL on a real S7-1500?

Live SCL sessions: declarations, UDTs, arrays, loops and FB design on real hardware. Pune classroom or online.

Book a Free Demo Class 03

Typed Literals and Type Conversion in SCL

SCL checks types strictly. Move the raw analog value and watch it pass through NORM_X and SCALE_X from Int to Real, then try the rounding functions.

Tank level: raw Int → Real mm
"Tank_Level_Raw" %IW6413824Int
NORM_X(0 … 27648)0.5Real 0 … 1
SCALE_X(0.0 … 2000.0)1000.0Real
"DB_Process".Level_mm1000.0Real
MTP700 display1000.0 mmHMI
#Norm := NORM_X(MIN := 0, VALUE := 13824, MAX := 27648); // = 0.5 "DB_Process".Level_mm := SCALE_X(MIN := 0.0, VALUE := #Norm, MAX := 2000.0); // = 1000.0

Real → whole number: 25.7

16#FFHex Byte/Word value
2#0000_0101Binary bit pattern
INT#100Typed constant
25.0Real
1.5E3Real, exponent
T#2STime: 2 seconds
T#1M30STime: 90 seconds
TOD#08:30:00Time of day
D#2026-11-04Date
'Batch_01'String
Reference: common conversions in SCL
From → toSCLNote
Int → RealINT_TO_REAL(#Raw)No loss of precision
Real → DIntTRUNC(#Level) or ROUND(#Level)TRUNC cuts the decimals, ROUND goes to the nearest whole number
DInt → IntDINT_TO_INT(#Total)Values above 32 767 do not fit: check the range first
Raw analog → engineeringNORM_X then SCALE_X0 … 27 648 is the nominal range of S7-1500 analog modules
Word ↔ IntWORD_TO_INT / INT_TO_WORDSame 16 bits, different meaning
04

Slice Access in SCL: Reading Bits Inside a Word

No masks or shifts needed: #ZSW1.%X2 reads bit 2 of the G120 status word directly. Click bits, or watch the drive start up.

SINAMICS G120 status word ZSW1 · %IW256
%B1 = high byte = %IB256%B0 = low byte = %IB257

Reference: ZSW1 bits used here
SliceMeaning
%X0Ready to switch on
%X1Ready to operate
%X2Operation enabled
%X3Fault present
%X4No OFF2 (coast stop)
%X5No OFF3 (quick stop)
%X6Switching on inhibited
%X7Alarm active

Remember Part 3: Siemens stores the high byte first, so %X0 of %IW256 sits in %IB257. Slices count from the least significant bit, so you never need to think about byte order in SCL.

05

ARRAY and FOR Loop: One Loop for 16 Roller Beds

"Conveyor".PRB is the ARRAY[1..16] OF Motor_UDT from Part 3. One FOR loop checks every roller bed in a single scan.

FC_Conveyor_Summary

Quick Quiz: SCL Data Types and Memory

5 questions
Score: 0 / 5
1. Which section keeps its value between calls of an FB?
Static variables live in the instance DB, so they are still there at the next call.
2. Where does a download put the program first?
Download writes to load memory; the runtime-relevant parts are then copied into work memory.
3. #ZSW1.%X3 reads…
%X is a bit slice, %B a byte slice, %W a word slice.
4. TRUNC(-3.6) returns…
TRUNC simply cuts the decimals. FLOOR(-3.6) would give -4.
5. After power OFF → ON, a Non-retain Static value…
Only Retain values are kept in retentive memory.

Hands-On Lab: SCL Data and Memory in TIA Portal

15 minutes
Before you start
  • TIA Portal V17 or later with an S7-1500 CPU or PLCSIM.
  • The Motor_UDT from Part 3 (Run, Fault, Speed, Runtime_s).
1

Create FB_PRB in SCL

Add Start/Stop inputs, a Run output, Static Latch and Runtime_s, and a Temp EdgeStart. Set Runtime_s to Retain.

The instance DB shows Start, Stop, Run, Latch and Runtime_s, but not EdgeStart.
2

Power-cycle PLCSIM

Run the block, then switch PLCSIM to STOP, power off and on.

Runtime_s keeps its value; Latch goes back to FALSE.
3

Scale an analog value

Use NORM_X and SCALE_X to convert a raw Int (0 … 27 648) into a Real in mm.

13 824 gives 1000.0 mm for a 0 … 2000 mm range.
4

Loop over the array

Write the FOR loop from Step 05 and force one roller bed's Fault to TRUE.

#AnyFault turns TRUE in the same scan.

Frequently asked questions

What are the variable sections in an SCL block?

An SCL block declares variables in VAR_INPUT, VAR_OUTPUT, VAR_IN_OUT, VAR (Static, FB only), VAR_TEMP and VAR CONSTANT. The section decides where the value is stored and whether it is kept between calls.

What is the difference between Static and Temp variables?

Static variables belong to an FB and are stored in its instance DB, so they keep their value from one call to the next. Temp variables live on the local data stack only while the block runs, so write them before you read them.

What is load memory and work memory in an S7-1500?

Load memory is on the SIMATIC Memory Card and holds the whole project. Work memory holds the runtime-relevant code and data while the CPU runs. Retentive memory keeps values marked Retain through a power cycle.

How do I make a variable retentive in SCL?

In an optimized FB, set the Retain column of the variable in the block interface to Retain (or Set in IDB). In a global DB, tick Retain for the member. Non-retain values return to their start values after power OFF and ON.

How do I convert Int to Real in SCL?

Use INT_TO_REAL, or NORM_X and SCALE_X for analog values. To go back from Real to a whole number, use TRUNC to cut the decimals or ROUND for the nearest whole number.

What is slice access in SCL?

Slice access reads part of a bit-string tag directly: #Word.%X2 is bit 2, #Word.%B0 is the low byte. It works on S7-1200 and S7-1500 and replaces masks and shifts.

Reviewed by Bhawesh Kumar Singh Industrial Automation Trainer and Industry 4.0 Consultant · Softwell Automation · 21+ years industry experience

Get the full syllabus + free demo class

Share your details — a Softwell training advisor will call you within 24 hours with batch dates, fees and hardware access options.

No spam. Used only to share course details for this enquiry.

Learn with practical industrial examples

Join live online, Pune classroom or corporate in-plant automation training.

Request Course Details
Verified learning pathway

Discuss This Technical Course

Explore practical curriculum, software, hardware and batch options for this technology.

Content reviewed: 1 August 2026

Siemens PLC & TIA Portal Learning Path

Continue with the related Siemens PLC tutorials in this practical learning series.

  1. SCL vs Ladder Logic
  2. Upload PLC Program
  3. TIA Selection Tool
  4. Analog Input Scaling
  5. PLC Counters
  6. PLC Timers
  7. Addressing & Data Types
  8. Hardware & PLC Tags
  9. OB, FB, FC & DB
  10. Data Types & Memory in SCL
☎ Call WhatsApp ✉ Email Enquire Now