UID and UIE on a ControlLogix: Protecting a Critical Section From an Interrupt
Three setpoints that belong together — 120, 340 and 75 — reached the downstream controller as 120, 340 and 0, roughly once an hour, on no pattern anyone could find. A 5 ms task at priority 5 was reading the array while the 20 ms task at priority 10 was half-way through writing it, and the read landed between the second element and the third.
UID and UIE are the pair that stops that. When the rung is true, UID prevents higher-priority tasks from interrupting the current task; UIE lets them interrupt again. Both are available in ladder and in structured text as UID(); and UIE();, and the manual’s procedure is four steps long, the first of which is the one that matters: limit the rungs you do not want interrupted to as few as possible.
1756-L83E on v34, with a continuous task, a 20 ms periodic at priority 10 and a 5 ms periodic at priority 5.
What UID does under the hood
It is not a lock. It is a priority change with a counter attached.
The first UID call bumps the task’s priority, saves the old one, and increments a nesting counter to 1. Each subsequent UID increments the count further and does nothing else — the priority was already raised. Each UIE decrements the counter, and only the one that takes it to zero restores the saved priority. That design is why nesting pairs is legal and safe: an Add-On Instruction that protects itself with a pair can be called from inside a routine that has already opened one, and the inner UIE does not hand the task back to the scheduler early. A ControlLogix or CompactLogix has 15 priority levels to work with, tasks at equal priority share the controller 1 ms at a time, and the continuous task always sits at the bottom with no priority of its own.
The counter is the whole mechanism. Everything that goes wrong with these two instructions is the counter not getting back to zero.

The protected version delays the faster task by the length of the protected block. That delay is the entire cost, and it is why the block has to be short.
What it will not hold off
Three things carry on regardless, and two of them surprise people.
The manual states plainly that UID does not disable execution of a fault routine or the Controller Fault Handler — so a major fault raised inside your protected block still goes to the handler, which is exactly what you want and exactly what people assume is blocked. The motion planner is a separate matter: the Design Considerations manual says the planner interrupts all user tasks regardless of their priority, and UID works by raising priority among user tasks, so nothing in the documentation claims the pair holds the planner off and you should not design as though it does. The third is not an interruption at all but a consequence: disabling interrupts for a prolonged period can produce communication loss, because unscheduled communication is one of the things that gets squeezed out. One useful detail from the other direction — an event task cannot interrupt a task while a UID is active, and the same is true while a CPS instruction is executing.
Nothing here makes a block of logic atomic against everything. It makes it atomic against other user tasks.

The two marked rows in the middle are the assumptions worth unlearning before you rely on this pair for anything.
The three jobs the manual actually gives it
Each one is written down somewhere, and together they cover nearly every legitimate use.
The first is the wall clock. If a WALLCLOCKTIME GSV exists in a task that can be interrupted by a WALLCLOCKTIME GSV in another task, the object’s own notes tell you to put a UID/UIE pair around it — and add, helpfully, that no pair is needed when the GSV exists in only one user task. Reading the controller’s own data with GSV and SSV goes through the seven-element array that gets torn. The second is an Add-On Instruction: because an AOI executes like a routine, a higher-priority task can interrupt it part-way through, and the guideline is to use a UID/UIE pair when that must not happen. Building an Add-On Instruction covers where the pair goes relative to the parameters. The third is data that arrives asynchronously to your program scan — the comparison of messaging against produced and consumed tags recommends a programmatic handshake or a UID/UIE pair to reduce the impact. A handshake is usually better, because it costs no interrupt latency at all; produced and consumed tags between two controllers and the CIP Generic MSG both cover what the data is doing while your logic is not looking.
A multi-element copy that must not be split is the fourth, unwritten one. Moving a recipe into the PLC is that case exactly.
The pair that never closes
This is the failure that produces symptoms nobody can reproduce.
Open a UID, then leave the routine before the UIE — a RET, a TND, a jump past it, or a structured text RETURN inside a conditional — and the counter stays at 1 with the priority still raised. The task carries on running at a priority it was never meant to have, higher-priority work stops being able to interrupt it, and the evidence turns up somewhere else entirely: task overlaps on a task that has never overlapped before, an HMI that goes sluggish for no reason, a MSG instruction that starts timing out, comms that recover as soon as the machine is cycled. Read OverlapCount on the Task object for the tasks that should have been interrupting, because that counter moving is the cleanest sign you will get. The structural fix is to make the protected block a straight line with no early exit in it, and to keep it to the handful of rungs the manual asks for rather than wrapping a whole routine.
Put the UID and the UIE in the same routine, with nothing between them that can leave.

Only the outermost UIE restores the priority. The panel on the right is the shape this fault takes every time.
A wrinkle in the current revision
Worth knowing if you go looking for the operand table and come away confused.
In 1756-RM018A-EN-P the Available Languages section lists ladder and structured text for both instructions, with the structured text form given as UID(); and UIE();. The Operands section immediately below then says the instruction is not available under each of the two language headings, which reads as a layout slip rather than a statement about the product — the instructions have no operands at all, so there is nothing for those tables to hold. The genuinely useful sentence in that section is easy to miss: you must type the empty parentheses after the mnemonic in structured text even though there are no operands. Leave them off and the editor will not accept the line.
The dead end: raising the task priority instead
The instinct when two tasks are interfering is to change a priority number, and it almost always makes things worse.
Raising the writer above the reader does stop the tear, and it also means the writer now delays everything the reader was doing, including whatever was time-critical enough to justify a 5 ms task in the first place. Dropping the reader has the same problem from the other end. What the priority numbers are for is deciding which work is genuinely more urgent, not for serialising two pieces of logic that happen to share an array — and a priority change is invisible in the logic, so the next person has no idea why it is set the way it is. Measure first: read LastScanTime and OverlapCount on both tasks, then decide whether you have a priority problem or a shared-data problem. Scan time and cycle time is the method.
Go through your project for every UID and confirm there is a UIE on the same path out of the routine. Then check the length of each protected block: if it is more than a handful of rungs, shorten it before you ship, because the cost of this instruction is paid by every task that was trying to get in.