Low cost audio function generator(DDS)


Closed Thread
Results 1 to 31 of 31

Hybrid View

  1. #1
    speck's Avatar
    speck Guest


    Did you find this post helpful? Yes | No

    Default

    Hi Ingvar-

    Could this be made to work using the HPWM output & a timer interrupt to output very low frequency sine waves? (< 30hz) Using a lookup table & a variable timer interrupt cycle to vary the sample rate/freq. of the sine? Perhaps amplitude could be varied by scaling the wavetable values?

    Was it the case that the PWM output didn't give you a smooth sine at higher frequencies? Or it just didn't work well at all?

    Quote Originally Posted by Ingvar

    I did some experimenting with DDS a few years ago, i wrote this piece of code. If my memory serves me right, it worked up to 20kHz with reasonable good looking sine on the output. I also did some testing with PWMoutput but never got good results with that, there may be some leftovers in the program from that ...... just remove.
    Doing amplitde control is probably too much to ask from a 16F@20MHz but a 18F@40MHz might be able to pull it off.

    /Ingvar

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Talking comment

    10-MHz-DDS-Funktionsgenerator mit PC-Softwaresteuerung-preis:69,95 euro
    Das ist gut, Ya ?

  3. #3
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default HPWM works

    Hi Speck,

    It can always be done with a hardware PWM and low pass filter. See my sinewave inverter thread http://www.picbasic.co.uk/forum/showthread.php?t=1846 for a code snippet that does this at an update rate of 100Hz driving a half bridge. Scaling the sine table is impractical with only 8 bits of resolution. For example if you define your sinewave lookup table to produce the maximum peak value into an 8 bit one then you have to do fractional math.That is your modulation index (depth of modulation) is <= 1. (The dSPIC supports fractional math). So the trade-off is multiplying the lookup table with a 8bit value and shredding off the LSBs. This works okay for low fixed frequency. If you do a cycle by cycle computation then the overhead is manageable. But for a 20K function generator to work with a base frequency and modulating frequency it has to be updated every PWM interrupt cycle. That is too much you could ask for a 16F PIC @ 5 MIPS. The 18Fs have an extended instruction set featuring a single cycle hardware multiply that too @ 10MIPS. In fact you can use Darrel's Software PWM http://www.pbpgroup.com/modules/wfse...p?articleid=12 to make your life easy. It takes of all your pain in doing it in asm.

    BTW the PIC Hardware PWM uses upto 10bits and it is a good practice to set your PR2 to $FF. That is where you get the maximum usable PWM resolution.
    Regards

    Sougata

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S.
    10-MHz-DDS-Funktionsgenerator mit PC-Softwaresteuerung-preis:69,95 euro
    Das ist gut, Ya ?
    Hi,Joe

    I've "built" ( laughs ...) the 20Mhz one ...

    just need an extra output buffer for > 10 Mhz outputs ( there's a too low -pass response somewhere ! ) ... and because the HC132 is a bit weak on even small capacitive loads.

    Otherwise it works really fine !!! ... and 4Mhz is the Max I really need ...as a variable PIC clock drive.

    precision and resolution are really unbeaten for such price ...

    Yawohl ... sehr gut !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Talking

    Je dit... c'est le excellent prix pour le excellent produit ... yah!

    I don't know the following, and i don't know how good they are and are really far of the needed range here but...
    http://www.amqrp.org/kits/dds60/
    http://www.minikits.com.au/kits4.html

    Kinda time saver i guess.
    Last edited by mister_e; - 13th December 2006 at 07:37.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Post

    Hi Speck,

    It should be possible to do with hardware PWM, espescially at low frequencies like that. I just never got it working very well at higher freqs, so i never really finished it off to see where the limits were. Feel free to carry out your own investigation cause it should be possible.

    I think it was probably due to the fact that the loop runs at 5000000/28=178,571kHz and the highest (useable) PWM freq was around twice that ....... no resolution. However, like i said, i never took it all the way, i got the results i wanted with the R-2R ladder.

    /Ingvar

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink Appel au peuple...

    Hi,All

    I saw one application in a the French "Electronique Pratique" magazine, issue 247, page 86 ...

    But, halas, I didn't download the Pic ( Hex ) Program ... and it's no more available.

    May be someone has it in his computer memory ???

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 15:23
  2. Pic16f84 and RC5 kode
    By terminator in forum Bluetooth
    Replies: 5
    Last Post: - 18th June 2007, 21:40
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. Problems with RC2 and RC3
    By Christopher4187 in forum General
    Replies: 11
    Last Post: - 29th May 2006, 17:19
  5. 4-line LCD Help - using PortA instead of B
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 31st March 2005, 03:14

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts