i want to count frequency up to 6 Mhz and display it on LCD162 using arduino uno.then how to interface arduino board with LCD 162 and what type of extra circuitry required to count frequency up to Mhz.
plz send code and sketch diagram of circuit interface LCD with aurdino board.
manish_sharma:
...
plz send code and sketch diagram of circuit interface LCD with aurdino board.
Please do some work yourself.
You may be able to use one of the CPU's hardware timers in counter mode to count the pulses over a period of time.
If not you will need an external counter to reduce the 6MHz pulse stream to something manageable by the software.
One way or another you will need hardware to count/time that fast.
Nick Gammon presents code using the external clock source input to ATmega328 Timer/Counter1 which he has benchmarked to 8MHz.
Here is a simplified version of that code which does not use a second timer for the measurement period and does not handle overflow of Timer1. I don't have a signal source to bench mark the accuracy. You may be able to reduce the sample period to measure 5MHz.
//frequency counter using Timer1 counter without overflow count
//TCNT1 16 bit max value = 65,534
//20ms sample period gives frequency counter to a bit over 3.2 mhz
unsigned int dwell = 20000; // dwell in microseconds for counter
unsigned long final_counts;
unsigned long start_time;
unsigned long measured_time;
void setup()
{
Serial.begin(115200);
TCCR1A = 0; //initialize Timer1
TCCR1B = 0;
TCNT1 = 0;
pinMode( 5, INPUT_PULLUP); //external source pin for timer1
}
void loop()
{
start_time = micros();
TCNT1 = 0;//initialize counter
// External clock source on Timer1, pin (D5). Clock on rising edge.
// Setting bits starts timer
TCCR1B = bit (CS10) | bit (CS11) | bit (CS12); //external clock source pin D5 rising edge
while (micros() - start_time < dwell) {} // do nothing but wait and count during dwell time
TCCR1B = 0; //stop counter
final_counts = TCNT1; //frequency limited by unsigned int TCNT1 without rollover counts
measured_time = micros() - start_time;
Serial.print(measured_time); // report resulting counts
Serial.print("\t\t");
Serial.println(50 * final_counts); //20ms sample in Hz
}
Hi,
You seem desparate to get a solution.
Cross post..
http://forum.arduino.cc/index.php?topic=400286.0
What is your electronics, programming, arduino, hardware experience?
Is this a school/college/university project?
Tom...
The OP and his/her alter ego is currently enjoying a forum timeout for persistent cross-posting.
Cross-posts deleted.