AD9850 DDS code


Closed Thread
Results 1 to 16 of 16

Thread: AD9850 DDS code

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: AD9850 DDS code

    Hi,
    Sorry for the late reply, you've probably figured it out by now.
    But in case you haven't, have you verified that your PIC is actually running?
    I've just tried the following code here, all wired up on a breadboard using a 16F628 using a 4MHz x-tal and a AD9850 module, compiled with PBP 3.0.6.4. Module forced into serial mode by tying D0,D1 high and D2 low. It outputs a 500kHz signal as expected:
    Code:
    DEFINE OSC 4
    
    Clk VAR PortB.5                 ' Clock output pin
    Dta VAR PortB.6                 ' Data output pin
    FUd VAR PortB.7                 ' Frequency update output pin
    
    PortB = 0
    TRISB = 0                       ' All outputs
    
    Pause 1000                      ' Let everything power up
    
    ' Tuning word for 500kHz = 500000*2^32/125000000 = 17179869 or, in HEX, $010624DD
    ' The AD9850 wants the least significant byte first:
    SHIFTOUT Dta, Clk, 0, [$DD, $24, $06, $01, $00]
    
    ' Now pulse the Frequency update pin
    FUd = 1 : PauseUS 10 : FUd = 0
    
    ' Blink a LED to show we're alive.
    Done:
      Toggle PortB.3
      Pause 100
    Goto Done
    Here's the result:
    Name:  DSX_20130223011754.jpeg
Views: 5230
Size:  102.8 KB

    /Henrik.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: AD9850 DDS code

    Just a follow up to the previous post.
    For reference, here's the "schematic" for the setup I used with the above code. There are a couple of different modules in circulation so make sure the actual signals and not the pin numbers matches your particular module.

    Name:  AD9850-setup.jpg
Views: 8962
Size:  41.7 KB

    If you're programming the PIC in-circuit perhaps the programmer is loading RB6, RB7 (since they are the programming pins) preventing them from operating the AD9850 properly? I'm doing just that with a PICKit3 on my breadboard and don't see any issues but it's a thought.

    /Henrik.

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: AD9850 DDS code

    I now have the circuit working. I dont quite understand why the first attempt didnt work, but the following works for me. Thankyou for taking the time to solve my problem.

    DEFINE OSC 4 ;WE ARE USING A 4MHZ XTAL OSCILLATOR

    CLOCK VAR PortB.6 ;CLOCK SIGNAL IS ON RB6, PIN 12
    DATAPIN VAR PortB.5;DATA SIGNAL IS ON RB5, PIN 11
    FQUD VAR PortB.4 ;FREQUENCY UPDATE ON RB4, PIN 10

    TRISB = 0 ;SET ALL OF PORTB AS OUTPUTS
    PORTB = 0 ;SET ALL OF PORTB LOW

    Pause 1000 ;WAIT FOR CIRCUIT TO STABILISE
    PULSOUT FQUD,10 ;RESET DDS
    SHIFTOUT DATAPIN, CLOCK, 0, [$DD, $24, $06, $01, $00] ;SEND SERIAL DATA TO DDS
    PULSOUT FQUD,10 ;LOAD NEW FREQUENCY 500KHZ

    SHIFTOUT DATAPIN, CLOCK, 0, [$DD, $24, $06, $01, $00] ;SEND SERIAL DATA TO DDS
    PULSOUT FQUD,10 ;LOAD NEW FREQUENCY 500KHZ
    ;SERIAL DATA IS SENT TWICE, IF ONLY SENT ONCE DDS CHIP SOMETIMES LOCKS UP
    END

  4. #4
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: AD9850 DDS code

    Hi Henrik,
    I will like to understand what are OUTPUT_1 and OUTPUT_2 : any help? Sine or square ?
    What about the other two outputs ?
    What is the purpose of R_13 Trim ?

    I do not have any schematics for this board nor manual to read ! My board is exactly the one shown in your photo.

    Thanks again for the great help .
    Bye
    Ambrogio
    IW2FVO

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: AD9850 DDS code

    Hi,
    Not sure, I don't know much about the hardware I'm afraid. I wrote the code and put the board on the shelf.... I'd look at the AD9850 datasheet for details.
    I think both outputs are Sine outputs, the phase relationship between the two outputs is what you set with CONTROL word.

    /Henrik.

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: AD9850 DDS code

    Here's a schematic for the above module

    As I recall the pot will change the duty cycle on the square wave
    and will skew the sine wave



    Name:  Ad9850_ebay.jpg
Views: 7401
Size:  46.2 KB

  7. #7
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: AD9850 DDS code

    Henrik and Mark_s,
    thanks for the assistance.
    regards,
    Ambrogio
    IW2FVO

  8. #8
    Join Date
    Aug 2005
    Posts
    42


    Did you find this post helpful? Yes | No

    Default Re: AD9850 DDS code

    Quote Originally Posted by iw2fvo View Post
    I will like to understand what are OUTPUT_1 and OUTPUT_2 : any help? Sine or square ?
    What about the other two outputs ?
    What is the purpose of R_13 Trim ?
    The module has two outputs for Sine Wave and two outputs for Square wave.

    In Henriks handy pin-out picture he shows the two sine waves outputs, the next two pins above are the square wave outputs.

    Played with a module today and the code examples Henrik supplied work great and thank you Henrik.

    The Pic Chips tend to max out at 25khz when pulsing stepper drivers which retricts the speed when running them at say 2000 pulses per revolution. It limits you to a max of around 500 RPM.

    Now with the DDS boards + Pic Chip combination, I had some stepper motors here today hitting over 5000 RPM no problems at all.

    Great little modules and good prices.

    Cheers

    Sean.
    *********************
    http://www.cncdudez.co.uk
    *********************

  9. #9
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: AD9850 DDS code

    Sean,
    could I have the circuit diagram for your stepper motor implementation ?
    Thanks
    Ambrogio

  10. #10
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: AD9850 DDS code

    Henrik,

    I have used my module today , it is the same model that is shown in your picture.
    I have discovered an intermittent sine wave stream at the two output. This was due to the RESET line that has to be connected to ground.
    This is in my circuit lay_out.
    I hope it will help in some cases.
    Ambrogio

  11. #11
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: AD9850 DDS code

    Hi,
    Thank you very much for that post!
    I haven't noticed it any of my (two) breadboard sesions with the module. Just measured it and the Reset pin is indeed floating - must have been pure luck it worked for me.

    I wish I could fix the "schematic" but I can't....

    Thanks again!
    /Henrik.

Similar Threads

  1. Calculate tuning value for the AD9850 DDS.
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 21st July 2018, 00:49
  2. Working code but my layman approach uses too much code space
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 14th December 2012, 20:44
  3. Code: Why is this code greater than 2000 words?
    By DrDreas in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 1st June 2007, 19:51
  4. Need help in controlling DDS AD9850/51
    By vu2iia in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 7th March 2007, 12:40

Members who have read this thread : 1

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