Specialist Supplier of Crystals & Frequency Control Componentssales@mecxtal.com.cn0755-26500570
MERLIN home / Rednote / Passive Crystals and Oscillator Circuits

RS-485 is set to the right baud rate. Why does Modbus RTU sometimes receive only half a message?

A register read works repeatedly on a bench instrument. With the same cable connected to a gateway and polling faster, some messages are treated as two pieces and the receiver reports a check error. The new board uses the same nominal oscillator frequency and baud rate as the old board. Capture a complete failure and ask three questions. Does the bus waveform actually break? Is there extra idle time between characters? Does the gateway release its driver before the final stop bit? These checks tell you more than the oscillator marking alone.

RS-485 specifies the differential electrical interface. Modbus RTU uses its own rules to identify frame boundaries. An oscilloscope may decode each character into hexadecimal while the receiving software still groups those characters into the wrong frame. RTU uses an idle interval between frames. A pause that is too long inside a frame can cause an incomplete message to be discarded. A manual serial tool may hand a whole buffer to the UART at once. An application that submits each byte separately may leave enough time for task scheduling to insert a gap. A more accurate clock cannot replace a byte that never reached the UART in time.

Convert character times to measurements on the screen

Assume 11 bits per character, including the start bit, data and required parity or stop bits. At 9,600 bit/s, one character lasts about 1.146 ms. A 3.5-character interval takes about 4.01 ms, and a 1.5-character interval takes about 1.72 ms. If software treats 3.5 character times as 3.5 ms, it sets the gap too short for this rate. Counting only the eight data bits makes the error larger. Use the real character format and record both transmitter settings and receiver timing logic.

The Modbus Organization's serial-line guide recommends fixed timing above 19,200 bit/s, with 1.75 ms between frames and a 750 microsecond intra-frame timer. Test interoperability against the project's protocol declaration and actual devices. A legacy device accepting a shorter gap does not guarantee that another will accept it. Likewise, the high-speed values should not be applied indiscriminately at lower baud rates. When polling at several speeds, log the configured timing and measure the actual gaps at each speed.

In a hypothetical 9,600 bit/s transaction, the first ten characters leave the UART continuously. A task switch causes a 3 ms gap before character eleven. This is longer than 1.5 character times but shorter than 3.5. A receiver may discard the current frame as invalid without treating the rest as a valid new request. The application can report a CRC error or no response even though its checksum calculation is fine. If a contiguous hardware buffer removes the error, record the scheduling or buffering change. If the gap is normal but the last byte is truncated, investigate direction control.

The UART still has bits to send after software queues the last character

On a half-duplex bus the transmitter often switches a driver-enable signal. When the final byte is written, the UART may still be shifting it out. A flag that indicates buffer space or an empty software queue can arrive before the final stop bit. Observe the UART transmit signal, driver enable and differential bus voltage together. Trigger on the direction transition or fault. If enable is dropped early, check the controller's transmit-complete definition and driver turn-off delay. If the frame finishes, check when the slave may reply and whether the master is already in receive mode.

Use a known register-read command to compare the original gateway and old instrument over a short cable with the replacement gateway under the same conditions. Save the whole frame, silence interval, reply and direction trace. Then use the installed length and specified termination and loading, changing one factor at a time. Save actual byte timestamps with the waveforms and compare them to firmware events. A single line reading "timeout" does not tell you whether the message failed to arrive or was discarded later.

If an individual bit is actually too wide or narrow, trace the controller clock, divisor and oscillator tolerance. Specify the oscillator's place in the clock tree and the divider settings used for each baud rate when buying a replacement. The acceptance worksheet can record bit width, frame spacing, maximum intra-frame gap and driver turnaround. That gives the team a repeatable check after either an oscillator or transceiver substitution.

Timestamp location matters. A serial adapter can hand several batches of already received bytes to the PC at once. A late host notification does not show that the wire went idle. Conversely, buffering can hide a long wire gap in an application log. Reconstruct the message at the bus first and compare it with delivery events in the program. Keep the two sources clearly identified.

References

WeChat

MERLIN · TIMING COMPONENTS

Scan with WeChat to contact Sales

Add our WeCom contacts from your usual WeChat app.

On desktop, scan with your phone. On mobile, save the QR image and select it from your album in WeChat Scan.