Measuring ns pulse duration

Hi, I have looked around the internet for quite some time now and don't seem to find any feasible solution to my problem so I thought I'd ask you here.

I'm using an Adafruit ItsyBitsy M4 (ATSAMD51) with the Arduino IDE to measure the pulse coming from a photodiode. Measuring the peak voltage with a peak detector is quite standard and simple and now I'm at measuring the pulse duration. Pulses usually have a duration of 100ns to up to 1us so I don't need ns accuracy, I'm more than happy with around 10ns. After all that should not be completely unreasonable given that the ATSAMD51 is clocked at 120MHz.

Just to clarify, I don't care about the pulse shape or the amplitude. Further measuring the pure duration would be a lot faster with a digital signal instead of using the ADC, I guess, so I could also easily utilize a fast enough comparator; that's not the problem.

Maybe interrupts are the way to go here, maybe some other, better methods, I don't know for sure. I'm really looking forward to some ideas.

1 Like

I don't think its feasible with that hardware. A single clock cycle at that speed is~8nS. So, at best, one assembler instruction. You need something orders of magnitude faster or some external hardware to capture the time.

To time a pulse width like that requires extremely fast analog comparator(s) and high-speed counters. And perhaps a DAC to set the comparator threshold.

Possibly something like some member of the LTC6752 comparator family driving a TDC7200 timer (SPI interface, 3.3V only)

I'm using the OPA354 as comparator and so far that works great. Do you think it would be possible to charge a cap with the constant comparator voltage kind of like a time-to-voltage converter?

Using an OpAmp is a problem as it has a push-pull output, so you discharge the cap as fast as you charge it.

What may actually work is using a comparator, as they have an open drain output (but you need one that's fast enough to follow a 10 ns pulse!). Wire it such that when the pulse happens the output goes low, discharging the capacitor. An RC of some 700-1000 ns sounds good for a pulse length of up to 1µs.

schematic.png

The idea behind this (I'm using Arduino/AVR terms - you may need to translate to your special processor - the idea remains the same):

Use the analog pin to charge the cap full (set it to OUTPUT, HIGH). 2 µs is enough to fully charge it.

Then set the pin to INPUT, and start reading the value. Other than leakage it should keep charge at all times. The moment a pulse comes in (I assume a positive pulse of >0.5*Vcc), the comparator's output opens, and starts discharging the capacitor until the pulse is finished. The analog reading drops.

A reading takes ~110 µs, so when you notice a change take a second reading (the pulse may have happened during the reading) and you have the voltage remaining, and can calculate how long the pulse lasted.

With the values picked, a 10 ns pulse will drop the capacitor from 5.00V to 4.93V. Not much, but definitely measurable.

After detecting the pulse, charge the cap back up (set pin to OUTPUT for a while), and start measuring again.

schematic.png

Just don't use an LM339 as in the diagram, way too slow.

And you need an OC output comparator for this to work, certainly not an opamp.

You'd get a linear voltage/time response using an integrator stage after the comparator rather then an RC circuit too.

MarkT:
Just don't use an LM339 as in the diagram, way too slow.

True; I should have mentioned that - part is a common one just picked for symbol and as example (it has open collector output), not meant as recommendation for this particular purpose.

Thank you for the great ideas. I did not know that op-amps are push-pull.

MarkT:
You'd get a linear voltage/time response using an integrator stage after the comparator rather then an RC circuit too.

What would something like that look like? Do you mean just wiring the integrator up to the output of the comparator and dropping the rc for good?

wvmarle:
Wire it such that when the pulse happens the output goes low, discharging the capacitor.

Wouldn't it be more "time-efficient" to go HIGH when the pulse happens and charging the capacitor then discharging it through a high resistor and just measuring the voltage just once? Then one would not need to rely on all the "slow" arduino code to charge the cap and change pin modes. Or did I miss something?

Phoenix1747:
Thank you for the great ideas. I did not know that op-amps are push-pull.

They have to be - otherwise they can not produce any output voltage between Vcc and Vdd. Sink and source ability is needed.

What would something like that look like? Do you mean just wiring the integrator up to the output of the comparator and dropping the rc for good?

The RC circuit is part of the comparator... It seems to be an improvement as it's linear, while an RC circuit is not. So you can actually design it to use the full 5V range over 1 µs.

Wouldn't it be more "time-efficient" to go HIGH when the pulse happens and charging the capacitor then discharging it through a high resistor and just measuring the voltage just once? Then one would not need to rely on all the "slow" arduino code to charge the cap and change pin modes. Or did I miss something?

You miss at least the part where the comparator can only sink, not source. So you must bring the cap to +5V, and have the comparator drain it.
You miss the part where a 10 ns pulse is too short to even trigger an interrupt on an Arduino, so you can't know the pulse happened without sampling the ADC, and the pulse may happen during sampling so only the second is valid.
As the ADC takes 110µs to take a measurement, you need to keep the voltage effectively constant for 220µs. That implies an RC of 22ms (100x that time) for your resistor-recharge to not have significant effect during the measurement, and that in turn means over 100 ms for a full recharge between pulses. Still think the Arduino, which can do that recharge process in a few µs, slow? You can lower the value of R4 to all the way to 125Ω to speed it up even more, but then you're at the pin current limit...

I like the integrator. Good improvement. For OpAmp, an MCP6002 may do, an MCP6022 should do. There are no doubt many others. Then I get this circuit:

schematic.png

Note: I don't know how to calculate proper values of R3 and C1. It should be about 1 µs to go from one rail to the other. This again relies on the open drain of the comparator to not have a change to the voltage when there's no pulse; and needs a separate pin for recharge (OUTPUT, HIGH for charge; INPUT while detetcting).

The cap should be of film type for stability in timing operations. PET film works well, PP film is even better.

schematic.png

Once again thank you for the clarification, I will be investigating this circuit and the proper values.