S7-1200 FBD Programming: Converting S7-1500 Function Blocks

David Krause10 min read
SiemensTIA PortalTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview

Siemens S7-1200 and S7-1500 controllers both support Function Block Diagram (FBD) programming in TIA Portal, but the available instruction set, firmware features, and library blocks differ between the two families. Programs originally authored in S7-1500 FBD must be re-mapped to the S7-1200 instruction catalog because the S7-1500 includes additional data types, optimized blocks, and arithmetic/logic extensions not present on every S7-1200 CPU firmware version.

This reference documents the exact procedure for converting an S7-1500 FBD block into an equivalent S7-1200 FBD block using the TIA Portal editor, identifies the S7-1200 firmware constraints that block direct porting, and provides working FBD patterns for the most common conversion cases: string comparison, length optimization, IEC timers/counters, and arithmetic blocks.

Prerequisites

  • TIA Portal V15.1 or later (V17 or V18 recommended for current S7-1200 firmware coverage). Download: TIA Portal - Siemens Industry Online Support.
  • STEP 7 Basic (S7-1200 only) or STEP 7 Professional (S7-1200/S7-1500).
  • CPU firmware: S7-1200 CPU firmware V4.2 or later is required to support the FBD language set described here. Earlier firmware (V4.0, V4.1) supports FBD but lacks several instructions introduced for S7-1500 parity. Reference: S7-1200 programmable controller system manual.
  • Source project containing the S7-1500 FBD block exported as a TIA Portal archive (.zap) or opened in the same TIA Portal instance.
  • Target S7-1200 CPU selected in the project (CPU 1211C, 1212C, 1214C, 1215C, 1217C, or 1214C-F/1215C-F).

FBD Language Availability in S7-1200

The S7-1200 supports the following programming languages defined in IEC 61131-3:

Language S7-1200 S7-1500 Editor Switch Path
LAD (Ladder) Yes Yes Project tree → block → right-click → Properties → General → Language
FBD (Function Block Diagram) Yes (FW V4.0+) Yes Same as above
ST/SCL (Structured Text) Yes (S7-1200 with SCL option) Yes Same as above
GRAPH No Yes N/A
SFC Limited (V4.x optional) Yes Properties → Language

Function Block Diagram in the S7-1200 implements the IEC 61131-3 graphical representation. Blocks are connected with signal flow lines; each block executes left-to-right, top-to-bottom. Unlike the S7-1500, the S7-1200 does not support GRAPH sequential programming, motion control FBD blocks, or several extended instruction extensions introduced in TIA Portal V16+ for the S7-1500 platform.

Method 1 - Switch the Block Language in TIA Portal

The fastest path to an S7-1200 FBD block is to copy the S7-1500 block and switch the editor language. TIA Portal automatically inserts an IEC-conformant equivalent in the target language.

  1. Open the S7-1500 project containing the source FBD block.
  2. In the project tree, right-click the block (FB, FC, or OB) and select Copy.
  3. Right-click the target S7-1200 Program blocks folder and select Paste. TIA Portal prompts: "Convert and insert as new block?" Choose Yes.
  4. Open the pasted block. The editor opens in FBD if the source was FBD.
  5. If the block must be in LAD/FBD interchangeably, right-click the block → PropertiesGeneralLanguage and select FBD.

This method works for blocks that use only instructions present in both catalogs. The compiler reports unsupported instructions in the Information window when the S7-1500-only instructions are referenced. Each error identifies the network and instruction so you can substitute the equivalent S7-1200 instruction manually.

Method 2 - LAD Equivalence Then Switch Back to FBD

For blocks written in FBD where the engineer is more familiar with LAD, switching the block to LAD often reveals which IEC elementary functions and function blocks are used. The resulting LAD network is then switched back to FBD, and TIA Portal re-renders the connections graphically. This two-step conversion exposes implicit enable inputs (EN/ENO) that are not always visible in the FBD view.

  1. Open the S7-1500 FBD block.
  2. Right-click the block → Properties → change Language to LAD → OK.
  3. Verify the LAD rendering. EN/ENO behavior is shown explicitly.
  4. Switch Language back to FBD → OK. The FBD is regenerated from the LAD representation.
  5. Copy the regenerated block into the S7-1200 project (Method 1, step 3).

S7-1500 Instructions That Do Not Port Directly to S7-1200

S7-1500 Instruction Category S7-1200 Status Recommended Substitute
CALCULATE (with SCL expression) Math Not available (use CALCULATE with expression box on FW V4.2+) CALCULATE box, multiple arithmetic nodes, or move to SCL
SCALE_X / SCALE_BC Conversion SCALE_X / NORM_X available; SCALE_BC is S7-1500 only Implement with MUL + ADD
TIME_TCK (64-bit system time) Timer Returns 32-bit (DTL) on S7-1200; 64-bit LDT on S7-1500 Use DTL time stamp + slice operations
DPRD/DPRW (DP slave diagnostics) PROFIBUS Not available on S7-1200 None - PROFINET only
Recipe / Data Log extended blocks Recipies Basic recipe functions only Simplify recipe structure
MC_MoveAbsolute, MC_Power (motion) Motion Limited to S7-1200 motion-capable CPUs Use PWM or analog output
File operations (FileReadC, FileWriteC) File system Not available on S7-1200 Use DataLog to memory card
String with WSTRING (UTF-16) Strings S7-1200 FW V4.2+ adds WSTRING support STRING (ASCII) for V4.0/V4.1

String Handling: SCL to FBD Conversion

String instructions in S7-1200/S7-1500 FBD are located under Basic Instructions → String + Char. The following SCL example illustrates the typical input - the FBD equivalent uses the dedicated string function blocks.

SCL Source (S7-1500)

// Compare two strings and copy max-length to output
IF LEN(IBN_Enter) > LEN(IBN_Confirm) THEN
   IBN_Out := IBN_Enter;
ELSE
   IBN_Out := IBN_Confirm;
END_IF;

Equivalent S7-1200 FBD

The FBD implementation uses LEN (S_CONV / string length), GT (greater-than comparison), and MOVE_BLK or S_MOVE (string copy). Insert the following nodes from the Instructions task card:

FBD Node Location in TIA Portal Function
LEN (String length) Basic Instructions → String + Char → ... Returns INT length of STRING input
GT (Real/Int) Basic Instructions → Comparator operations Compares lengths
MAX (Real/Int) Basic Instructions → Math functions → MIN/MAX Optional: choose longer length
S_MOVE (Assign string) Basic Instructions → String + Char → MOVE Copies source STRING to target
SWAP Basic Instructions → String + Char Reverses string content

Implementation pattern in FBD:

  1. Insert LEN block, connect IBN_Enter to IN, output to a temporary INT tag iLenA.
  2. Insert a second LEN block for IBN_Confirm, output to iLenB.
  3. Insert GT (greater-than), IN1 = iLenA, IN2 = iLenB, output = bLongerA.
  4. Insert two S_MOVE blocks (one for each source). Wire bLongerA to the EN of the first S_MOVE and its negation (NOT) to the second S_MOVE EN. The outputs both connect to IBN_Out.

String Length Optimization

Declaring HMI tags as the default STRING (254 characters) wastes PLC work memory. Tighten the declared length to the largest value the field can ever contain. This reduces per-instance memory cost across the data block.

Declaration Memory per instance Use when
STRING 256 bytes (254 chars + 2 length) Default; use only if max is unknown
STRING[20] 22 bytes Names, short IDs, batch codes
STRING[50] 52 bytes Operator messages, error text
WSTRING[80] 164 bytes (UTF-16 + 2 length) FW V4.2+ only, multi-byte text
Note: Always compare strings of identical declared length. The S7-1200 string comparator pads the shorter string with null (0x00) bytes up to its declared length. A STRING[20] input is not equal to a STRING[50] input even if the visible text is identical, because the trailing bytes of the longer tag differ.

IEC Timer and Counter Blocks in FBD

The S7-1200 uses simplified IEC timers. Each timer is a single FB instance (TP, TON, TOF, TONR, RT) in FBD:

FBD Block Function IEC Type
TP (Pulse) Generate fixed-width pulse on rising edge IEC_TIMER
TON (On-delay) Delay rising edge by PT IEC_TIMER
TOF (Off-delay) Delay falling edge by PT IEC_TIMER
TONR (Retentive on-delay) Accumulate on-time; reset explicitly IEC_TIMER
RT (Reset) Reset TONR accumulator IEC_TIMER
CTU (Up counter) Count up to CV IEC_Counter
CTD (Down counter) Count down to 0 IEC_Counter
CTUD (Up/down counter) Bidirectional count IEC_Counter

Each instance occupies a separate Instance DB when the timer is dropped onto a network. To share a multi-instance, open the parent FB and drag the timer into the FB's Static section; the compiler generates a multi-instance inside the parent DB.

Program Flow Control (OBs) Compatibility

Organization blocks differ between families. Verify the following OBs exist in the S7-1200 target before copying FBD logic that calls them:

OB S7-1200 S7-1500 Purpose
OB1 Yes (Main, cyclic) Yes Cyclic main
OB30-OB38 Yes (cyclic interrupt) Yes Time-of-day interrupts
OB82 Yes Yes I/O fault
OB121 Yes Yes Programming error
OB122 Yes Yes I/O access error
OB80 No Yes Time error (S7-1500 only)
OB83 / OB86 / OB88 Limited Yes Module/prognosis errors

Verification Procedure

  1. Compile the S7-1200 block. Open Project tree → Program blocks → right-click → Compile → Software (rebuild all blocks). The Information window must show zero errors.
  2. Cross-reference tags via Options → Cross-reference. Every tag used in the S7-1500 source must be declared in the S7-1200 DB or symbol table.
  3. Download to the target CPU using Online → Download to device. Select Stop all on first download if the controller is in RUN.
  4. Monitor the FBD online. Click the glasses icon to enter Monitor mode. Verify EN/ENO at each block - a missing EN indicates the ladder/contact was not wired.
  5. Force and watch tags via Project tree → Watch and force tables. Confirm that the S7-1200 string comparison produces the same result as the S7-1500 source for three sample pairs (equal length equal content, equal length different content, different length).
  6. Cycle time: open Online → Diagnostics → Cycle time / memory. The S7-1200 FBD block should run within the configured OB1 maximum cycle time. If the source FBD used S7-1500-optimized arithmetic, the S7-1200 may take 5-15% longer per scan.

Troubleshooting Matrix

Symptom Compile Error / Behavior Root Cause Resolution
Block icon greyed out in Instructions pane FBD node not insertable Instruction only available in S7-1500 Use SCL block or substitute IEC elementary block
Compiler reports "Instruction not supported on CPU" Compile error Firmware too old for instruction Upgrade CPU firmware to V4.2+ or substitute
String compare returns unexpected result Runtime mismatch Tags have different declared lengths Match STRING[20] = STRING[20] across the comparison
ENO = 0 at the end of the network ENO false Division by zero, invalid REAL, or array bound Insert EN check / check input validity before math
Multi-instance DB not created automatically Compiler warning Timer/counter was placed outside parent FB Drag timer into FB Static section
Download rejected: "CPU is in RUN" Online error Existing program holds resources Stop CPU before download (Online → Stop → Download)
Tag marked "Memory area not accessible" Online monitor red Optimized block access and absolute addressing mix Set DB property "Optimized block access" = unchecked or change accesses to symbolic
WSTRING block missing in Instructions pane Cannot drop WSTRING CPU firmware < V4.2 Use STRING or upgrade firmware

Related Standards and References

How do I switch an existing S7-1500 FBD block to FBD on an S7-1200 in TIA Portal?

Copy the S7-1500 block, paste it into the S7-1200 Program blocks folder, and confirm the conversion prompt. Then open the block, right-click the editor background, choose Properties, and set the Language to FBD. Recompile and address any unsupported-instruction errors reported in the Information window.

Which S7-1500 instructions cannot be used on an S7-1200?

The S7-1200 lacks GRAPH sequential blocks, most PROFIBUS DP slave diagnostics, motion control blocks (except on motion-capable CPUs), extended recipe / file system blocks, the SCALE_BC instruction, and the 64-bit LDT system time type. WSTRING and CALCULATE with expressions are also unavailable on firmware below V4.2.

Why do S7-1200 string comparisons return unexpected results?

String comparison is byte-wise up to the declared length of each tag. If two STRING tags have different declared lengths, the shorter is padded with null bytes, and the comparison fails. Always match the declared length (e.g. STRING[20] compared to STRING[20]) for predictable results.

What is the memory cost of declaring an HMI string as STRING[20] instead of STRING?

A default STRING reserves 256 bytes (254 characters + 2 length bytes). Declaring STRING[20] reduces this to 22 bytes per instance. Across hundreds of HMI tags this saves significant work memory on the S7-1200.

Can I monitor an S7-1200 FBD block online and force tags during commissioning?

Yes. Open the block in the TIA Portal editor, click the Monitor (glasses) icon to view live EN/ENO and tag values. Use a Watch table under Project tree → Watch and force tables to force inputs and observe outputs during commissioning.

Back to blog