标题:
STM32单片机16路ADC采集通道,AD值3种处理方式效果对比
[打印本页]
作者:
骑着小猪去旅游
时间:
2020-8-10 14:48
标题:
STM32单片机16路ADC采集通道,AD值3种处理方式效果对比
视频
https://www.bilibili.com/video/BV1tt4y1C7Yb
单片机源程序如下:
/**********************************************************************************/
#include "stm32f10x.h"//SystemInit()
#include "main.h"
#include "adc.h"
#include "sys.h"
#include "delay.h"
#include "wdg.h"
#include "time2.h"
#include "adc.h"
/************************************************************************************/
uint8_t i=0;
double ii=0;
uint8_t xunhuan_for=0; //FOR循环中使用的变量
double ADC_Zhi0=0;
double DianYa0=0;
double ADC_Zhi1=0;
double DianYa1=0;
double ADC_Zhi2=0;
double DianYa2=0;
double ADC_Zhi3=0;
double DianYa3=0;
double ADC_Zhi4=0;
double DianYa4=0;
double ADC_Zhi5=0;
double DianYa5=0;
double ADC_Zhi6=0;
double DianYa6=0;
double ADC_Zhi7=0;
double DianYa7=0;
double ADC_Zhi8=0;
double DianYa8=0;
double ADC_Zhi9=0;
double DianYa9=0;
double ADC_Zhi10=0;
double DianYa10=0;
double ADC_Zhi11=0;
double DianYa11=0;
double ADC_Zhi12=0;
double DianYa12=0;
double ADC_Zhi13=0;
double DianYa13=0;
double ADC_Zhi14=0;
double DianYa14=0;
double ADC_Zhi15=0;
double DianYa15=0;
/************************************************************************************/
/************************************************************************************/
int main(void)
{
YinJiao_init();
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
delay_init();
Adc_Init();
TIM2_Init(9999,7199);//10Khz的计数频率,计数到5000为500ms;;10000为1000ms = 1S;定时时间:Tout= ((arr+1)*(psc+1))/Tclk;(250MS)
IWDG_Init(4,1875); //设置分频数为4*2^(4)=64,重载值为625,溢出时间为1s;;1875时为3S
/************************************************************************************/
while(1)
{
// ADC_Zhi0=Get_Adc(0);//通道0
// DianYa0=ADC_Zhi0*2.5/4096;
//
// ADC_Zhi1=Get_Adc(1);//通道1
// DianYa1=ADC_Zhi1*2.5/4096;
//
// ADC_Zhi2=Get_Adc(2);//通道2
// DianYa2=ADC_Zhi2*2.5/4096;
//
// ADC_Zhi3=Get_Adc(3);//通道3
// DianYa3=ADC_Zhi3*2.5/4096;
//
// ADC_Zhi4=Get_Adc(4);//通道4
// DianYa4=ADC_Zhi4*2.5/4096;
//
// ADC_Zhi5=Get_Adc(5);//通道5
// DianYa5=ADC_Zhi5*2.5/4096;
//
// ADC_Zhi6=Get_Adc(6);//通道6
// DianYa6=ADC_Zhi6*2.5/4096;
//
// ADC_Zhi7=Get_Adc(7);//通道7
// DianYa7=ADC_Zhi7*2.5/4096;
//
// ADC_Zhi8=Get_Adc(8);//通道8
// DianYa8=ADC_Zhi8*2.5/4096;
//
// ADC_Zhi9=Get_Adc(9);//通道9
// DianYa9=ADC_Zhi9*2.5/4096;
//
// ADC_Zhi10=Get_Adc(10);//通道10
// DianYa10=ADC_Zhi10*2.5/4096;
//
// ADC_Zhi11=Get_Adc(11);//通道11
// DianYa11=ADC_Zhi11*2.5/4096;
//
// ADC_Zhi12=Get_Adc(12);//通道12
// DianYa12=ADC_Zhi12*2.5/4096;
//
// ADC_Zhi13=Get_Adc(13);//通道13
// DianYa13=ADC_Zhi13*2.5/4096;
//
// ADC_Zhi14=Get_Adc(14);//通道14
// DianYa14=ADC_Zhi14*2.5/4096;
//
// ADC_Zhi15=Get_Adc(15);//通道15
// DianYa15=ADC_Zhi15*2.5/4096;
/************************************************************************************/
/************************************************************************************/
// ADC_Zhi0=Get_Adc10_Average(0,60);//通道0
// DianYa0=ADC_Zhi0*2.5/4096;
//
// ADC_Zhi1=Get_Adc10_Average(1,60);//通道1
// DianYa1=ADC_Zhi1*2.5/4096;
//
// ADC_Zhi2=Get_Adc10_Average(2,60);//通道2
// DianYa2=ADC_Zhi2*2.5/4096;
//
// ADC_Zhi3=Get_Adc10_Average(3,60);//通道3
// DianYa3=ADC_Zhi3*2.5/4096;
//
// ADC_Zhi4=Get_Adc10_Average(4,60);//通道4
// DianYa4=ADC_Zhi4*2.5/4096;
//
// ADC_Zhi5=Get_Adc10_Average(5,60);//通道5
// DianYa5=ADC_Zhi5*2.5/4096;
//
// ADC_Zhi6=Get_Adc10_Average(6,60);//通道6
// DianYa6=ADC_Zhi6*2.5/4096;
//
// ADC_Zhi7=Get_Adc10_Average(7,60);//通道7
// DianYa7=ADC_Zhi7*2.5/4096;
//
// ADC_Zhi8=Get_Adc10_Average(8,60);//通道8
// DianYa8=ADC_Zhi8*2.5/4096;
//
// ADC_Zhi9=Get_Adc10_Average(9,60);//通道9
// DianYa9=ADC_Zhi9*2.5/4096;
//
// ADC_Zhi10=Get_Adc10_Average(10,60);//通道10
// DianYa10=ADC_Zhi10*2.5/4096;
//
// ADC_Zhi11=Get_Adc10_Average(11,60);//通道11
// DianYa11=ADC_Zhi11*2.5/4096;
//
// ADC_Zhi12=Get_Adc10_Average(12,60);//通道12
// DianYa12=ADC_Zhi12*2.5/4096;
//
// ADC_Zhi13=Get_Adc10_Average(13,60);//通道13
// DianYa13=ADC_Zhi13*2.5/4096;
//
// ADC_Zhi14=Get_Adc10_Average(14,60);//通道14
// DianYa14=ADC_Zhi14*2.5/4096;
//
// ADC_Zhi15=Get_Adc10_Average(15,60);//通道15
// DianYa15=ADC_Zhi15*2.5/4096;
/************************************************************************************/
/************************************************************************************/
ADC_Zhi0=Get_Adc_Average(0,61);//通道0
DianYa0=ADC_Zhi0*2.5/4096;
ADC_Zhi1=Get_Adc_Average(1,61);//通道1
DianYa1=ADC_Zhi1*2.5/4096;
ADC_Zhi2=Get_Adc_Average(2,61);//通道2
DianYa2=ADC_Zhi2*2.5/4096;
ADC_Zhi3=Get_Adc_Average(3,61);//通道3
DianYa3=ADC_Zhi3*2.5/4096;
ADC_Zhi4=Get_Adc_Average(4,61);//通道4
DianYa4=ADC_Zhi4*2.5/4096;
ADC_Zhi5=Get_Adc_Average(5,61);//通道5
DianYa5=ADC_Zhi5*2.5/4096;
ADC_Zhi6=Get_Adc_Average(6,61);//通道6
DianYa6=ADC_Zhi6*2.5/4096;
ADC_Zhi7=Get_Adc_Average(7,61);//通道7
DianYa7=ADC_Zhi7*2.5/4096;
///////////////////////////////////////////////////
ADC_Zhi8=Get_Adc_Average(8,61);//通道8
DianYa8=ADC_Zhi8*2.5/4096;
ADC_Zhi9=Get_Adc_Average(9,61);//通道9
DianYa9=ADC_Zhi9*2.5/4096;
ADC_Zhi10=Get_Adc_Average(10,61);//通道10
DianYa10=ADC_Zhi10*2.5/4096;
ADC_Zhi11=Get_Adc_Average(11,61);//通道11
DianYa11=ADC_Zhi11*2.5/4096;
ADC_Zhi12=Get_Adc_Average(12,61);//通道12
DianYa12=ADC_Zhi12*2.5/4096;
ADC_Zhi13=Get_Adc_Average(13,61);//通道13
DianYa13=ADC_Zhi13*2.5/4096;
ADC_Zhi14=Get_Adc_Average(14,61);//通道14
DianYa14=ADC_Zhi14*2.5/4096;
ADC_Zhi15=Get_Adc_Average(15,61);//通道15
DianYa15=ADC_Zhi15*2.5/4096;
}
/************************************************************************************/
}
/************************************************************************************/
复制代码
代码下载:
CeShiChengXu.7z
(186.09 KB, 下载次数: 34)
2020-8-10 17:28 上传
点击文件名下载附件
下载积分: 黑币 -5
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1