How to Ensure FX5U Communicates Properly with Barcode Scanners

How to Ensure FX5U Communicates Properly with Barcode Scanners
Search on WeChat
How to Ensure FX5U Communicates Properly with Barcode Scanners
Technical Training

1. Description of Case Task Control Requirements

How to Ensure FX5U Communicates Properly with Barcode Scanners

The Serial Port Debugging Assistant is a software based on the Windows system:

1. Supports TCP, UDP, and Serial Port

2. Supports domain name resolution for addresses

3. Allows creating multiple connections of the same type

4. Periodic sending, hexadecimal display, automatic line wrapping, file input, file output

5. Window integration and separation, adjustable size after separation

6. The underlying development uses livevent, ensuring stable and reliable communication. This depends on the software development engineer’s design of this assistant, as each company’s serial port debugging assistant is quite similar.

Control Instructions: Regardless of the devices involved in serial communication, when it fails, we often find ourselves at a loss as to where to analyze.

Analysis can be divided into two parts: hardware and software

1. Hardware includes: whether the hardware device is faulty, whether the wiring is correct;

2. Software includes: whether the software settings are correct, whether the program is correct?

At this point, we can use the Serial Port Debugging Assistant to determine software issues. Send the data from the PLC to the Serial Port Debugging Assistant; the Serial Port Debugging Assistant sends the data to the corresponding device; this is divided into two parts. By comparing the data from these two parts, we can clearly see if there is a software issue.

Taking the barcode scanner as an example, when the FX5U cannot communicate with the barcode scanner, we can use FX5U to send data to the Serial Port Debugging Assistant, which then sends data to the barcode scanner. If both devices are functioning normally, comparing the data can resolve the issue. As shown in Figure 1-1.

How to Ensure FX5U Communicates Properly with Barcode Scanners

▲ Figure 1-1 Serial Port Debugging Assistant

2. Key Knowledge Explanation

How to Ensure FX5U Communicates Properly with Barcode Scanners

1. Serial Data Transmission RS2 Command Description

How to Ensure FX5U Communicates Properly with Barcode Scanners

How to Ensure FX5U Communicates Properly with Barcode Scanners

How to Ensure FX5U Communicates Properly with Barcode Scanners

How to Ensure FX5U Communicates Properly with Barcode Scanners

▲ Communication Channel Description as shown in Figure 2-1

How to Ensure FX5U Communicates Properly with Barcode Scanners

▲ Figure 2-1 Communication Channel Description

3. Implementation of the Task

How to Ensure FX5U Communicates Properly with Barcode Scanners

This case will explain from six aspects: hardware wiring – barcode scanner settings – error data – Serial Port Debugging Assistant and barcode scanner – Serial Port Debugging Assistant and FX5U – identifying and correcting errors.

1. Hardware Wiring Diagram

When purchasing a barcode scanner, remember to choose a compatible model. The barcode scanner used in this case has a network port and comes with an RJ45 to RS232 communication cable. Since the communication interfaces are all female, two male connectors need to be shorted together, and the receiving and sending lines need to be connected correctly, as shown in Figure 3-1.

Since the FX5U PLC has a 485 interface, an RS232 to RS485 module needs to be selected, as shown in Figure 3-2.

After the RS485 port conversion, since only TXD and RXD are present, and in Figure 3-1, the sending and receiving have already been matched correctly, in Figure 3-1, it is necessary to short RDA and SDA and connect to TXD, and RDB and SDB should be shorted and connected to RXD.

How to Ensure FX5U Communicates Properly with Barcode Scanners

▲ Figure 3-1 Wiring Diagram between FX5U and Barcode Scanner

When purchasing a barcode scanner, remember to choose a compatible model. The barcode scanner used in this case has a network port and comes with an RJ45 to RS232 communication cable. Since most laptops on the market are USB ports, an RS232 to USB communication cable needs to be purchased separately, as shown in Figure 3-2.

How to Ensure FX5U Communicates Properly with Barcode Scanners

▲ Figure 3-2 Wiring Diagram between Barcode Scanner and Serial Port Debugging Assistant

The FX5U has a 485 interface, and the laptop has a USB interface, so there are two wiring methods between the computer and FX5U: one is to connect via a USB to RS485 communication cable; the other is to connect via a USB to RS232 communication cable, and then through an RS232 to RS485 module. This case adopts the second method, as shown in Figure 3-3.

How to Ensure FX5U Communicates Properly with Barcode Scanners

▲ Figure 3-3 Wiring Diagram between FX5U and Serial Port Debugging Assistant

2. Barcode Scanner Parameter Settings

1. Power on the barcode scanner.

2. Scan the “Restore Factory Settings” barcode with the barcode scanner to reset all parameters to factory configuration.

How to Ensure FX5U Communicates Properly with Barcode Scanners

3. Scan the “RS232 Serial Output” barcode with the barcode scanner to configure the serial communication format.

How to Ensure FX5U Communicates Properly with Barcode Scanners

4. Sequentially scan the corresponding barcodes to configure the baud rate and serial parity settings in the serial communication format. This setting uses “9600bps” and “ODD”. Note: The barcode scanner’s serial communication format is fixed to 8 data bits and 1 stop bit.

1) Baud Rate Setting

How to Ensure FX5U Communicates Properly with Barcode Scanners

2) Serial Parity Configuration

How to Ensure FX5U Communicates Properly with Barcode Scanners

How to Ensure FX5U Communicates Properly with Barcode Scanners

5. To control the scanner to scan by sending commands, first scan the “Serial & Full Code Enable” barcode.

How to Ensure FX5U Communicates Properly with Barcode Scanners

Then scan the “Command Trigger Mode” barcode to activate command trigger mode. In this mode, the barcode scanner will start reading when it receives the scan command from the host, and will stop reading after successfully outputting information or when the single read time ends.

Note: In command trigger mode, the serial command to trigger scanning is: 7E 00 08 01 00 02 01 AB CD; after receiving the trigger command, the barcode scanner will first output a seven-byte response and simultaneously start scanning (response content: 02 00 00 01 00 33 31)

How to Ensure FX5U Communicates Properly with Barcode Scanners

3. Error Data

1. Set the parameters as shown in Figure 3-4;

How to Ensure FX5U Communicates Properly with Barcode Scanners

▲ Figure 3-4 Communication Format

2. Write the program as shown in Figure 3-5

How to Ensure FX5U Communicates Properly with Barcode Scanners

▲ Figure 3-5 Error Program

3. Assign the data as shown in Figure 3-6

How to Ensure FX5U Communicates Properly with Barcode Scanners

▲ Figure 3-6 Data

4. Detection result: no data, as shown in Figure 3-7.

How to Ensure FX5U Communicates Properly with Barcode Scanners

▲ Figure 3-7 Result

4. Serial Port Debugging Assistant and Barcode Scanner

Detection result: no data, as shown in Figure 3-7. Set the serial port settings of the Serial Port Debugging Assistant as follows: check the device manager for the COM port number, and ensure the rest matches the barcode scanner. In the send area settings, select to send in hexadecimal, sending 7E 00 08 01 00 02 01 AB CD to the barcode scanner, which will automatically return the corresponding data “02 00 00 01 00 33 31” followed by the QR code data “37 35 31 39 38 34 32 33 39 38 0D” as shown in Figure 3-8.

How to Ensure FX5U Communicates Properly with Barcode Scanners

▲ Figure 3-8 Serial Port Debugging Assistant and Barcode Scanner Communication Test

5. Serial Port Debugging Assistant and FX5U

After multiple PLC data modifications, a correct string of numbers was finally sent; as shown in the last line;

How to Ensure FX5U Communicates Properly with Barcode Scanners

▲ Figure 3-9 Serial Port Debugging Assistant and FX5U Communication Test

6. Identify Issues and Correct Errors

Using the program sent from FX5U to the Serial Port Debugging Assistant to send to the barcode scanner, correct data can be obtained. The modified program:

How to Ensure FX5U Communicates Properly with Barcode Scanners

How to Ensure FX5U Communicates Properly with Barcode Scanners

Test results are as follows:

How to Ensure FX5U Communicates Properly with Barcode Scanners

Source: Technical Training Network, Author: Lin Ruihua, Unauthorized reproduction is prohibited!
HISTORY
/
Previous Recommendations

Three essential tools for electricians, use WeChat to access them with one click!

Which of the five major electrical drawing software (CAD, Eplan, CADe_simu…) do you pick?

The latest electrical version CAD drawing software, with a super detailed installation tutorial!

The latest electrical drawing software EPLAN, with a super detailed installation tutorial!

Common issues for beginners using S7-200 SMART programming software (with download link)

Comprehensive electrical calculation EXCEL sheets, automatically generated! No need to ask for electrical calculations!

PLC programming basics: Ladder diagrams and control circuits (with 1164 practical cases for Mitsubishi PLC)

Still can’t understand electrical diagrams? Take away the basics of electrical drawing and simulation software, and quickly get started with theory and practice!

12 free electrician video courses, 10GB of software/eBooks, and 30 days of free electrician live classes are being given away!

Don’t forget to like + follow!
How to Ensure FX5U Communicates Properly with Barcode Scanners

Leave a Comment