欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 用單片機制作自動配藥系統 源程序Proteus仿真圖 [打印本頁]

作者: 133456789    時間: 2022-4-14 13:38
標題: 用單片機制作自動配藥系統 源程序Proteus仿真圖
自動配藥系統設計,設置配置比例和總藥量,自動配藥
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)


單片機源程序如下:
  1. #define uint unsigned int
  2. #define uchar unsigned char
  3. #include "Lcd1602.h"
  4. #include <intrins.h>
  5. #include "math.h"
  6. #define delay4us() {_nop_();_nop_();_nop_();_nop_();}//格式

  7. int P_Air,P_Water,H_Water;
  8. int Err,Err_L;
  9. sbit CS  = P1^5;
  10. sbit CLK = P1^6;
  11. sbit DIO = P1^7;//        DI和DO并聯接入P1^2;

  12. void display() ;

  13. uchar Get_AD_Result_ch2(unsigned char num) //得到 雙通道U5 ad采集的電壓
  14. {
  15.          uchar i,dat1=0,dat2=0;
  16.         CS  = 0; CLK = 0;DIO = 1; _nop_(); _nop_();
  17.         CLK = 1; _nop_(); _nop_(); CLK = 0;                         //準備

  18.         CLK = 1; _nop_(); _nop_();CLK = 0;                 //開始          核實準備工作
  19.         DIO = num; _nop_(); _nop_();CLK = 1;              //上升沿傳地地址的低位
  20.         DIO = num; _nop_(); _nop_();CLK = 0;                    //下降沿傳地地址的高位
  21.         DIO = 1; _nop_(); _nop_();                                   //準備傳輸數據
  22.         for(i=0;i<8;i++)
  23.         {   
  24.             dat1 = dat1 | DIO;
  25.                  CLK = 1; _nop_(); _nop_();
  26.                 CLK = 0; _nop_(); _nop_();
  27.                
  28.                 dat1 = dat1 << 1 ;
  29.               
  30.         }
  31.         CS = 1;
  32.         return dat1;
  33. }
  34. void Get_Info()
  35. {
  36.         uchar temp;
  37.         temp = Get_AD_Result_ch2(0);//采集氣壓
  38.         P_Air = (uchar)(temp/5);
  39. }
  40. /*******************************************************************************
  41. * 函 數 名         : main
  42. * 函數功能                   : 主函數
  43. * 輸    入         : 無
  44. * 輸    出         : 無
  45. *******************************************************************************/
  46. void main(void)
  47. {  
  48.         InitLcd1602();
  49.         while(P_Water<=1)
  50.         {
  51.                 Get_Info();//得到采集數據
  52.                 display();//數據顯示                        
  53.         }

  54.         while(1)
  55.         {
  56.                 Get_Info();//得到采集數據
  57.                 display();//數據顯示
  58.         }                                
  59. }

  60. void display()      //lcd顯示提示信息以及測到的數據
  61. {
  62. unsigned char shu[8],shu1[8],shu2[8];
  63. shu[0]='R';               
  64.         shu[1]=':';        
  65. shu[2]=P_Air/1000+0x30;     //取百位 加0x30是為了轉化成字符型
  66. shu[3]='.';     //取百位 加0x30是為了轉化成字符型
  67. shu[4]=(P_Air-(shu[2]-0x30)*1000)/100+0x30;   //取十位
  68. shu[5]=((P_Air-(shu[2]-0x30)*1000)-100*(shu[4]-0x30))/10+0x30;      //取個位(下同)
  69. shu[6] =P_Air%10+0x30 ;
  70. shu[7]=' '        ;
  71. shu[8]='\0';

  72. LcdShowStr(0,0,shu);
  73. }
復制代碼
Keil代碼與Proteus仿真下載:
本人初學,僅供參考,存在錯誤和不足之處,請大家回帖多多指教,切勿照搬,文件下載:
仿真代碼.7z (102.98 KB, 下載次數: 35)







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