SystemTest × Positron

Lamp panel
Programming

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 tasks
Buttons and lamps
Buttons → Siemens S7-1214 → Lamps
Illustrative diagram
8 taskschoose one to solve
3 difficulty levelsfrom basic logic to counting
2 languagesSCL and Ladder
Three difficulty levels

Lamp panel tasks

Choose 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.

Difficulty 01

Basic logic

Task 01

A lamp and a button

Lamp 1 may be on while you hold button 1 down.

Task 02

Two buttons together

Lamp 3 may be on only when both buttons 1 and 3 are pressed.

Task 03

Three lamps, one button

All three lamps turn on while you hold button 2 down.

Difficulty 02

Conditions and memory

Task 04

An inhibiting condition

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.

Task 05

Switch on and off

Pressing button 1 turns lamp 1 on, and it stays on. Pressing button 2 turns lamp 1 off.

Difficulty 03

Timing and counting

Task 06

Flashing lamps

All three lamps must flash while button 1 is held down.

Task 07

A short light pulse

Pressing button 1 turns all three lamps on, but only for a short time.

Task 08

Count the presses

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.

Programming guide

Start building your solution

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.

01

Choose a task

Read the requirements of your chosen task and think about which buttons should affect which lamps.

02

Choose a programming language

SCL is a text-based language. Ladder is a visual language using contacts, coils and other logic blocks.

03

Open the blue function block

Double-click the blue function block for your chosen language. Use the function block rather than the nearby green function or purple data block.

Find the right block in the project tree

Open Program blocks and select the branch for your language. For SCL, open Funktsiooni blokk (SCL) [FB2]. For Ladder, open Funktsiooni blokk (ladder) [FB1].

Project tree: SCL and Ladder function blocks. Click the image to enlarge.

The variables are already prepared

Input

The button inputs are Nupp_1, Nupp_2 and Nupp_3.

Output

The lamp outputs are Lamp_1, Lamp_2 and Lamp_3.

Static

Add your own helper variables under Static if needed. Set their type in the Data type column.

Bool — two possible values: TRUE or FALSE.Int — an integer from −32768 to 32767.
SCL · text-based programming

Write your code in the white area

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 ;.

SCL editor: variable table and code area.

IF · conditional execution

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;
Example from the programming guide. Click to enlarge.

This is a syntax example. If the block runs repeatedly while the condition remains true, the value increases on every execution.

AND · OR · NOT

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;
Example from the programming guide. Click to enlarge.
Ladder · visual programming

Build the logic in a Network

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.

Ladder editor: variable table and Network 1.

Find the bit logic operations

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.

Basic instructions: bit logic operations and the timer and counter groups.

A contact and a coil

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.

Example: Nupp_1 controls output Lamp_3.

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.

Ready to test?

Compile and test with a team member

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.