標(biāo)題:
用單片機(jī)制作自動(dòng)配藥系統(tǒng) 源程序Proteus仿真圖
[打印本頁]
作者:
133456789
時(shí)間:
2022-4-14 13:38
標(biāo)題:
用單片機(jī)制作自動(dòng)配藥系統(tǒng) 源程序Proteus仿真圖
自動(dòng)配藥系統(tǒng)設(shè)計(jì),設(shè)置配置比例和總藥量,自動(dòng)配藥
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
51hei.gif
(87.05 KB, 下載次數(shù): 38)
下載附件
2022-4-14 18:51 上傳
單片機(jī)源程序如下:
#define uint unsigned int
#define uchar unsigned char
#include "Lcd1602.h"
#include <intrins.h>
#include "math.h"
#define delay4us() {_nop_();_nop_();_nop_();_nop_();}//格式
int P_Air,P_Water,H_Water;
int Err,Err_L;
sbit CS = P1^5;
sbit CLK = P1^6;
sbit DIO = P1^7;// DI和DO并聯(lián)接入P1^2;
void display() ;
uchar Get_AD_Result_ch2(unsigned char num) //得到 雙通道U5 ad采集的電壓
{
uchar i,dat1=0,dat2=0;
CS = 0; CLK = 0;DIO = 1; _nop_(); _nop_();
CLK = 1; _nop_(); _nop_(); CLK = 0; //準(zhǔn)備
CLK = 1; _nop_(); _nop_();CLK = 0; //開始 核實(shí)準(zhǔn)備工作
DIO = num; _nop_(); _nop_();CLK = 1; //上升沿傳地地址的低位
DIO = num; _nop_(); _nop_();CLK = 0; //下降沿傳地地址的高位
DIO = 1; _nop_(); _nop_(); //準(zhǔn)備傳輸數(shù)據(jù)
for(i=0;i<8;i++)
{
dat1 = dat1 | DIO;
CLK = 1; _nop_(); _nop_();
CLK = 0; _nop_(); _nop_();
dat1 = dat1 << 1 ;
}
CS = 1;
return dat1;
}
void Get_Info()
{
uchar temp;
temp = Get_AD_Result_ch2(0);//采集氣壓
P_Air = (uchar)(temp/5);
}
/*******************************************************************************
* 函 數(shù) 名 : main
* 函數(shù)功能 : 主函數(shù)
* 輸 入 : 無
* 輸 出 : 無
*******************************************************************************/
void main(void)
{
InitLcd1602();
while(P_Water<=1)
{
Get_Info();//得到采集數(shù)據(jù)
display();//數(shù)據(jù)顯示
}
while(1)
{
Get_Info();//得到采集數(shù)據(jù)
display();//數(shù)據(jù)顯示
}
}
void display() //lcd顯示提示信息以及測(cè)到的數(shù)據(jù)
{
unsigned char shu[8],shu1[8],shu2[8];
shu[0]='R';
shu[1]=':';
shu[2]=P_Air/1000+0x30; //取百位 加0x30是為了轉(zhuǎn)化成字符型
shu[3]='.'; //取百位 加0x30是為了轉(zhuǎn)化成字符型
shu[4]=(P_Air-(shu[2]-0x30)*1000)/100+0x30; //取十位
shu[5]=((P_Air-(shu[2]-0x30)*1000)-100*(shu[4]-0x30))/10+0x30; //取個(gè)位(下同)
shu[6] =P_Air%10+0x30 ;
shu[7]=' ' ;
shu[8]='\0';
LcdShowStr(0,0,shu);
}
復(fù)制代碼
Keil代碼與Proteus仿真下載:
本人初學(xué),僅供參考,存在錯(cuò)誤和不足之處,請(qǐng)大家回帖多多指教,切勿照搬,文件下載:
仿真代碼.7z
(102.98 KB, 下載次數(shù): 35)
2022-4-14 18:51 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1