Hi all,
I'm currently having an issue figuring out how to attain decent resolution when generating square waves around 100kHz. I am looking for a very cost effective solution, I may add.
For example, I am currently using a microcontroller. It's cheap and it can generate square waves pretty easily. But when working around 100kHz with a 16MHz clock you can only divide by clock cycles to reach a particular frequency.
An easily understood example, say it takes one clock cycle for square wave high and a second clock cycle for square wave low. That means the highest frequency achievable is 8MHz. At 100k the microcontroller is waiting 80 clock cycles for a full square wave. 8M / 80 cycles = 100kHz
But here comes the monkey wrench: the next closest achievable frequency would be 8M / 79 cycles = 101265Hz! That's 1265Hz to the next achievable frequency!
I would like to continue to use a microcontroller but I was hoping to keep a resolution of 100Hz or better. I am open to analog circuits as well. I at least would like to control/set the frequency with a microcontroller.
I've been racking my brain over this problem, someone please enlighten me! Thanks!
I'm currently having an issue figuring out how to attain decent resolution when generating square waves around 100kHz. I am looking for a very cost effective solution, I may add.
For example, I am currently using a microcontroller. It's cheap and it can generate square waves pretty easily. But when working around 100kHz with a 16MHz clock you can only divide by clock cycles to reach a particular frequency.
An easily understood example, say it takes one clock cycle for square wave high and a second clock cycle for square wave low. That means the highest frequency achievable is 8MHz. At 100k the microcontroller is waiting 80 clock cycles for a full square wave. 8M / 80 cycles = 100kHz
But here comes the monkey wrench: the next closest achievable frequency would be 8M / 79 cycles = 101265Hz! That's 1265Hz to the next achievable frequency!
I would like to continue to use a microcontroller but I was hoping to keep a resolution of 100Hz or better. I am open to analog circuits as well. I at least would like to control/set the frequency with a microcontroller.
I've been racking my brain over this problem, someone please enlighten me! Thanks!