counting clock cycles as a fast timer

Status
Not open for further replies.
newbie here
i am dealing also with a Time to Digital problem. The best i have so far is around 16ns accuracy with FreqMeasureMulti and this code

// Measure 2 frequencies at the same time! :)
//FreqMeasureMulti freq1; // tacho counter
FreqMeasureMulti freq1; // IAS counter


void setup() {
Serial.begin(57600);
while (!Serial) ; // wait for Arduino Serial Monitor
delay(10);
Serial.println("FreqMeasureMulti Begin");
delay(10);
freq1.begin(5); // tacho counter pin 6
//freq2.begin(6); // IAS counter pin7

// analogWriteResolution(10);
// timer0.begin(timer0_callback, 1.25);
// pinMode(A21,OUTPUT);
// analogWrite(A21,0);

}
int dim=32000;
elapsedMillis timeout;
unsigned long enc_data[32000]={0};
volatile int16_t t = 0, m=0;

void loop() { // ciclo di calcolo
if (freq1.available()) {
enc_data[t]=freq1.read();
if (t==(dim)) {
for ( m=1; m<=(dim); m=m+1 ) {
// output section
Serial.print(m);
//delay(1);
Serial.print(", ");
Serial.print(freq1.countToNanoseconds(enc_data[m] ));
Serial.println();
}
while(1) { } //stop loop
}
t=t+1;
}
}

Actually i let it log a run and when its done i get measures from serial terminal. My issues are about pushing accuracy and a way to move out data for a real time Time to digital analyzer. For the last i am considerind to build an analog out with MCP4922 while wisely limit the range. Any further advice will be appreciate
 
Why is 16ns a problem for you ? That's 62.5 MHz. Your MCPs' max SPI(!!) speed is 20MHz. I havn't read the datasheet in detail.. let's assume it wants 2 bytes: Divide 20Mhz by 16 (->2 Bytes) and you'll get 1.25 MHz theoretical maximum speed. Am I missing something :confused:
 
Last edited:
Just for a little perspective, this wikipedia page says "hypervelocity" is approx 3000 meters/second. That's really fast!

But 16ns is *really* short. In fact, an object traveling that fast manages to move only 1/20th of a millimeter (48 microns) during those 16ns.

Then again, perhaps an even better question would be whether the sensors and all analog signal acquisition involved really truly has a full 60 MHz bandwidth. I'm guessing probably not?
 

what i meant is I need the best accuracy on Time to Digital Counter routine, I still expect to loose accuracy on putting in code related to TDC conditioning. Advices ?
Then I need to feed a data out with those results at an approx rate of 30kHz.
Do you think MCP is viable? Otherwise I think I should deepen in a TCP/IP based protocol (CANbus ?) and since my limited skills i would prefer something cheaper.
thank you Frank B
 
@rozilla Since you are looking to measure very brief events, obviously less than 16nS and perhaps more like 5nS or 1nS you have to change how you are looking at the problem. What you need is something called a 'time to voltage converter". Google it, there are papers describing it out there. It measures the time by charging a capacitor with a (gated) constant current. The resulting voltage is proportional to the time of the event. I don't know if there are chips available to do this, you gotta look around. The accuracy of these things can be phenomenal. The teensy can then be relegated to doing the boring, but important housekeeping routines of your instrument.

As far as being a 'noob'...... Welcome to the fire of indoctrination.
 
Status
Not open for further replies.
Back
Top