After completing the configuration, parameter assignment, and program creation and establishing the online connection, you can download complete user programs or individual blocks to a programmable controller. To test individual blocks, you must download at least one organization block (OB) and the function blocks (FB) and functions (FC) called in the OB and the data blocks (DB) used. To download the system data created when the hardware was configured, the networks configured, and the connection table created to the programmable controller, you download the object “System Data".
You download user programs to a programmable controller using the SIMATIC Manager, for example, during the end phase of the program testing or to run the finished user program.
Relationship - Load Memory and Work Memory
The complete user program is downloaded to the load memory; the parts relevant to program execution are also loaded into the work memory.
CPU Load Memory
- The load memory is used to store the user program without the symbol table and the comments (these remain in the memory of the programming device).
- Blocks that are not marked as required for startup will be stored only in the load memory.
- The load memory can either be RAM, ROM, or EPROM memory, depending on the programmable controller.
CPU Work Memory
The work memory (integrated RAM) is used to store the parts of the user program required for program processing.
Possible Downloading/Uploading Procedures
You use the download function to download the user program or loadable objects (for example, blocks) to the programmable controller. If a block already exists in the RAM of the CPU, you will be prompted to confirm whether or not the block should be overwritten.
- You can select the loadable objects in the project window and download them from the SIMATIC Manager (menu command: PLC > Download).
- When programming blocks and when configuring hardware and networks you can directly download the object you were currently editing using the menu in the main window of the application you are working with (menu command: PLC > Download).
- Another possibility is to open an online window with a view of the programmable controller (for example, using View > Online or PLC > Display Accessible Nodes) and copy the object you want to download to the online window.
Alternatively you can upload the current contents of blocks from the RAM load memory of the CPU to your programming device via the load function.
The STEP 7 programming software allows you to structure your user program, in other words to break down the program into individual, self-contained program sections. This has the following advantages:
- Extensive programs are easier to understand.
- Individual program sections can be standardized.
- Program organization is simplified.
- It is easier to make modifications to the program.
- Debugging is simplified since you can test separate sections.
- Commissioning your system is made much easier.
The example of an industrial blending process illustrated the advantages of breaking down an automation process into individual tasks. The program sections of a structured user program correspond to these individual tasks and are known as the blocks of a program.
Block Types
There are several different types of blocks you can use within an S7 user program:
Block | Brief Description Of Function |
Organization blocks (OB) | OBs determine the structure of the user program. |
System function blocks (SFB) and system functions (SFC) | SFBs and SFCs are integrated in the S7 CPU and allow you access to some important system functions. |
Function blocks (FB) | FBs are blocks with a "memory" which you can program yourself. |
Functions (FC) | FCs contain program routines for frequently used functions. |
Instance data blocks (instance DB) | Instance DBs are associated with the block when an FB/SFB is called. They are created automatically during compilation. |
Data blocks (DB) | DBs are data areas for storing user data. In addition to the data that are assigned to a function block, shared data can also be defined and used by any blocks. |
OBs, FBs, SFBs, FCs, and SFCs contain sections of the program and are therefore also known as logic blocks. The permitted number of blocks per block type and the permitted length of the blocks is CPU-specific.
Introduction to Data Types and Parameter Types
All the data in a user program must be identified by a data type. The following data types are available:
- Elementary data types provided by STEP 7
- Complex data types that you yourself can create by combining elementary data types
- Parameter types with which you define parameters to be transferred to FBs or FCs
General Information
Statement List, Ladder Logic, and Function Block Diagram instructions work with data objects of specific sizes. Bit logic instructions work with bits, for example. Load and transfer instructions (STL) and move instructions (LAD and FBD) work with bytes, words, and double words.
A bit is a binary digit "0" or "1." A byte is made up of eight bits, a word of 16 bits, and a double word of 32 bits.
Math instructions also work with bytes, words, or double words. In these byte, word, or double word addresses you can code numbers of various formats such as integers and floating-point numbers.
When you use symbolic addressing, you define symbols and specify a data type for these symbols (see table below). Different data types have different format options and number notations.
This chapter describes only some of the ways of writing numbers and constants. The following table lists the formats of numbers and constants that will not be explained in detail.
Format | Size in Bits | Number Notation |
Hexadecimal | 8, 16, and 32 | B#16#, W#16#, and DW#16# |
Binary | 8, 16, and 32 | 2# |
date | 16 | D# |
time | 32 | T# |
Time of day | 32 | TOD# |
Character | 8 | 'A' |
Each elementary data type has a defined length. The following table lists the elementary data types.
Type and Description | Size in Bits | Format Options | Range and Number Notation (lowest to highest value)_ | Example |
BOOL(Bit) | Boolean text | TRUE/FALSE | TRUE | |
BYTE (Byte) | 8 | Hexadecimal number | B16#0 to B16#FF | L B#16#10 L byte#16#10 |
WORD (Word) | 16 | Binary number Hexadecimal number BCD Decimal number unsigned | 2. 0 to 2#1111_1111_1111_1111 W#16#0 to W#16#FFFF C#0 to C#999 B#(0.0) to B#(255.255) | L 2#0001_0000_0000_0000 L W#16#1000 L word16#1000 L C#998 L B#(10,20) L byte#(10,20) |
DWORD (Double word) | 32 | Binary number Hexadecimal number Decimal number unsigned | 2#0 to 2#1111_1111_1111_1111 1111_1111_1111_1111 DW#16#0000_0000 to DW#16#FFFF_FFFF B#(0,0,0,0) to B#(255,255,255,255) | 2#1000_0001_0001_1000_ 1011_1011_0111_1111 L DW#16#00A2_1234 L dword#16#00A2_1234 L B#(1, 14, 100, 120) L byte#(1,14,100,120) |
INT (Integer) | 16 | Decimal number signed | -32768 to 32767 | L 1 |
DINT (Integer, 32 bits) | 32 | Decimal number signed | L#-2147483648 to L#2147483647 | L L#1 |
REAL (Floating-point number) | 32 | IEEE Floating-point number | Upper limit: 3.402823e+38 Lower limit: 1.175 495e-38 | L 1.234567e+13 |
S5TIME (SIMATIC time) | 16 | S7 time in steps of 10 ms (default) | S5T#0H_0M_0S_10MS to S5T#2H_46M_30S_0MS and S5T#0H_0M_0S_0MS | L S5T#0H_1M_0S_0MS L S5TIME#0H_1H_1M_0S_0MS |
TIME (IEC time) | 32 | IEC time in steps of 1 ms, integer signed | -T#24D_20H_31M_23S_648MS to T#24D_20H_31M_23S_647MS | L T#0D_1H_1M_0S_0MS L TIME#0D_1H_1M_0S_0MS |
DATE (IEC date) | 16 | IEC date in steps of 1 day | D#1990-1-1 to D#2168-12-31 | L D#1996-3-15 L DATE#1996-3-15 |
TIME_OF_DAY (Time) | 32 | Time in steps of 1 ms | TOD#0:0:0.0 to TOD#23:59:59.999 | L TOD#1:10:3.3 L TIME_OF_DAY#1:10:3.3 |
CHAR (Character) | 8 | ASCII characters | 'A','B' etc. | L 'E' |
Parameter Types
In addition to elementary and complex data types, you can also define parameter types for formal parameters that are transferred between blocks. STEP 7 recognizes the following parameter types:
- TIMER or COUNTER: this specifies a particular timer or particular counter that will be used when the block is executed. If you supply a value to a formal parameter of the TIMER or COUNTER parameter type, the corresponding actual parameter must be a timer or a counter, in other words, you enter "T" or "C" followed by a positive integer.
- BLOCK: specifies a particular block to be used as an input or output. The declaration of the parameter determines the block type to be used (FB, FC, DB etc.). If you supply values to a formal parameter of the BLOCK parameter type, specify a block address as the actual parameter. Example: “FC101" (when using absolute addressing) or “Valve" (with symbolic addressing).
Parameter | Capacity | Description |
TIMER |
| Indicates a timer to be used by the program in the called logic block. Format: T1 |
COUNTER | 2 bytes | Indicates a counter to be used by the program in the called logic block. Format: C10 |
BLOCK_FB BLOCK_FC BLOCK_DB BLOCK_SDB | 2 bytes | Indicates a block to be used by the program in the called logic block. Format: FC101 DB42 |