# Square generator 1KHz to 1MHz with 1KHz precision

I would like to make a square wave generator which will output a signal with amplitude X voltages and frequency between 1KHz to 1MHz, with the precision of 1KHz (for example: 785kHz, 926kHz, 999kHz, etc ...). I have tried to do that with Arduino Uno, but I realized that I would need a precision of 1ns to be able to do that. 1ns equals to 1GHz. So, what hardware do I need to be able to do that?

• Why do you need a resolution of 1 nanosecond? Commented Jul 15, 2015 at 16:31
• Let's say you have 1us, that will give you 1MHz. If you have 2us you get 500 kHz. You see, a micro second is not enough. Commented Jul 15, 2015 at 16:34
• @NickJohnson The time difference between 999kHz and 1MHz for a single cycle is aprox 1ns Commented Jul 15, 2015 at 16:35
• 1/1 ns = 1 GHz not 1 THz. Which is only about twice the toggle rate of simple logic in a fast FPGA. However not all the required periods are a whole number of nanoseconds...
– user16324
Commented Jul 15, 2015 at 16:40
• BTW, seemingly trivial, this question is not that easy..The problem, that is for a linear frequency range you will need a totally non-linear (1/F) period times. Commented Jul 15, 2015 at 16:45