Electronics > Projects, Designs, and Technical Stuff
Measuring time span very precise
HendriXML:
From the project below I get two digital signals from laser GateA and GateB I would like to determine the time between them.
Nerfo meter - measuring the speed of Nerf darts
The timing circuit will be reused in other experiments and needs to be readable by an Arduino Mega2560.
I came up with the following:
Why not use the 74LV8154 to count ticks in 32 bit mode. At the GateA signal the counter is saved to its registers. At the same time the Arduino is triggered/interrupted to read this data. This is allowed to take 100 us. The same will happen when the GateB signal fires.
The ticks will be at around 1 Mhz. Thus allowing for 1 hour of high precision timing. But if I where to generate the ticks with a M74HC4060 (oscillator/14 stage binary counter), I could also use a divider output of 16x or 32x etc. This will mean running that IC on about 16 Mhz. Which would mean it could run for 50 days using the greatest divider (off course with a lowered resolution).
Is there a way to use an special purpose IC to hook the counter IC to a by a software chosen divider pin? Or is this a case where AND gate's would be needed? (I could also use jumpers, losing software capabilities...)
If the Arduino reads the counter registers too slow, the circuit is limited by how small the time span between GateA and GateB might be. To solve this 2 synchronous counters (2x 74LV8154) could be used, clocking and starting them at the same time. But that seems like a uneconomical solution.
This seems to me like it could work, but any thoughts or suggestions are appreciated!
HendriXML:
I think that doing a counter clear on the GateA signal would be the most easy solution to keep the minimal timespan short. This way the registers will not need to be read during the 2 events. :popcorn:
hamster_nz:
Simple, accurate, and cheap. Borrow an FPGA dev board
DaJMasta:
You can probably get good results with a hardware interrupt for the end pulse edge and a software start, but if you want really fast, why not a hardware counter?
Whatever timebase you want piped into an AND gate to control when it runs and then into the clock input of a counter like a 74 series 4040. Micro turns on the other and gate input to enable the clock, counter runs, ending trigger pulse either goes into the AND as well, or pulls down the micro's control line, or through another mechanism to stop it. Micro reads the 12 bits of output from the counter, then triggers the reset line, then you wait until you want to time another.
If you don't have the micro controlling the start, you can have the first laser trigger a latch (like a D flip flop), then have the second laser trigger a second latch. Have the normal output of the first latch start the AND gate and the inverted output of the second latch enter the AND gate as well to stop it. If you reset between laser trigger pulses, that should give you the 12 bits of counting for each counter. If you run your counter's clock from a 1MHz or 10MHz crystal oscillator, it should be pretty accurate and stable and you'll get a 1us/100ns resolution on your reading.
The problem with the 14 bit is that the two least significant bits aren't broken out in the standard pinout. Cascading counters works great, and at 1MHz especially, 24 bits of counting gives you a maximum of over 16s of delay that can be measured at 1us.
IDEngineer:
How about a small MCU? Many are available with relatively low pin counts and small packages, and you'd have more flexibility than any dedicated IC.
I happen to have a PIC18F spec sheet sitting here. At quick glance, it has direct support for cascading eight and 16 bit timers to form a 24 bit counter that can be clocked by anything from the main oscillator (62.5nS resolution) on up to a bunch of intervals that are selectable via prescalers. That's a counting range of 16M, and at 62.5nS resolution that's a run time of one second. You can obviously scale resolution to lengthen the max time period.
Still not enough? With a single pin-to-pin connection you could cascade two 16 bit timers. Now you're at 4G counts, which at the highest resolution gives you 268 seconds. I suspect you could cascade two of the 8+16 arrangements to get up to 48 bits, again with a single pin-to-pin connection. That would give you 203 DAYS of counting before overflow at 62.5nS resolution.
As for reading/writing, MCU's (including this one) have all sorts of communications peripherals on chip. This one has SPI, I2C, UART, etc. and you could bit-bang your own if necessary (nybble-wide bus, anyone?). Personally I'd go for SPI if the Arduino supports it since you cannot get out of phase and the bit rates are probably several megahertz, but even a serial link would probably be fast enough for what you want to do. Again, all on chip, ready to go, and reconfigurable with a reflash as you gain experience and redesign things.
Just something to consider. Small MCU's are often a great alternative to one or more dedicated devices.
Edit: Oh yeah, forgot to mention that MCU timer/counters generally have several hardware pin options. You can externally clock them, gate them for easy start/stop, they can emit a level or pulse upon match with an internal preset register... all of which would ease your interfacing. This one even has gating based on an on-chip analog comparator so you could trigger based on a non-digital-friendly voltage threshold.
Navigation
[0] Message Index
[#] Next page
Go to full version