AD9833 Waveform Generator
This module is a programmable waveform generator capable of generating sine, triangle, and square wave outputs. Waveform generators are essential for various applications such as testing, signal excitation, and Time Domain Reflectometry (TDR). The output frequency and phase can be programmed through software, making adjustments simple and requiring no external components. The frequency register is 28 bits: with a clock rate of 25 MHz, it can achieve a resolution of 0.1 Hz, and with a clock rate of 1 MHz, it can achieve a resolution of 0.004 Hz.
Module Source
Purchase Link:
https://item.taobao.com/item.htm?spm=a1z10.3-c-s.w4002-24156567531.9.1b2460d4xUH1Am&id=560010764422
Baidu Netdisk Download Link:
https://pan.baidu.com/s/1JZ0ga4uTyXUq5u-Or9BVlg?pwd=GOOD
Password: GOOD
Specifications
Operating Voltage: 2.3V to 5.5V power supply
Operating Current: 12.65 mW (at 3V)
Communication Interface: 3-wire SPI interface
Chip Pin Count: 10-pin MSOP package
Hardware Connection
AD9833 pin -> development board pin
VCC -> 5V
GND -> GND
SDATA -> 11
SCK -> 13
FSYNC -> 10
2
3
4
5
6
Usage Method
Install Library
In the Library Manager, search for "AD9833", find "MD_AD9833" and install it.
Enter the code:
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 11, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
#include <MD_AD9833.h>
#include <SPI.h>
// 与AD9833的SPI通信引脚
const uint8_t PIN_DATA = 11; ///< SPI Data pin number
const uint8_t PIN_CLK = 13; ///< SPI Clock pin number
const uint8_t PIN_FSYNC = 10; ///< SPI Load pin number (FSYNC in AD9833 usage)
MD_AD9833 AD(PIN_FSYNC); // Hardware SPI
// MD_AD9833 AD(PIN_DATA, PIN_CLK, PIN_FSYNC); // 任意SPI引脚设置
void setup(void)
{
AD.begin();
}
void loop(void)
{
static uint8_t m = 0;
static MD_AD9833::mode_t modes[] =
{
MD_AD9833::MODE_TRIANGLE,
MD_AD9833::MODE_SQUARE2,
MD_AD9833::MODE_SINE,
MD_AD9833::MODE_SQUARE1
};
AD.setMode(modes[]);
delay(500);
AD.setFrequency(MD_AD9833::CHAN_0, 2000);
m++;
if (m >= 4 ) m = 0;
delay(10000);
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Usage Testing
The module outputs a different type of 2KHz waveform every 5 seconds.