Categories
Statistics
Flag Counter
Since 08.08.2014
Counts only, if "DNT = disabled".

Your IP is 54.167.135.61
ec2-54-167-135-61.compute-1.
Info
Valid HTML 4.01 Transitional Creative Commons Lizenzvertrag
rss
เราจะทำแบบวิศวกรผู้ยิ่งใหญ่
We love the King
Your valuable opinion :
4 stars

Avg. 4.29 from 7 votes.



AD9833-MicroWaveformGenerator.php   14790 Bytes    16-05-2016 17:36:28


AD9833 Micro Waveform Generator


Probably the smallest DIY USB Waveform Generator



➤ Just in case Big G mixed up Microwave Generator and Micro Waveform Generator, please accept our apologies. You mayst find the RF-2849 (soon) much more interesting ...


AD9833 Micro Waveform Generator







✈ Motivation




This (micro) board was designed to test those AD9833 Programmeable Waveform Generator IC's. Especially to see when and how the triangle/square waves are starting to degrade. It can be seen, that the waveform looks nice from 1 Hz to 800 kHz (and then it starts slowly to degrade). When using squarewave, it is advantageous to use the DAC data MSB/2 and program twice the frequency value. Duty cycle is more symmetric.

As there was a lot of space left, we also packed an 8 Bit I2C DAC (MAX5381) and a CMOS switch (ADG779BKSZ) on the board. This mayst be used as a low frequency arbitrary waveform generator. (Update rate in the kHz range). To keep the form-factor small, 0603 components have been used. As their number is manageable, this might as well serve as a soldering exercise. (for advanced students :-) In case you also want to squeeze that in a SucoBox, it is advantageous to remove the reset button as well as the ISP header.




✈ Controlling that thing




This Micro Waveform Generator is fully controlled (and powered) via USB. And as the name suggests, you need an Arduino/Genuino Micro to handle those programming things. When connected to a pc, a small menue will show up on the serial monitor.


AD9833 Micro Waveform Generator




✈ The Sketch for Arduino Micro



Double click on code to select ...

/*
 *    ARDUINO TESTCODE FOR AD9833 Micro Waveform Generator
 *    http://www.changpuak.ch/electronics/AD9833-MicroWaveformGenerator.php
 *    Software Version 1.0, 
 *    25.04.2016, Alexander C. Frank
 */
 
#include "Wire.h"       
#define MAX5381 0x64     
// Suffix "L" : 0x60
// Suffix "M" : 0x62
// Suffix "N" : 0x64
// Suffix "P" : 0x66
#include "TimerOne.h"
int TimerUpdateRate = 1000;

const int SOURCE = A5;        // ARBITRARY = 1 OR AD9833 = 0
const int FSYNC = 6;        
const int SDATA = 7;       
const int SCLK = 8;   

const float CRYSTAL = 24000000.0 ;
const int SINE = 0x2000;                    
const int SQUARE = 0x2020;                   
const int TRIANGLE = 0x2002; 
unsigned long FREQ = 1000;   

char Command ;                 
byte byteRead ;


// ///////////////////////////////////////////////////////////// 
//! Updates the DDS registers
// ///////////////////////////////////////////////////////////// 
void UpdateDDS(unsigned int data){
  unsigned int pointer = 0x8000;
  // Serial.print(data,HEX);Serial.print(" ");
  digitalWrite(FSYNC, LOW);     // AND NOW : WAIT 5 ns
  for (int i=0; i<16; i++){
   if ((data & pointer) > 0) { digitalWrite(SDATA, HIGH); }
      else { digitalWrite(SDATA, LOW); }
    digitalWrite(SCLK, LOW);
    digitalWrite(SCLK, HIGH);
    pointer = pointer >> 1 ;
  }
  digitalWrite(FSYNC, HIGH);
}

// ///////////////////////////////////////////////////////////// 
//! Updates the Freq registers
// ///////////////////////////////////////////////////////////// 
void UpdateFreq(long FREQ, int WAVE){
  
  long FTW = (FREQ * pow(2, 28)) / CRYSTAL;
  if (WAVE == SQUARE) FTW = FTW << 1;
  unsigned int MSB = (int)((FTW & 0xFFFC000) >> 14);    
  unsigned int LSB = (int)(FTW & 0x3FFF);
  LSB |= 0x4000;
  MSB |= 0x4000; 
  UpdateDDS(0x2100);   
  UpdateDDS(LSB);                   
  UpdateDDS(MSB);                   
  UpdateDDS(0xC000);                
  UpdateDDS(WAVE);
  
}

// ///////////////////////////////////////////////////////////// 
//! Reads User Input from Serial
// ///////////////////////////////////////////////////////////// 
void ReadUserInput()
{
  boolean ende = false ;
  FREQ = 0;
  while ( ( Serial.available() ) || ( ende == false ) ) 
      {
      byteRead = Serial.read();
      if ( byteRead == 10 ){ ende = true ; }
      if (( byteRead > 64 ) & (byteRead < 91)) { 
        Command = byteRead ; }                      // A..Z
      if (( byteRead > 47 ) & (byteRead < 58)) { 
        FREQ = FREQ * 10;
        FREQ = FREQ + byteRead - 48 ; }             // 0..9
      }
}


// ///////////////////////////////////////////////////////////// 

void setup() {
  pinMode(SOURCE, OUTPUT);
  pinMode(FSYNC, OUTPUT);
  pinMode(SDATA, OUTPUT);
  pinMode(SCLK, OUTPUT);
  digitalWrite(SOURCE, LOW);
  digitalWrite(FSYNC, HIGH);
  digitalWrite(SDATA, LOW);
  digitalWrite(SCLK, HIGH);
  
  Wire.begin();
  Serial.begin(9600);
  // Micro Hack fails ....
  // while (!Serial) { delay(10); // wait for serial port to connect. }
  delay(6999);
  Serial.println("AD9833 Micro Waveform Generator V1.0");
  Serial.println("-------------------------------------------------------");
  Serial.println("COMMAND  : [WAVEFORM]+[FREQUENCY IN HERTZ]");
  Serial.println("WAVEFORM : S-SINE, T-TRIANGLE, R-RECTANGLE, A-ARBITRARY");
  Serial.println("E.G:: S1000 OUTPUTS A SINE AT 1000 Hz");
  Serial.println("-------------------------------------------------------");
  // INIT DDS, AS DESCRIBED IN AN-1070, "Programming the AD9833/AD9834"
  // BY LIAM RIORDAN (ANALOG DEVICES)
  UpdateDDS(0x2100);                                    
  UpdateDDS(0x50C7);                                    
  UpdateDDS(0x4000);                                    
  UpdateDDS(0xC000);                                    
  UpdateDDS(0x2000); 
  // SWITCH TO SOURCE = DDS 
  digitalWrite(SOURCE, LOW);
  // NOW THERE SHOULD BE A 
  // 384 Hz SIGNAL AT THE OUTPUT                               
  delay(999);
}

void loop() {

    ReadUserInput();
    
    switch (Command)
    {

      case 82 :
        // THAT WAS AN "R" FOR "DAC data MSB"  
        Serial.print("\nRECTANGLE, FREQ = ");
        Serial.print(FREQ,DEC);Serial.println(" Hz");
        UpdateFreq(FREQ, SQUARE);
        digitalWrite(SOURCE, LOW);
        Serial.println("\nO.K.");
        break;

      case 83 :
        // THAT WAS AN "S" FOR "Sinusoid"   
        Serial.print("\nSINE, FREQ = ");
        Serial.print(FREQ,DEC);Serial.println(" Hz");
        UpdateFreq(FREQ, SINE);
        digitalWrite(SOURCE, LOW);
        Serial.println("\nO.K.");
        break;

      case 84 :
        // THAT WAS AN "T" FOR "Triangle" 
        Serial.print("\nTRIANGLE, FREQ = ");
        Serial.print(FREQ,DEC);Serial.println(" Hz");
        UpdateFreq(FREQ, TRIANGLE);
        digitalWrite(SOURCE, LOW);
        Serial.println("\nO.K.");
        break;

      default:
        Serial.println("\nUnknown Command.");
        Serial.println("Try again :-)");
        delay(100);
        break;
    } 
}

// ///////////////////////////////////////////////////////////// 
// END OF FILE.
// ///////////////////////////////////////////////////////////// 




✈ Downloads








✈ Garbage on the USB supply • The Capacitance Multiplier




Using a digital supply to power analog circuit is somehow challenging. Putting a veeeery large capacitor there mostly solves any issues - but the formfactor of the capacitor was slightly larger than the box. We therefore remembered this capacitance multiplier thing, which finally did its job very well. The circuit below explains how it works ...
Capacitance Multiplier

As the capcitance C7 is seen by the load to be of the value 100 µF * β we have chosen a transistor with as much β as possible. The value of C7 was the largest available in size 1206. Ideally R9 is as large as possible, but that will lower the output voltage. R9 = 1 kΩ is a good compromise to have approx 4.3 V at the load with a still useful smoothing.




✈ Share your thoughts


✈ Nothing more to be seen below this point ? Maybe your browser blocks the facebook iframe.
The webmaster does not read the comments regularly. Urgent questions should be send via email.








 
t1 = 3910 d

t2 = 579 ms

★ ★ ★  Copyright © 2006 - 2017 by changpuak.ch  ★ ★ ★

PRchecker.info Impressum