Arduino + ESP32-C3 + TFT(1.8‘ ST7735S)基础平台(实验六)手机控制 DDS AD9851 (70MHz 正弦波 方波 )

发布于:2022-12-31 ⋅ 阅读:(520) ⋅ 点赞:(0)

----------------------------------------------------------------------------------------------------------------------------

https://blog.csdn.net/jiangge12/article/details/123971499 基础平台
https://blog.csdn.net/jiangge12/article/details/123978932 基础平台(实验一)
https://blog.csdn.net/jiangge12/article/details/124713438 基础平台(实验二)玩具示波器
https://blog.csdn.net/jiangge12/article/details/126218280 基础平台(实验三)折腾 TFT_eSPI 库
https://blog.csdn.net/jiangge12/article/details/126277548 基础平台(实验四)直接显示网络图片
https://blog.csdn.net/jiangge12/article/details/126338835 基础平台(实验五)温湿度
https://blog.csdn.net/jiangge12/article/details/126572573 基础平台(实验六)手机控制 AD9851
https://blog.csdn.net/jiangge12/article/details/127134354 基础平台(实验七)温湿度动态图表

----------------------------------------------------------------------------------------------------------------------------

号称正弦波 70MHz,其实呢。。。实测正弦波 0-20M较好,20-30M勉强,30-70M比较玄幻。

方波 1MHz 倒是有的,甚至10M也能出波形,只是惨些。

正弦波 方波 切换靠模块的两对物理引脚提供,所以只剩下一个参数 “频率值” 可以设定,网页控制比较简单。

手机控制 波形发生器 AD9851-其他-高清完整正版视频在线观看-优酷 (youku.com)https://v.youku.com/v_show/id_XNTkwMDAxMTE5Ng==.html


 

----------------------------------------------------------------------------------------------------------------------

下面是基础测试,把以下两个文件都放 AD9851 目录里,写入UNO即可:

1。    AD9851.ino

const int WCLK = 10;  // UNO接线
const int FQUP = 9;
const int REST = 8;
const int DATA = 7;

# include "AD9851.h"

String Input_Command;
unsigned long Input_Frequency = 0;   // 取值范围 0-4294967295 (2^32-1)

void setup() {
    pinMode(WCLK, OUTPUT);
    pinMode(FQUP, OUTPUT);
    pinMode(REST, OUTPUT);
    pinMode(DATA, OUTPUT);
    Serial.begin(115200);
    AD9851_First_Load();
}

void loop() {
}

2。      AD9851.h

void AD9851_Reset_Serial_Model()  
{
  Serial.print("Reseting AD9851 to Serial Model...");
  digitalWrite(WCLK, LOW);
  digitalWrite(FQUP, LOW);
  //restSignal
  digitalWrite(REST, LOW);
  digitalWrite(REST, HIGH);
  digitalWrite(REST, LOW);
  //wclkSignal
  digitalWrite(WCLK, LOW);
  digitalWrite(WCLK, HIGH);
  digitalWrite(WCLK, LOW);
  //fqupSignal
  digitalWrite(FQUP, LOW);
  digitalWrite(FQUP, HIGH);
  digitalWrite(FQUP, LOW); 
  Serial.println("done!");
}

void DataJudge(unsigned char w)
{
  if (w == 1) digitalWrite(DATA, HIGH);
  else if (w == 0) digitalWrite(DATA, LOW);
}

void Write_Frequency_To_AD9851_Via_SPI(unsigned char w0, double frequence)
{
  unsigned char i, w;
  long int y;
  double x;    //计算频率的HEX值
  x = 4294967295 / 180; //适合180M晶振/180为最终时钟频率(或30M六倍频)  //如果时钟频率不为180MHZ,修改该处的频率值,单位MHz  !!!
  frequence = frequence / 1000000;
  frequence = frequence * x;
  //Serial.print("Frequency in HEX:"); Serial.println(frequence); // 折算后的频率值,熟悉后可不要这句
  
  y = frequence;
  //写w4数据
  w = (y >>= 0);
  for (i = 0; i < 8; i++)
  {
    DataJudge((w>> i) & 0x01);
    digitalWrite(WCLK, HIGH);
    digitalWrite(WCLK, LOW);
  }
  //写w3数据
  w = (y >> 8);
  for (i = 0; i < 8; i++)
  {
    DataJudge((w>> i) & 0x01);
    digitalWrite(WCLK, HIGH);
    digitalWrite(WCLK, LOW);
  }
  //写w2数据
  w = (y >> 16);
  for (i = 0; i < 8; i++)
  {
    DataJudge((w>> i) & 0x01);
    digitalWrite(WCLK, HIGH);
    digitalWrite(WCLK, LOW);
  }
  //写w1数据
  w = (y >> 24);
  for (i = 0; i < 8; i++)
  {
    DataJudge((w>> i) & 0x01);
    digitalWrite(WCLK, HIGH);
    digitalWrite(WCLK, LOW);
  }
  //写w0数据
  w = w0;
  for (i = 0; i < 8; i++)
  {
    DataJudge((w>> i) & 0x01);
    digitalWrite(WCLK, HIGH);
    digitalWrite(WCLK, LOW);
  }
  //移入始能
  digitalWrite(FQUP, HIGH);
  digitalWrite(FQUP, LOW);
}

void AD9851_First_Load()
{
  AD9851_Reset_Serial_Model();
  Write_Frequency_To_AD9851_Via_SPI(0x01, 1000);
  Serial.println("Set AD9851 Frequency = 1 kHz by default.");
}

-------------------------------------------------------------------------------------------------------------

进入高频信号的世界,需要正确选择器材。简单说至少需要100M示波器和100M探头才能较好的反映模块的真实波形,杜邦线也就1M以下玩玩。

扩展资料

1、高频(HF)3 MHz~30 MHz,对应电磁波的波长为短波100 m~10 m。

2、甚高频(VHF)30 MHz~300 MHz,对应电磁波的波长为米波10 m~1 m。

甚高频多数是用作电台及电视台广播,同时又是航空和航海的沟通频道。

VHF主要是作较短途的传送,和高频(HF)不同的是,电离层通常不会反射VHF的信号,而且甚高频常常会受环境因素(如:地形)影响其信号。

本文含有隐藏内容,请 开通VIP 后查看

网站公告

今日签到

点亮在社区的每一天
去签到