Frequency generator

Discussion in 'General Electronics Chat' started by cmartinez, May 7, 2017.

  1. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    4,222
    4,467
    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?
     
  2. Papabravo

    Expert

    Feb 24, 2006
    11,068
    2,152
    cmartinez likes this.
  3. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    4,222
    4,467
  4. Papabravo

    Expert

    Feb 24, 2006
    11,068
    2,152
    You're more than welcome, my friend.

    I have an Antenna Analyzer that used one of these chips to probe an unknown antenna to calculate the SWR, return loss, and resonant frequency. Great product.

    http://www.radiomanual.info/schemi/ACC_instrument/Palstar_ZM30_user.pdf
     
    Last edited: May 7, 2017
    cmartinez likes this.
  5. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    4,222
    4,467
    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...
     
  6. Papabravo

    Expert

    Feb 24, 2006
    11,068
    2,152
    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
     
    cmartinez likes this.
  7. BR-549

    Distinguished Member

    Sep 22, 2013
    2,997
    724
    cmartinez likes this.
  8. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    4,222
    4,467
    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.
     
  9. KeepItSimpleStupid

    Well-Known Member

    Mar 4, 2014
    2,012
    350
  10. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    4,222
    4,467
    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.
     
  11. BR-549

    Distinguished Member

    Sep 22, 2013
    2,997
    724
    I believe that dds goes to dc......with a parallel input.....if not mistaken.
     
  12. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,827
    924
    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.
     
    cmartinez likes this.
  13. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    4,222
    4,467
    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.
     
  14. AnalogKid

    AAC Fanatic!

    Aug 1, 2013
    5,570
    1,576
  15. frpr666

    Active Member

    Feb 2, 2010
    50
    8
    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.
     
    cmartinez likes this.
  16. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    4,222
    4,467
    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.
     
  17. frpr666

    Active Member

    Feb 2, 2010
    50
    8
    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.
     
  18. frpr666

    Active Member

    Feb 2, 2010
    50
    8
  19. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    4,222
    4,467
    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.
     
  20. AnalogKid

    AAC Fanatic!

    Aug 1, 2013
    5,570
    1,576
    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
     
    frpr666 likes this.
Loading...