Skip to main content
Explore ERDILRF

Press ↑↓ to move, Enter to open, Esc to close.

Rangefinder UART Flow Control: When You Need It

For rangefinder UART flow control, first check whether the host can drain incoming bytes fast enough and has room for its longest processing pause. If it can, a correctly sized receive buffer may be sufficient; if it cannot, a larger buffer merely postpones overflow. Use hardware flow control only when the exact sensor and host both document compatible support. Otherwise, consider a documented request-and-response mode or redesign the receive path.

Start with the actual frame and output rate

Calculate the incoming data rate from the complete reply length, including header and check bytes, multiplied by the maximum frame rate for the mode you will use. Do not substitute the UART baud rate for the sensor’s output rate: baud describes line capacity, while the frame rate describes how much information the device produces. Include configuration responses or other traffic if they can arrive during the same interval.

For example, the LRF600H source describes a four-byte output and automatic selection of 1 kHz or 50 Hz according to reflected-signal intensity. If each measurement at 1 kHz produces one four-byte frame, that would be 4,000 bytes per second, before any additional traffic; confirm the actual output rate for the delivered configuration. Its UART is documented at 460,800 bps, adjustable, with eight data bits, one stop bit and no parity. Under that 8N1 format, each byte occupies ten line bits; the theoretical line capacity is 46,080 bytes per second. That is a line limit, not a promise that the sensor continuously sends at that rate.

The SPD1200N2 source describes eight-byte frames and a default baud rate of 115,200 bps. It documents single and continuous ranging commands; determine the actual mode and response traffic before budgeting. Its source gives an adaptive frequency as 2–15 Hz or 4–15 Hz, with the lower bound unresolved. Do not choose between those lower bounds: confirm the delivered configuration with ERDI. Fifteen eight-byte frames per second would be 120 bytes per second as a conditional calculation, not a guarantee of evenly spaced frames or the complete traffic profile.

The practical difference is not just the average. A sensor can send complete frames in short bursts, and a host may be unavailable while servicing storage, networking or another interrupt. The UART module overview provides a starting point for selecting the interface; the buffer budget must come from the actual mode and host workload.

Turn a host pause into a buffer budget

For a bounded pause, start with incoming bytes during the pause + bytes already queued + burst and in-flight allowance. The usable capacity of the receiving stage must cover that total. Count only free space at the start of the pause, and check each stage separately: a hardware FIFO can overflow before a large software ring buffer gets a chance to help.

As an illustration, assume the four-byte stream above is evenly paced at 1,000 frames per second, no other messages arrive, and the receive hardware continues moving bytes into the ring while the application is paused for 100 ms. The average arrival is 400 bytes. Allowing one extra four-byte frame for timing at the boundary gives a planning estimate of 404 bytes of free ring capacity, before existing backlog and any additional margin. This is not a worst-case guarantee for an undocumented burst pattern. For a conservative bound where the transmitter might occupy the 460,800 bps 8N1 line continuously, 100 ms corresponds to 4,608 bytes, again before backlog and margin. Establish the actual traffic envelope instead of silently assuming either pattern.

If the ring begins with 100 bytes already waiting, the evenly paced illustration needs at least 504 bytes of usable capacity before margin. A nominal 512-byte ring would then leave only eight bytes of headroom; it is not an adequate engineering margin for uncharacterised bursts. Check whether the implementation reserves a slot to distinguish full from empty, and use usable rather than allocated capacity.

When processing resumes, the consumer must be faster than the ongoing input long enough to eliminate the backlog. At 4,000 incoming bytes per second, a consumer draining 6,000 bytes per second has a net recovery rate of 2,000 bytes per second. A 400-byte backlog would take about 0.2 seconds to clear, assuming both rates stay constant and no further pauses occur. If the drain rate is at or below the arrival rate, no finite buffer fixes sustained overload.

Choose between buffering and flow control

  • Use buffering when incoming traffic and host pauses have bounded, measured limits, every receive stage has enough free capacity, and the consumer can recover between pauses.
  • Reduce host-side work by moving parsing or logging out of the time-critical receive path. DMA or interrupt-driven reception can help where the host supports it, but neither removes the need to size each buffer and detect overruns.
  • Consider hardware flow control only after confirming supported pins, electrical levels, polarity and stop/resume behaviour for both endpoints. Budget bytes already in flight and any transmitter response delay. A host RTS/CTS setting alone cannot make an undocumented sensor stop sending.
  • Consider application pacing if the delivered protocol explicitly supports a suitable request-and-response mode. Limit outstanding requests and account for replies and timeouts; do not assume a streaming mode can be paused by a generic command.
  • Change the architecture if worst-case traffic or host pauses cannot be bounded, or if the consumer cannot catch up. A larger buffer buys time, not infinite throughput.

The cited product records do not establish RTS/CTS support for these two models. Ask ERDI for the applicable interface documentation and delivered configuration before enabling or wiring hardware flow control. In particular, the LRF600H record lists a supply range of 9–36 V DC but says the UART logic level is not specified in the source. Supply voltage is not a signal-level specification; confirm the electrical interface before connecting a host.

Acceptance test at the maximum intended rate

Run the test on the intended host, firmware and receive path. Use the highest documented output rate applicable to the delivered configuration, and exercise the real competing workload. If rate is adaptive, do not assume the unit is in its fastest mode: establish the operating condition or verify the observed output rate without claiming an undocumented control method.

  1. Record the selected mode, frame format, serial settings, usable capacity of every receive stage, and measured output rate.
  2. Measure the longest interval during which each stage cannot be serviced, including interrupt masking and application scheduling delays. Record the largest occupancy or backlog.
  3. Exercise those pauses repeatedly while receiving, including startup and any documented configuration exchanges. Monitor hardware overruns, buffer overflow counters, malformed frames and checksum failures separately.
  4. Verify recovery after each pause: backlog should return toward its normal level, not increase from cycle to cycle. Compare the observed high-water mark with the free capacity and planned margin.
  5. Inject a controlled dropped byte in a test stream and verify the parser discards suspect data and resynchronises using the applicable frame and checksum rules. A checksum is not proof that every loss was detected; use sequence information only if the actual protocol provides it.
  6. Define the run duration and pass limits for your application before testing. Record the conditions and results; passing one workload does not prove operation under every possible burst or pause.

If capacity is exhausted, capture which stage overflowed before changing the design. Increasing an application buffer will not repair an overrun in a hardware FIFO that was not serviced in time. For help checking the delivered interface and the assumptions in your budget, use the contact page.

FAQ

Is RTS/CTS supported?

The cited records do not establish RTS/CTS support for either model discussed here. Confirm the delivered interface, signal levels and stop/resume behaviour with ERDI before relying on it.

How big a buffer?

Budget for bytes arriving during the longest bounded service pause, existing backlog, bursts and in-flight bytes, plus margin. Check each receive stage and ensure the consumer can clear the backlog afterward.

What happens if I drop a byte?

A frame may become invalid and subsequent bytes may be misaligned. Discard suspect data and resynchronise using the model’s documented framing and checksum; a checksum alone cannot guarantee detection of every loss.

Models mentioned in this article