简易信号采集系统,文件现象和源程序如下。
单片机源程序如下:- #include "bsp_systick.h"
- #include "OLED_I2C.h"
- #include "bsp_i2c_gpio.h"
- #include "bsp_adc.h"
- #include "bsp_advanced_timer.h"
- #include <math.h>
- #include "pingmu.h"
- #include "PWM.h"
- #include "IC.h"
- #define pi 3.1415926535
- #define accur 0.015295
- extern uint16_t ConvData;
- extern unsigned char BMP1[];
- uint16_t ADValue;
- float Voltage;
- float max=0;
- float min=3.30;
- int main()
- {
- PWM_Init();
- OLED2_Init();
- ADCx_Init();
- IC_Init();
- OLED2_ShowString(1, 1, "ADValue:");
- OLED2_ShowString(2, 1, "max:0.00V");
- OLED2_ShowString(3, 1, "min:0.00V");
- OLED2_ShowString(4, 1, "Freq:0000000Hz");
- uint8_t x;
- OLED_Init();
- ADCx_Init();
- AdvancedTim_Init();
- Before_State_Update(accur*ConvData);
- OLED_CLS();
- while(1)
- {
-
-
- for(x=0;x<128;x=(x+1)%128)
- {
-
-
- ADValue = AD_GetValue();
- Voltage = (float)ADValue / 4095 * 3.3/0.360;
- OLED2_ShowNum(1, 9, ADValue, 4);
- if(max<Voltage )
- {
- max=Voltage ;
- }
- OLED2_ShowNum(2, 5, max , 1);
- OLED2_ShowNum(2,7, (uint16_t)(max * 100) % 100, 2);
- if(min >Voltage )
- {
- min=Voltage ;
- }
- OLED2_ShowNum(3, 5, min , 1);
- OLED2_ShowNum(3,7, (uint16_t)(min * 100) % 100, 2);
- OLED_DrawWave(x,accur*ConvData);
- OLED2_ShowNum(4, 6, IC_GetFreq(), 7);
- }
-
- }
- }
复制代码 原理图:无
仿真:无
Keil代码下载:
Keil代码.7z
(194.19 KB, 下载次数: 39)
|