|
視頻https://www.bilibili.com/video/BV1tt4y1C7Yb
單片機(jī)源程序如下:- /**********************************************************************************/
- #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循環(huán)中使用的變量
- 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的計(jì)數(shù)頻率,計(jì)數(shù)到5000為500ms;;10000為1000ms = 1S;定時(shí)時(shí)間:Tout= ((arr+1)*(psc+1))/Tclk;(250MS)
- IWDG_Init(4,1875); //設(shè)置分頻數(shù)為4*2^(4)=64,重載值為625,溢出時(shí)間為1s;;1875時(shí)為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;
- }
- /************************************************************************************/
- }
- /************************************************************************************/
復(fù)制代碼
代碼下載:
CeShiChengXu.7z
(186.09 KB, 下載次數(shù): 34)
2020-8-10 17:28 上傳
點(diǎn)擊文件名下載附件
|
評(píng)分
-
查看全部評(píng)分
|