以下為我們的C語言...是使用AD590做溫度感測 不過一直顯示在28度C
但是目前室溫約23 左右...他一開始就顯示28...是哪裡出錯了...不過用手捏住AD590 他溫度會上升.....我們程式是寫說 到達27度 LED會閃爍!
麻煩大大 幫解答
//----------------------------------------------------------------------------
// C main line
//----------------------------------------------------------------------------
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User
Modules
int idata,iout;
char i,j;
const unsigned char ASCII[]={"0123456789ABCDEF"};
void delay(unsigned int x);
void main()
{
M8C_EnableGInt;
LCD_Start();
ADCINC12_Start(3);
ADCINC12_GetSamples(0);
PGA_Start(3);
for(;;)
{
while(ADCINC12_fIsDataAvailable()==0);
ADCINC12_ClearFlag();
idata=ADCINC12_iGetData();
idata=2048+idata;
iout=idata;
LCD_Position(0,1);
LCD_PrHexInt(idata);
LCD_Position(0,8);
LCD_WriteData(ASCII[iout/1000]);
LCD_Position(0,9);
LCD_WriteData(ASCII[(iout%1000)/100]);
LCD_Position(0,10);
LCD_WriteData(ASCII[((iout%1000)%100)/10]);
LCD_Position(0,11);
LCD_WriteData(ASCII[iout%10]);
iout=iout*6.5;
LCD_Position(1,1);
LCD_PrCString("TEMP");
LCD_Position(1,6);
LCD_WriteData(ASCII[iout/1000]);
LCD_Position(1,7);
LCD_WriteData(ASCII[(iout%1000)/100]);
LCD_Position(1,8);
LCD_PrCString(".");
LCD_Position(1,9);
LCD_WriteData(ASCII[((iout%1000)%100)/10]);
LCD_Position(1,10);
LCD_WriteData(0xdf);
LCD_Position(1,11);
LCD_PrCString("C");
if(iout>2700)
{
delay(2000);
PRT2DR=0XFF;
delay(2000);
PRT2DR=0X00;
}
else
PRT2DR=0X00;
}
}
void delay(unsigned int x)
{
unsigned i;
for(i=0;i<x;i++);
} |
|