S7-1200 LED Instruction: Resolving Error 16#8091 in TIA Portal

David Krause11 min read
S7-1200SiemensTroubleshooting
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

S7-1200 LED Instruction: Resolving Error 16#8091 in TIA Portal

The "LED" instruction (Read LED status) is part of the extended diagnostics instruction set for the SIMATIC S7-1200 and S7-1500 families in TIA Portal. The instruction queries the current state of a specific LED (RUN/STOP, ERROR, MAINT, LINK, etc.) of the CPU or of an interface module and returns it to the user program. When the Ret_Val returns 16#8091, the call is technically correct, but the input parameters do not address a valid LED-capable module or LED number. This article documents the root cause, the correct way to determine the LADDR hardware identifier, and the proper selection of the LED parameter so the instruction returns the on/off state without error.

1. Problem Description

A user program calls the LED extended instruction from the TIA Portal library on a SIMATIC S7-1200 CPU (firmware V4.x). The block compiles cleanly, is downloaded to the CPU, and is executed cyclically, but the Ret_Val output returns:

  • 16#8091 — most common
  • Other error codes such as 16#8090 or 16#8092 may also be observed depending on what the user typed into LADDR and LED.

The two parameters that cause the error are:

  1. LADDR — the user is unsure which hardware identifier (HW-ID) corresponds to the CPU, and types an arbitrary value such as 65, 0, or a duplicate of another module's HW-ID.
  2. LED — the user is unsure which numeric constant selects which physical LED on the face of the CPU.

Because the function is not a high-frequency call, the error typically does not crash the CPU but does prevent the diagnostic logic from working. The RUN LED still flashes; the application that needs to know whether the MAINT or ERROR LED is on simply never gets a correct answer.

2. Root Cause: Invalid Hardware Identifier on LADDR

The LED instruction does not address modules by slot number (1, 2, 3, ...), I/O address, or rack position. It requires a hardware identifier (HW-ID), which is a 32-bit value TIA Portal assigns automatically to every device, interface, and submodule in the device configuration. The HW-ID of a CPU's diagnostic interface is a project-specific number, not a fixed constant across PLC families or firmware revisions.

Per the official instruction reference, the LADDR input must point at a module that has at least one readable LED. A value of zero, a typo of an HW-ID, or a value that points at a non-LED module (for example, a digital input module) causes 16#8091 to be returned.

Why the constant 65? In some early community examples, the diagnostic interface of an S7-1200 CPU appears with HW-ID 65. The constant value is not portable. It can change when the CPU model changes (e.g. CPU 1211C to CPU 1215C), when firmware is upgraded, when an interface module is added or removed, or when the project is re-compiled against a different TIA Portal version. Always use the symbolic name from the PLC's system constants rather than the literal number.

3. The LED Instruction: Inputs and Outputs

The full interface of the LED extended instruction (LAD/FBD/ST) is:

Parameter Declaration Data Type Description
LADDR Input HW_IO (WORD) Hardware identifier of the module whose LED is to be read (CPU or interface module).
LED Input UINT Numeric identifier of the LED on the module face (see table below).
Ret_Val Return INT Function return / error code. 0 = no error.
Status Output BOOL TRUE if the LED is currently on (or flashing for the S7-1500, see note below).

For the LED input, the valid identifiers depend on the module family. The most common assignments for an S7-1200 CPU are:

LED value CPU LED Description
1 STOP / RUN Combined RUN/STOP state LED (TRUE when STOP or RUN is active depending on model).
2 ERROR ERROR LED on the CPU.
3 MAINT MAINTENANCE LED (where available).
4 LINK LINK LED of the PROFINET port (Port 1).
5 Rx/Tx Receive/Transmit activity on the PROFINET port.
The exact mapping is published in the official LED: Read LED status (S7-1200, S7-1500) - STEP 7 (TIA Portal) V20 reference. The numeric constants can be used directly, but for portability use the symbolic system constant names where available.

4. Resolving Error 16#8091

Follow this sequence in the project tree of the S7-1200 station:

4.1 Open the Device Configuration of the CPU

In the project tree, double-click Devices & networks > [PLC_x] > Device configuration. The hardware view of the S7-1200 station opens, showing the CPU rack with all inserted modules.

4.2 Read the Hardware Identifier of the CPU's Diagnostic Interface

Click once on the CPU symbol. In the inspector window (lower right of the TIA Portal UI), switch to the Properties > System constants tab. The list shows every HW-ID that the CPU exposes, including:

  • Diagnostic interface of the CPU itself
  • PROFINET interface X1 (Port 1 / Port 2)
  • Integrated I/O if present
  • Optional interface / communication / port submodules

Note the symbolic name (e.g. <PLC_1>.Local~PROFINET_interface_1) and the numeric HW-ID beside it. This is the value that must be applied to LADDR.

4.3 Replace the Hard-Coded Constant with the Symbolic Name

In the LAD/FBD network containing the LED call, click the LADDR input terminal. Delete any literal number. Click the small dropdown arrow, choose System constants, then select the symbolic HW identifier that points to the CPU (or to a specific interface if the application wants to read the LINK LED of port X1 P1).

With the symbolic name wired, the Ret_Val is no longer tied to a specific number; the compiler re-derives the correct HW-ID for the actual hardware and firmware of the target CPU.

4.4 Verify the LED Parameter

Replace the value at the LED input with the symbolic constant if your TIA Portal version exposes one (e.g. LED_ERROR); otherwise enter the numeric constant (e.g. 2 for ERROR) consistent with the table in section 3.

4.5 Recompile and Download

Compile the S7-1200 station (right-click > Compile > Software (rebuild all)). Download to the CPU. Place the CPU in RUN and observe the Ret_Val tag in the watch table. The expected value is 16#0000; Status toggles to TRUE when the addressed LED is illuminated.

5. Diagnostic Flowchart

LED call returns 16#8091? LADDR is a literal number (e.g. 65)? Open Device configuration > Properties > System constants Replace LADDR with symbolic HW identifier of the CPU Recompile, download, check Ret_Val = 16#0000 Done — Status reflects LED state

6. Common Error Codes Returned by LED

The Siemens TIA Portal help enumerates the following status values from the LED instruction. Treat this as a quick field reference; the exact list for a given firmware is in the official help linked at the end of this article.

Ret_Val Meaning Likely cause
16#0000 No error Instruction executed successfully.
16#8090 Specified HW identifier does not exist on the CPU Numeric value at LADDR was typed incorrectly.
16#8091 Module addressed by LADDR has no readable LED / invalid LED identifier LADDR points to a sub-module without a displayable LED, or LED parameter value is not in the valid range.
16#8092 Invalid LED parameter LED constant is out of range or refers to a non-existent LED on the addressed module.
16#80B0 CPU is not in RUN Function cannot read LED state because the CPU is in STOP, startup, or hold.
16#80B1 LED not available on the addressed module Module hardware revision does not expose the selected LED (e.g. MAINT LED on a CPU that does not have one).

7. Symbolic vs. Hard-Coded LADDR — Why It Matters

Three reasons to prefer the symbolic HW identifier, in order of importance for production support:

  1. Portability across hardware — a project that runs on a CPU 1214C will likely also run on a CPU 1215C once the device is exchanged. The symbolic name survives the swap; the number 65 does not.
  2. Portability across firmware — firmware updates occasionally shift HW-IDs. With the symbolic name, the re-compile step automatically picks up the new value.
  3. Readability — the network comment becomes self-explanatory; the engineer reading the code does not need to look up what 65 refers to.

8. Sample Structured Text (SCL) Implementation

The following SCL snippet shows the recommended implementation. Replace "PLC_1" with the actual name of your S7-1200 station.

// LED read sample - S7-1200 / S7-1500
// Reads the ERROR LED of the CPU and stores the result in a flag

FUNCTION_BLOCK "FB_LED_Read"
VAR
    retValLED   : INT;
    statusError : BOOL;
    statusRun   : BOOL;
END_VAR

BEGIN
    // ERROR LED (LED = 2)
    "LED"(
        LADDR := "PLC_1".Local~PROFINET_interface_1,  // symbolic HW identifier
        LED   := 2,
        Ret_Val := retValLED,
        Status  := statusError);

    // RUN/STOP LED (LED = 1)
    "LED"(
        LADDR := "PLC_1".Local~PROFINET_interface_1,
        LED   := 1,
        Ret_Val := retValLED,
        Status  := statusRun);
END_FUNCTION_BLOCK

Place a watch on the tags retValLED, statusError, and statusRun. With the CPU in RUN, retValLED should display 16#0000, statusRun should be TRUE, and statusError should be FALSE unless an error condition is active.

9. Verifying the Fix

Use a watch table or the online & diagnostics view of TIA Portal to confirm:

  1. Open Online & diagnostics > Diagnostics status for the CPU. Note the active state of the physical ERROR / MAINT / RUN LEDs.
  2. Toggle the watch table online; observe Ret_Val = 16#0000.
  3. Force the CPU to STOP using the programming software or a STOP switch wired to a digital input. Verify the RUN/STOP LED state change is reflected in the Status output within one PLC cycle.
  4. Force an error condition (e.g. remove a configured but absent module). Verify Status = TRUE for the ERROR LED read.

10. Field-Proven Caveats

  • Function-block instance DBs. The LED instruction requires a valid instance or works as a stateless call only when both LADDR and LED are constants. Calling it inline from OB1 with non-constant inputs is allowed but the instance DB is generated automatically.
  • OB82 / OB83 / OB86 — the LED read is independent of diagnostic OBs. Even with the diagnostic OB missing, the LED instruction still returns the on/off state because it reads the physical LED, not the diagnostic buffer.
  • Port LEDs on CM/CP modules. For S7-1200 communication modules (CM 1241, CP 1243, etc.) the same instruction reads their LINK and Tx/Rx LEDs. Use the symbolic HW identifier of the specific port, not the module itself.
  • Flashing LEDs on S7-1500 — the S7-1500 CPU distinguishes between a solid LED and a flashing LED in the Status output. On the S7-1200 the Status output simply indicates on/off and cannot distinguish a slow flash from a steady on.
  • CPU in STOP — the LED instruction is permitted in RUN only. If the CPU is in STOP, startup, or hold, Ret_Val = 16#80B0 is returned regardless of the validity of the inputs.

11. Quick-Reference Troubleshooting Matrix

Symptom Ret_Val Likely cause Action
Constant 16#8091 from a fresh project 16#8091 Hard-coded LADDR value is wrong for the actual CPU / firmware Replace LADDR with the symbolic HW identifier from the system constants tab.
Value flips between 0 and 8090 16#8090 LADDR typed number does not exist in the device Open device configuration, copy the symbolic name exactly.
Status never goes TRUE 16#0000 LED parameter does not match the LED you are observing Cross-check against the table in section 3; some S7-1200 firmware versions do not expose a MAINT LED.
Ret_Val = 16#80B0 in STOP 16#80B0 CPU is in STOP Switch CPU to RUN, or guard the call with a CPU-status check.
After firmware update the call fails 16#8091 Numeric LADDR shifted due to added internal resources Re-read system constants; symbolic name requires no manual change.

12. Related Siemens Documentation

Frequently Asked Questions

What does error 16#8091 mean on the S7-1200 LED instruction?

Error 16#8091 is returned when the value at LADDR does not point to a module that has a readable LED, or when the LED parameter is invalid for the addressed module. It typically indicates that a hard-coded HW identifier no longer matches the project (CPU model or firmware change) or that the wrong symbolic name was selected.

How do I find the hardware identifier of my S7-1200 CPU for the LED instruction?

Open the device configuration of the S7-1200 station, click the CPU, then go to Properties > System constants in the inspector. Use the symbolic name listed there (for example PLC_1.Local~PROFINET_interface_1) instead of the raw numeric value when wiring LADDR.

What numeric value should I use for the LED parameter to read the ERROR LED?

For the S7-1200 CPU the ERROR LED corresponds to LED = 2. The RUN/STOP LED is LED = 1, the MAINT LED (where present) is LED = 3, and the PROFINET port LINK LED is LED = 4. Always verify the mapping against the official Siemens reference for your firmware version.

Can I use a literal number like 65 as the LADDR value?

You can, but it is not recommended. The value 65 happens to match the diagnostic interface of certain S7-1200 CPU/firmware combinations, but the number is not portable. When the CPU model, firmware, or station layout changes, the constant must be re-verified. Use the symbolic HW identifier from the system constants instead.

Why does the LED instruction return 16#80B0 even though the parameters are correct?

16#80B0 is returned when the CPU is not in RUN. The LED read requires the CPU to be executing the user program. In STOP, startup, or HOLD the instruction cannot read the physical LED state and the return value is 16#80B0 regardless of LADDR or LED.

Back to blog