|
stm32数字示波器 带ESP8266wifi 参数传到手机APP,使用内部ADC 进行采样,DMA模式,TFT彩屏显示。
信号产生程序 用于下载到另外一块普中STM32开发板上通过PC1口产生一个脉冲信号,然后在另外一块普中STM32开发板下载简易示波器程序,将一根导线将装有信号发生器程序的板子PC1口接到装有示波器程序的PA2口上进行检测,一般通过按键调节,将频率值调节到1000000us/div,电压调节到500mv/div
程序仅供参考,如有问题可参考实验例程内的一些基础程序理解
附件中有简易示波器stm32源程序和信号产生程序
部分单片机代码预览如下:
- #include "sys.h"
- #include "delay.h"
- #include "usart.h"
- #include "led.h"
- #include "button.h"
- #include "lcd_driver.h"
- #include "gui.h"
- #include "tim.h"
- #include "stm32f10x_it.h"
- #include "systeminit.h"
- #include "adc.h"
- #include "displaycanshu.h"
- #include "system.h"
- #include "SysTick.h"
- #include "esp8266_drive.h"
- #include "sta_tcpclent_test.h"
- u16 b = 0;
- float temp;
- float temp1;
- u8 res;
- char str[100]={0};
- u8 Vmax_alarm[5];
- int main(void)
- {
- u8 i;
- delay_init();
- rcc_init(); //外设时钟配置
- led_init();
- TFT_Init();
- TFT_ClearScreen(BLACK);
- nvic_init(); // 中断优先级配置
- gpio_init(); //外设io口配置
- set_io0();
- key_init();
-
- ADC1_Init(); //adc配置
- set_background(); //初始化背景
-
- time_init(); //定时器配置,测频率用的二个定时器
- time_enable(); //同步开始计数
- ADC_Get_Value();
- vpp = ADC_Get_Vpp();
-
- Systick_Init(72);
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
- USART1_Init(115200);
- printf("普中科技ESP8266 WIFI模块STA TCPClent透传测试\r\n");
- ESP8266_Init(115200);
- ESP8266_STA_TCPClient_Test();
-
- while ( 1 )
- {
- if(Vmax>=3000)
- { Vmax_alarm[0]='A';
- Vmax_alarm[1]='l';
- Vmax_alarm[2]='a';
- Vmax_alarm[3]='r';
- Vmax_alarm[4]='m';}
- else
- { Vmax_alarm[0]='I';
- Vmax_alarm[1]='s';
- Vmax_alarm[2]=' ';
- Vmax_alarm[3]='O';
- Vmax_alarm[4]='k';}
- sprintf(str,"\r\nfrequency=%dHz\r\n Vmax=%dmV\r\n vpp=%dmV\r\n",frequency,Vmax,vpp);
- ESP8266_SendString ( ENABLE, str, 0, Single_ID_0 );//向手机WIFI发送信号的频率
- ESP8266_SendString ( ENABLE, Vmax_alarm, 0, Single_ID_0 );
-
- /*********************绘制电压曲线************************************/
- //gpio_init();
- for(b=index;b<index+250;b++)
- {
- temp = a[b] * 3300 / 4096 * 25 /vcc_div;
- temp1 = a[b + 1] * 3300 / 4096 * 25 / vcc_div;
- clear_point(b-index);
- if(temp>200) {temp=200;}
- if(temp<0) {temp=0;}
- if(temp1>200){temp1=200;}
- if(temp1<0) {temp1=0;}
-
- lcd_huadian(b-index,temp,POINT_COLOR);
- lcd_huaxian(b-index,temp,b-index+1,temp1,POINT_COLOR);
- hua_wang();
- }
-
- displaycanshu();
-
-
- ADC_Get_Value();
- vpp = ADC_Get_Vpp();//当中包括了最大值的获取
-
- if(TcpClosedFlag) //检测是否失去连接
- {
- ESP8266_ExitUnvarnishSend(); //退出透传模式
- do
- {
- res = ESP8266_Get_LinkStatus(); //获取连接状态
- }
- while(!res);
-
- if(res == 4) //确认失去连接后重连
- {
- printf ( "\r\n请稍等,正在重连热点和服务器...\r\n" );
-
- while (!ESP8266_JoinAP(User_ESP8266_SSID, User_ESP8266_PWD ) );
-
- while (!ESP8266_Link_Server(enumTCP, User_ESP8266_TCPServer_IP, User_ESP8266_TCPServer_PORT, Single_ID_0 ) );
-
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
完整的源码资料51hei提供下载:
简易示波器应用(黑底加WIFI).7z
(9.65 MB, 下载次数: 211)
|
评分
-
查看全部评分
|