One Machine End to End: PLC Data to a Dashboard Through OPC UA, a Broker and a Historian
Belt 1 on transfer TR-14 was stopped for 60 of the 480 minutes of a Tuesday day shift, and the guard door was open for 17 of them. The other 43 minutes were the machine standing there with the door shut, waiting for somebody to press two buttons in the right order.
Nobody at the panel could have told you that, and not because they were not paying attention. Each of those waits averaged 63 seconds, there were 41 of them, and a minute standing at a conveyor does not feel like anything at all.
Getting PLC data to a dashboard is five stops and no gaps: choose which tags leave the controller, expose them, get them onto a broker, store them, and draw the one thing the panel cannot draw. This article does all five on one small machine, in order, with the rung numbers and the topic strings. The machine is transfer TR-14 — the two-belt carton transfer the January articles built, where Belt 1 cannot run unless Belt2_Running is confirmed true — and the whole data layer it gains here is three new rungs, one user-defined type and sixteen OPC UA nodes.
Sixteen nodes out of the 1200 a 1756-L83E serves. This is a small job that is usually done badly.

Five stops. The interesting parts of this job are the four gaps between them, because a gap is where a value stops being the same value it was on the other side.
What the machine already has
Two 400 V gearmotors through contactors K11 and K21, a 1756-L83E in slot 0, a 1756-IB16 in slot 2, a 1756-OB16E in slot 4 and a PanelView Plus 6 on the machine network.
The logic is a routine called Transfer_Belts in a 30 ms periodic task. Rung 1 turns the Belt 2 request into Belt2_Run, rung 2 confirms it as Belt2_Running when the mirror contact Belt2_Aux agrees, and rungs 4 and 5 do the same for Belt 1 with one extra contact: Belt1_Run also needs Belt2_Running, which is the interlock that stops four cartons stacking against the transfer plate. Rungs 6 and 9 are the feedback timers that latch Belt1_Fault and Belt2_Fault when a run command produces no mirror contact inside 1500 ms. K30_Mirror is the auxiliary on the safety contactor, which the 440R guard circuit drops whatever the controller thinks. PE_EOL is the eye at the discharge and Cnt_EOL is the carton count it drives through a CTU on rung 54.
None of that changes. The data layer is additive or it is not worth doing.
Step 1: which tags leave the controller
Fifteen members in a user-defined type called TR14_Pub, and the choosing is the part with judgement in it.
Eleven of them already exist: Belt1_Run and Belt2_Run for what the controller commanded, Belt1_Aux and Belt2_Aux for what the contactors did, Belt1_Running and Belt2_Running for the two agreeing, K30_Mirror, Belt1_Fault and Belt2_Fault, PE_EOL and Cnt_EOL. Three do not exist yet and they are the reason this machine becomes legible instead of merely visible. Belt1_Blocked, on a new rung 18, is Belt1_Req true with Belt1_Running false — the operator asked and the interlock refused — and it is the single most useful bit on the whole machine because it separates a belt that is idle from a belt that is waiting. Line_State, on rung 61, is a SINT that collapses everything into one number: 0 idle, 1 ready, 2 running, 3 blocked, 4 faulted. Pub_Seq, on rung 62, increments every time the copy runs, and a flat Pub_Seq on a dashboard means the data is stale even though every other value still looks plausible. Pub_Stamp is a GSV of the wall clock time on the same rung, so the historian knows when the copy was taken rather than only when it arrived. The copy itself is a CPS from a 500 ms periodic task rather than a COP, because the source is data another task can change and publication 1756-RM018A-EN-P is explicit that tasks trying to interrupt a CPS are delayed until it has finished.
Three rungs. That is the entire controller-side cost.

Three of these did not exist in January. Belt1_Blocked, Line_State and Pub_Seq are the whole cost of making the machine readable from outside, and every one of them is one rung.
Step 2: turning the server on, which is not a checkbox
TR-14’s controller was on v34, and the embedded OPC UA server is enabled from version 36 firmware.
That is a planned outage on a production line, so it is worth saying plainly rather than glossing: if you cannot take the firmware, put an OPC UA server alongside the controller instead and let it poll, which costs a box and a licence and is a perfectly respectable answer. We took the upgrade. After it, publication 1756-UM023B-EN-P says both the server and the client are disabled by default, and what turns the server on is a message instruction rather than a tick box: message type CIP Generic, service type Set Attribute Single, class 3c1 hex, instance 1, attribute 1, path THIS, with a source element that is a small user-defined type of 8 bytes on a single-IP controller carrying a count, the TCP/IP instance and two enable flags. The server then listens on port 4840 and serves up to ten external clients. One line in that manual is the one to obey before anything else: synchronise the controller clock before enabling the engine. Do it the other way round and every timestamp that leaves the controller is wrong by however much a processor has drifted since the last power cut, the trends still draw perfectly, and they disagree with the machine next door in a way that costs somebody a day. Which clock wins when you timestamp PLC data is the longer version of that problem.
Then set OPC UA Access. It defaults to None on controller and program scoped tags, which is the right default, and the only thing that changes is TR14_Pub, set to Read Only on the structure. Nothing on this machine is writable from outside at all.
Sixteen nodes published. Everything else in the controller stays at None.

The clock row is the one that gets skipped, because nothing fails when you skip it. The queue size of four is what covers a four-second gap in the client without losing a transition.
Step 3: what the broker sees
The edge node is the only OPC UA client on this machine. It opens one subscription with a publishing interval of 1000 ms, monitors fifteen items at a 500 ms sampling interval, and republishes what changes as Sparkplug B.
Six topics carry the whole machine and the shape of them is worth reading once. On connect, the node registers its own death certificate — spBv1.0/Pack2/NDEATH/EDGE-CTN-01, at QoS 1 with retain false, carrying a single bdSeq metric — as the MQTT will message inside the CONNECT packet, which means the broker publishes it if the node stops answering and the node never publishes it itself. Then comes the birth: spBv1.0/Pack2/NBIRTH/EDGE-CTN-01 with a sequence number of 0, the same bdSeq so a host can pair the birth with its eventual death, and a Node Control/Rebirth boolean that lets a host application ask for the whole thing again. The specification is strict about what NBIRTH carries: every metric the node will ever report on, with name, datatype and current value, because a host that has the birth needs nothing else to interpret the stream. spBv1.0/Pack2/DBIRTH/EDGE-CTN-01/TR14 follows with the fifteen members. After that the machine is quiet until something moves, and each change goes out as DDATA on the same device topic at QoS 0 with retain false, carrying only what changed and a sequence number one higher than the last, wrapping back to 0 after 255. On this machine that is about 17,500 DDATA messages a shift and an average of 0.6 a second, which is less traffic than one badly configured trend pen. The MQTT and Sparkplug side of this covers the payload encoding; what matters here is that the birth and death pair is what lets a host mark every metric stale the moment the node goes, instead of drawing a flat line that looks like a stopped machine.
A flat line and a dead link look identical on a chart. That is what the will message exists to fix.

The death certificate is the only row the edge node never publishes. It is handed to the broker at connect time and sent on the node’s behalf when it stops answering.
Step 4: what the historian stores
Everything on change, no deadband on the discrete points, and one deliberate argument about the eye.
Six state bits at 82 edges each over a shift is 492 rows, which is nothing. Cnt_EOL at one row a carton is 16,794 rows, and it is the point everything else reconciles against, so it is kept forever. PE_EOL at two edges a carton is 33,589 rows and it is the row worth arguing about: it lets you reconstruct the gap between cartons months later when somebody asks why the case packer starved, and it is two thirds of the whole volume. The answer we took is to keep it a fortnight and keep everything else indefinitely, because the question it answers is always asked within days. Add Pub_Seq at one row a minute regardless of activity and the total is 51,605 rows a shift, 154,816 a day, about 1.86 MB of raw values before any compression. That is a machine producing a rounding error of data, which is the point: a correctly chosen tag list on a small machine is not a storage problem, and if yours is, the list is wrong rather than the disk being small. Sizing tag history from the sample rate and the deadband is the general arithmetic.

The eye is two thirds of the volume and the only line here with a retention argument attached to it. Everything else is small enough that the decision does not need making.
Step 5: four things on the glass
One number, one count, one bar chart and one clock.
Line_State as a single coloured word is the pane the shift manager looks at, because idle and blocked are different words and on the panel they are the same two dark lamps. Cnt_EOL for the shift against the same hour last Tuesday is the pane operations looks at. The bar chart is the one below. And the fourth pane is Pub_Seq and the age of the last DDATA in seconds, which is the pane nobody asks for and the only one that tells you whether to believe the other three: a dashboard with no liveness indicator will happily show you a perfectly rendered picture of eleven o’clock last night.
What the dashboard tells somebody the panel cannot
Belt 1 stopped 41 times in that shift and every stop began with the guard door.
The door accounts for 16.9 minutes of it, mean 24.7 seconds, and if you ask anyone on the line why Belt 1 stops they will say the door, and they will be right about the cause and wrong about the cost. The other 43.3 minutes is the gap between the door shutting and Belt1_Run going true again, mean 63 seconds, longest 126. That gap has a mechanical explanation and it is the interlock from the January article doing exactly what it was designed to do: K30 dropping takes both belts down, so the restart has to be Belt 2 first, then wait for Belt2_Aux and the Belt2_Running confirmation, then Belt 1 — and an operator who starts Belt 1 first gets nothing, tries again, and eventually works out the order. Belt1_Blocked is true for the whole of it, which is why that one invented bit is worth more than the other fourteen put together. Over 480 minutes, 43.3 minutes of avoidable stoppage at 40 cartons a minute is 1732 cartons. Getting the restart down to 15 seconds — a two-step prompt on the PanelView, or an auto-restart of Belt 2 on K30 returning with the request still latched — recovers 33.0 of those minutes and 1321 cartons a shift, for an afternoon of work. None of that is visible from the panel, none of it is in any existing report, and it took three rungs and sixteen nodes to see it. Reading production counts and downtime reasons out of the PLC is where that number turns into a reason code somebody can act on.
Forty-three minutes a shift, and the operators were right about the cause the whole time.

The left bar is the honest answer to a question asked at the machine. The right bar is the same shift with the second half of it measured, and the difference is two and a half times the thing everybody already knew about.
What the first version got wrong
The first dashboard for this machine published Belt1_Run and Belt2_Run and was useless.
It was useless in a way that took a fortnight to notice, because the chart looked right: two traces, plenty of transitions, obvious downtime. What it could not do was answer a single question anybody asked, and the reason is that Belt1_Run is false in exactly the same way at half past twelve when the line is at lunch and at half past nine when a carton is jammed and the machine is waiting. A run bit tells you what the machine is doing and never why. The fix was not a better chart and it was not more tags: it was one rung, in the controller, that combines a request the operator made with an outcome the machine produced, and publishes the difference. That is the general rule this whole exercise produced. If a question cannot be answered from the tags you are publishing, the answer is usually a rung rather than a query. The OPC UA path from a controller tag to a client has the plumbing for whatever you decide to add.
There is one diagnostic worth knowing about once this is running. The 5580 controller publishes an OPC UA diagnostic assembly, instance 32940, carrying UsedNodes, MaxNodes and NodesPerSecond, and reading it takes about a minute of work. It is the only honest answer to “is the data layer costing the controller anything”, and on TR-14 it reads 16 of 1200 and a handful of nodes a second, which is the number you want to be able to show when somebody asks for forty more tags at 100 ms.
What to do next
Pick your smallest machine rather than your most important one, and write down the three questions people actually ask about it — not the tags, the questions. Then work backwards: for each question, find the tag that answers it, and where there is no such tag, write the rung that creates one before you publish anything. Count the nodes, set everything else to None, synchronise the clock, and take the firmware outage if you need it. The publication structure and the three rungs are an afternoon each. The fortnight goes on deciding which fifteen members deserve to be in it.