Retrieve the state of the CPU

NET.LOGIX v2.0.2010.311 and later supports retrieving the state of a ControlLogix / CompactLogix CPU.   This is achieved by assigning the Tag.Name property the string constant "$CPU_STATE".

Syntax

Tag.Name = "$CPU_STATE"

Returns

When successful, Tag.Value will return a 3 element System.Int32[] array containing the current state of the ControLogix / CompactLogix CPU. Otherwise Tag.Value is null (Nothing in VB)

Tag.Value

 

Value[0]

OK LED State

 

0 = Solid Red (Power Up)

 

1 = Flashing Red (Firmware Update)

 

2 = Flashing Red (Communication Fault)

 

3 = Flashing Green (Awaiting Connection)

 

4 = Flashing Red (Configuration Bad)

 

5 = Flashing/Solid Red (Major Fault)

 

6 = Solid Green (Connected)

 

7 = Flashing Green (Program Mode)

Value[1]

Minor/Major Fault

 

0 = No Fault

 

1 = Minor Recoverable Fault (OK LED State not affected)

 

2 = Minor Unrecoverable Fault (OK LED State not affected)

 

3 = Major Recoverable Fault (OK LED State Flashing Red)

 

4 = Major Unrecoverable Fault (OK LED State Solid Red)

Value[2]

Key Switch Position

 

1 = Run Mode (RUN)

 

2 = Program Mode (PROG)

 

3 = Remote (REM)

Remarks

  1. The name "$CPU_STATE" is not case sensitive.  

  2. "$CPU_STATE" is READ_ONLY tag.  Invoking Controller.WriteTag or Controller.GroupWrite will result in an Exception.

 

VB.NET Example
Imports Logix
Dim myPLC As New Controller("192.168.1.2")
Dim cpuState As New Tag("$CPU_STATE")
Dim stateCPU As Array

If Logix.ResultCode.E_SUCCES = myPLC.ReadTag(cpuState) Then

  stateCPU = cpuState.Value

  Console.WriteLine ("LED STATE = " + stateCPU.Value(0).ToString())

  Console.WriteLine ("FAULT STATE = " + stateCPU.Value(1).ToString())

  Console.WriteLine ("KEY SWITCH = " + stateCPU.Value(2).ToString())

End If

 

C# Example
using Logix;
Controller myPLC = new Controller("192.168.1.2");
Tag cpuState = new Tag("$CPU_STATE");
Array stateCPU;

if(Logix.ResultCode.E_SUCCES == myPLC.ReadTag(cpuState) )

{

  stateCPU = cpuState.Value;

  Console.WriteLine ("LED STATE = " + stateCPU.GetValue(0).ToString());

  Console.WriteLine ("FAULT STATE = " + stateCPU.GetValue(1).ToString());

  Console.WriteLine ("KEY SWITCH = " + stateCPU.GetValue(2).ToString());

}