Time Stamping on a NanoSecond Scale

Hello Arduino Community! I'm making a coincidence counter for an optics experiment. So currently the problem is this: An event of interest occurs at a frequency of 6-7KHz. This is in the form of 50ns pulses. So they're actually impulses. I need to 'time-stamp' these events i.e. at what time they occured. The simple approach I'm trying here is running a timer with an external clock and whenever the event occurs, save the timer value. So the external clock needs to be of time period 1,2 or 5ns. Directly feeding this clock to the arduino due(that's the fastest arduino, right?) would work or not? I think not because external clock to the timer could not be faster than half the system clock.

Another problem would be the time taken to latch the value of the timer to the register. Does it take many clock cycles or does the latching occur in real time?

Is this project beyond arduino capability? Any suggestions for the task at hand would be welcome.

With what resolution and accuracy do you need to record the time stamps? Do you need to record the time of just the leading edge of the pulse, or just the trailing edge, or both edges?

If you only need to time stamp the leading edge, and resolution of 62.5ns is good enough, then you can use some simple electronics to extend the length of the pulse to (say) 1us, and then the input capture facility of timer 1 in an Arduino Uno or similar could be used to generate the time stamps.

Using an Arduino Due, I think you could get a resolution of about 24ns using a similar technique. To get a higher resolution than that, you would need to use an external high speed counter and latch.

Thanks for the reply.

I need to record only the time of the leading edge.

And no, I need at least a resolution of 5ns.

And how does arduino due achieve a resolution of 24 ns. Isn't its clock period 12ns? Did you include one cycle for the latching process? where can I learn more about the latching process?

So what high speed counters and latches would you suggest? And will the latch reading be easily processed by the arduino?

I have no background in FPGAs and beaglebones. On a cursory glance, the latter seems easier to program.

Is such time-stamping possible on a beaglebone, given that its processor has a 1GHz clock?

The Duet master clock period is a little under 12ns, however the fastest clock that can be used for the timer/counters is half the master clock frequency.

To obtain a resolution of 5ns you will need to clock the counter at 200MHz or greater. I am not aware of any CMOS or TTL devices that can count this fast. So I think your only option may be to use emitter-coupled logic (ECL). I have only used ECL once, and that was many years ago. Looking at some datasheets, I think you could build a solution using about four 10E016 8-bit synchronous counters, some 10EL01 gates to link them together, some 10E131 D-flipflops to condition the input signal, 10E175 latches to latch the count, and some ECL to CMOS or TTL converters.

You might wish to google "Time to digital converter" for other possible solutions.

PS - if what you are trying to do is to measure time of flight, then there are chips available to do this with resolution of a few 10s of picoseconds, such as the TDC-GP22 and MAX35101.

the project was initially using a Time to Amplitude converter and my project is to miniaturise and make an inexpensive setup of the experiment, so TAC is out of question.

People have implemented such counters using a PLL generated 200MHz clock on FPGA. Essentially isn't it the same scheme if ECL logic you proposed? I was wondering if the same could be implemented on a beagle bone?

Having a beaglebone won't help, the issue is that you need a 200MHz+ counter with an input capture facility. FPGA is probably the best solution, but I can't help you with that.

so a beagle bone with 1GHz processor and having 32-bit timers won't help?what's the reason for that?

And these TAC chips are quite cheap compared to a TAC module we have in the lab. I might revert to the old technique.

Is this project beyond arduino capability? Any suggestions for the task at hand would be welcome.

The arduinos inbuilt micros counter timer is more than adequate. If you are trying to time stamp a pulse with a frequency of 6-7KHz. The duration of the pulse has nothing to do with anything!.

So where did you get the requirement for a nano second timer.

If you where to use an external clock then the pulse needs to cause the external clock to latch the time at which the event occurred, you can then read it in your own time.

Mark

@Mark The experiment involves measuring coincidence counts. Let's suppose we have two detectors. Each detector registers signals(50ns) pulses at 5-6Khz. But how much of these two signals were coincident? So if an event from detector A occured within a time window of,say, 5ns from an event from detector B, the two events are coincident. The conventional approach has been to use a TDC. But we were thinking of time tagging and then post-processing to see which events occured on the same sample number on the 5ns-step-discrete time scale.

AWadood7: so a beagle bone with 1GHz processor and having 32-bit timers won't help?what's the reason for that?

I may have been wrong. I see now that the processor used on the beaglebone has an ECAP unit. It's not completely clear to me what the maximum clock frequency of the ECAP unit is, but it may be high enough for your purposes. So if the beaglebone board brings out the ECAP pins from the chip to somewhere you can get at them, you may be in luck.

Thanks for your suggestions dc42. I'll try the beagle bone and also the TDC approach. We'll see which one fits the bill.

Hello once again. I'm exploring the TDC approach. There are the following problems: 1)MAX35101: How should I interface it with the arduino? Should I make a PCB board? 2)THS788: Same problem. No evaluation board. And by the looks of this thesis here https://www.politesi.polimi.it/bitstream/10589/92658/1/Thesis_V1.0.2_Build04031059.pdf, this looks like an arduous task in itself. 3)TDC-GP22: An individual chip is quite cheap but the programming library is quite expensive. So if I were to drive it with an arduino, that would also require making an evaluation board.

There are no evaluation boards available nor their schematics.

It's like i've struck a hard wall and would need to tunnel through it.

Then look at other tech, er DSP's maybe or FPLA?

Mark

AWadood7:
3)TDC-GP22: An individual chip is quite cheap but the programming library is quite expensive. So if I were to drive it with an arduino, that would also require making an evaluation board.
There are no evaluation boards available nor their schematics.

I had already replied to this in some detail on your duplicate post (that has now been deleted with my reply) but the essence is ACAM make an evaluation board for the GP22 and you can download the EVA-KIT datasheet + schematics + software for free. Not sure what ‘programming library’ your referring to and I have never used the downloadable software. If the evaluation board is no longer made then you can always ‘roll your own’.

So apparently if one can make the board, now there's one more question.... What is the dead time of tdc, i.e. time during which it makes the measurement and I can't measure another incoming event. GP-22 guys state that the maximum input rate is 500KHz. So i'm guessing the measurement time is 2ms? that's a big loss.

Hi,

is this open source project made by the NIST (http://www.nist.gov/pml/div684/grp03/multicoincidence.cfm) what you are looking for ?

Have you found a solution for that?

A 50 ns window with a DUE seems a bit tricky, but you can try to record time with a blocking code and calibrate to subtract the delay necessary to read SysTick Timer (always the same = 1 clock cycle). SysTick Timer counts down from 84000 to 0 each and every ms, i.e. one tick = 1 clock cycle = 11.9 ns.

void loop() {
  static uint32_t Time_ms;
  uint32_t Time_ns;
  float T_ns = 1.0f;

  do
  {
    Time_ms = millis();
  } while (!(PIOB->PIO_PDSR & PIO_PDSR_P27));

  T_ns = 84000 - SysTick->VAL - 1;
  Time_ns = (uint32_t)(T_ns * 11.9f);

  printf(
    " Time = %d ms plus\r"
    " %d ns\n",
    Time_ms,
    Time_ns
  );
}

Please be aware that this thread is four years old.