Siemens#Using LED Function to get the CPU Status

There are so many ways to get the status from S7-1200 or S7-1500.This time I will show a simple way to use the “LED” Functions.

This LED Function can get the status of an LED that is installed on the CPU. You can see where the LED of the S7-1200 is in the above images.By using this LED Functions, we know the Run LED is On or Not? Error LED is on or off?.. something like this.


Depending on the LADDR and LED parameters that you passed into the function, the result will be changed.Please be careful that some devices do not have all “LEDs”. please refer to the manual of that device.

These are the parameters of this LED Function:


LADDRHW_IOThe  Address of Devices that you would like to take.If you would like to capture the Status of CPU, just input Local~~XXX.
LEDUINTWhich LED that you would like to take:STOP/RUNERRORMAINTRedundantLink(Green)Rx/Tx(Yellow)


Ret_ValINTCurrent status of LED0=LED not exist/not accessible1=OFF2=Color1(The Green LEd of Run/Stop) is On.3=Color2(The Orange LEd of Run/Stop) is On.4=Color1 is Flashing at 2Hz.5=Color2 is Flashing at 2Hz.6=Color1 and 2 are Flashing at 2Hz.7=Color1 is Available.8=Color2 is Available.9=LED not exist/not accessible8086=R/H system is not running8091=LADDR is wrong8092=The device of that LADDR does not respond.8093=The device of that LADDR does not has this LED.808x=The device of that LADDR does not supoort LED function

Example1#Get the Run/Stop Status

I will show the example to get the Stop/Run status from S7-1200.

Set LADDR=Local~Common and LED=1.

Download the program to CPU, we can see the function return 16#0002.

2=Color1=Green LED is ON.

Example2#Get the Error Status

In this Example, I will show you how to capture the error status of S7-1200.

Firstly, Insert a “Fake” device in my Hardware Configuration.


And I do not want the CPU to stop, just add some error OBs in my program.

Set LADDR=Local~Common and LED=2.

This Time LED Function will return 16#0004.

4=Color is Flashing at 2Hz.

That means the Error LED is flashing at 2Hz.


Here is the LED status of S7-1200:


  • このエントリーをはてなブックマークに追加