A lamp and a button
Lamp 1 may be on while you hold button 1 down.
The lamp panel is designed to demonstrate how to program a PLC (Programmable Logic Controller). It has three buttons and three lamps, all connected to the PLC. The task is to write a program that links the inputs to the outputs in a specified way.
Choose one of eight tasks and make the three lamps follow your program. Write your solution in TIA Portal 18 (PLC programming software), using SCL (Structured Control Language) or Ladder (a language resembling an electrical circuit diagram).
View tasksChoose one task that interests you. The difficulty levels help you find a starting point. All tasks use the same panel with three buttons and three lamps.
Lamp 1 may be on while you hold button 1 down.
Lamp 3 may be on only when both buttons 1 and 3 are pressed.
All three lamps turn on while you hold button 2 down.
While button 1 is held down, lamp 1 must be on. If buttons 1 and 2 are pressed together, none of the lamps may be on.
Pressing button 1 turns lamp 1 on, and it stays on. Pressing button 2 turns lamp 1 off.
All three lamps must flash while button 1 is held down.
Pressing button 1 turns all three lamps on, but only for a short time.
Pressing button 2 twice turns all three lamps on. A single press does nothing. Button 3 resets the press counter and turns the lamps off.
The setup uses a Siemens S7-1214 controller and TIA Portal 18. SystemTest provides the computer. A SystemTest team member will help you compile the program and download it to the controller.
Read the requirements of your chosen task and think about which buttons should affect which lamps.
SCL is a text-based language. Ladder is a visual language using contacts, coils and other logic blocks.
Double-click the blue function block for your chosen language. Use the function block rather than the nearby green function or purple data block.
Open Program blocks and select the branch for your language. For SCL, open Funktsiooni blokk (SCL) [FB2]. For Ladder, open Funktsiooni blokk (ladder) [FB1].
The button inputs are Nupp_1, Nupp_2 and Nupp_3.
The lamp outputs are Lamp_1, Lamp_2 and Lamp_3.
Add your own helper variables under Static if needed. Set their type in the Data type column.
TRUE or FALSE.Int — an integer from −32768 to 32767.In the open SCL block, the white area is where you write the program. The variable table is above it. Each SCL statement ends with a semicolon ;.
IF checks a condition. When #Bool is true, this example increases #Int by one. END_IF; closes the conditional block.
IF #Bool THEN
#Int := #Int + 1;
END_IF;This is a syntax example. If the block runs repeatedly while the condition remains true, the value increases on every execution.
AND requires both conditions to be true. OR requires at least one true condition. NOT reverses a Boolean value. Use parentheses to make the grouping of conditions clear.
IF (#Int < 5) AND #Nupp_1 OR NOT #Nupp_2 THEN
#Int := 5;
END_IF;In Ladder, build your program in the Network area. The variable table works as it does in SCL: inputs and outputs are already prepared, and you can add helper variables under Static.
On the right, open Basic instructions → Bit logic operations. Drag the required element onto the Network line. Hover over an element to read what it does.
In the guide example, Lamp_3 takes the value of input Nupp_1. When the button is active, the condition on the left is true and the lamp output becomes TRUE.
Contact —| |— checks its assigned Boolean variable. The condition is satisfied when the value is true.
Coil —( )— sets the output to TRUE when the condition on its left is satisfied, and to FALSE otherwise.
When you have written your program, ask a SystemTest team member for help. They will help you compile it and download it to the controller. Then use the buttons and lamps to check every condition of your chosen task.