A rangefinder that measures to the millimetre is useless if the number arriving at the PLC is wrong one time in a thousand. Most of the failures I see in machine integrations are not optical — they are framing, timing and level problems on a cable that was 30 m instead of 2 m.
Here is the sequence that removes them, in the order the mistakes usually appear.
1. 3.3 V TTL over 30 m is where it breaks
A UART at 3.3 V works on a bench with a 30 cm jumper. Down a cabinet run next to a motor drive it does not, and the failure is intermittent, which is the expensive kind. RS-422 differential signalling exists for that distance; use it, or put the converter at the sensor and run 422 back.
Rule of thumb: under 2 m, TTL is fine. Over 5 m, in a cabinet with drives, treat differential as mandatory.
2. Decide the number format before the protocol
The sensor sends a distance in millimetres as an integer, or as ASCII digits, or as a float in a binary frame. Each has a different failure mode:
- ASCII digits: easy to debug, slow at high rates, and a truncated frame looks like a valid short distance.
- Binary integer: compact and fast, but needs an explicit unit and a sign convention agreed in writing.
- Float: rarely needed; a float that arrives byte-swapped is still a plausible number, which is worse than garbage.
Pick one, write the byte order down, and put a length or a checksum in the frame. A frame without either is a frame that will eventually be misread as a shorter distance — and a shorter distance from a crane or an AGV is the dangerous direction.
3. Triggering: free-running versus on-request
Free-running output at 1 kHz is simple, and it means the PLC receives 999 readings it discards. On-request triggering is efficient, and it means a missed request looks like a stalled sensor.
For a diverter, free-running plus a median filter over 3–5 samples usually beats on-request, because the median removes the odd wild reading and the PLC never has to wait. For a slow positioning axis, on-request is cheaper to debug.
4. Handle the no-return case explicitly
Every sensor has a maximum range and a target that returns too little light. The reading in that case is not zero and not infinity — it is an error code that has to reach the PLC as a distinguishable state. If the frame has no error bit and drops to "0 mm", a control loop will act on a distance that does not exist.
Ask what the module sends when it does not get a return, and test it deliberately by pointing it at the sky.
5. Check the timing budget against the machine, not the datasheet
A 1 kHz sensor updates every 1 ms; the PLC scan is typically 5–20 ms; the fieldbus adds a cycle. The number the control loop uses is therefore always 10–30 ms old. For a diverter moving at 1 m/s that is 10–30 mm of travel.
Decide whether that lag is acceptable before choosing between a faster sensor and a faster control loop. Usually the control loop is the cheaper fix.
A short checklist
| Item | Question to answer in writing |
|---|---|
| Cable run | Length and route; TTL or differential |
| Frame | Units, byte order, length or checksum, error code |
| Trigger | Free-running or on-request; who filters |
| No-return | What value arrives, and how the PLC distinguishes it |
| Lag | Age of the reading at the moment of decision |
None of this is optical engineering. All of it decides whether the measurement survives the trip to the PLC.
If you are integrating one of these now, describe the cable run and the frame you plan to use, and I will tell you where it will bite.
Licensed CC BY 4.0. Timing and interface details here are general engineering practice; specific module figures are published with their conditions at specs.erdilrf.com.
Top comments (0)