回答

收藏

[评测分享] [Wio Terminal开发板测评]+音频信号采集测试

#板卡评测 #板卡评测 2780 人阅读 | 0 人回复 | 2021-08-02

本帖最后由 jinglixixi 于 2021-8-2 19:48 编辑

Wio终端,配有麦克风及音频信号采集电路,其工作原理图见图1所示。

1 电路原理图
本次测试有2个目标,即音频信号采集和数据曲线显示。
1.音频信号采集
要进行音频信号采集的只需正确指导信号采集的引脚即可,因为所采集的信号为模拟信号,故需使用函数analogRead(),其次就是使用串行通讯将采集的数据显示出来,其程序及上传结果如图2所示。

2 程序及上传
在上传后,通过串口监视器可观察到图3所示的结果,若打开串口监视器,则可观察到图4所示的波形。

3 采集数据

4 数据波形

2.屏幕显示波形
Wio终端,不但能采集音频信号,还可借助其液晶屏的强大显示性能来显示数据波形,其效果如图5所示。
在使用其波形显示功能前,应安装LCD 库和Linechart库以获得支持。
5波形显示

其波形显示程序为:
  1. #include"seeed_line_chart.h"   //include the library
  2. #include <math.h>
  3. TFT_eSPI tft;
  4. #define max_size 50 //maximum size of data
  5. doubles data; //Initilising a doubles type to store data
  6. TFT_eSprite spr = TFT_eSprite(&tft); // Sprite
  7. void setup() {
  8. pinMode(WIO_MIC, INPUT);
  9. tft.begin();
  10. tft.setRotation(3);
  11. spr.createSprite(TFT_HEIGHT,TFT_WIDTH);
  12. }

  13. void loop() {
  14. spr.fillSprite(TFT_DARKGREY);
  15. int val = analogRead(WIO_MIC);
  16. if (data.size() == max_size) {
  17. data.pop();//this is used to remove the first read variable
  18. }
  19. data.push(val); //read variables and store in data
  20. //Settings for the line graph title
  21. auto header = text(0, 0)
  22. .value("Microphone Reading")
  23. .align(center)
  24. .color(TFT_WHITE)
  25. .valign(vcenter)
  26. .width(tft.width())
  27. .thickness(2);
  28. header.height(header.font_height() * 2);
  29. header.draw(); //Header height is the twice the height of the font
  30. //Settings for the line graph
  31. auto content = line_chart(20, header.height()); //(x,y) where the line graph begins
  32. content
  33. .height(tft.height() - header.height() * 1.5) //actual height of the line chart
  34. .width(tft.width() - content.x() * 2) //actual width of the line chart
  35. .based_on(0.0) //Starting point of y-axis, must be a float
  36. .show_circle(true) //drawing a cirle at each point, default is on.
  37. .y_role_color(TFT_WHITE)
  38. .x_role_color(TFT_WHITE)
  39. .value(data) //passing through the data to line graph
  40. .color(TFT_RED) //Setting the color for the line
  41. .draw();
  42. spr.pushSprite(0, 0);
  43. delay(50);
  44. }
复制代码


此外,在进行其他的A/D转换时,我们也可将程序中的采集对象修改为自己的引脚并借助该程序来实现数据曲线的绘制。

分享到:
回复

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /3 下一条