MS1100甲醛浓度传感器使用
时间:10-02
整理:3721RD
点击:
STC12c5a60s2单片机读取的,转换出来的电压值偏小,请大家帮我看看,是不是龙错了。我用的是P1.4!
/*----------------------------
Get ADC result
----------------------------*/
GetADCResult(int ch)
{
ADC_CONTR = ADC_POWER | ADC_SPEEDLL | ch | ADC_START;
_nop_(); //Must wait before inquiry
_nop_();
_nop_();
_nop_();
while (!(ADC_CONTR & ADC_FLAG)); //Wait complete flag
ADC_CONTR &= ~ADC_FLAG; //Close ADC
return (ADC_RES*4+ADC_RESL); //Return ADC result
}
/*----------------------------
Initial ADC sfr
----------------------------*/
void InitADC()
{
P1ASF = 0xff; //Open 8 channels ADC function
ADC_RES = 0;
ADC_RESL = 0; //Clear previous result
ADC_CONTR = ADC_POWER | ADC_SPEEDLL;
// delay(2);
}
void ADC()
{
INT16U Shishu=0,shiwei=0,ya=0;
double c;
INT16U cdisplay;
shiwei=GetADCResult(4);
/*lcd_pos(0x40); //éè????ê??????aμúò?DDμ?μú1??×?·?
lcd_wdat('A');
lcd_pos(0x41);
lcd_wdat('=');
lcd_pos(0x42);
lcd_wdat(shiwei/1000+0x30);
lcd_pos(0x43);
lcd_wdat((shiwei%1000)/100+0x30);
lcd_pos(0x44);
lcd_wdat((shiwei%100)/10+0x30);
lcd_pos(0x45);
lcd_wdat((shiwei%10)+0x30);*/
c = ((double)shiwei*(5.50/1024))*100;
cdisplay = (INT16U) c;
GraphicDispNum(0, 0,DISPLAY_NORMAL, cdisplay/100);
GraphicDispNum(0, 5,DISPLAY_NORMAL, cdisplay%100);
GraphicDispNum(0, 12,DISPLAY_NORMAL, shiwei%100);
/*----------------------------
Get ADC result
----------------------------*/
GetADCResult(int ch)
{
ADC_CONTR = ADC_POWER | ADC_SPEEDLL | ch | ADC_START;
_nop_(); //Must wait before inquiry
_nop_();
_nop_();
_nop_();
while (!(ADC_CONTR & ADC_FLAG)); //Wait complete flag
ADC_CONTR &= ~ADC_FLAG; //Close ADC
return (ADC_RES*4+ADC_RESL); //Return ADC result
}
/*----------------------------
Initial ADC sfr
----------------------------*/
void InitADC()
{
P1ASF = 0xff; //Open 8 channels ADC function
ADC_RES = 0;
ADC_RESL = 0; //Clear previous result
ADC_CONTR = ADC_POWER | ADC_SPEEDLL;
// delay(2);
}
void ADC()
{
INT16U Shishu=0,shiwei=0,ya=0;
double c;
INT16U cdisplay;
shiwei=GetADCResult(4);
/*lcd_pos(0x40); //éè????ê??????aμúò?DDμ?μú1??×?·?
lcd_wdat('A');
lcd_pos(0x41);
lcd_wdat('=');
lcd_pos(0x42);
lcd_wdat(shiwei/1000+0x30);
lcd_pos(0x43);
lcd_wdat((shiwei%1000)/100+0x30);
lcd_pos(0x44);
lcd_wdat((shiwei%100)/10+0x30);
lcd_pos(0x45);
lcd_wdat((shiwei%10)+0x30);*/
c = ((double)shiwei*(5.50/1024))*100;
cdisplay = (INT16U) c;
GraphicDispNum(0, 0,DISPLAY_NORMAL, cdisplay/100);
GraphicDispNum(0, 5,DISPLAY_NORMAL, cdisplay%100);
GraphicDispNum(0, 12,DISPLAY_NORMAL, shiwei%100);
传感器之的好东西。
谢谢小编的帖子,学习了
大哥,能否共享下ms1100 的电路接法,我没用过,现在想做这个试试,谢谢了。
因为所测环境内的挥发性有机化合物(甲醛、苯等)的浓度低
有在做STM32和学习的技术朋友们,可加我qq2232894713希望能帮到你们,项目的一些问题也可以互相交流