Overview
Barcode scanners, weighing indicators, analyzers and many older measuring devices do not speak a protocol; they send each measurement or each reading as a text that ends with a line end. This driver reads those lines, splits them by the rule in the tag address and gives the value to the tag.
| Driver entry | Connection |
|---|---|
| Serial device (RS-232 / RS-485) | The connection’s address is a serial port on the Live computer (for example COM3). The port belongs to this connection; no other serial connection can use the same port.
|
| Serial device, Ethernet serial server (TCP) | The device is connected to an RS-232 / RS-485 to Ethernet converter. The address and port are the converter’s raw TCP port (4001 on most). The device can be far from the Live computer.
|
Listen and Request / response
The connection’s Operating mode is one of two:
- Listen: the device sends lines by itself. Barcode scanners and continuously sending scales work this way. An incoming line is processed without waiting for the read cycle.
- Request / response: on every read cycle Live sends the command in the tag address and reads the answer line. Example: sending
"SI"to a scale and taking the weight from the answer.
The Connection Status window shows the last line that came in on the connection; during commissioning you see there what the device sends.
Tag addresses
SATIR | LINE // The whole incoming line, for example the scanned barcode SAYAC | COUNT // Number of incoming lines; grows with every reading (Listen only) ALAN 3 | FIELD 3 // The 3rd field of the line split by the separator PARCA 5 8 | MID 5 8 // 8 characters starting at the 5th (0 = to the end of the line) DESEN ([-+]?[0-9.]+)\s*kg // The first capture group of the regular expression; only matching lines change the value GONDER | SEND // Text written to the String tag is sent to the device "T" // The command is sent when 1 is written to a Bool or number tag, for example tare "SI" SATIR // Request / response: the command is sent and the answer line is read
- Bool
- Byte
- SInt
- Int
- UInt
- DInt
- UDInt
- Real
- LReal
- String
In number tags the first number inside the selected text is taken: from the line ST,GS,+0012.34kg, 12.34 is read; the decimal separator is a point or a comma. Escapes such as \r, \n, \t and \x02 are written in command text. Studio checks how the address is written and gives the reason when it is wrong.
Writing every reading to the PLC or an internal tag
With a barcode scanner the same barcode can be scanned twice in a row; because the tag’s value does not change, the PLC cannot see the new reading. The forwarding settings solve this:
- Write every reading: tag: every incoming line is written to this tag. If it is a PLC tag, the value goes to the PLC; if it is an internal tag, it stays in Live. The same barcode scanned twice is written twice.
- Part to write (regular expression): if empty, the whole line is written. If filled, only matching lines are forwarded and the first capture group is written; for example
^01(.*)$takes only the barcode of reader number 01. - New reading bit (Bool tag): after the value is written, 1 is written to this bit. The PLC sets the bit to 0 once it has processed the reading.
Readings are forwarded in order: value first, then the bit. Forwarding works in Listen mode only, and a reading cannot be forwarded to a tag of the same connection. A reading that cannot be forwarded is written to the event log.
-
A reading arrives
The scanner sends
8690123456789. -
The value is written
Live writes the text to the String tag in the PLC.
-
The bit goes to 1
Live writes 1 to the new reading bit; the PLC processes the barcode and sets the bit to 0.
Connection parameters
| Parameter | Options |
|---|---|
| Speed, parity, data and stop bits | 1200 – 115200 baud (default 9600), parity N / E / O, 7 or 8 data bits, 1 or 2 stop bits. Serial port only; the values must match the device setting. |
| Flow control, DTR / RTS | None, RTS / CTS or XON / XOFF. DTR / RTS is on by default: many devices do not send data unless this line is on. |
| End of incoming line | CR or LF (most devices), CR, LF, ETX, a custom character or silence (no bytes for a set time). |
| Line start marker | None or STX: the line starts with STX, bytes before it are dropped. |
| Character encoding | ASCII / Latin-1, Turkish (Windows-1254) or UTF-8. |
| Field separator, end of sent command | The separator for FIELD n (default comma). CR LF, CR, LF or nothing is added to the end of a command; it can also be wrapped in STX … ETX. |
| Treat as lost without data (s) | For devices that send all the time: if no data comes for this long, the connection is treated as lost and reopened. Leave it at 0 (off) for a barcode scanner. |
Limits
- The scanner connects to the Live computer or to an Ethernet serial server. A scanner plugged into a computer that monitors from a browser is not read by this driver.
- The driver is for line-based plain text; there are no binary protocols and no PLC serial protocols other than Modbus.
- In a redundant server pair, the master forwards the readings.
- The driver has been tested in automated tests with a simulated serial line and TCP endpoint. Test with your own device before commissioning.
Frequently asked
Which barcode scanners work?
Scanners that send each reading as text ending with a line end, over a serial port or an Ethernet serial server. The scanner’s speed, parity and line end are entered in the connection parameters.
How does a scanned barcode reach the PLC?
Put a String tag in the PLC into the connection’s Write every reading: tag field; with the optional New reading bit, the PLC knows there is a new reading and resets the bit.
Related pages
Modbus RTU / ASCII
Reads and writes Modbus devices on an RS-485 or RS-232 line through a serial port.
StudioConnections
The Connections table, driver selection, connection test, diagnostics, reconnection and password storage.
LiveBatch records
Batch traceability: raw material lots, critical parameters, outputs, signature and approval, genealogy.
StudioHMI tags
External and internal tags, scaling, quality, structures (UDT), cross reference and Excel transfer.