標(biāo)題: 想問一下這個MCU程序中的溫度計算公式是怎么來的? [打印本頁]

作者: duanpy    時間: 2024-6-19 19:06
標(biāo)題: 想問一下這個MCU程序中的溫度計算公式是怎么來的?
#include<reg51.h>
#include <intrins.h>

#define Disdata P3
#define discan P0

sbit adrd=P2^7;          //IO口定義
sbit adwr=P2^6;
sbit csad=P2^4;
sbit  DIN=P3^7;       //LED小數(shù)點控制

unsigned char j,k,ad_data,t;
unsigned char dis[4]={0x00,0x00,0x00,0x00};

unsigned char code dis_7[12]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x40};
/* 共陽LED段碼表對應(yīng)           "0"  "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9" "不亮" "-" */                 
unsigned char code  scan_con[4]={0xfe,0xfd,0xfb,0xf7};      // 列掃描控制字   

void delay(unsigned int t)  
{  
  for(;t>0;t--)
  {
    ;
  }  
}  //11微秒延時函數(shù)

void scan()  
{  
   char k;      
   
   for(k=0;k<4;k++)        //四位LED掃描控制      
   {        
     Disdata=dis_7[dis[k]];        
         if(k==1)
         {
           DIN=1;                                  //加入小數(shù)點
         }        
         discan=scan_con[k];
         delay(90);
         discan=0xff;      
   }   
}
void ad0804()
{
  P1=0xff;              //讀取P1口之前先給其寫全1
  csad=0;               //選通ADCS
  adrd=0;               //AD讀使能
  ad_data=P1;                        //AD數(shù)據(jù)讀取賦給P1口
  adrd=1;
  csad=1;               //關(guān)閉ADCS
  adwr=0;
}

void ad_compute()       //u=2.55+T/100, 2.55反映在AD上為0x83
{
  unsigned char t_temp;

  //if(ad_data>=0x83)
  //{
    ad_data=ad_data-0x83;
    t_temp=ad_data*2-4;
        if(t_temp<=110)
        {
         dis[3]=t_temp/100;
         dis[2]=t_temp/10-dis[3]*10;
         dis[1]=t_temp%10;
         dis[0]=t%5*2;
        }
        else
        {
          t_temp=256-t_temp;
      dis[3]=11;
      dis[2]=t_temp/10;
      dis[1]=t_temp%10;
      dis[0]=t%5*2;
        }
//         
//  }

}
void main()                //        主程序
{
  while(1)
  {
    ad0804();
        ad_compute();
        scan();
  }
}

mmexport1718791766041.png (53.82 KB, 下載次數(shù): 14)

mmexport1718791766041.png

作者: cedtek    時間: 2024-6-20 03:58
找了個參考資料,希望對你有幫助! 用MCP3421與RTD-PT100設(shè)計的鉑電阻溫度計.pdf (6.46 MB, 下載次數(shù): 5)

作者: donglw    時間: 2024-6-20 10:18
上傳圖紙模糊,ADC的具體型號是?基準(zhǔn)電壓是多少?恒流源的型號?運算放大器的型號?
作者: coody_sz    時間: 2024-6-20 11:18
沒看到計算公式,只有程序,沒空揣摩。
作者: yzwzfyz    時間: 2024-6-20 19:47
查閱一下MCU中,關(guān)于溫度傳感器使用的說明部分。
作者: zh_junwei    時間: 2024-6-21 11:53
是PT100對應(yīng)AD采樣值的運算公式吧




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1