基于单片机的智能电梯控制系统的设计与实现_第1页
基于单片机的智能电梯控制系统的设计与实现_第2页
基于单片机的智能电梯控制系统的设计与实现_第3页
基于单片机的智能电梯控制系统的设计与实现_第4页
基于单片机的智能电梯控制系统的设计与实现_第5页
已阅读5页,还剩33页未读, 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

附录附录A源程序#include"sys.h"#include"delay.h"#include"hx711.h"#include"key.h"#include"led.h"#include"beep.h"#include"step_motor.h"#include"oled.h"u16weight=0;u16weight_set=1000;intmain(void){ u8i; u8start=0;//开始运行 u8now_step=0;//目前楼层 u8stop_step=0;//要停的楼层 u8key_value=0; u8delay_count=0; u8oled_buf[20]={0}; delay_init(); //延时函数初始化 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置NVIC中断分组2:2位抢占优先级,2位响应优先级 key_init(); step_motor_init(); beep_init(); hx711_init(); oled_init(); led_init(); oled_clear(); while(1){ //扫描按键 key_value=get_key_value(); if(key_value){ if(key_value<9){ stop_step|=1<<(key_value-1);//1byte=8bit }elseif(key_value==10){//上行 start=1; }elseif(key_value==12){ start=2;//下行 } } //显示逻辑 oled_clear(); get_weight_value(&weight);//获取重量 sprintf(oled_buf,"W:%d%d",weight,weight_set); oled_show_string(0,0,oled_buf,8); if(start==1){ oled_show_string(80,1,"UP",16); }elseif(start==2){ oled_show_string(80,1,"DOWN",16); }else{ oled_show_string(80,1,"STOP",16); } sprintf(oled_buf,"%d",now_step+1);//当前楼层 oled_show_string(0,1,oled_buf,16); for(i=0;i<8;i++){//需要停靠的楼层 if(stop_step&(1<<i)){ sprintf(oled_buf,"%d",i+1); oled_show_string(i*10,3,oled_buf,8); } } set_led(stop_step);//显示灯状态 //运行逻辑 if(start==1&&stop_step){//上行 step_num(0,2000,2); if(stop_step&(1<<now_step)){//需要停靠 oled_show_string(90,3,"open",8); get_weight_value(&weight);//获取重量 sprintf(oled_buf,"W:%d%d",weight,weight_set); oled_show_string(0,0,oled_buf,8); delay_ms(1000); while(weight>weight_set){//超重报警 get_weight_value(&weight);//获取重量 sprintf(oled_buf,"W:%d%d",weight,weight_set); oled_show_string(0,0,oled_buf,8); BEEP=BEEP_ON; } get_weight_value(&weight);//获取重量 sprintf(oled_buf,"W:%d%d",weight,weight_set); oled_show_string(0,0,oled_buf,8); BEEP=BEEP_OFF; oled_show_string(90,3,"close",8);//关门 set_led(stop_step); stop_step=stop_step&(~(0xff&(1<<now_step)));//清除已经停靠的楼层 } if(!stop_step||now_step==8){//没有要到的楼层或者到顶了,停止 start=0; stop_step=0; }else{ now_step++; } }elseif(start==2&&stop_step){//下行 step_num(1,2000,2); if(stop_step&(1<<now_step)){//需要停靠 oled_show_string(90,3,"open",8); get_weight_value(&weight); sprintf(oled_buf,"W:%d%d",weight,weight_set); oled_show_string(0,0,oled_buf,8); delay_ms(1000); while(weight>weight_set){//超重报警 get_weight_value(&weight);//获取重量 BEEP=BEEP_ON; sprintf(oled_buf,"W:%d%d",weight,weight_set); oled_show_string(0,0,oled_buf,8); } get_weight_value(&weight);//获取重量 sprintf(oled_buf,"W:%d%d",weight,weight_set); oled_show_string(0,0,oled_buf,8); BEEP=BEEP_OFF; oled_show_string(90,3,"close",8); set_led(stop_step); stop_step=stop_step&(~(0xff&(1<<now_step)));//清除已经停靠的楼层 } if

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论