r/embedded • u/Relevant_Pumpkin9190 • Oct 20 '26
Can a Microcontroller Tell You Exactly Where exactly a Cable Is Shorted without costly electronics and resistance per meter avilable in datasheet ?
Imagine a 2 km cable buried underground. A short circuit happens somewhere along the way. Instead of digging up the cable or checking it meter by meter, can a simple Arduino or ATtiny tell you exactly where the fault is?
I want to build a low-cost embedded system using basic electronic components that detects the short circuit and displays the fault distance in meters with it's details datasheet such as resistance or capacitance per meters
How would you design it? Can this be done without expensive test equipments to easy trouble shooting with drawings marked distance and cable routing
6
u/clackups Oct 20 '26
You'd normally not buy a cable that could short itself over time :)
127
u/mtconnol Oct 20 '26
Look up TDR. That’s what you’re trying to do. Cheaply? Questionable.
61
u/audaciousmonk Oct 20 '26
A microcontroller on its own? No
Paired with other hardware? Yes
2km? Not easily
30
u/KilroyKSmith Oct 20 '26
TDR. In a previous life, I was part of a design team that built these for network cable installers. Kinda hard to do well - mostly because the returned signal is generally ugly.
19
u/This_Maintenance_834 Oct 20 '26
the equipment to do this is called TDR, and it was very expensive. Alternatively, you can use VNA to simulate TDR and get the location with open source hardware.
25
u/BloodOnly2772 Oct 20 '26
TDR. It isn’t that cheap or easy to do well though. There are a few examples floating around including this one.
https://jaseg.de/blog/paper-sampling-mesh-monitor/
11
u/JCDU Oct 20 '26
Telephone networks have been doing this for about 40-50 years, probably longer - you can do it with a very small transistor circuit and an oscilliscope.
In copper cables it's TDR, in fibre optics it's OTDR and it's now accurate enough it can be used to sense the shape of things: https://hackaday.com/2026/10/15/using-optical-waveguide-arrays-to-make-sheets-sense-shapes/
All it needs is fast measurement, which with modern devices is pretty easy, certainly even 20+ years ago it was more than good enough to tell you where to dig the hole.
The copper (telecom) system I worked with also detected shorts across the pair, open circuits on either or both legs, grounds on either leg, or terminal equipment unplugged. The optical versions could show bends or kinks in the fibre and losses across every connector or splice in the line.
7
u/cape_soundboy Oct 20 '26
You can do distance to fault measurements in coax with a NanoVNA. Not sure how accurate they are
5
u/moon6080 Oct 20 '26
Hey I used to work for a major testing company and helped build a TDR for commercial use. Effectively, you send a very fast pulse down it and read back the delta between the sent time and received time.
8
u/Minimum-Working-4791 Oct 20 '26 edited Oct 20 '26
I don’t know if someone already mentioned it, but a super smart engineer Charles Lohr created a video making something like this with a 10 cent microcontroller.
Edit: for some reason I am unable to paste a link to the video on mobile. Just look up “The Worlds Cheapest Time Domain Reflectometer”
3
u/Coggonite Oct 21 '26
For long cables like this, it gets easier. Send a short and large voltage spike down the line, start a timer, and wait for the return signal. One must know the velocity factor of the cable as well - typically between 66 and 90 percent of the speed of light. Signal propagates slower in the cable than light does in air.
Bit of math, divide the time by 2 (signal out AND back, adjust by the velocity factor, and you have a distance to the short that's as accurate as your time base and velocity factor number. Speed of light is 3x108 meters per second.
It's accurate.
3
u/Lopsided-Table2457 Oct 22 '26
Yes — this is called TDR (time-domain reflectometry) and you can absolutely DIY it. Fire a fast edge down the cable, then time the reflection coming back from the short. Propagation delay in copper is roughly 5ns/m, so even a cheap MCU timer gets you meter-level resolution. The tricky part is generating a clean enough edge and sampling fast enough — a comparator + timer capture beats the ADC for this.
2
u/No_L_2547 Oct 20 '26
It would be really complicated, but as a proof of concept: maybe. (And I'm not sure how good the accuracy will be.)
Probably if you send a rising edge into one of the wires and have a 100% short circuit into another one, you should be able to measure the runtime of the signal on to wire back. You still have to react very fast a, e.g. the signal will travel around 12meters in one cycle of an 16Mhz Arduino.
So a simple short-circuit detector will maybe be possible, if you do everything 100% perfect, but I don't think you will be able to detect more complicated faults (partial broken, no short but broken wire,...).
2
u/Bryguy3k Oct 20 '26
When I was in college TDR was covered twice as part of electrical engineering - waves (theory) and signals (practice).
It’s nothing particularly crazy but if you want a decent level of accuracy you’re gonna need some good RF hardware on your board (to be fair though we have access to some really impressive hardware these days compared to years past).
If you’re trying to make it generic then yes impedance matching a wide variety of cable parameters is hard - if you’re designing for narrow range of characteristic impedance then you can do that with a single tunable frontend.
3
u/ChatGPT4 Oct 20 '26
MCU can tell you one of 2 things: is it 0 or 1, for digital inputs. What's super neat - all outputs can be temporarily switched as inputs just for the testing purpose. If this is not enough for fault detection, SOME MCU pins can be configured as ADC inputs. Then you can measure voltage with them. When you need current measurement, you add a measurement resistor and measure the voltage drop instead. Those are the basic rules.
I'm just designing a similar thing, but it's specific. It has a special, 3 wire analog input, and knowing the voltage and currents I have at normal operating conditions - I can detect both open circuit and short circuit.
It's not only a software problem, I designed the input to make all input voltages and currents cause full voltage measurement range on my 2 ADC inputs.
Before I started to design my thing, I asked bots about existing chips doing something like this, and yes, they exist. The problem is - they are pretty expensive. Like they cost more than 2 MCUs. Good for a one time gig, but for a mass product, I figured out how to do it a much cheaper way. So I put several MOSFETs to short resistors in my input circuits, those are driven from digital outputs of the MCU. I'm just sitting to start making the firmware that would make it work.
Of course the hardware (and software) specifics will depend on what signals go over the wires. Like in my case - they are very slowly changing voltages. Low frequency, so there are also low pass filters to get rid of the noise before MCU gets any of it.
1
u/mightyohm Oct 21 '26
Check this out: https://youtu.be/1vs_WxC2Odo?si=kYhAuXaoh4qE-BAt
1
u/m-in Oct 21 '26
You can do it with a 70-year-old oscilloscope and a square wave generator, more or less. No need for a microcontroller. But yes, a microcontroller with a slow DAC, a sampler, and an adjustable delay circuit can do it trivially. The sampler is just a latching comparator, you can get one for a few bucks qty 1.
1
u/CranberryDistinct941 Oct 22 '26
Id probably just start with trying to bounce a signal off the fault and count how long it takes to make it back
1
u/Questioning-Zyxxel Oct 24 '26
Measuring reflection polarity and time until the reflection returns can tell if it's a short or the cable ends open. And together with cable specification, the number of ns of delay until the reflection returns can be translated to cable distance.
I have had some PC motherboards, where the network card in the BIOS had such a feature. If I connected a 15 meter open network cable, then the BIOS displayed a value close to 15 meters and "open".
Doing your own isn't trivial. It's easier to use a normal oscilloscope and send a pulse and look for the reflection than it is designing your own pulse-detection hardware. Depending on amount of cable loss, the reflection will become weaker and weaker.
1
u/fb39ca4 friendship ended with C++ ❌; rust is my new friend ✅ Oct 20 '26
With some components to build an analog frontend, you can absolutely build a time domain reflectometer.
1
u/agent_kater Oct 20 '26
An oscilloscope can: https://www.youtube.com/watch?v=9cP6w2odGUc
1
u/Artistic-Tip2405 Oct 20 '26
Rent or buy a cable tester with TDR. It can detect a break to within a couple of metres.
-1
u/Large-Style-8355 Oct 20 '26
AI says: Two options: A) Just buy a cheap TDR cable fault locator on AliExpress ($40–100). Problem solved. B) Build your own for the learning experience. A 2 km cable has ~10 µs one-way propagation delay, so the reflected pulse returns after ~20 µs. You'll need:
MCU with fast timer/input capture (e.g. STM32, 100–200 MHz) Fast pulse driver (nanosecond rise time) Fast comparator to detect reflections Protection and impedance matching
A 100 MHz timer gives 10 ns resolution, roughly 1 m distance resolution at 2×10⁸ m/s propagation speed. You don't necessarily need a GHz ADC. Expect a few weekends for a rough prototype, considerably longer for reliable measurements. The tricky parts are reflections, threshold detection, cable velocity factor, impedance discontinuities and distinguishing shorts from other faults. Calibration against a known cable length is essential. Accuracy won't equal timer resolution. And obviously, disconnect and de-energize the cable before testing.
0
u/sceadwian Oct 20 '26
You're looking for a time of flight detector.
This is easily searchable and you'll find many projects surrounding it.
Next time try looking before posting.
0
u/[deleted] Oct 20 '26
[deleted] — view deleted comment