Xinlong IoT
Menu

PLC integration

How to wire a barcode scanner to a PLC and verify the first read

A bench commissioning guide for verifying the trigger circuit, the received bytes and the first complete PLC string.

On this page

To connect a barcode scanner to a PLC, identify the scanner's supply, trigger input and data interface on the ordered version. Match each circuit to the specific PLC terminal or communications module. A 24 V digital input can receive a compatible on/off signal. To receive the barcode string, the PLC needs a compatible data port or a receiving host that passes the string to the PLC.

Start at the bench with a known-good code and one read request. Capture the data before the PLC program converts it, then compare the complete string with the expected value. Keep machine outputs inhibited during commissioning under the site's test procedures.

Three distinct connections between a barcode scanner setup and a PLC: supply, discrete trigger and the barcode data port
The diagram identifies signal paths. Use the wiring diagrams for the exact reader and PLC modules to select terminals and interface hardware.

1. Identify both ends of every connection

Use the reader ordering suffix and PLC module number to find the correct wiring diagrams. Record the supply input, each terminal's function and direction, the signal levels, and the expected idle state. Confirm the power pins and polarity before energizing the installation. An RJ45 or FPC connector can be used for different signals on different equipment.

Connections to verify before power-up
What you need to connect Check on the reader Check on the PLC or receiving host
Power Supply range, polarity and current, including startup and illumination peaks A supply rated for that reader. Size it for peak load and the voltage drop in the installed cable.
Trigger or discrete status Signal direction, voltage, active level, pulse width and isolation rating, where documented Whether the output or input circuit is sourcing, sinking or a contact. Use a compatible interface circuit where levels or wiring topology require it.
TTL UART data Logic thresholds, TX/RX pinout and reference ground A compatible UART receiver or an appropriate transceiver or gateway to the available port.
RS-232 data Documented RS-232 version, signal direction and any hardware flow control A genuine RS-232 port or transceiver. Verify TX-to-RX mapping and the specified reference connection.
RS-485 data Two- or four-wire mode, pair polarity and supported application protocol Match the topology and protocol. Confirm polarity by the manuals, since A/B naming can vary. Follow the documented termination and biasing scheme.
Ethernet data Separate supply requirements, application protocol, connection role and port A PLC or host that implements the same protocol. When a host performs the conversion, document the string and status it passes to the PLC.

For a 3.3 V-powered scan module and a 24 V PLC, provide the module's rated supply. Keep 24 V outputs away from logic-level UART pins. Connect a PLC output to a trigger input only after checking the trigger circuit against the documented voltage, polarity and current limits. TI RS-232 transceiver datasheet · TI RS-485 design guide · Barcode scanner interface selection

Check the ordered variant before choosing an adapter

The G53-AI specification lists 3.3 V power, TTL UART on a 12-pin FPC and a separate TRIG input. Confirm the UART and TRIG electrical limits before selecting a carrier or interface circuit. Check the signal thresholds separately from the power requirement. G4503 lists a 5 V supply and USB, TTL UART and RS-232 connections on an 8-pin FPC. Check the ordered interface and harness before choosing the PLC port. G53-AI specification · G4503 product page

The XL-5090 Ethernet version sends data over RJ45 and uses a separate 12 V DC supply. A lit link LED confirms the physical link. Check the reader's documented protocol and the receiver's capabilities before connecting it to a PLC or passing data to an MES application. XL-5090 Ethernet version

2. Capture one complete barcode at the PLC

  1. Configure both endpoints. For serial, match baud rate, data bits, parity and stop bits. Match flow control where supported. For Ethernet, confirm the IP settings and application protocol. Enable the output mode and establish whether the receiver uses a delimiter, length or protocol-defined frame.
  2. Run one known-good sample. Set the PLC receiver to capture raw bytes. Read the sample once with the documented trigger method. Note the reader's documented decode indication and the receiver's byte count. If the PLC port shows nothing, use a suitable test receiver for that interface to test the output independently.
  3. Compare the completed message. Verify the documented prefix, suffix and encoding. Collect bytes until the frame is complete, even when they arrive across several PLC scans. If the connection uses TCP, the application must reconstruct messages from its byte stream. Store identifier values as strings when leading zeroes matter. TCP specification
Four checks in order: decoder output, byte capture at the port, PLC receive buffer, and the value used by PLC logic
Illustrative example. If a reader is configured to transmit ASCII followed by CR/LF, the code 000742 yields 30 30 30 37 34 32 0D 0A in hexadecimal. The PLC should buffer a trailing CR until LF arrives, then store the string 000742 after removing the delimiter. Confirm the delimiter for the supplied device and configuration.

3. Find where the PLC stopped receiving data

Troubleshooting by observed symptom
What you observe What to check next
The trigger output changes, but the reader gives no decode indication Verify trigger mode, output wiring, pulse polarity and power at the reader. Then try a known-good code under the reader's documented test mode.
The reader indicates a decode and the PLC buffer stays empty Check enabled output, interface variant, TX/RX direction or differential pair, and the receiving port. On Ethernet, check the application connection state.
The buffer fills, but the PLC program stays in receive Compare the actual bytes with the frame definition. A configured CR/LF parser will wait if the reader sends CR alone. Check timeout, maximum length and buffer handling.
A frame arrives and the stored ID differs from the label Look for leading zeros dropped by numeric conversion, a symbology prefix, a character encoding mismatch or a string length limit. Compare raw bytes with the stored PLC string.

Keep the known code, raw capture and final PLC value together with the wiring revision. Before running parts, repeat the test with your expected longest identifier and verify recovery after a deliberate communications interruption. The assembly also needs a test for cycle timeouts, retries and linking the result to the right workpiece record. Fixed-mount trigger and host acceptance guide

Request a sample for your PLC

Send Xinlong IoT the PLC CPU and communications module models, available terminals, reader variant if known, and the trigger and decode output you need. Include a sample label and the expected barcode string so we can review the interface for a bench evaluation.