Build a task for measuring the frequency of square wave signals above 100 kHz using a microcontroller. Achieve maximum range for measuring frequency.
Note: You can use any approach or method that can generate frequencies greater than 100 kHz (e.g., Function Generator, etc.)
Example:
Generating Frequency > 100 kHz using Arduino UNO
We have used one Arduino UNO along with a potentiometer to generate frequencies between 100 kHz and 8 MHz, where the potentiometer is used to vary the frequency.
The corresponding code for generating these frequencies is provided below.
#define pot A0
void setup() {
cli();
TCCR1A = (1 << COM1A0); // Toggle OC1A on compare match
TCCR1B = (1 << WGM12) | (1 << CS10); // CTC mode, prescaler = 1
OCR1A = 0;
// Corrected DDRB Configuration
DDRB |= (1 << PB1); //D9 (PB1) as outputs
sei(); // Enable interrupts
}
void loop()
{
uint16_t potValue = analogRead(pot);
//map pot value to genetate frequency >100KHz
OCR1A = map(potValue, 0, 1024, 0, 80);
}