標(biāo)題: 單片機(jī)太陽(yáng)能熱水控制器源程序與Proteus仿真原理圖(可使利用率最大化) [打印本頁(yè)]

作者: xiamoduyi    時(shí)間: 2018-5-27 16:24
標(biāo)題: 單片機(jī)太陽(yáng)能熱水控制器源程序與Proteus仿真原理圖(可使利用率最大化)
本設(shè)計(jì)通過(guò)對(duì)溫度測(cè)量系統(tǒng)、上水循環(huán)系統(tǒng)、輔助加熱系統(tǒng),這三個(gè)太陽(yáng)能熱水器中最重要的組成部分的自動(dòng)控制設(shè)計(jì),使其太陽(yáng)能的利用率達(dá)到最大化,通過(guò)科技的手段造福人類(lèi),在proteus中進(jìn)行仿真實(shí)現(xiàn)家用太能熱水控制器的主要功能,在一定程度上提高使系統(tǒng)的利用率!

太陽(yáng)能熱水控制器仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)


太陽(yáng)能控制器的單片機(jī)源程序如下:
  1. #include <reg51.h>
  2. #include <intrins.h>
  3. #include <stdio.h>
  4. #include <lcd1602.h>
  5. #include <ds1302.h>
  6. #include <ds18b20.h>
  7. #include <depth.h>

  8. sbit heater = P2^3;
  9. sbit k1=P1^0; //選擇按鍵
  10. sbit k2=P1^1; //增加按鍵
  11. sbit k3=P1^2; //減小按鍵
  12. sbit k4=P1^3;// 確認(rèn)按鍵
  13. sbit k5=P1^4; //加熱開(kāi)關(guān)按鍵
  14. sbit k6=P1^5;// 上水開(kāi)關(guān)

  15. unsigned char x;
  16. unsigned char flag = 0;
  17. unsigned char temp_max = 55;             //保存溫度變量
  18. unsigned char temp_min = 40;                 //保存濕度變量
  19. unsigned char presskeynum = 0;                    //按鍵次數(shù)變量
  20. unsigned char Current_MIN[4];
  21. unsigned char Current_MAX[4];
  22. unsigned char integer,symbol,decimal;       


  23. /************更新***************/
  24. void updatatime()
  25. {  systemtime datetime;
  26.         dsgettime(&datetime);                         //獲取時(shí)間
  27.         lcdoutput(0,0,"DATE:");                    //日期
  28.         datezstr(&datetime,datestring);
  29.         lcdoutput(5,0,"20");
  30.         lcdoutput(7,0,datestring);
  31.         lcdoutput(0,1,"TIME:");
  32.         for(x=8;x>0;x--)                        //循環(huán)顯示時(shí)間
  33.         {
  34.         converttemp();
  35.         dsgettime(&datetime);
  36.     timezstr(&datetime,timestring);
  37.     lcdoutput(5,1,timestring);
  38.         delay_ms(5);
  39.     }

  40. }
  41. void updatatemp()
  42. {         
  43.         lcdoutput(0,0,"SWEN:");                        //水溫
  44.         lcdoutput(0,1,"SWEI:");                        //水位
  45.         lcdoutput(13,0,Current_MAX);                        //水溫
  46.         lcdoutput(13,1,Current_MIN);

  47.         for(x=8;x>0;x--)                                //循環(huán)顯示時(shí)間
  48.         {
  49.         converttemp();
  50.         lcdoutput(5,0,tempstr);
  51.         depthprocess();
  52.         delay_ms(5);
  53.         }
  54. }

  55. void key()
  56. {
  57.      if (k1==0) //調(diào)整按鍵檢測(cè)
  58.      {
  59.          delay_ms(1);
  60.          if (k1==0)
  61.          {
  62.              presskeynum++;        flag = ~flag;
  63.              if(presskeynum==4)
  64.              presskeynum=0;
  65.              while(k1==0);         //若一直按下,循環(huán)
  66.                         lcdwrite(command,clear_screen);       
  67.          }
  68.      }

  69.      if(presskeynum==1)//設(shè)置模式溫度上限
  70.      {
  71.          if(k2==0)                            // 加
  72.          {
  73.                         delay_ms(1);
  74.                         temp_max++;
  75.                         if (temp_max>99)
  76.                         temp_max=99;
  77.                         while(k2==0);       //加上此句必須松按鍵才處
  78.                         lcdwrite(command,clear_screen);       
  79.           }
  80.           if(k3==0)//減
  81.           {
  82.                         delay_ms(1);
  83.                         temp_max--;
  84.                         if (temp_max<1)
  85.                         temp_max=1;
  86.                         while(k3==0);       //加上此句必須松按鍵
  87.                         lcdwrite(command,clear_screen);       
  88.            }
  89.        }
  90.        if(presskeynum==3)//濕度設(shè)置
  91.        {
  92.               if(k2==0)// 加
  93.               {
  94.                   delay_ms(1);
  95.                   temp_min++;
  96.                   if (temp_min>99)
  97.                   temp_min=100;
  98.                   while(k2==0);
  99.                                   lcdwrite(command,clear_screen);       
  100.                 }
  101.                 if(k3==0)//減
  102.                 {
  103.                     delay_ms(1);
  104.                     temp_min--;
  105.                     if (temp_min<1)
  106.                     temp_min=1;
  107.                                         while(k3==0);                                                        //這句是調(diào)試加入的
  108.                                         lcdwrite(command,clear_screen);       
  109.                 }
  110.         }
  111.         if(k4==0)// 退出鍵                                                                   //設(shè)置完初始值以后通過(guò)IIC寫(xiě)入24c02并清屏       
  112.         {
  113.             delay_ms(1);
  114.             if((k4==0)&&(flag != 0))
  115.             {
  116.                 while(k4==0);
  117.                                 lcdwrite(command,clear_screen);       
  118.                                 lcdoutput_delay(0,0,"SAVE DATE...");                   
  119.              }
  120.         }

  121. }

  122. /************主函數(shù)***************/
  123. void main()
  124. {       

  125.     ds1302init();
  126.         lcdini();
  127.         while(1)
  128.         {
  129.                 key();       
  130.                 sprintf(Current_MAX,"+%2d",(int)temp_max);
  131.                 sprintf(Current_MIN,"-%2d",(int)temp_min);
  132.        
  133.                 dsgettemp(&integer,&decimal,&symbol);        //獲取溫度
  134.                 if(integer<temp_min)                                         //自動(dòng)加熱設(shè)置temp的上下限
  135.                 {
  136.                          heater=0;       
  137.                 }
  138.                 else if(integer>temp_max)
  139.                 {
  140.                          heater=1;
  141.                 }
  142.                 if(flag)
  143.                 {          
  144.                         updatatemp();
  145.                 }else
  146.                 {
  147.                         updatatime();                    //關(guān)鍵顯示部分
  148.                 }                                                         
  149.         }         
  150.          
  151. }

  152. ……………………

  153. …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼

所有資料51hei提供下載:
工程源碼.zip (65.66 KB, 下載次數(shù): 132)
仿真文件.zip (69.78 KB, 下載次數(shù): 112)


作者: Jokera    時(shí)間: 2018-5-28 08:38
正好是我所需要的!感謝,
作者: 那個(gè)susan    時(shí)間: 2019-1-16 21:07
請(qǐng)問(wèn)有沒(méi)有流程圖?程序有點(diǎn)看不懂……
作者: woaiduman1979    時(shí)間: 2020-4-4 15:56
仿真電路圖里面沒(méi)有DS1302啊!怎么也找不到!
作者: 大花貓?zhí)羰?nbsp;   時(shí)間: 2020-4-15 20:57
不錯(cuò)不錯(cuò)  支持一下
作者: STC123456    時(shí)間: 2020-4-23 23:17
大花貓?zhí)羰?發(fā)表于 2020-4-15 20:57
不錯(cuò)不錯(cuò)  支持一下

程序編譯錯(cuò)誤,target創(chuàng)建不成功啊
作者: STC123456    時(shí)間: 2020-4-23 23:18
代碼編譯不成功
作者: 1305354239    時(shí)間: 2021-5-5 20:02
能不能發(fā)我一份,謝謝
作者: chengge123    時(shí)間: 2021-7-13 11:02
非常感謝,學(xué)到許多
作者: wl521520    時(shí)間: 2021-9-29 14:07
12864可以用么???
作者: wl521520    時(shí)間: 2021-10-16 15:11
如果轉(zhuǎn)換成實(shí)物怎么搞那個(gè)東西。。。。
感覺(jué)很難




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