A time domain reflectometer (TDR) can be built using a microcontroller's ADC and timer to measure cable length by sending a signal pulse and detecting reflections; the time delay between the transmitted pulse and reflected signal, combined with the cable's velocity factor (typically 85% of light speed), allows calculation of cable length, making this a practical tool for identifying cable faults and breaks.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
The Worlds Cheapest Time Domain ReflectomoeterAdded:
I had a fun little project his weekend where I took one of my fun little ch32v006 boards and I just took a little coil of wire and decided to see if I could measure inductance. And this is just measuring inductance using some of the built-in stuff with the ch32v006.
Now there are common ways to measure inductance, such as being able to use a frequency counter or something like that. But I decided to see if I could use it a little more of a creative way.
To cut to the chase though, I just wanted to show what some of these different things look like. So if I take in a piece of transformer ferrite from a high frequency transformer, we can see that it greatly increases the inductance. But if we take something like aluminium, like from an aluminium circuit board, it reduce the inductance of the system. And there's lots of other materials that have interesting properties surrounding this.
You can see most of the materials in here will reduce it. There are other materials.
this pair of clips here. For some reason, interestingly, it causes the waveforms to pinch together. Now you might be wondering, if I'm measuring inductance, what are all these waveforms? Why are there so many differnet waveforms. We'll go into that in a minute.
This is using one of my new tricks. This is using Scheduled IO. And I've done things like this in the past, like my little SAO for the MAGFest swadge where I was using DMA to drive the array.
But this one is a little more generic. I have it set up where you can schedule I/O operations to happen. So you can say at a certain time, output this value to this port. And this value to this port. And you can set all of these up, and then you can say go run the scheduled operation.
There's ones you can read and write arbitrarily. Ones that will read and write from anywhere at specific times, and one that will operate at a specific timing increment for each of the values. Reading from a certain place and writing to another. Using these primitives we are able to control something pretty neat. Going over to the projects folder here and open the inductance tester. And we want the inductance tester. And for the inductance tester we've set up the ADC to start sampling. So what we'll do is turn on a given pin. We'll turn on the pin associated with this side of the coil right here. So this is PD2. And so that pin turns on, and we're set up to measure that pin as well. We're set up to receive and see what's on that pin. Then we turn the pin back off after these specific times. Now one of the fun things is we can go through, and in increments of 1/48 Millionths of a second we can sample at different times.
So while we're not sampling at 48MHz, we're able to take a snapshot where we control that time to within 1/48Millionth of a second.
What we can see here is we can see that what I've decided to do was sample many times (32 times) and for each of the 32 times, I wanted to, in order, start sampling (in order) it happens around here. The ADC opens the gate some time around here. And then we turn the I/O back off.
After showing the video to a couple of people they pointed out that it's probably better to visualize the time domain graph in this way instead of the other way. This is kidna showing a faded view of where the line was. And we can see very clearly how sort of how inserting and removing these has the effect on the time. And the idea is the time starts here on this side and we bump it up and what happens is the inductor saturates and eventually it's just DC resistance across the inductor. And if we put something in that can take in more energy, it will. Verses if we put in something like a quarter it kinda mutes it down. And so you guys see what it looks like on this mode with a pair of dykes. I don't know why it changes what looks like a much longer tail, but yeah so it's just a different way of seeing it.
And what I mean by opens up the gate is there is a mux, internal to the ADC and that mux will open for a short time for the ADC capacitor to charge and be able to start sampling and measuring the signal.
So we're able to say start at different times back here so the gate will close at various points here so we can measure the exact voltage at different points along this arc. So what we've done is now, at each different point along the arc. So yellow, the firthest point this way, then blue then orange and then purple and then on down, using these they're able to sample at different points and while it's very difficult to see any kind of change in the shape of the curve based on the inductance the precision on the 006 allows us to see very clearly changes with the inductance.
So the idea there is by measuring those specific places we can get a very good idea what the value is.
Now I am oversampling, so let's see what it looks like if we do no oversampling.
So we're just going to do a single sample each. We're going to go a little bit faster. Well it's not going to go faster, it's going to go, I'm actually debugprintfing, so it's going to go about the same speed the data coming through. But now it's a lot noisier. You can see a lot more fuzz in the signal. It's the same type of signal, it's still doing the same kind of thing, but it's a lot furrier. The signal is coming through. Now there's a fun thing on these ch32v006 boards I have, there's actually a little crystal on them. Now that crystal will help us make that timing more precise. A lot of the error inside an ADC is actually due to the crystal's ability to be precisely timed. In addition the time that we're able to measure the point on the curve is very much controlled by how precise our clock is.
Now what I'm going to do is go into funconfig and I'm going to say USE_HSE, that's the external oscillator and we're going to rebuild everything and run it. So, now, even though it's only doing a single sample, you can see that it's way less noisy. And it comes through with a much cleaner signal. So you can see it's very very clear now that we have it. Now there's some interesting points to note.
One of them is it looks like the ADC in the 006 has some issues. So if we take a look at the teal line here. As we approach a certain code value that is divisible by 512, we end up having a strange behavior where there's sort of like a discontinuity. I don't really know what causes that. I don't know what's there, but I do notice that if we oversample that does seem to go away for the most part. I know it can't go away completely but it goes away for the most part. So let's go back to oversampling and now this is the the crystal so it's going to be super duper quiet. And you can see the teal line there is pretty darn quiet. There's really no discontinuities getting it right near one of those values that cause problems.
One of the things the time domain reminded me of was this tektronix training video from the 1950's or 40's or something that show transmission lines. And I was wondering. Can I do something like that? The only thing was I would need some absolutely insane roll of crazy coax cable. Which sure enough, I just emailed some people at work and turns out someone purchased one a while ago for some reason and I decided why not give this a shot. So I took a uiapduino, this is from Yuuki here, and hook it up and run the same firmware. Extend it out some and make it so I send a little pulse instead of driving it high, and see what happens over time. So right now it's not connected or anything so you just see the pulse. but if I plug it into the coax cable here, then all of a sudden you will see that this now reflects. And what's actually going on here is the signal is being generated here, it's going down the coax cable, going back and forth. And it's hitting this open end right here and reflecting back. And here's the neat part.
When you do this with a coax cable like this and you have a reflection... if it's open on the end, the reflection that's coming back is positive. If we short this out, so I take this right here and pinch that right there, you can see that the reflected signal is actually going to now reflect back in a negative way. It's kinda hard for me to keep my hand there. And if we instead then go and take this, it's a little 51 ohm resistor. It's a 50 ohm characteristic coax cable, if we apply a resistor to the end, it completely negates the reflected signal. And that's why it's important to always terminate your signals. Now one of the other things that's kinda interesting to see here is we can actually see both the signal and the reflection and we can measure the length of the cable based on the velocity factor but we also see these other reflections. So what's happening is the signal is coming out of here, going down the cable, bouncing off the end of the cable coming back and bouncing off this end and going back and forth and back and forth and that's what the other pulses are. But what we can actually do is take a little extension and plug it in and we can see now it's almost completely gone. It's still a little bit but that's because I don't quite know the right value to be an input to the ch32v006. But it's almost completely gone. But yeah, let's now take a moment say based on this, how long is this cable?
So what we're going to do is we're going go start it at about the 50th percntile to about maybe about here. And we're going to see how this works out. So what I'm gonna do is start by counting the number of 1/48millionths of a second from here to here. It's actually a little bit less than 59. Maybe 58.5. That's 58.5 48millionths of a second. And we're gonna convert that into microseconds. So that's going to be over 48. And then what I'm gonna do is we're gonna go take these microseconds and convert them into feet. So what we do is we take 9.836 and we get 1198.76. It should be a 500' roll, but, it is there and back. So it has to go down the cable, turn around and return. That's still 1000, why are we getting 1198.76, and the answer is something called velocity factor. So we take a look at the velocity factor. So that's 85%. So instead of the speed of light, it's 85% of the speed of light. So what we'll do is multiply this by .85. And that will give us 1018 feet. I dunno how long that cable is but if we take that and divide it by 2, we get 509 feet total. I dunno that's pretty close to how long the cable should be. Certainly within the margin of error of the increments we're working with here. This is kinda a toy problem right here that we have with a cable going here and back and seeing that it wasn't terminated right, but this is used in real life to identify where in a cable there's a problem. So if you have a long line like back in the days of DSL, and there's a problem like a cut in the cable or a short to ground, like where the cable is shorted out, you would see these reflections going in at different points in the cable and by viewing this you would be able to identify where in the cable there was a break. So I dare say we might have created with this ch32v006, this little 15 cent microcontroller or 12 cent, the world's cheapest time domain reflectometer, or sampling scope. I'm not realy sure what to call this thing.
This is a fun little project you can do with the ch32v006 devboards, and just about any devboard because all it takes is an ADC pin because the same ADC pin can be used both for driving high and low for measuring inductance. This was a fun little project. One of the other things I guess I should mention that this got me to do was work on this little tool here, called dyngraph which is part of my usefulcmds repository. And that's like a whole thing.
I was pretty happy how I was able to throw something together with rawdraw and now the idea is if you just print a bunch of values on lines, just a bunch of values in a row, this tool can those those and plot those in this sort of consistent way. And, you can mouse over various fields and see what they're doing. One of the things I'd still be curious about is why something, like this tool here causes this weird pinching behavior, like what kind of material is this that causes that. If you know, please let me know.
I had a lot of fun doing this little project, and it was all based off a little nerd sniple that happened earlier this week by my friend HikariFaith. So I hope you guys thought it was as interesting as I thought it was and yeah. Thanks for watching.
Related Videos
U.S. Military Just Flexed The Most Dangerous Aircraft Ever Built The F-47
MaxAfterburnerusa
11K views•2026-05-29
Heating Staying On On The Hottest Day Of The Year
PlumbLikeTom
507 views•2026-05-29
발전 효율을 높이는 태양광 추적 시스템의 기술적 원리 #공학 #공정 #태양광 #알고리즘 #재생에너지
찐현장기술
2K views•2026-05-29
How Far Can A Tomahawk Missile Actually Travel?
WarCurious
13K views•2026-05-28
직관 및 곡관 배관 결합 고정 작업 #worker #process #fabrication #pipework #clamp
월드촌촌
2K views•2026-05-30
Wire To Wire Connection Trick | Strong And Secure Electrical Joint #shortvideo #wireworks
ElectricianTips-b1h
5K views•2026-06-02
Peterborough to Newark Northgate Driver's Eye View aboard an InterCity 225 - East Coast Main Line
TrainsTrainsTrains
822 views•2026-05-31
AI turbine design: hypersonic cooling leap #shorts #ai #hypersonic
bobbby_rn
671 views•2026-05-31











