自己写的一些关于NTC MF52程序源码,详细请见附件
单片机源程序如下:
- #include "led.h"
- #include "delay.h"
- #include "key.h"
- #include "sys.h"
- #include "lcd.h"
- #include "usart.h"
- #include "adc.h"
- #include "math.h"
- const float Rp=10.0; //10K
- const float T2 = (273.15+25.0);;//T2
- const float Bx = 3435.0;//B
- const float Ka = 273.15;
-
- int main(void)
- {
- u16 adcx;
- float Vx;
- float resistence;
- float Tem;
- delay_init(); //延时函数初始化
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置中断优先级分组为组2:2位抢占优先级,2位响应优先级
- uart_init(115200); //串口初始化为115200
- //LED_Init(); //LED端口初始化
- //LCD_Init();
- Adc_Init(); //ADC初始化
- //POINT_COLOR=RED;//设置字体为红色
- //LCD_ShowString(60,50,200,16,16,"WarShip STM32");
- //LCD_ShowString(60,70,200,16,16,"ADC TEST");
- //LCD_ShowString(60,90,200,16,16,"ATOM@ALIENTEK");
- //LCD_ShowString(60,110,200,16,16,"2015/1/14");
- //显示提示信息
- //POINT_COLOR=BLUE;//设置字体为蓝色
- //LCD_ShowString(60,130,200,16,16,"ADC_CH0_VAL:");
- //LCD_ShowString(60,150,200,16,16,"ADC_CH0_VOL:0.000V");
- while(1)
- {
- adcx=Get_Adc_Average(ADC_Channel_1,10);
- //LCD_ShowxNum(156,130,adcx,4,16,0);//显示ADC的值
- printf("\r\n%d\r\n",adcx);
- Vx=((float)adcx*3.3)/4096;
- printf("\r\n%f\r\n",Vx);
-
- resistence=(10*Vx)/(3.3-Vx);
- printf("\r\n%f\r\n",resistence);
- Tem=resistence/Rp;
- printf("\r\n%f\r\n",Tem);
- Tem=log(Tem);
- printf("\r\n%f\r\n",Tem);
- Tem/=Bx;
- printf("\r\n%f\r\n",Tem);
- Tem+=(1/T2);
- printf("\r\n%f\r\n",Tem);
- Tem=1/(Tem);
- printf("\r\n%f\r\n",Tem);
- Tem-=Ka;
- printf("\r\n%f\r\n",Tem);
- delay_ms(1000);
-
-
- }
- }
复制代码
所有资料51hei提供下载:
ADC-热敏实验.rar
(338.29 KB, 下载次数: 72)
|