DDS-AD9850 + Open oscilloscope – Lxardoscope

AD9850-Logo

The DDS module is base on AD9850 which is provided by ADI Company and common used in many DDS module.The chip provide 0-40MHz measurement capability.  Here we will show you how to control AD9850 module by Arduino, and then show the output wave by Lxardoscope, which  is an Arduino based oscilloscope for Linux, using the Xforms library.  You can get more detailed how to use it from our other post Linux+Arduino open oscilloscope – Lxardoscope.

The DDS module of AD9850/AD9851 has two data transfer modes : Serial mode and  Parallel mode. You can select one of them by Label 1 as below figure.

 More detailed about the DDS pin define from our Wiki. Here I just show you how to quick control AD9850 and show wave on  Lxardoscope.

 

 

First of all, of course, you need one  Arduino boards and one DDS module,  and some of jumper wires and at least one of test hook.  If you don’t have, you can get them in our store in a very low cost.

If you use a standard Arduino board, you’d better use the Arduino board’s 3.3V pin(VDD3V3) to provide power.  Of course you can use 5V which the DDS module of AD9850 max support power supply.

The Serial mode of demo pins to Arduino as below:

GND–GND, VCC – 3.3V, BitData(D7)- D8, CLK – D9, FQUP – D10, REST – D11 

Test Hook Red  -  Square Wave 1,   Test Hook Black  -  Sine Wave 1(with 70MHz Low-pass filter)

 

 

Download our library for DDS AD9850 Serial mode,  run the example demo of LXARDOSCOPE.  The demo code as below:


/*********************************************************************
**  Device: AD9850/9851                                             **
**  File:   EF_AD9850.cpp v1.2                  **
**                    **
**  Created by ElecFreaks Robi.W /28 Oct 2011                       **
**                                                                  **
**  Description:                                                    **
**  This file is a sample code for your reference.About AD9850/9851 **
**  module use on Arduino with serial mode. And then show the       **
**  square wave and sine wave by LXARDOSCOPE which is an free       **
**  Arduino based oscilloscope Linux, using the Xforms library.     **
**  Note:This library just Serial mode for AD9850                   **
**                                                                  **
**  This demo code is free software; you can redistribute it and/or **
**  modify it under the terms of the GNU Lesser General Public      **
**  License as published by the Free Software Foundation; either    **
**  version 2.1 of the License, or (at your option)           **
**  any later version.                **
**                                                                  **
**  Copyright (C) 2011 ElecFreaks Corp.                           **
**                                                                  **
**  http://www.elecfreaks.com                                       **
*********************************************************************/


#include <EF_AD9850.h>

//Define for LXARDOSCOPE
int sensorValue = 0;        // value read from the pot
byte lb;
byte hb;

//BitData - D8, CLK - D9, FQUP - D10, REST - D11
EF_AD9850 AD9850(9, 10, 11, 8);

void setup()
{
  AD9850.init();
  AD9850.reset();
  AD9850.wr_serial(0x00, 200); //200Hz
  // initialize serial communications at 115200 bps:
  Serial.begin(115200);
}

void loop(){
  // read A0:
  sensorValue = analogRead(A0);
// shift sample by 3 bits, and select higher byte
  hb=highByte(sensorValue<<3);
// set 3 most significant bits and send out
  Serial.print(hb|224,BYTE);
// select lower byte and clear 3 most significant bits
  lb=(lowByte(sensorValue))&31;
// set bits 5 and 6 and send out
  Serial.print(lb|96,BYTE);
// read A1
  sensorValue = analogRead(A1);
// shift sample by 3 bits, and select higher byte
  hb=highByte(sensorValue<<3);
// set bits 5 and 6 and send out
  Serial.print(hb|96,BYTE);
// select lower byte and clear 3 most significant bits
  lb=(lowByte(sensorValue))&31;
// set bits 5 and 6 and send out
  Serial.print(lb|96,BYTE);
}

Then connect to you Linux’s Lxardoscope, type ‘ lxardoscope /dev/ttyUSB0 ‘. There will show the square wave and sine wave on lxardoscope menu as before.

Note:

  • If you can’t see square wave as figure, please change duty cycle adjustable at label 8 postion.

  • lxardoscope just support a 420 Hz sine wave and a 1471Hz square wave from a
    sound card based generator are displayed.  So we demo set 200Hz for test.  If setting 600Hz will distortion as below:

 

  •   lxardoscope just for verify the DDS module is work well. The data just for you reference.

 

The Parallel mode of demo pins to Arduino as below:

GND–GND, VCC – 3.3V, BitData(D0-D7) – PORTD(D0-D7), CLK – D9, FQUP – D10, REST – D11 

Test Hook Red  -  Square Wave 1,   Test Hook Black  -  Sine Wave 1(with 70MHz Low-pass filter)

Download our Arduino Parallel mode code for DDS AD9850 Serial mode,  run the example demo of LXARDOSCOPE.

//Define for AD9850
#define REST 11
#define FQUP 10
#define CLK 9

#define BitData_Port PORTD
#define BitData_DIR DDRD
#define BitData_IN PIND

//Define for LXARDOSCOPE
int sensorValue = 0; // value read from the pot
byte lb;
byte hb;

void AD9850_Init(){
......

}

void AD9850_Reset(){
.....
}

void AD9850_WR(unsigned char w0,double frequence){
......
}

void setup(){
AD9850_Init();
AD9850_Reset();
AD9850_WR(0x00, 200); //500Hz
// initialize serial communications at 115200 bps:
Serial.begin(115200);
}

void loop(){
// read A0:
sensorValue = analogRead(A0);
// shift sample by 3 bits, and select higher byte
hb=highByte(sensorValue<<3);
// set 3 most significant bits and send out
Serial.print(hb|224,BYTE);
// select lower byte and clear 3 most significant bits
lb=(lowByte(sensorValue))&31;
// set bits 5 and 6 and send out
Serial.print(lb|96,BYTE);
// read A1
sensorValue = analogRead(A1);
// shift sample by 3 bits, and select higher byte
hb=highByte(sensorValue<<3);
// set bits 5 and 6 and send out
Serial.print(hb|96,BYTE);
// select lower byte and clear 3 most significant bits
lb=(lowByte(sensorValue))&31;
// set bits 5 and 6 and send out
Serial.print(lb|96,BYTE);
}

 

If you have any problem, please feel free to contact us. Any of you suggestion is help.

Download : 

 

VN:F [1.9.13_1145]
Rating: 8.3/10 (3 votes cast)
VN:F [1.9.13_1145]
Rating: +1 (from 1 vote)
DDS-AD9850 + Open oscilloscope - Lxardoscope , 8.3 out of 10 based on 3 ratings

Related Posts

5 Comments

  1. chris

    Hello, i just bought from you this unit.
    The example in the library has wrong in the pin order,
    the wright order is
    //CLK – D9 FQUP – D10, REST – D11, BitData – D8

    I cant manage to work the module in parallel mode with an arduino mega 2560. Have you any further tip.

    How we can change the phase modulation?
    What to insert instead of (0×00)?

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
    Reply
  2. Konst

    it returns – Function definition does not declare parameters

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
    Reply
  3. Konst

    Hi, guys! can I do the same on this unit – http://www.ebay.com/itm/130669935322?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649?

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
    Reply
  4. Bid-Ninja Click Here

    I usually don’t write comments on posts, but your post urged me to commend your writings. Thanks for writing this, I will certainly favorite your site and occur back as soon as in awhile. Happy blogging.

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
    Reply
  5. wu

    Hi,

    I’m getting an error when trying to compile this code. Any idea how I can fix this…?

    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Arduino.h:199: error: default argument given for parameter 3 of ‘long unsigned int pulseIn(uint8_t, uint8_t, long unsigned int)’
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Arduino.h:108: error: after previous specification in ‘long unsigned int pulseIn(uint8_t, uint8_t, long unsigned int)’
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Arduino.h:201: error: default argument given for parameter 3 of ‘void tone(uint8_t, unsigned int, long unsigned int)’
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/WProgram.h:24: error: after previous specification in ‘void tone(uint8_t, unsigned int, long unsigned int)’

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Go To Top