analog way of measuring time between rise edges? - Page 1
Forum section: electronics / projects

author: ice595
author_rank: Regular Contributor
timestamp: February 07, 2014, 04:02:05 am
content: I have this idea of making an inexpensive Time Domain Reflectometer.Inexpensive means its got to be self-contained and could be operated without an oscilloscope.Here's our forum member W2AEW's tutorial on TDR ->Now if I got a waveform like the one below which has 2 rising edges then 2 falling edgesHow can I measure the time delay between the 2 rising edges?1 way would be to use an oscilloscope, but that means it won't be self-containedanother way to do it is to use a really fast ADC, but that means it won't be inexpensiveWhat if I use a couple of edge detectors to charge a capacitor in a RC circuit then read the voltage of the cap?by knowing the value of R, C and V then I could calculate Tthe first rise edge starts to charge the capacitor, then the second rise edge stops the charging,then the following falling edge discharges the cap and the final falling edge discharges it again for good measures.will this idea be crazy enough to work?or will it be just too hard to implement? (i.e. massive amounts of current required to charge a cap in a few nanoseconds)

author: T3sl4co1l
author_rank: Super Contributor
timestamp: February 07, 2014, 05:28:32 am
content: Yea... how accurate?A relatively simple method might be a fast comparator to detect the voltage threshold, an integrator to convert time to voltage, and a sample circuit to 'latch' that signal while the integrator gets reset (or an ADC to store it digitally). This will also need a trigger/holdoff system (as scope timebases use) for general purpose timing, so you time a single pulse, not accidentally a whole series of chattering pulses or something (unless that's something you want, in which case you could add logic for that too).Time measurement is (or can be) a very involved task. I recall reading about an HP time interval system that used vernier timing to count off picoseconds. This is done by taking the classic 10.000 MHz reference, multiplying it by adjacent ratios with a good pair of PLL locked oscillators, and resetting the phase of one when an event occurs. Because the difference between edges of the two high frequency references is some small amount (say 200ps), counting the number of cycles required for the two signals to cross phase angles gives that degree of accuracy for the event itself.Tim

author: fcb
author_rank: Super Contributor
timestamp: February 07, 2014, 09:14:42 am
content: Use a ramp generator.So you have a small FET (2N7002 example, although probably not ideal) across a capacitor to 0v. Use a simple constant current source (one transistor, zener diode and a two resistors) to feed the ramp capacitor.When your pulse is sent, you release the gate on the FET, when your return pulse turns up - shut down your current source.Use a hi-z buffer amp to drive your ADC from the ramp cap, when your sample has been converted prime your circuit again (switch on the current source, set the gate.I would estimate $0.25 + your buffer opamp + a bit of logic (74HC74?).You could also use a 4016/4066/DG411 quad analog switch to switch the current source, clamp the ramp capacitor, etc... Just watch-out for charge injection affecting your results.

author: Marco
author_rank: Super Contributor
timestamp: February 07, 2014, 09:40:08 am
content: Quote from: fcb on February 07, 2014, 09:14:42 amFor high accuracy they generally tell you to direct the current rather than switch it.QuoteThe hard part seems generating the control signal to stop the charging.

author: fcb
author_rank: Super Contributor
timestamp: February 07, 2014, 10:26:29 am
content: Current source switching - there's a bunch of different ways to do it, certainly switching the current source into a dummy load will keep it more consistent, but that will depend on the pulse repetition rate if it make much difference - certainly that's not the biggest deal here.Fast comparators, and latches probably the only simple way to capture the pulse. Perhaps some windowing also, but the micro could deal with this (arming the latches etc..).I did a TDR based fluid level probe last century, we averaged over 10K samples - very accurate. I don't remember the recognition of the waveform trigger points being difficult, I think I used LM361 at the time.

author: muvideo
author_rank: Frequent Contributor
timestamp: February 07, 2014, 10:46:17 am
content: Hello, what you want to do is not too hard, but also not the easiest thing.It's usually done in Time Interval Counters, to measure times less thaninternal timebase resolution, usually it's called "interpolator".Google for Time to Voltage converter or Time to Amplitude Converter.An easy way to do is to build a constant current source, and thenuse some bjt or other switches to switch the current trough a capacitorduring the pulse, and bypass it otherwise.The actual schematic details depends on what kind of pulses you have,and the time you want to measure.The fun part is that you can use normal parts and a microcontroller todo all the experiments, and learn much from it.See PICTIC schematic:http://ko4bb.com/dokuwiki/doku.php?id=precision_timing:picticSome examples from Dr Bruce Griffiths:http://www.ko4bb.com/~bruce/TAC.htmlCiao!

author: AlfBaz
author_rank: Super Contributor
timestamp: February 07, 2014, 11:03:40 am
content: If you are using adc's and controllers, how about feeding the signal into a buffer and drive a cap with a low resistive load on the other end. You'll get a couople of spikes on each vertical transition. You can the condition these spikes with a fast comparator to create a couple of trigger pulses into an interrupt pin on the controller and simply read off a timer

author: Rerouter
author_rank: Super Contributor
timestamp: February 07, 2014, 12:28:40 pm
content: For open and shorted stub it looks like you can use a window comparator (you only want to catch it as your signal)then if you weren't very picky could take this voltage and sum the 2 comparator outputs into a smoothing cap say 10nF (through say 10K) and this will give you a frequency dependent PWM, which if you scale and gain correctly can then give you a completly analog circuit to turn picosecond delays into multimeter readable voltage, (or at-least in theory)now to be honest i have no idea if this circuit would actually work, but as you can get bloody fast comparators and they are the only active devices i cannot see any unrealistic expectations apart from the scaling of the reading,Edit: woops, looks like it would require a matched impedance frequency source,

author: dannyf
author_rank: Super Contributor
timestamp: February 07, 2014, 02:23:44 pm
content: I would use comparators: one to turn on a pulse and another to turn it off. If the incoming signal is a pulse train (repeated pulses), the time between pulse edges are represented as duty cycle in the output -> can be measured easily.

author: ice595
author_rank: Regular Contributor
timestamp: February 07, 2014, 02:24:24 pm
content: how about using a T-flipflop to charge a capacitor?the first rise edge toggles Q to high then the second rise edge toggles Q to low. connect a diode in series with the Q output to the capacitor so it doesn't get discharged when Q toggles to low

author: dannyf
author_rank: Super Contributor
timestamp: February 07, 2014, 02:36:56 pm
content: The capacitor may introduce timing delays - which may / may not matter.I would do away with it.

author: dannyf
author_rank: Super Contributor
timestamp: February 07, 2014, 02:44:28 pm
content: A logic gate can be viewed as a comparator: the threshold voltage for '1' or '0' differs.So you can construct a simple high-speed comparator easily with some inexpensive gates.

author: Marco
author_rank: Super Contributor
timestamp: February 07, 2014, 04:29:32 pm
content: The temperature dependence of the trigger level will be god awful though.

author: dannyf
author_rank: Super Contributor
timestamp: February 07, 2014, 07:07:12 pm
content: Depending on how you define "god awful".

author: Marco
author_rank: Super Contributor
timestamp: February 07, 2014, 08:01:04 pm
content: I think it will need a means of continuous calibration.

author: dannyf
author_rank: Super Contributor
timestamp: February 07, 2014, 08:27:16 pm
content: It depends.

author: G0HZU
author_rank: Super Contributor
timestamp: February 07, 2014, 11:26:17 pm
content: Quote from: dannyf on February 07, 2014, 07:07:12 pmHi dannyfI would define godawful precision as slightly worse than the level of precision your various ESR meter designs achieved. But it is probably debateable either way

author: G0HZU
author_rank: Super Contributor
timestamp: February 08, 2014, 12:26:34 am
content: Quote from: ice595 on February 07, 2014, 04:02:05 amDo you just want to measure the cable length/delay by electronic means? The TDR method in the video is a bit crude and not something I would use because it is so coarse in resolution.

author: ice595
author_rank: Regular Contributor
timestamp: February 08, 2014, 12:28:58 am
content: Okay, today I thought i would be nice to whack a RC circuit on my breadboard and take some measurements.All I did was connect a switch, 100ohm resistor and a 1nF cap in series.With channel 1 of my oscilloscope connected to the resistor and channel 2 connected to the capacitor.Then I set the trigger to single-shot on channel 1 with rising edge.the charge time of the capacitor was as expected, nice exponential increase in voltage with time.but when I triggered off the falling edge, I could see that as soon as the switch opens, the capacitor's voltage fall faster than a lead brickcould the oscilloscope's 1 megaohm input resistance act like a load and discharge my capacitor as soon as charging stops?well, there goes my hope of making a time to voltage converter with just a RC circuit.If my scope's input resistance is enough to discharge the capacitor completely in 2ms, measuring the voltage with the built-in ADC in a MCU would be much worse i would imagine

author: G0HZU
author_rank: Super Contributor
timestamp: February 08, 2014, 01:22:56 am
content: Do you just want to measure the time delay of the cable with your low cost TDR?If so then there's cheap/small/easy ways to do it with far greater precision than the edge/scope method.

author: ice595
author_rank: Regular Contributor
timestamp: February 08, 2014, 01:43:09 am
content: Quote from: G0HZU on February 08, 2014, 01:22:56 amhow?

author: Marco
author_rank: Super Contributor
timestamp: February 08, 2014, 02:10:12 am
content: He'll probably have some much better ones ... but a couple of methods come to my mind.- You could sweep a generator or put in some broadband signal with a known power spectrum and look for the frequencies which give minimum/maximums in the ratio of the input signal and the signal at the input of the coax, generator output resistance doesn't even have to be equal to the characteristic impedance for this.- You could short the other end, put in a square wave with a generator with an output resistance equal to the characteristic impedance of the coax and then put the square wave + reflections at the input of coax through a schmitt trigger (too much cable loss and this stops working because the reflection won't pull the input signal low enough). The duty cycle of the resulting pulse train is a function of the delay, the duty cycle can be measured easily by simple low pass filtering.

author: G0HZU
author_rank: Super Contributor
timestamp: February 08, 2014, 02:19:21 am
content: QuoteYes, the cheapo method would be to sweep a AD9850 DDS module ($5 on ebay) and have a simple RF detector at the source end and look for the first standing wave null on the detector. This should be really easy to detect with very good accuracy.You would need a cheap MCU plus the DDS module + 50MHz roofing filter plus the RF detector (few cents) plus a cheap LCD display.You should be able to measure cables from about 1metre long to 'very long' using this method and you should get fairly accurate results for the time delay. The size of the unit would be dictated by the size of the LCD display and the batteries but you could also make it USB powered and use a netbook or tablet for the display. For very long cables you could verify the result by looking for the first few null frequencies and make sure the results agree fairly closely.It's still a time domain method but the null at the detector happens when the reflected wave cancels the forward wave voltage at the detector when the far end is left open.If you want to measure extremely long cables then I guess you could revert to measuring the pulse + time delay method. I've never tried to measure cables much longer than about 50 metres.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: February 08, 2014, 03:09:34 am
content: Supposedly LVDS inputs make passable comparators. The guaranteed spread is certainly better than, say, CMOS. But you might as well just get a proper LT1016 or something.Tim

author: ice595
author_rank: Regular Contributor
timestamp: February 08, 2014, 03:31:41 am
content: I just hooked up my function generator to a T-piece then into my scope with 1 end not terminated, I was able to get a fairly consistent amplitude across the full range of my function generator (1 to 25MHz)when I connected a 1.6 meter long coax cable to the un-terminated T end, the amplitude dropped to half its value around 18MHz.I don't know much about standing waves in transmission linesin fact, I barely know anything about RF at all.So, I guess amplitude is a function of the length of the cable under test?if so, what is the equation for calculating the length?

author: w2aew
author_rank: Super Contributor
timestamp: February 08, 2014, 04:06:19 am
content: Quote from: ice595 on February 08, 2014, 03:31:41 amThe principle that G0HZU is referring to is the fact that an open ended transmission line will appear like a short circuit at odd quarter-wavelengths. This is why you start from a low frequency and move up, so the first null you hit is when the first quarter wavelength null (as opposed to the 3/4 or 5/4 wavelength).Thus, the equation for the length is: L = 300/f * 0.25 * VFWhere L is the length in meters, f is the frequency of the first null in MHz, and VF is the cables velocity factor.In your case, you never reached the first deep null because your generator didn't get up to the quarter wavelength frequency of the cable, which would be about 31MHz assuming 66% VF.The second half of this video demonstrates the quarter wavelength transmission line behavior:

author: dannyf
author_rank: Super Contributor
timestamp: February 08, 2014, 12:59:47 pm
content: QuoteIt could be due to the charge transfer to the adc in the scope. The input resistance of your capacitor is so much higher than 100ohm that if it were the main source of discharge, you would see the voltage to drop very slowly.If the scope's adc is connected to the capacitor, each time a sampling is done, the adc's Chold is connected to the 1nf capacitor and a charge transfer takes place -> the voltage on the 1nf capacitor goes down a little (1/2 * 1nf * (Vt)^2 -> 1/2 * (1nf + Chold) * (Vt+1) ^2, so Vt+1 < Vt).If a lot of samplings were taken place, the voltage could go down significantly and quickly, particularly when the capacitor's capacitance is small.One way to test that hypothesis is to use a large capacitor (uf range) - if Chold << the capacitor's capacitance, the effect of charge transfer is minimized.

author: dannyf
author_rank: Super Contributor
timestamp: February 08, 2014, 01:01:44 pm
content: BTW, if you want to find cable length, talk to a telephone company crewman: they have had a simple way to find cut cable length for decades. None of which involves those fancy mcus or dds.That's why smart engineering is all about.

author: Marco
author_rank: Super Contributor
timestamp: February 08, 2014, 02:11:49 pm
content: What's the point, you are here and you obviously know what they will say ... so how about you tell us? Resistance measurement of a shorted cable?

author: fcb
author_rank: Super Contributor
timestamp: February 08, 2014, 04:05:45 pm
content: Quote from: dannyf on February 08, 2014, 01:01:44 pmAll the telephone company engineers I've met have a company issued TDR.

author: ice595
author_rank: Regular Contributor
timestamp: February 09, 2014, 04:29:41 am
content: speaking of telephone and cable companies, is that how they selectively remove TV channels that you didn't pay for?well back in the days of analog cable TV of course.I have access to a 100KHz to 2.4GHz RF generator at school, maybe I'll try this experiment next week.by the way, do I need a series resistor or capacitor with the output of the RF generator to protect it?since the notch filter acts like a short at its particular frequency.

author: G0HZU
author_rank: Super Contributor
timestamp: February 11, 2014, 12:05:08 am
content: Depending on the sig gen type you can either stick an external 10dB attenuator on the output or turn down the generator level until it clicks in its own 10dB attenuator.I quickly set up the following fairly well controlled experiment if you want to know what to expect:Marconi 2024 sig gen set to 2MHz +6dBm feeding into a BNC T piece.HP8473C detector on one arm of the BNC T piece via a SMA to BNC adaptorI used a HP8120-1840 as the test cable. This is about 48 inches long with its BNC connectors.Keithley 2015THD DMM to read the DC voltage from the HP8473C detector diode via another BNC coax cable.I then increased the sig gen frequency to look for a null and this occured at about 39.506MHz where the detector output fell to a sharp null of about -3mV dc. At 2MHz the detector was showing about -500mV dc.The HP8120-1840 cable measures just under 1.23m long.Add 1.5cm for the lengthening effect of the T piece to get 1.245m. 1/4 wavelength at 39.506MHz = 1.898mSo the VF = 1.245/1.898 = 0.656 which is pretty close to the typical VF of 0.66 for this type of cable.This method should be very accurate for the length of cable used in the W2AEW video and your typical timing requirements. For extremely long cables then other methods might be more suitable but it depends what your requirements are.QuotedannyfIf you can find proof that a typical telephone engineer can (electronically) measure the delay of a 4 or 5 foot cable more accurately than the VSWR nulling method above then I'd like to see how they do it