8 PLCs Serial Communication with Laser Distance Sensor Guide

Integrating a laser distance sensor into an industrial automation system often requires robust serial communication with a programmable logic controller. This guide walks through the process of connecting a laser rangefinder to eight different PLC platforms using RS485. The goal is to trigger a single distance measurement every 1000 ms from a sensor with station address 01, using a custom protocol over a 19200 bps, 8 data bits, no parity, 1 stop bit (8N1) link. All data is handled in hexadecimal format.

Laser Sensor Communication Setup

The laser distance sensor comes preconfigured with 19200 bps, 1 start bit, 8 data bits, no parity, and 1 stop bit. Before wiring, verify these settings using the manufacturer’s configuration tool. The physical layer is RS485, which allows multi-drop networks up to 1200 meters. A typical electrical control panel design includes a 24V DC power supply, a PLC with an RS485 port, and the sensor. Proper grounding and termination resistors (120 Ω at both ends) are essential to avoid signal reflections.

Communication Protocol Breakdown

The sensor uses a fixed command frame to start an automatic measurement. The request and response structures are shown below:

Field Bytes Request (Hex) Response (Hex) Description
Start Delimiter 1 AA AA Fixed header
Station Address 1 01 01 Sensor ID
Register Address 2 00 20 00 20 Command register for auto measurement
Payload Count 2 00 01 Variable Number of data bytes following
Payload 2 00 00 Variable Reserved or status
Distance Value 4 32-bit integer Measured distance in millimeters
Checksum 1 Calculated Calculated Low byte of sum from start delimiter to end of payload

The checksum is computed by summing all bytes from the start delimiter through the last payload byte, then taking the lower 8 bits. For the request frame (AA 01 00 20 00 01 00 00), the sum is AA+01+00+20+00+01+00+00 = CC, so the checksum is CC. The complete request becomes AA 01 00 20 00 01 00 00 CC. The response frame includes the distance value in millimeters as a 32-bit integer, which the PLC must extract and convert.

PLC Implementation Details

Each PLC brand requires specific configuration and programming. Below are the steps for eight common controllers. All examples assume a receive timeout of 5000 ms to accommodate sensor response time. A trigger bit (e.g., M0) initiates the measurement cycle.

Rockwell Automation Micro850

The Micro850 uses a 2080-SERIALISOL plug-in module on channel 5. Configure the port for 19200, 8N1. Use the Micro800_NP_Send and Micro800_NP_Recv function blocks. Set the receive timeout to 5000 ms. When M0 is set, the send block transmits the request frame. The received distance is stored in a designated register. Ensure the serial isolator module is properly seated and the RS485 wiring matches the sensor’s A/B terminals.

Siemens S7-1200

With a CB 1241 communication board, the hardware identifier is typically 269. Set the port parameters to 19200, 8N1. Call S71200_NP_Send and S71200_NP_Recv in a cyclic interrupt OB to ensure consistent timing. The receive timeout is 5000 ms. A rising edge on M10.0 triggers the send. The distance data is parsed from the response buffer and moved to a data block. The CB 1241 supports RS485, but check the wiring diagram for proper termination.

Siemens S7-200 SMART

The SB CM01 signal board provides an RS485 port, assigned as port 1. Configure the port for 19200, 8N1. Use S7200_NP_Send and S7200_NP_Recv with a 5000 ms timeout. M0.0 starts the measurement. The distance value is stored in V memory. The S7-200 SMART’s freeport mode allows custom protocols, but remember to switch back to PPI mode if needed for programming.

Schneider Electric Modicon M241

The M241 uses the Serial_Line_2 port with the ASCII_Manager driver. Set the baud rate to 19200, 8 data bits, no parity. The Modicon_NP_Send and Modicon_NP_Recv function blocks handle the communication. A timeout of 5000 ms is set in the receive block. M0 triggers the send. The received distance is placed in a %MW array. The ASCII_Manager requires careful configuration of the frame reception conditions; use a character timeout to detect the end of the response.

Mitsubishi FX5U

The FX5U’s built-in RS485 port is configured for “Non-Procedural” protocol. Set the baud rate to 19200, 8 data bits, no parity. Disable start/end characters and checksum. Choose Format 1 and 16-bit mode. The timeout is set to 10 ms for character reception, but the overall receive timeout in the function block is 5000 ms. Use FX5_NP_Send and FX5_NP_Recv. M0 initiates the measurement. The distance data is stored in D registers.

Omron CP1H

With a CP1W-CIF11 RS-232C/RS485 adapter on serial port 1, set the mode to RS-232C (the adapter handles conversion). Disable start code, set end code to 256 bytes, delay to 0, baud rate 19200, format 8N1. CP1_NP_Send and CP1_NP_Recv function blocks are used. W0.00 triggers the send. The distance is stored in DM area. The CP1H’s serial port settings are in the PLC Setup; ensure the port is in no-protocol mode.

Panasonic FPXH

The FPXH uses COM1 with a COM3 communication module. Set the mode to “General Communication,” speed 19200, 8 data bits, no parity, 1 stop bit. Disable start character, set reception end to time (5 ms). The receive buffer starts at DT1000 with a capacity of 100 words. FP_NP_Send and FP_NP_Recv user libraries manage the protocol. M0 starts the measurement. The distance is extracted from the buffer and converted to a real value.

Delta DVP-ES3

The DVP-ES3 uses COM1. Configure the port by writing to special registers: SR209 for 8N1, 19200; SR210 for timeout (0); SM106 for 16-bit mode; SM209 to switch protocol. DVPES3_NP_Send and DVPES3_NP_Recv function blocks are called. M0 triggers the send. The distance is stored in D registers. The ES3’s COM1 can be RS232 or RS485 depending on the model; verify the wiring.

Inovance Easy521

The Easy521’s built-in RS485 port is set to “Free Protocol.” Configure port 0 for 19200, 8N1, frame interval 2 ms. Easy500_NP_Send and Easy500_NP_Recv function blocks are used. M0 starts the measurement. The distance is stored in D elements. The Easy500 series supports up to 115200 bps, but 19200 is reliable for longer cable runs.

Wiring and Electrical Control Panel Considerations

When integrating these components into an electrical control cabinet, follow best practices for noise immunity. Use twisted-pair shielded cable for RS485, with the shield connected to earth at one point only. Separate communication cables from power wiring. In an electrical control panel design, include a dedicated terminal block for the RS485 network, with clearly labeled A, B, and GND terminals. A 120 Ω termination resistor should be installed at the PLC end if it is the last device on the bus. Some PLCs have built-in termination that can be enabled via DIP switch or software.

Troubleshooting Common Issues

If communication fails, check the following:

  • Verify the sensor’s station address matches the request frame (01).
  • Confirm baud rate and data format on both devices.
  • Measure the voltage between A and B lines; idle state should be around 1.5–3.5 V differential.
  • Use a serial monitor to capture the raw data and compare with the expected frames.
  • Ensure the PLC’s receive timeout is long enough; some sensors may take up to 2 seconds to respond.
  • Check the checksum calculation; a single bit error will cause the sensor to ignore the command.

Expanding to Other Automation Control Systems

The principles described here apply to many other PLCs and industrial automation control devices. For example, when using a distributed control system or an electrical control system with a PC-based controller, the same RS485 protocol can be implemented with a USB-to-RS485 converter and a custom script. In larger electrical control systems, multiple sensors can be polled sequentially by changing the station address in the request frame. This approach is common in conveyor positioning, level measurement, and robotic guidance applications.

By following these guidelines, engineers can reliably integrate laser distance sensors into their automation control solutions, improving precision and efficiency in manufacturing and process control.

Similar Posts