Monday, March 30, 2015

Arduino with AD9850 - Redesign

Today, we have a meeting to test the target frequencies by using Pico Oscilloscope and the game programmed by Sven. The test was sucessful with high accuracy. Hence, we move to redesign the Arduino + AD9850 set to make it more compact so that it can be treated as a wearable device.

Thanks to the first set up by Andy in the group, I am able to rearrange the Ardunio and AD9850 so that it takes less space and looks a bit cooler. The below figure shows the new set up where the AD9850 board sits on top of the Ardunio.




By pushing the AD9850 chip into the Arduino right digital pin set, The AD9850 uses different pins in the Ardunio compare to the orgional propose by Andy. Here is the full new pins set up;

  • Wire from AD9850 VCC pin to 3.5V on Arduino
  • Male AD9850 W_CLK pin plug to directly to pin 10 on Arduino
  • Male AD9850 FV_VD pin plug to directly to pin 11 on Arduino
  • Male AD9850 DATA pin plug to directly to pin 12 on Arduino
  • Male AD9850 RESET breadboard row to digital pin 11 on Arduino
  • Male AD9850 GND pin plug to directly to pin GND on Arduino
  • Wire from AD9850 ZOUT2 so that we can use it for testing
As the new pins set have been changed the code for the Arduino has been changed to adapt to a new set up. Here the full new code based on the origional code by Andy:

 //AD9850 DDS test  
 #define DDS_CLOCK 125000000  
 #define CLOCK 10 //pin connections for DDS  
 #define LOAD 11  
 #define DATA 12  
 #define RESET 13  
 int flag=0;  
 int time = 2000;  
 bool on = false;  
 long lastTime;  
 long freq1 = 5000000;  
 long freq2 = 6000000;  
 long freq3 = 7000000;  
 long freq4 = 8000000;  
 long freq5 = 9000000;  
 long freq6 = 10000000;  
 long freqUp = freq3;  
 long freqDown = freq3;  
 void setup()  
 {  
  pinMode (DATA, OUTPUT);  
  pinMode (CLOCK, OUTPUT);  
  pinMode (LOAD, OUTPUT);  
  pinMode (RESET, OUTPUT);  
  AD9850_init();  
  AD9850_reset();  
  SetFrequency(freqUp);  
  Serial.begin(9600);  
  lastTime = millis();  
 }  
 /*void loop() {  
 SetFrequency(freqUp);  
 while(1);  
 } */  
 void loop()  
 {  
  // if(flag==1)  
  if (millis() - lastTime > time)  
  {  
   if (on)  
   {  
    SetFrequency(freqUp);  
   }  
   else {  
    SetFrequency(freqDown);  
   }  
   on = !on;  
   lastTime = millis();  
  }  
  // read the input on analog pin 0:  
  int sensorValue = analogRead(A0);  
  // print out the value you read:  
  Serial.println(sensorValue);  
  delay(1);  
 }  
 void SetFrequency(unsigned long frequency)  
 {  
  unsigned long tuning_word = (frequency * pow(2, 32)) / DDS_CLOCK;  
  digitalWrite (LOAD, LOW);  
  shiftOut(DATA, CLOCK, LSBFIRST, tuning_word);  
  shiftOut(DATA, CLOCK, LSBFIRST, tuning_word >> 8);  
  shiftOut(DATA, CLOCK, LSBFIRST, tuning_word >> 16);  
  shiftOut(DATA, CLOCK, LSBFIRST, tuning_word >> 24);  
  shiftOut(DATA, CLOCK, LSBFIRST, 0x0);  
  digitalWrite (LOAD, HIGH);  
 }  
 void AD9850_init()  
 {  
  digitalWrite(RESET, LOW);  
  digitalWrite(CLOCK, LOW);  
  digitalWrite(LOAD, LOW);  
  digitalWrite(DATA, LOW);  
 }  
 void AD9850_reset()  
 {  
  //reset sequence is:  
  // CLOCK & LOAD = LOW  
  // Pulse RESET high for a few uS (use 5 uS here)  
  // Pulse CLOCK high for a few uS (use 5 uS here)  
  // Set DATA to ZERO and pulse LOAD for a few uS (use 5 uS here)  
  // data sheet diagrams show only RESET and CLOCK being used to reset the device, but I see no output unless I also  
  // toggle the LOAD line here.  
  digitalWrite(CLOCK, LOW);  
  digitalWrite(LOAD, LOW);  
  digitalWrite(RESET, LOW);  
  delay(5);  
  digitalWrite(RESET, HIGH); //pulse RESET  
  delay(5);  
  digitalWrite(RESET, LOW);  
  delay(5);  
  digitalWrite(CLOCK, LOW);  
  delay(5);  
  digitalWrite(CLOCK, HIGH); //pulse CLOCK  
  delay(5);  
  digitalWrite(CLOCK, LOW);  
  delay(5);  
  digitalWrite(DATA, LOW);  //make sure DATA pin is LOW  
  digitalWrite(LOAD, LOW);  
  delay(5);  
  digitalWrite(LOAD, HIGH); //pulse LOAD  
  delay(5);  
  digitalWrite(LOAD, LOW);  
  // Chip is RESET now  
 }  

To sump up, It has been a great work to reduce the side of the device. The new set up may also promise a space for the 9V battery to sit on top of the Arduino and next to the AD9850.

No comments:

Post a Comment