Skip to main content

Selecting a product from a table

Goal: the PLC sends an article number, and the printer looks up which label, and how many copies, to print for it. The product data is maintained on the printer, and the PLC only needs to know the article numbers.

Printer setup​

Create a table on the printer, for example Products:

ArticleLabelCopies
A100Carton1
A200Pallet2

Add a register mapping:

FieldValue
Address36
MappingSelect from table
Data typeSTRING
Length8
PrinterNoLabel
Table nameProducts
Key columnArticle
Label columnLabel
Copies columnCopies
Queue labelOn

PLC​

Write the article number to registers 36–43 with function 16, once per job. With Queue label on, each write adds a job to the printer's queue.

Exception 04 means the article is not in the table, or the table, label or printer is missing. The printer's log says which.

Try it​

from common import *

check(client.write_registers(36, to_string("A200", 8))) # 2 x Pallet

response = client.write_registers(36, to_string("X999", 8))
print(response.exception_code) # 4, not in the table