在多通道数据采集的基础上,通过添加NTC温度感知器件即可实现温度检测及波形绘制功能。 为简化设计的这里仅以一个温度检测点为例加以介绍,在实际应用中,由于温度滞后现象的存在,是会采用多点温度检测的。 实现多通道数据采集及波形绘制的主程序为: - int main(void)
- {
- BOARD_TFT_Config();
- tft_Init();
- LCD_Clear(RED);
- BACK_COLOR=RED;
- POINT_COLOR=YELLOW;
- LCD_ShowString(120,10,"APM32F402");
- POINT_COLOR=WHITE;
- LCD_DrawLine(0, 30, 319, 30);
- LCD_DrawLine(0, 210, 319, 210);
- LCD_Fill(0,31,319,209,BLACK);
- BACK_COLOR=BLACK;
- POINT_COLOR=YELLOW;
- BACK_COLOR=RED;
- LCD_ShowString(10,220,"ch0: mV");
- LCD_ShowString(110,220,"ch1: mV");
- LCD_ShowString(210,220,"ch2: C");
- ADC_Init();
- ii=1;
- sp1=0;
- sp2=0;
- sp3=0;
- while (1)
- {
- ADC_MultiChannelPolling();
- Delay(1000);
- }
- }
经程序的编译与下载,其运行效果如图2所示。 图1 显示屏连接
图2 波形绘制 实现NTC温度检测及波形绘制的功能函数为: - void ADC_MultiChannelPolling(void)
- {
- float voltage;
- uint8_t index;
- uint32_t k,V,u;
- for (index = 0; index < ADC_CH_SIZE; index++)
- {
- voltage = (adcData[index] * 3300.0) / 4095.0;
- u=voltage;
- k=voltagev*180/3300;
- if(k>180) sj=180;
- else sj=k;
- if(index ==0)
- {
- POINT_COLOR=WHITE;
- LCD_ShowNum(50,220,voltage,4);
- POINT_COLOR=GREEN;
- LCD_DrawLine(2+4*(ii-1),200-sp1, 2+4*ii,200-sj);
- sp1=sj;
- }
- if(index ==1)
- {
- POINT_COLOR=WHITE;
- LCD_ShowNum(150,220,voltage,4);
- POINT_COLOR=BLUE;
- LCD_DrawLine(2+4*(ii-1),200-sp2, 2+4*ii,200-sj);
- sp2=sj;
- }
- if(index ==2)
- {
- POINT_COLOR=WHITE;
- V=0;
- if((u<=1644) && (u>1268))
- V=10+(1644-u)/37;
- if((u<=1268) && (u>947))
- V=20+(1268-u)/32;
- if((u<=947) && (u>692))
- V=30+(947-u)/25;
- LCD_ShowNum(250,220,V,4);
- V=V*2;
- POINT_COLOR=RED;
- LCD_DrawLine(2+4*(ii-1),200-sp3-1, 2+4*ii,200-V-1);
- sp3=V;
- ii=ii+1;
- if(ii>79)
- {
- ii=1;
- LCD_Fill(0,31,319,209,BLACK);
- POINT_COLOR=WHITE;
- }
- }
- }
- }
在连接NTC温感器件的情况下,检测与波形绘制相关如图4所示。 图3 连接NTC检测模块
图4 升温测试
|