液体点滴速度监控装置设计的程序
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include
#define DB0_DB7 P0
#define busy 0x80
#define SCANPORT P1
sbit E=P2^2;
sbit RW=P2^1;
sbit RS=P2^0;
//1110 1111, 1101 1111, 1011 1111, 0111 1111
unsigned char uca_LineScan[4]={0xEF,0xDF,0xBF,0x7F}; //列线扫描电压分为第1,2,3,4根列线unsigned char key_ctt[4]={0};
unsigned char speed_bcd[4]={0};
unsigned char speed_sc[2];
unsigned char yy=0,temp;
unsigned int speed_ck[4]={0};
unsigned int di_xx[2]={0};
unsigned int ct=0,ttb=0,xx=0,tt3=0,speedct=0,speed=0,speedcd=10,cott=0;
unsigned int time_sq[4]={0};
typedef unsigned char uchar;
unsigned char code lcd3[]={"0123456789abcdef"};
unsigned char code lcdnow[]={"NOW:000"};
unsigned char code lcdset[]={"SET:000"};
unsigned char CONTROL[8]={0x38,0x18,0x98,0x88,0xC8,0x48,0x68,0x28};
unsigned char codes1[8]={0xb8,0x98,0xd8,0xc8,0xe8,0x68,0x78,0x38};//9,18,36,45,54,63,72,81度顺时针unsigned char codes2[8]={0xb8,0x98,0xd8,0xc8,0xe8,0x68,0x78,0x38};//9,18,36,45,54,63,72,81度逆时针unsigned char counts,pt;
unsigned char uc_KeyTemp=0;
unsigned char uc_ClickCount=0;
unsigned char ucCount;
bit flag=1; //度数,正反转,速度控制
bit a_ac=0;//比较系统标志
bit bleept=0;//报警标准
bit moto=0;//电机标志位
bit a_key=0;
bit b_key=0;
void vKeyProcess(unsigned char ucKeyCode);
void bleep();//报警
void ac();//电机速度比校
void akey();//功能处理
void getspeed();//速度检侧
void stdisplay();//显示
void Delay(unsigned int t);
void delay_50ms(unsigned int t); //延时
void SendCommand(unsigned char ch); //发送命令
void InitLcd(); //初始化
void DisplayOneChar(unsigned char x,unsigned char y,unsigned char ddata);//按指定位置显示一个字符
void DisplayListChar(unsigned char x,unsigned char y,unsigned char *DData);//按指定位盆显示一串字符
//================================================
//================================================
void Delay (unsigned int t) //delay 40us
{
//for(;t!=0;t--);
while(t--);
}
void deley_50ms(unsigned int t)
{
unsigned int j;
//可以在此加少许延时补偿,以称补大数值传递时(如delay_50ms(1000))造成的误差,但付出的代价是造成传递小数值//(delay_50ms(1))造成更大的误差。因为实际应用更多时候是传递小数值,所以补建议加补偿!
for(;t!=0;t--)
for(j=6245;j>0;j--);
}
//==============================================
//===============================================
void SendCommand(unsigned char ch) //发送命令
{
/*CheckBusy();*/
RS=0;
RW=0;
DB0_DB7=ch;
E=1;
Delay(1);
E=0;
Delay(5); //delay 40us
}
//=============================================
//===================================================
void vWriteData(unsigned char ch) //发送数据
{
/*CheckBusy();*/
RS=1;
RW=0;
DB0_DB7=ch;
E=1;
Delay(1);
E=0;
Delay(5); //delay 40us
}
//=========================================================
//===========================================================
void InitLcd() //初始化