Frequency generator

Thread Starter

cmartinez

Joined Jan 17, 2007
8,727
I'd like to build a frequency generator that would generate squarewaves with a low state of 0V and a high state of 5V. This generator would have a range of integer number frequencies between 1 Hz and 60 kHz. But up to 100 kHz would be desirable.

Specifically, I'd like a circuit having a parallel input signal of 16 bits (that would be in the range of between 0 and 65,535) and have the circuit output the equivalent frequency. Example: if I feed the circuit a binary number of 0011 1001 1001 1001, I'd like to obtain a frequency output of 14,745 Hz

I've been thinking doing that using an MCU, but it's beginning to look like some very complicated code would be involved, although I might just have to dip my head into that approach if I can't find a better alternative.

Question; Other than using an analog oscillator (which I'm trying to avoid) what other digital options are out there that could be better alternatives?
 

Papabravo

Joined Feb 24, 2006
22,058
Last edited:

Thread Starter

cmartinez

Joined Jan 17, 2007
8,727
Well, I'm in trouble now... all of the DDS chips that I could find at Digike are SMT, which is something that I'm trying to avoid. It's also bad that they have so many pins!
On the other hand, they output sine waves and work at very high output frequencies. I require square wave output, but I guess I could use a comparator to transform the sine wave into one. But the high frequency output will most probably require the use of a divide-by-x circuit. I'll have to work on that too.

The chip that I think could do the trick, among others, is the AD9833. But it doesn't look like it's easy to use... at all...

This little endeavor is looking much more complex than I thought at first...
 

Papabravo

Joined Feb 24, 2006
22,058
Well, I'm in trouble now... all of the DDS chips that I could find at Digike are SMT, which is something that I'm trying to avoid. It's also bad that they have so many pins!
On the other hand, they output sine waves and work at very high output frequencies. I require square wave output, but I guess I could use a comparator to transform the sine wave into one. But the high frequency output will most probably require the use of a divide-by-x circuit. I'll have to work on that too.

The chip that I think could do the trick, among others, is the AD9833. But it doesn't look like it's easy to use... at all...

This little endeavor is looking much more complex than I thought at first...
So there are PIC processors that come with an NCO peripheral. There are low cost kits for a TST(Tayloe Simple Transmitter) that use them. They may be more to your liking since many PICs still come in DIP versions.

http://ww1.microchip.com/downloads/en/AppNotes/90003131A.pdf
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,727
I didn't know about NCO modules, and they seem to be the thing that I've been after all this time. Gonna study them more carefully and then get back here with my observations.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,727
Ideally, I'd like a programmable square wave oscillator with an output of between 1 Hz and 60 kHz. I've been looking at several candidate chips for that. I still have lots of reading to do before I make a decision. Many thanks.
 

atferrari

Joined Jan 6, 2004
5,002
Prior buying a fully fledged signal generator I started to develope one using IIRC the AD9834 able to do different types of sweepings. Most of the AD's chips cannot do that.

What stopped me was the design of the output filter. I collected way too many "easy", "simple" and the like answers in various forums but nothing more concrete than that.

Because the above I finally gave up but the idea of controlling one with a micro is very appealing and I would say, simple.

I suspect my signal generator is built based on that chip.

I also built a dual NCO signal generator using two micros driven by the same clock running exactly the same software allowing to vary the phase (by stealing clock cycles to one of them). My farewell design to the 16F84A in pure Assembly. It works OK.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,727
I also built a dual NCO signal generator using two micros driven by the same clock running exactly the same software allowing to vary the phase (by stealing clock cycles to one of them). My farewell design to the 16F84A in pure Assembly. It works OK.
Agustín, would you mind elaborating? This project is very important for me and I'd like to consider all options before making a decision.
These last three days I've been trying to write some code for a single-cycle 8051 for this purpose, but the amount of time taken to perform the necessary calculations is just ridiculous. Ideally, I'd like to have a device that could input a parallel number in binary form (I'm aiming for 11 bits) and output the proportional frequency without it stopping or slowing down between changes.
One of the things I've been considering is a PWM to voltage to frequency converter, but I'd like to keep this application completely digital, if possible.
 

frpr666

Joined Feb 2, 2010
53
I think you can build this generator using an single atmega328p chip. The same one which is usually used in Arduino. It has many I/O and the 16bit timer2 which can be used as the signal generator or PWM.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,727
I think you can build this generator using an single atmega328p chip. The same one which is usually used in Arduino. It has many I/O and the 16bit timer2 which can be used as the signal generator or PWM.
I'm already using an AT89LP4052, which also has a 16 bit timer (mode 1). But I fail to see how I could implement in a practical way a function that would deliver a linear frequency output.
 

frpr666

Joined Feb 2, 2010
53
I would recommend to use the atmega328p. You can directly write the 16 bit. register that exactly equals the period. You can also chain the timers. For instance the timer1 could pre-divide the frequency of the system clock and its output can fed the timer2 clock input.
atmega328p is modern chip and you can buy the ready-to-use board for cheap.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,727
I would recommend to use the atmega328p. You can directly write the 16 bit. register that exactly equals the period. You can also chain the timers. For instance the timer1 could pre-divide the frequency of the system clock and its output can fed the timer2 clock input.
atmega328p is modern chip and you can buy the ready-to-use board for cheap.
Thanks, but programming for a given period is not really the issue. In fact, period generation of any value is extremely easy.

The hard part is writing a program for frequency. And the code necessary to calculate the division operation involved is too long for it to be practical. At least using a single mcu.

That's why I'm eagerly waiting for Agustín to clarify his comment about using two mcu's for this task. I'd really like to know how he did it.
 

AnalogKid

Joined Aug 1, 2013
12,057
Frequency is the inverse of period, so I don't see a drastic change in programming complexity. One way to shortcut things is with a lookup table. It's only 65,000 entries to type in; how hard can it be?

ak
 
Top