久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 4113|回復: 0
打印 上一主題 下一主題
收起左側

基于單片機+TLC2543的熱敏電阻測溫源程序與Proteus仿真

[復制鏈接]
跳轉到指定樓層
樓主
ID:879793 發(fā)表于 2021-3-10 15:18 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
基于單片機的熱敏電阻測溫設計完整版包含文檔、硬件電路搭建以及仿真結果。

元件清單:
P1    LCD1602液晶顯示屏+16P插座
PR1    103排阻
Q1    8550三極管
R1, R5    10K電阻
R2, R6, R7    1K電阻
R3    熱敏電阻 帶線+2P白色插頭
R4    電位器
SW1    自鎖開關
U1    TLC2543芯片+DIP20插座
U2    STC89C52單片機+DIP40插座
Y1    12M晶振
   
9*15板子   
錫絲   
導線   
USB供電線或者電池盒   
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)

Altium Designer畫的原理圖和PCB圖如下:(51hei附件中可下載工程文件)


單片機源程序如下:
  1. #include<reg52.h>                                 //頭文件
  2. #include<intrins.h>
  3. #include"eeprom52.h"
  4. #include "math.h"
  5. #define uchar unsigned char                 //宏定義
  6. #define uint unsigned int
  7. #define LCD1602_dat P0


  8. sbit LCD1602_rs=P2^5;//IO 定義
  9. sbit LCD1602_rw=P2^6;
  10. sbit LCD1602_e=P2^7;
  11. sbit beep=P2^0;
  12. sbit led_1=P1^5;
  13. sbit led_2=P1^6;

  14. sbit key_1=P3^5;
  15. sbit key_2=P3^6;
  16. sbit key_3=P3^7;


  17. sbit TCL2543_EOC  = P1^0;
  18. sbit TCL2543_CLK  = P1^1;
  19. sbit TCL2543_ADIN = P1^2;
  20. sbit TCL2543_DOUT = P1^3;
  21. sbit TCL2543_CS   = P1^4;


  22. float zhi;
  23. int shu;

  24. char temp,temp_h,temp_l;
  25. uchar state,ms;

  26. bit s1,beep1;

  27. void delay(uint T)
  28. {
  29.         while(T--);
  30. }

  31. // 其中 port 為通道: 通道0:port = 0x01 通道1:port = 0x02 通道2:port = 0x04 ...
  32. uint read2543(unsigned char port)  
  33. {  
  34.         unsigned int i;   
  35.         uint ad_value=0;  
  36.         TCL2543_CLK=0;   
  37.         TCL2543_CS=0;   
  38.         TCL2543_EOC=1;   
  39.         port<<=4;   
  40.         for(i=0;i<12;i++)   
  41.         {  
  42.                 if(TCL2543_DOUT) ad_value|=0x01;   
  43.                 TCL2543_ADIN=(bit)(port&0x80);   
  44.                 TCL2543_CLK=1;   
  45.                 _nop_();  
  46.                 _nop_();   
  47.                 _nop_();  
  48.                 TCL2543_CLK=0;   
  49.                 _nop_();   
  50.                 _nop_();  
  51.                 _nop_();  
  52.                 port=port<<1;  
  53.                 ad_value=ad_value<<1;   
  54.         }
  55.         TCL2543_CS=1;   
  56.         ad_value=ad_value>>1;   
  57.         return ad_value;  
  58. }

  59. void LCD1602_write(uchar order,dat)                                  //1602 一個字節(jié)  處理
  60. {
  61.     LCD1602_e=0;
  62.     LCD1602_rs=order;
  63.     LCD1602_dat=dat;
  64.     LCD1602_rw=0;
  65.     LCD1602_e=1;
  66.     delay(1);
  67.     LCD1602_e=0;                                                                                                                                                                                                     
  68. }

  69. void LCD1602_writebyte(uchar *prointer)                                   //1602 字符串    處理
  70. {
  71.     while(*prointer!='\0')
  72.     {
  73.         LCD1602_write(1,*prointer);
  74.         prointer++;
  75.     }
  76. }

  77. void LCD1602_cls()                                                                         //1602 初始化
  78. {
  79.         LCD1602_write(0,0x01);     //1602 清屏 指令
  80.         delay(1500);
  81.         LCD1602_write(0,0x38);     // 功能設置 8位、5*7點陣
  82.         delay(1500);
  83.         LCD1602_write(0,0x0c);     //設置 光標   不顯示開關、不顯示光標、字符不閃爍
  84.         LCD1602_write(0,0x06);
  85.         LCD1602_write(0,0xd0);
  86.         delay(1500);
  87. }


  88. void show()                        //顯示數(shù)據(jù)
  89. {

  90.                 LCD1602_write(0,0x80);
  91.                 LCD1602_writebyte("Temp:");
  92.                 if(temp>=0)
  93.                 {
  94.                            if(temp>99)LCD1602_write(1,0x30+temp/100%10);
  95.                         else LCD1602_writebyte(" ");
  96.                         if(temp>9)LCD1602_write(1,0x30+temp/10%10);
  97.                         else LCD1602_writebyte(" ");
  98.                         LCD1602_write(1,0x30+temp%10);
  99.                 }else
  100.                 {
  101.                         LCD1602_writebyte("-");
  102.                         if(temp*-1>9)LCD1602_write(1,0x30+(temp*-1)/10%10);
  103.                         else LCD1602_writebyte(" ");
  104.                         LCD1602_write(1,0x30+(temp*-1)%10);        
  105.                 }
  106.                 LCD1602_write(1,0xdf);
  107.                 LCD1602_writebyte("C   ");



  108.                  LCD1602_write(0,0xC0);
  109.                 LCD1602_writebyte("H:");
  110.                 if(state==1&&s1==1)
  111.                 {
  112.                         LCD1602_writebyte("   ");
  113.                 }else
  114.                 {


  115.                         if(temp_h>=0)
  116.                         {
  117.                                    if(temp_h>99)LCD1602_write(1,0x30+temp_h/100%10);
  118.                                 else LCD1602_writebyte(" ");
  119.                                 if(temp_h>9)LCD1602_write(1,0x30+temp_h/10%10);
  120.                                 else LCD1602_writebyte(" ");
  121.                                 LCD1602_write(1,0x30+temp_h%10);
  122.                         }else
  123.                         {
  124.                                 LCD1602_writebyte("-");
  125.                                 if(temp_h*-1>9)LCD1602_write(1,0x30+(temp_h*-1)/10%10);
  126.                                 else LCD1602_writebyte(" ");
  127.                                 LCD1602_write(1,0x30+(temp_h*-1)%10);        
  128.                         }
  129.                 }
  130.                 LCD1602_write(1,0xdf);
  131.                 LCD1602_writebyte("C L:");
  132.                 if(state==2&&s1==1)
  133.                 {
  134.                         LCD1602_writebyte("   ");
  135.                 }else
  136.                 {
  137. //                        LCD1602_write(1,0x30+temp_l/10%10);
  138. //                        LCD1602_write(1,0x30+temp_l%10);

  139.                         if(temp_l>=0)
  140.                         {
  141.                                    if(temp_l>99)LCD1602_write(1,0x30+temp_l/100%10);
  142.                                 else LCD1602_writebyte(" ");
  143.                                 if(temp_l>9)LCD1602_write(1,0x30+temp_l/10%10);
  144.                                 else LCD1602_writebyte(" ");
  145.                                 LCD1602_write(1,0x30+temp_l%10);
  146.                         }else
  147.                         {
  148.                                 LCD1602_writebyte("-");
  149.                                 if(temp_l*-1>9)LCD1602_write(1,0x30+(temp_l*-1)/10%10);
  150.                                 else LCD1602_writebyte(" ");
  151.                                 LCD1602_write(1,0x30+(temp_l*-1)%10);        
  152.                         }
  153.                 }
  154.                 LCD1602_write(1,0xdf);
  155.                 LCD1602_writebyte("C");
  156.         
  157. }


  158. void proc()
  159. {
  160.         if(temp>temp_h)
  161.         {
  162.                 led_1=0;         
  163.         }else
  164.         {
  165.                 led_1=1;         
  166.         }
  167.         if(temp<temp_l)
  168.         {
  169.                 led_2=0;
  170.         }else
  171.         {
  172.                 led_2=1;        
  173.         }

  174.         if(temp>temp_h||temp<temp_l)
  175.         {
  176.                 beep1=1;
  177.         }else
  178.         {
  179.                 beep1=0;
  180.         }
  181. }


  182. void key()
  183. {

  184.         if(!key_1)
  185.         {
  186.                 delay(888);
  187.                 if(!key_1)
  188.                 {
  189.                         state=(state+1)%3;
  190.                         while(!key_1);
  191.                 }
  192.         }
  193.         if(state!=0)
  194.         {
  195.                 if(!key_2)
  196.                 {
  197.                         delay(888);
  198.                         if(!key_2)
  199.                         {
  200.                                 while(!key_2) show();
  201.                                 switch(state)
  202.                                 {
  203.                                         case 1:
  204.                                         if(temp_h<99)temp_h++;
  205.                                         SectorErase(0x2000);         //保存上限值
  206.                                         byte_write(0x2000,temp_h);
  207.                                         break;
  208.                                         case 2:
  209.                                         if(temp_h>temp_l+1)temp_l++;        
  210.                                         SectorErase(0x2200);         //保存上限值
  211.                                         byte_write(0x2200,temp_l);
  212.                                         break;
  213.                                 }
  214.                         }
  215.                 }
  216.                 if(!key_3)
  217.                 {
  218.                         delay(888);
  219.                         if(!key_3)
  220.                         {
  221.                                 while(!key_3) show();
  222.                                 switch(state)
  223.                                 {
  224.                                         case 1:
  225.                                         if(temp_h>temp_l+1)temp_h--;
  226.                                         SectorErase(0x2000);         //保存上限值
  227.                                         byte_write(0x2000,temp_h);
  228.                                         break;
  229.                                         case 2:
  230.                                         if(temp_l>-40)temp_l--;
  231.                                         SectorErase(0x2200);         //保存上限值
  232.                                         byte_write(0x2200,temp_l);
  233.                                         break;

  234.                                 }
  235.                         }
  236.                 }
  237.         }
  238. }

  239. float TempCalculate(float Rx,float B,float Revise,float BasicRx)
  240. {
  241. /*

  242. Rx:  熱敏電阻當前阻值
  243. B:   熱敏電阻參數(shù)B值
  244. Revise:  校正溫度
  245. BasicRx:  熱敏電阻25度時電阻(標稱電阻數(shù)值)


  246. 返回: 攝氏度

  247. */  


  248.     Rx = Rx / BasicRx;
  249.    
  250.     Rx = log(Rx);
  251.    
  252.     Rx = (Rx) / B;
  253.    
  254.     Rx = Rx + 0.003356;
  255.     Rx = 1 / Rx;
  256.     Rx = Rx - 273.13;  
  257.     Rx = Rx + Revise;
  258.    
  259.    
  260.     return Rx;
  261.   
  262. }

  263. void main()
  264. {
  265.         float Rad;
  266.         LCD1602_cls();
  267.         TMOD=0x01;
  268.         TH0=0x4c;
  269.         TL0=0x00;
  270.         ET0=1;
  271.         TR0=1;
  272. ……………………

  273. …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼

所有資料51hei提供下載:

1.png (18.42 KB, 下載次數(shù): 109)

1.png

2.png (50.38 KB, 下載次數(shù): 119)

2.png

4.png (30.36 KB, 下載次數(shù): 144)

4.png

熱敏電阻.7z

2.86 MB, 下載次數(shù): 101, 下載積分: 黑幣 -5

評分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏2 分享淘帖 頂 踩
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 欧美一区二区视频 | 日韩视频一区在线观看 | 国产精品久久久久久久午夜片 | 欧美激情精品久久久久 | 日韩中文字幕网 | 97精品超碰一区二区三区 | 欧美涩 | 成人综合视频在线观看 | 亚洲成人免费视频 | 在线观看亚洲专区 | 欧美日韩第一页 | 综合一区二区三区 | 亚洲一级在线 | 欧美日韩综合一区 | 久久精品亚洲 | 日本精品一区二区三区在线观看视频 | 亚洲免费av一区 | 九色在线| 国产精品第2页 | 999精品在线观看 | www4虎 | 中文字幕亚洲免费 | 精品一区二区三区在线视频 | 亚洲电影免费 | 日韩电影免费在线观看中文字幕 | 国产精品一区二 | 97人人澡人人爽91综合色 | 国产精品区一区二 | 久久久99国产精品免费 | 国产高清久久 | 国产精品久久久久久久久大全 | 欧美黑人一级爽快片淫片高清 | 中文字幕三区 | 国产精品久久九九 | 老司机深夜福利网站 | 91久久综合亚洲鲁鲁五月天 | 欧美综合一区 | 日韩国产一区二区三区 | 欧美日韩久 | 99精品热视频 | 日日碰狠狠躁久久躁婷婷 |