Low cost audio function generator(DDS)


Closed Thread
Results 1 to 31 of 31

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Unavailability of components

    Dear Steve,

    Thanks for replying. Actually I live in a part of my country where sourcing of specialized components is a real problem. Initially I considered using a DDS chip. But set back due to unavailability. Frequency range is within 10K. I haven't done the homework yet. Just trying to get some guidelines whether to base it on a 16F. The possibility you can say. If it is technically possible then I might consider using a 18F too. That depends on the overall BOM cost.
    Regards

    Sougata

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


    Did you find this post helpful? Yes | No

    Default

    Hi, Sougata

    ICL 8038, voltage controlled ??? ... you use the Pic as the freq regulator ... say, you build a simple PLL !!! but 8038 outputs some sinewaves ...

    bad idea ???


    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 " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default Down memory lane

    Dear Alain,

    Thanks for your reply. I just don't want to go the conventional (traditional)way. I have used MAX038 (big brother of XR8038) earlier but it was a pure analogue design with some fancy digital control as you mentioned. This project is all about low cost and best control. In fact with a PC side software the lookup tables could be modified to generate other waveforms as well. I am asking you guys for the possibility on a 16F. Storing one quadrant of data in the lookup table and building the sinewave is easy. But while modulating it, for a 8bit modulation index, I am doubtful on the processor througput considering 16/32 bit math. If there is an easy way out to do this in software please guide.
    Regards

    Sougata

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


    Did you find this post helpful? Yes | No

    Default Commercial example ...

    Hi, Sougata

    Here, you will find such a DDS module ... for the price ... just tears left !!!

    http://shop.elv.de/output/controller...0&detail2=6325

    or here, with a PC interface:

    http://shop.elv.de/output/controller...&detail2=10617

    Alain
    Last edited by Acetronics2; - 12th December 2006 at 11:24.
    ************************************************** ***********************
    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
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Smile

    Hi Sougata,

    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.
    Code:
    '****************************************************************
    '*  Name    : DDS16F.BAS                                        *
    '*  Author  : Ingvar Gillholm                                   *
    '*  Date    : 2004-03-11                                        *
    '*  Version : 1.0                                               *
    '*  Notes   : This program produces a sinewave through PortB,   *
    '*          : which should have a R-2R leadder connected to it. *
    '****************************************************************
    
    
    @ device  pic16F876, hs_osc, wdt_off
    
    define OSC 20
    'DEFINE LOADER_USED 1
    
    TonePort    VAR PortB
    CheckNew    VAR PortA.3
    
    Phase       VAR BYTE[3] BANK0
    Freq        VAR BYTE[3] BANK0
    Zero        VAR BYTE    BANK0
    
    TempVar     VAR BYTE
    
    ADCON1 = 7      'Porta is digital
    TrisA = $ff     'All inputs
    PortB = 0       'Start with all outputs low
    TrisB = 0       'All outputs            
    Zero = 0
    
    PR2 = $3f
    OUTPUT PortC.2
    T2CON = %00000100
    CCP1CON = %00001100
    GOTO New
    
    Main:
    asm
    ;
    ;======================== MAIN LOOP =========================
    ;
    
        bcf STATUS,RP0
        bcf STATUS,RP1
    
    Loop
        BTFSC   _CheckNew     ; Check for a new	frequency
        GOTO    _New          ; and get new frequency
                              ;
    	MOVF	_Freq,W       ; Get the current frequency
    	ADDWF	_Phase,F	  ; and increment the phase
    	btfss STATUS,C        ;
        goto NoCarry          ;burn time if no carry
    	incf _Phase+1         ;
    	btfsc STATUS,Z        ;
    	incf _Phase+2         ;
    AfterCarry	              ;
    	MOVF	_Freq+1,W     ;
    	ADDWF	_Phase+1,F    ; 
    	btfsc STATUS,C        ;
    	incf _Phase+2	      ;
    	MOVF	_Freq+2,W	  ;
    	ADDWF	_Phase+2,F    ;
    
    	MOVF	_Phase+2,W	  ;
    
    	ANDLW	07Fh		  ;Reduce to 7 bits for 180 degrees
    	CALL	SineTbl		  ; and get amplitude
        
    	BTFSS  _Phase+2,7	;Is amplitude supposed to be negative?
    	SUBWF  _Zero,w		;Change polarity of sine amplitude
       	
        MOVWF	_TonePort     ;Output to DAC
    	GOTO	Loop		  ;
    
    NoCarry
        goto AfterCarry
    
    ;*********** SINE TABLE ****************
    
    SineTbl
    	ADDWF  PCL
        retlw 080h
        retlw 083h
        retlw 086h
        retlw 089h
        retlw 08Ch
        retlw 090h
        retlw 093h
        retlw 096h
        retlw 099h
        retlw 09Ch
        retlw 09Fh
        retlw 0A2h
        retlw 0A5h
        retlw 0A8h
        retlw 0ABh
        retlw 0AEh
        retlw 0B1h
        retlw 0B3h
        retlw 0B6h
        retlw 0B9h
        retlw 0BCh
        retlw 0BFh
        retlw 0C1h
        retlw 0C4h
        retlw 0C7h
        retlw 0C9h
        retlw 0CCh
        retlw 0CEh
        retlw 0D1h
        retlw 0D3h
        retlw 0D5h
        retlw 0D8h
        retlw 0DAh
        retlw 0DCh
        retlw 0DEh
        retlw 0E0h
        retlw 0E2h
        retlw 0E4h
        retlw 0E6h
        retlw 0E8h
        retlw 0EAh
        retlw 0EBh
        retlw 0EDh
        retlw 0EFh
        retlw 0F0h
        retlw 0F1h
        retlw 0F3h
        retlw 0F4h
        retlw 0F5h
        retlw 0F6h
        retlw 0F8h
        retlw 0F9h
        retlw 0FAh
        retlw 0FAh
        retlw 0FBh
        retlw 0FCh
        retlw 0FDh
        retlw 0FDh
        retlw 0FEh
        retlw 0FEh
        retlw 0FEh
        retlw 0FFh
        retlw 0FFh
        retlw 0FFh
        retlw 0FFh
        retlw 0FFh
        retlw 0FFh
        retlw 0FFh
        retlw 0FEh
        retlw 0FEh
        retlw 0FEh
        retlw 0FDh
        retlw 0FDh
        retlw 0FCh
        retlw 0FBh
        retlw 0FAh
        retlw 0FAh
        retlw 0F9h
        retlw 0F8h
        retlw 0F6h
        retlw 0F5h
        retlw 0F4h
        retlw 0F3h
        retlw 0F1h
        retlw 0F0h
        retlw 0EFh
        retlw 0EDh
        retlw 0EBh
        retlw 0EAh
        retlw 0E8h
        retlw 0E6h
        retlw 0E4h
        retlw 0E2h
        retlw 0E0h
        retlw 0DEh
        retlw 0DCh
        retlw 0DAh
        retlw 0D8h
        retlw 0D5h
        retlw 0D3h
        retlw 0D1h
        retlw 0CEh
        retlw 0CCh
        retlw 0C9h
        retlw 0C7h
        retlw 0C4h
        retlw 0C1h
        retlw 0BFh
        retlw 0BCh
        retlw 0B9h
        retlw 0B6h
        retlw 0B3h
        retlw 0B1h
        retlw 0AEh
        retlw 0ABh
        retlw 0A8h
        retlw 0A5h
        retlw 0A2h
        retlw 09Fh
        retlw 09Ch
        retlw 099h
        retlw 096h
        retlw 093h
        retlw 090h
        retlw 08Ch
        retlw 089h
        retlw 086h
        retlw 083h
    
    ENDASM
    New:
    ' The frequency is calculated as FreqValue = DesiredFreq/((1/2^24)*(5*10^6/28))
    ' Same as FreqValue = DesiredFreq/((1/16777216)*(5000000/28))
    ' Same as FreqValue = DesiredFreq*16777216*28/5000000
    ' Same as FreqValue = DesiredFreq*93,9524096
    ' The resolution is 1/93,9524096 = 0,01064368656703404........Hz
    
    ' The eight frequencies selected for this test is........
    '  67,0 = 001896
    '  94,8 = 0022CA
    ' 118,8	= 002B99
    ' 146,2	= 0035A7
    ' 173,8	= 003FC8
    ' 199,5	= 004937
    ' 225,7	= 0052D5
    ' 254,1 = 005D41
    
        TempVar = PortA & %00000111     'Only lower 3 bits
    '    LOOKUP TempVar,[$00,$00,$00,$00,$00,$00,$00,$00],Freq[2]    'Stuff Hibyte            
    '    LOOKUP TempVar,[$1a,$25,$2e,$39,$44,$4e,$58,$63],Freq[1]    'Stuff Midbyte
    '    LOOKUP TempVar,[$58,$47,$b7,$7d,$57,$72,$c0,$eb],Freq[0]    'Stuff Lowbyte
        LOOKUP TempVar,[$00,$00,$00,$00,$00,$00,$00,$00],Freq[2]    'Stuff Hibyte            
        LOOKUP TempVar,[$18,$22,$2b,$35,$3f,$49,$52,$5d],Freq[1]    'Stuff Midbyte
        LOOKUP TempVar,[$96,$ca,$99,$a7,$c8,$37,$d5,$41],Freq[0]    'Stuff Lowbyte    
        GOTO Main
    END
    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

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


    Did you find this post helpful? Yes | No

    Default Thanks Ingvar

    Hi All,

    Thanks Ingvar at least you share the same vision as me.
    Doing amplitde control is probably too much to ask from a 16F@20MHz but a 18F@40MHz might be able to pull it off.
    Actually my client wants to put this module into a breadboard trainer to make it compete better. he does'nt want to increase the manufacturing cost however.

    Because the amplitude control will also be used to modulte the base sinewave at a lower frequency it needs to be computed on the fly through a modulation index (I suppose).

    Thanks Alain for the link but I cannot read German.(I am not sure even if it is German at all)
    Last edited by sougata; - 12th December 2006 at 12:45.
    Regards

    Sougata

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


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by sougata
    Hi All,


    Thanks Alain for the link but I cannot read German.(I am not sure even if it is German at all)
    The only interesting info here is the price reached ... ~ 50 US $ ( sold ...) .

    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 " !!!
    *****************************************

  8. #8
    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

  9. #9
    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 ?

Similar Threads

  1. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 16:23
  2. Pic16f84 and RC5 kode
    By terminator in forum Bluetooth
    Replies: 5
    Last Post: - 18th June 2007, 22:40
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 18:27
  4. Problems with RC2 and RC3
    By Christopher4187 in forum General
    Replies: 11
    Last Post: - 29th May 2006, 18: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, 04: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