← All articles
SIEMENS TIA PORTAL

How to export ladder logic to TIA Portal

Logivyx engineering team · · 5 min read

There is no "import ladder" button in TIA Portal. If your logic lives in another tool and needs to end up on an S7-1200 or S7-1500, the reliable route is SCL source files. Here's what works, what doesn't, and a checklist so the first compile isn't a wall of errors.

The four ways code gets into TIA Portal

RouteCarriesFrom outside TIA?Notes
External source files (.scl)SCL (Structured Text)YesPlain text. Import, then "Generate blocks from source". Supported for S7-1200/1500 since TIA Portal V13.
TIA Portal Openness (SimaticML XML)All languages, including LADPossible, but hardNeeds the Openness option and a scripted application. The XML schema is version-specific and strict.
Global / project librariesAll languagesNoTIA-to-TIA only. Great for reuse, useless for migration from another vendor.
Reference project / drag-and-dropAll languagesNoCopy blocks between two TIA projects.

So in practice, getting ladder logic from another platform into TIA Portal means one of two things: generate SimaticML XML for each version of TIA you support (fragile), or translate the logic to SCL and import it as a source file (robust). Almost every migration tool takes the SCL route.

Expect SCL, not rungs. When ladder is exported as SCL, it arrives in TIA Portal as SCL code, not as LAD networks. TIA Portal cannot convert SCL blocks back to LAD. If your customer insists on seeing ladder in TIA, agree that up front: it means re-drawing in TIA or a much more involved XML route.

Importing an SCL source file, step by step

  1. In the project tree, expand your PLC and open External source files.
  2. Choose Add new external file and select your .scl file. TIA Portal stores a copy in the project.
  3. Right-click the file and choose Generate blocks from source. The FBs, FCs and DBs appear under Program blocks.
  4. Compile the PLC software. Errors show with block and line numbers — fix them in the source and generate again, or in the generated block directly.
  5. Create the PLC tag table for physical I/O (%I, %Q) if it isn't in the source, and call your blocks from OB1 (Main).

What an SCL source file looks like

This is the same form TIA Portal uses itself when you right-click a block and choose Generate source from blocks. A valve with a feedback timeout:

FUNCTION_BLOCK "FB_Valve"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
   VAR_INPUT
      OpenCmd   : Bool;    // command from sequence / HMI
      FbOpen    : Bool;    // limit switch: valve open
      FbClosed  : Bool;    // limit switch: valve closed
      Reset     : Bool;
      Timeout   : Time := T#5S;
   END_VAR
   VAR_OUTPUT
      OutOpen   : Bool;    // solenoid output
      Fault     : Bool;
   END_VAR
   VAR
      tOpen {InstructionName := 'TON_TIME'; LibVersion := '1.0'} : TON_TIME;
      tClose {InstructionName := 'TON_TIME'; LibVersion := '1.0'} : TON_TIME;
   END_VAR

BEGIN
   #OutOpen := #OpenCmd AND NOT #Fault;

   // Commanded open but no open feedback in time
   #tOpen(IN := #OutOpen AND NOT #FbOpen, PT := #Timeout);
   // Commanded closed but no closed feedback in time
   #tClose(IN := NOT #OutOpen AND NOT #FbClosed, PT := #Timeout);

   IF #tOpen.Q OR #tClose.Q THEN
      #Fault := TRUE;
   ELSIF #Reset THEN
      #Fault := FALSE;
   END_IF;
END_FUNCTION_BLOCK

A few things a plain IEC 61131-3 Structured Text file won't have, and that the translation must add:

  • Block names in double quotes ("FB_Valve") and global tags as "DB_Line".Speed or "Start_PB".
  • Local variables prefixed with # in the code body.
  • The BEGIN keyword between declarations and code.
  • Block attributes such as S7_Optimized_Access and a VERSION.
  • Timer instances declared as multi-instances (TON_TIME) inside the FB rather than as global timers.

Checklist before you export

  • Data types. In TIA, Int is 16-bit and DInt is 32-bit; Real is 32-bit float. Make sure counters and totals that can exceed 32,767 are DInt.
  • Integer division. 7 / 2 on integers gives 3. Convert to Real first where it matters.
  • Timers and edges are instances. Every TON, R_TRIG and CTU needs its own instance and must be called every scan — don't call a timer only inside an IF.
  • Retentive data. Retentivity is set per DB / variable in TIA. Note which variables must survive power loss and set them after import.
  • Physical I/O. Keep logic on symbolic names and map them to %I/%Q in the PLC tag table once the hardware configuration exists.
  • Reserved words and name lengths. Rename anything that clashes with an SCL keyword or instruction name.
  • Test before you export. Simulate the logic first; debugging a translation and a logic bug at the same time is painful.

How Logivyx exports to TIA Portal

In Logivyx, Ladder Diagram generates Structured Text, so ladder, ST and the logic behind sequences share one execution path. That same logic can be exported as SCL for TIA Portal — and as L5X for Rockwell Studio 5000.

A typical way OEMs use it:

  1. Build screens and logic together in Logivyx Studio and test them on the built-in simulator.
  2. Run the machine on Logivyx's embedded soft PLC — or, if a customer's plant standard requires Siemens, export the logic as SCL.
  3. Import it into TIA Portal with the steps above, compile, map the I/O and download to the S7-1200/1500.
  4. Keep Logivyx as the HMI on top of the S7, reading data blocks over S7 communication.

Your logic is never locked into one runtime. If you're writing ST from scratch, our Structured Text examples are a good starting point.

FREE TRIAL

Try it on your own project.

Design screens, write Ladder or Structured Text, and run both on the built-in simulator — or connect to your own Siemens, Allen-Bradley or Mitsubishi PLC. No separate PLC needed.