ExamRobotic

Ladder logic (LAD) in TIA Portal

Level: Intermediate 7 min read 43 questions

LAD is Siemens’ name for ladder logic, the contact-based language. In the international standard IEC 61131-3 it is called LD (Ladder Diagram), and in German-speaking countries KOP (Kontaktplan). It is the most widely used language on machines because it looks like an electrical schematic: any technician who can read schematics can follow a ladder program, which makes troubleshooting on the plant floor much easier. This topic explains its basic instructions as they are used in TIA Portal with the S7-1200 and S7-1500.

How to read a network

A ladder program is divided into networks (also called rungs). Each network starts at a vertical bar on the left, which represents the “power supply”, and ends in one or more output instructions, such as a coil. You read it like a circuit: if there is a path that “conducts” from the bar to the coil, the coil is energised. The result of evaluating the path is called the RLO (result of logic operation).

Remember what you saw in the scan cycle: networks are executed from top to bottom and each network from left to right, once per scan.

Stop Overload_OK Start Motor Motor coil
Start/stop with seal-in in LAD. The stop button and the overload relay are wired normally closed, which is why the program uses normally open contacts for them: they are at 1 while everything is fine.

Contacts

Contacts in series make an AND function; contacts in parallel, an OR function. It is the same old Boolean logic, drawn.

Typical mistakeConfusing the program contact with the physical contact. A stop push button wired normally closed gives a 1 on the input at rest; in the program it is checked with a normally open contact, which conducts while the stop is not pressed. If a normally closed contact is used, the machine would only run with the stop pressed.

Coils

With S and R, the value is stored between scans. If an S and an R on the same operand both run in the same scan, the last one executed wins, as with the double coil.

SR and RS flip-flops

TIA Portal also has flip-flops as a single instruction, where the priority is clear:

For a motor it is usually preferable for stop to have priority, that is, a reset-dominant flip-flop: if start and stop are pressed at the same time, the motor does not start.

Edges

A positive edge contact -|P|- conducts only in the scan in which its operand goes from 0 to 1; the negative edge contact -|N|-, in the scan in which it goes from 1 to 0. Each one needs its own memory bit to remember the previous state. There are also the R_TRIG and F_TRIG instructions, which store that state in their own instance data block.

IEC timers

Timers have an input IN, a preset time PT (for example T#5s), an output Q and the elapsed time ET. Each timer needs its own instance (a data block where it stores its state). The three most used:

IN TON Q TOF Q TP Q PT
The same input signal on all three timers. The second IN pulse is shorter than PT: the TON never turns on, the TOF stretches it and the TP gives its full pulse.

IEC counters

Counters count edges, not levels: even if CU stays at 1 for many scans, it only adds one.

Compare, move and calculate

Tags, addresses and data types

Every signal has an address: %I0.0 is bit 0 of input byte 0, %Q4.1 bit 1 of output byte 4, and %M10.0 an internal memory bit. In TIA Portal you do not program with bare addresses, but with named tags, defined in the PLC tag table: "Start" instead of %I0.1. The program is much easier to understand and, if a terminal changes, only the address in the table needs changing.

TypeWhat it storesExample
BoolOne bit: 0 or 1State of a sensor
Int16-bit integer, from −32768 to 32767Raw value of an analog input
DInt32-bit integerLarge part counter
RealNumber with decimalsTemperature in °C
TimeDurationT#2s500ms

Blocks

Typical mistakes in LAD

Summary

Test what you have learned

43 practical questions with explained answers. Free, no sign-up.

Start the test