Setting a lot number
Goal: print the current lot number, which the PLC knows, on every label.
Printer setup
-
Create a variable
Lot, and use it on the label, for example with the dynamic text{VARIABLE;Lot}. See Dynamic text. -
Add a register mapping:
Field Value Address 2 Mapping Variable Name LotData type STRINGLength 8, room for 16 characters Writable On
If the lot number is always a number, a UINT32 item is simpler for the PLC.
The variable then holds the number as decimal text.
PLC
Write the lot number when it changes, with function 16. The text may be shorter than the item; the printer clears the rest. Labels printed after the write use the new value.
Reading the item back returns the variable's current value, which may also have been changed on the printer, for example by an operator.
Try it
from common import *
check(client.write_registers(2, to_string("L0042", 8)))
print(from_string(check(client.read_holding_registers(2, count=8)).registers))
# L0042