Hi,
Im working on a project to measure the time difference between on off signals.
The output is 0-24v (however this can be reduced easily) and i need to measure with sub microsecond accuracy.
I just want to measure the time that the signal is high and then output this time digitally to a microcontroller (probably a raspi eventually but an arduino will do for now)
I realise that all this is possible with an arduino due however i will have 6 sensor recording in parallel and think that the loop time will cause me an issue with getting an accurate time.
Does anyone have suggestions of ic chips or small boards that would be suitable for my application? any help would be really appreciated
the sensors use reflected light to detect when an object passes in front of them, im interested in how long the object is in front of the sensor. each sensor is placed in a different location.
I imagine that each sensor will be attached to its own timing circuitry, each of these circuits will then output a time signal each time an object has moved in front of it to an arduino or cpu.
You wrote: " i need to measure with sub microsecond accuracy.",
You cannot do this with reflected light due to diffraction at the edge of the object, change in amount of reflected light as more and more of the object is illuminated as it enters the measuring arena, and then the reverse happens as it leaves.
You need "break-beam" measurements so the edges, only of the object are involved in the measuring to get the time in front that you desire.
its not exactly an object im looking at, its a mark on a plate that is moving, one part of the plate is reflective, the other is black. the plate is moving at high speed.
I have a very quik idea:
First of all its better if you create a easy circuit to mesure time with the precision that you want, something that, precisly every 1 your needed precision do something on a pin. That is connected to a interrupt pin. What interrupt does? Add 1 to a variable. You have also a second interrupt pin, connected to the 0/5V (the 0/24V reduced). What it does? Charge a "last time" variable with the value of the time variable and assign 0 at the time variable.
The loop only use the value of 'last time"
The PCNT (Pulse Counter) module is designed to count the number of rising and/or falling edges of an input signal. Each pulse counter unit has a 16-bit signed counter register and two channels that can be configured to either increment or decrement the counter. Each channel has a signal input that accepts signal edges to be detected, as well as a control input that can be used to enable or disable the signal input. The inputs have optional filters that can be used to discard unwanted glitches in the signal.
I have had a similar issue, reading 3 sensor that pulse at quite high frequency (as fast as 180 millis() delay). Having them directly on an interrupt pin would cause the main program to freeze almost.
I decided to use two ATTiny85 doing this constant job, and send their record every second to a Nano by I2C, where the ATTinies act as Masters.
On breadboard this worked with one, test should be done with the two and real life setup is yet to be tested...