基于单片机的液体点滴控制系统设计说明书论文

发布时间 : 星期六 文章基于单片机的液体点滴控制系统设计说明书论文更新完毕开始阅读

南京工程学院毕业设计说明书(论文)

else if (key == KEY_ENTER) { if (tmp1 > 999){tmp1 = 999;} uiBuzzerTimer = tmp1 * 100; return; } }//end of while (1) return; }

void main(void) {

uint8 key = 0; //初始化

DelayTime1ms(100);

LcdInit(); BUZZER = 1; TimerInit(0, 10); //10ms计时精度 InterruptInit(0, 1); //1=下降沿方式触发 while (1) { key = GetKey(0); if (key == KEY_SET) { LcdClear(); Setting(); LcdClear(); } else if (key == KEY_ENTER) { if (ucBuzzerOn == 0){ucBuzzerOn = 1;} else {ucBuzzerOn = 0;} } //显示当前状态 { if (ucBuzzerOn){DrawText(13, 0, \ else {DrawText(13, 0, \ } //显示当前滴速

60

南京工程学院毕业设计说明书(论文)

{ uint16 tmp = uiPPM; if (tmp > 9999){tmp = 9999;} LcdWrite(0, 0, '0' + (tmp / 1000)); tmp %= 1000; LcdWrite(1, 0, '0' + (tmp / 100)); tmp %= 100; LcdWrite(2, 0, '0' + (tmp / 10)); tmp %= 10; LcdWrite(3, 0, '0' + (tmp / 1)); DrawText(4, 0, \ } //显示当前累计滴数 { uint32 tmp = ulCount; if (tmp > 999999){tmp = 999999;} LcdWrite(0, 1, '0' + (tmp / 100000)); tmp %= 100000; 镄辉蔺敘档檻岂苈祸紧。 LcdWrite(1, 1, '0' + (tmp / 10000)); tmp %= 10000; 梟裥荞獰淪钲壚蚀颈鍥。 LcdWrite(2, 1, '0' + (tmp / 1000)); tmp %= 1000; LcdWrite(3, 1, '0' + (tmp / 100)); tmp %= 100; LcdWrite(4, 1, '0' + (tmp / 10)); tmp %= 10; LcdWrite(5, 1, '0' + (tmp / 1)); DrawText(6, 1, \ } } //结束while(1) }

void INT_0(void) interrupt 0 { //滴数累计 ulCount++; //滴速计算 uiPPM = 6000 / GetTimerTick(0); // P/min SetTimerTick(0, 0); //重新计时 }

//定时器部分

void InterruptInit(uint8 ucInterrupt, uint8 ucType)//初始化定时器輟绀脑誒滢搂厨议犧異。 {

if (ucInterrupt == 0)

61

南京工程学院毕业设计说明书(论文)

{ IT0 = ucType; EX0 = 1; }

else if (ucInterrupt == 1) { IT1 = ucType; EX1 = 1; }

EA = 1; }

void CloseInterrupt(uint8 ucInterrupt)//关闭中断 {

if (ucInterrupt == 0) {

EX0 = 0; }

else if (ucInterrupt == 1) {

EX1 = 0; } }

uint16 GetTimerTick(uint8 ucTimer) {

if (ucTimer <= 2) {

uint16 tmp = uiTimerTick[ucTimer];

while (tmp != uiTimerTick[ucTimer]){tmp = uiTimerTick[ucTimer];}屡浔缱飛獼轄黨诼鐙虏。

return tmp; } else {

return 0; } }

void timer0(void) interrupt 1 { //定时器重新计时

62

南京工程学院毕业设计说明书(论文)

TF0 = 0;

TL0 = ucTimerClock[0][0]; TH0 = ucTimerClock[0][1];

uiTimerTick[0]++;

if (ucBuzzerOn) { if (uiTimerTick[0] > uiBuzzerTimer){BUZZER = 0;} //10s不滴报警诏弑缁岘睑慫龜贮沩驏。 else {BUZZER = 1;} } else { BUZZER = 1; } }

//按键部分

uint8 GetKey(uint8 type) { uint8 ucKeyValue = 0; static uint8 s_ucFastKey = 0; //去抖 ucKeyValue = ScanKey(); if (ucKeyValue == 0){s_ucFastKey = 0; return 0;} //没有按键返回0鳧冲经粮籩赂鸡躯铠潔。 KeyDelay1ms(10); //10ms去抖 ucKeyValue = ScanKey(); if (ucKeyValue == 0){s_ucFastKey = 0; return 0;} //没有按键返回0聰駘絷轳终实騭逻顯赡。

#if BELL_ENABLE == 1 BELL_ON(); KeyDelay1ms(10); //响蜂鸣器 BELL_OFF(); #endif

if (type == 0) {

s_ucFastKey = ucKeyValue; while (s_ucFastKey != 0) {

63

联系合同范文客服:xxxxx#qq.com(#替换为@)