How to Read the Key Switch Position in ControlLogix
To Read the Key Switch Position in ControlLogix, we will use the GSV command. The GSV command Gets a System Value. Once we read the status of our processor, we will store the result to a tag. Bits 13 and 12 will tell us the current position of the key switch. At this point, we can flash a warning on the HMI, or turn on a strobe that indicates the key is not in the desired position.
In some cases, for safety, your facility may need to verify the key is locked into RUN. When the key is in the RUN position, you cannot modify the structure of a program. Additionally, you cannot download to the processor. This allows technicians to troubleshoot equipment without the risk of making unintentional modifications. It’s important to realize, though, that you can still modify tag values such as presets on timers and counters.
The downside of keeping the key in RUN is that someone will have to place the key into remote or program before anyone can update a ControlLogix project. This may be unfeasible for processors at remote locations.
Create Your Tag
In this case, we only need one tag with the INT data type. I’m just adding this to program tags. You can add the tag to the controller tag database as well. This will be the destination tag for our GSV command.
Add the GSV Command
At this point, we’ll add the GSV Command. The purpose of the GSV Command is to GET SYSTEM VALUE. In other words, the GSV Command copies data from the processor. After that, it will store this system data to a tag where you can see it. You can use the values from this tag in your logic.
Find the Key Switch Position
The integer value of the processor status does not tell us much. We’ll need to use the Help file in Studio 5000 to find the meaning of each individual bit.
Go to HELP within Studio 5000, then go to SEARCH. Search for “ControllerDevice”. The item you want to look for is “Accessing the ControllerDevice Object”. Basically, we are just looking at bits 13 and 12, respetively.11
- 01 — Run Position
- 10 — Program Position
- 11 — Remote Position
Writing the Logic
To demonstrate, I’ll create a new BOOL tag called “RunPosition”. The logic is simple. If bit 13 is OFF, and 12 is ON, then we know the processor key switch is in the RUN Position.
In this case, my key is in REMOTE. As you can see, it is not in the run position.
Once I turn the key to “RUN”, you will see that our RunPosition bit goes true.
Summary of Read the Key Switch Position
Keep in mind that if the key is locked into run, then you cannot change the logic. Additionally, you cannot add a tag, or change the structure of any tag. You cannot download to the processor. Another key point is that if you need to have someone in the area change the key position to make changes, they could inadvertently turn the key too far. If this happens, the processor will go into program mode. When the processor goes into program mode, your outputs will go to the program mode state. This is usually off. Also, your logic stops scanning. In most cases, your equipment shuts down.
If the key switch is in remote, you can make program changes such as modifying logic and creating tags. Some changes, however will require you to drop offline. This would include changing the slot number of a module, IP addresses, etc. It’s up to you to determine the best key switch mode for your facility. Simply use the GSV Command to determine if it’s in the mode you desire or not.
For more information about the processor, check out this link.
— Ricky Bryce