Fast Counter

Hello everyone!

I am facing a problem of measuring widths of the pulses accurately. I did programming and my counter now counts every 1 microsecond but I need better resolution than this to measure the pulses accurately so can anyone guide me that how to increase the clock frequency or if someone has the experience of using external fast counter which can do fast counting and then I can use that with arduino.

Please guide and thanking you in advance!

Have a look into the datasheet. You might want to configure Timer 1 for external clock and thus count in hardware.

Unless you tell us exactly what you are after it is pretty hard to tell what you really need. Why are measuring pulses with such high time resolution / how much time resolution do you need?

If need significantly higher time resolution Google for "diy logic analyzers".

Actually I need a high resolution since the pulses are too short between 8 to 15 microseconds and therefore I need a way of producing a counter which can measure let's say 10 counts in one microsecond I already have a algorithm of fast counter but this is giving me 1 count after every microsecond which is not good enough so therefore I need a way to improve this resolution. here is the code

#include<stdlib.h>

unsigned int pulse_counts = 0;
char buffer[20];
char buffer2[20];
char s[4]=" , ";

unsigned int count = 0;
void setup()
{
Serial.begin(9600);
// Serial.println("pulse width measurment");

pinMode(3, INPUT);
}

void loop()
{
count = 0;
pulse_counts++;
while ((PIND & B00001000) == B00000000); // wait for HIGH
while ((PIND & B00001000) == B00001000) count++; // start counting until LOW

float usec = 1.0 * count * 0.50;

// For text file output - Uncomment this

// Serial.print("#S|AAA|[");
// Serial.print(dtostrf(usec,5,2,buffer));
// Serial.print(s);
// Serial.print(itoa((pulse_counts), buffer2, 10));
// Serial.println("]#");

// For serial output display - Uncomment this

Serial.print("Count = ");
Serial.print(pulse_counts);
Serial.print(" , Width = ");
Serial.print(usec, 2);
Serial.println (" microseconds");

// delay(1000);
}

http://www.pjrc.com/teensy/td_libs_FreqCount.html