Monitoring printer status
Goal: show the printer's state on an HMI, and stop the line if the printer has a fault.
Printer setup
Add a read-only coil for each status signal:
| Address | Bind to | Signal |
|---|---|---|
| 0 | Signal | printer.NoLabel.ready |
| 1 | Signal | printer.NoLabel.printing |
| 2 | Signal | printer.NoLabel.label_selected |
| 3 | Signal | printer.NoLabel.red |
| 4 | Signal | printer.NoLabel.ink_low |
Any signal can be mapped, including user expressions that combine other signals, for example "ready and label selected". See Built-in signals.
PLC
Read coils 0–4 in one request with function 01 or 02, every cycle or every few hundred milliseconds. Coils that are not mapped read 0, so a larger read, for example 0–31, also works and leaves room for more signals later.
Try it
from common import *
names = ["ready", "printing", "label_selected", "red", "ink_low"]
bits = check(client.read_coils(0, count=5)).bits
for name, bit in zip(names, bits):
print(f"{name:15} {bit}")