Hardware-timed Datalogging

Hi!

I'm brand new to the Arduino community, and most of my projects prior have been for fun (making an LED blink, a buzzer, etcetera) and I'm starting my first "real" project.

Problem Statement:

I'm hoping to use an Arduino to timestamp pulses and transmit them via serial to a computer. The problem is that the timestamps need to be as precise as possible -- utilizing the full speed of the clock to achieve 63 ns resolution would be ideal. I'd like to do better than micros() can afford me.

The pulses come in the form of a 6V square wave that lasts 500 ns (from what I've read, 6 V will actually fry the input pins .. so I'll handle that, too). I'd like to be able to handle count rates up to 100,000 per second.

The final hiccup is that I'd like to log these pulses as being "ON" when another, separate pin is high, and "OFF" when that same other pin is low (I'm looking at the correlation between two signals); this pin will see a square wave of 5V that lasts around 4 milliseconds in the on cycle, and the same in the off cycle.

Proposed Solution (pending your vicious critique):

I got my hands on a copy of the Arduino cookbook, and in Chapter 18, the author talks about using hardware timing at length.

Example 18.7 is pretty damn applicable to what I'm after, I think-- the author sets Timer1 to clock on the rising edges of an input pulse (1,1,1 for CS12 / CS11 / CS10), and then resets & polls the counter every second, and transmits at 9600 baud the total count accumulated in each second using delay(1000).

Can this be adapted to far higher speeds? Say -- to transmit the count each microsecond?

This isn't exactly what I want, but I could still work with it-- ideally, I'm after just the timestamp being broadcasted itself (since the pulses are essentially indistinguishable). Thoughts here?

Thanks in advance,
Matt

If the pulses arrive at 500ns intervalls and you want to transmit timing information oneach and every one (1byte) you will need to have a serial speed of 20Mbaud of 40Mbaud for 2 bytes. It look to me that you need to rethink you problem.

You're right .. 2 - 4 MBaud is a bit much :wink:

I could probably achieve a modest 4 MB / second with an SD card, though, right?
I'll probably go that route with an SD shield add-on.

mbanar:
I could probably achieve a modest 4 MB / second with an SD card, though, right?

Wrong.

Arduino does NOT use the "Four-Bit SD Bus Mode" while reading/writing a SD card. For that you'd need a computer (PC, Raspberry Pi, Smartphone) or something like that, with a CPU which provides much more clock frequency than 16 MHz.

Arduino just uses the "SPI Bus Mode".
With that you can possibly achieve a 230 KB/s read rate and a even lesser write rate.

What you want to do is absolutely beyond all limits which an Arduino can handle.

Perhaps counting such a quick signal on one pin would be possible and sending the summed up number of counts every couple of microseconds. But not sending each single count along with a nanosecond timestamp in realtime.

Would you say this project is better geared towards a Raspberry Pi with an external clock, like the Chronodot, instead?

Or possibly, from what I've investigated, a BeagleBoard Black (which seems to boast two 200 MHz internal clocks -- but I may not get away from my write speed issues) ?

Thanks for all your input here, and being gentle.

EDIT: Nix the Chronodot; just realized it was a long-term accuracy clock, not a precision clock.

mbanar:
Would you say this project is better geared towards a Raspberry Pi with an external clock, like the Chronodot, instead?

Perhaps something like this http://www.rigolna.com/products/digital-oscilloscopes/ds1000d/ds1052d/ can sample logic level data at high data rates.

I don't know.

But "modest 4 MB / second with an SD card" as well as "count rates up to 100,000 per second" combined with "63 nanoseconds resolution" for any "timestamps" to send is not possible with the Arduino platform.

Any computers with something as an "operating system" like Linux, Windows, Android or such, ist not realtime-enabled (while they are able to deal with high data rates, but not a guaranteed timing). So perhaps you can sample your data with something like a "logic analyzer" and then send to a computer for further data processing. But you cannot sample and send 100000 timestamps per second with 63 nanoseconds resolution to anywhere using an Arduino. At least: I don't know how this would be possible.