ImageVerifierCode 换一换
格式:DOCX , 页数:43 ,大小:209.26KB ,
资源ID:723989      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-723989.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(无线货架仓储控制系统实验项目报告.docx)为本站会员(b****1)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

无线货架仓储控制系统实验项目报告.docx

1、无线货架仓储控制系统实验项目报告无线货架仓储控制系统实验 项目报告一:实验名称 无线货架仓储控制系统实验二:实验目的掌握嵌入式系统开发的方法, 熟练掌握从总体方案设计、硬件电路的搭建调试、软件的编写测试到最终的软硬件联调、系统性能测试等各环节;掌握无线模块的控制方法.三:实验内容利用51单片机开发板,无线模块,液晶显示屏等实现低成本,简单的无线仓储系统的设计。四:相关知识 五:实验步骤1.总体方案设计 总体方案设计图2.软件设计单片机部分主程序流程首先是初始化,主要包括通用IO端口,UART,SPI,以及LCD初始化,并在LCD 上显示开机初始信息。接着单片机开始接收从无线模块发的信息,然后进

2、行485通信,实现仓储管理。总机#include #include #include #include LCD1602.h#define uchar unsigned char#define uint unsigned int#define _ERR_ 0xff#define _SUCC_ 0xfesbit REDE = P34;uchar rec;uchar num,temp;void delay(uint t) for(;t0;t-);void ldelay(uint t) uint i = 100; for(;i0;i-) for(;t0;t-);void Send_date(uchar

3、 *buf) uchar len; uchar ecc; uchar i; len = strlen(buf); ecc = len; REDE = 1; TI = 0; TB8 = 0; SBUF = len; while(!TI); TI = 0; for(i=0;ilen;i+) ecc = ecc(*buf); TB8 = 0; SBUF = *buf; buf+; while(!TI); TI = 0; TB8 = 0; SBUF = ecc; while(!TI); TI = 0; REDE = 0;void Send_addr(uchar addr, uchar *buf) uc

4、har tmp = addr-1; while(tmp != addr) REDE = 1; TI = 0; TB8 = 1; SBUF = addr; while(!TI); TI = 0; REDE = 0; RI = 0; ldelay(1); while(!RI); tmp = SBUF; RI = 0; tmp = _ERR_; while(tmp != _SUCC_) Send_date(buf); REDE = 0; RI = 0; while(!RI); tmp = SBUF; RI = 0; wdec(addr);/ wstr(#OK );void init() delay(

5、10); /延时等待复位 wcmd(0x38); /设置为8总线16*2,5*7点阵 wcmd(0x01); /清屏幕 wcmd(0x06); /光标移动,显示区不移动 wcmd(0x0f); /开显示,光标闪烁 void display(uchar aa)/ wcmd(0x80); loc(2,1); wdate(aa); uchar keyscan() P2=0xef; temp=P2; temp=temp&0x0f; while(temp!=0x0f) delay(5); temp=P2; temp=temp&0x0f; while(temp!=0x0f) temp=P2; switch

6、(temp) case 0xee:num=0x30; break; case 0xed:num=0x31; init(); wstr(zongj); loc(2,1); SCON=0x90; PCON=0x80; ES=1; EA=1; REDE = 0; Send_addr(0x01, a); break; case 0xeb:num=0x32; init(); wstr(zongj); loc(2,1); SCON=0x90; PCON=0x80; ES=1; EA=1; REDE = 0; Send_addr(0x01,b); Send_addr(0x02,b); break; case

7、 0xe7:num=0x33; break; while(temp!=0x0f) temp=P2; temp=temp&0x0f; P2=0xdf; temp=P2; temp=temp&0x0f; while(temp!=0x0f) delay(5); temp=P2; temp=temp&0x0f; while(temp!=0x0f) temp=P2; switch(temp) case 0xde:num=0x34; break; case 0xdd:num=5; init(); wstr(zongj); loc(2,1); SCON=0x90; PCON=0x80; ES=1; EA=1

8、; REDE = 0; Send_addr(0x01, s); break; case 0xdb:num=6; break; case 0xd7:num=7; break; while(temp!=0x0f) temp=P2; temp=temp&0x0f; P2=0xbf; temp=P2; temp=temp&0x0f; while(temp!=0x0f) delay(5); temp=P2; temp=temp&0x0f; while(temp!=0x0f) temp=P2; switch(temp) case 0xbe:num=8; break; case 0xbd:num=9; br

9、eak; case 0xbb:num=A; break; case 0xb7:num=B; break; while(temp!=0x0f) temp=P2; temp=temp&0x0f; P2=0x7f; temp=P2; temp=temp&0x0f; while(temp!=0x0f) delay(5); temp=P2; temp=temp&0x0f; while(temp!=0x0f) temp=P2; switch(temp) case 0x7e:num=C; break; case 0x7d:num=D; break; case 0x7b:num=E; break; case

10、0x77:num=F; break; while(temp!=0x0f) temp=P2; temp=temp&0x0f; return num;void main() INIT(); num=0; while(1) display(keyscan(); 分机#include #include #include LCD1602.h#define uchar unsigned char#define uint unsigned int#define MYADD 0x01#define _ERR_ 0xff#define _SUCC_ 0xfesbit REDE = P34;uchar buf10

11、;/JIADE sbit you=P21;sbit youchu=P23;/JIADE void delay(uint t) for(;t0;t-);void ldelay(uint t) uint i = 100; for(;i0;i-) for(;t0;t-);uchar Rec_date(uchar *buf) uchar len; uchar ecc; uchar tmp; uchar i; REDE = 0; RI = 0; while(!RI); if(RB8 = 1) return 0xfe; len = SBUF; RI = 0; ecc = len; for(i=0;ilen

12、;i+) while(!RI); if(RB8 = 1) return 0xfe; *buf = SBUF; RI = 0; ecc = ecc(*buf); buf+; *buf = 0; while(!RI); if(RB8 = 1) return 0xfe; tmp = SBUF; RI = 0; ecc = tmpecc; if(ecc != 0) *(buf-len) = 0; REDE = 1; TI = 0; TB8 = 0; SBUF = _ERR_; while(!TI); TI = 0; REDE = 0; return 0xff; REDE = 1; TI = 0; TB

13、8 = 0; SBUF = _SUCC_; while(!TI); TI = 0; REDE = 0; return 0;void serial_RI()interrupt 4 uchar tmp; tmp = 0; while(tmp != MYADD) while(!RI); tmp = SBUF; RI = 0; delay(1000); REDE = 1; TI = 0; TB8 = 0; SBUF = MYADD; while(!TI); TI = 0; REDE = 0; SM2 = 0; tmp = 0xff; while(tmp = 0xff) tmp = Rec_date(b

14、uf); if(tmp = 0xfe) SM2 = 1; wstr(buf);void init() delay(10); /延时等待复位 wcmd(0x38); /设置为8总线16*2,5*7点阵 wcmd(0x01); /清屏幕 wcmd(0x06); /光标移动,显示区不移动 wcmd(0x0f); /开显示,光标闪烁void main() init(); wstr(fenj1); loc(2,1); SCON=0xb0; PCON=0x80; ES=1; EA=1; REDE = 0; P2=0xf7; while(1) if(you=0) delay(5); if(you=0) yo

15、uchu=1; while(!you); delay(5); while(!you); youchu=0; if(P1=a)youchu=1; if(P1=b)youchu=1; if(P1=s)youchu=0; 无线发射、接受部分#include #define uchar unsigned char #define uint unsigned int#define BYTE_BIT0 0x01#define BYTE_BIT1 0x02#define BYTE_BIT2 0x04#define BYTE_BIT3 0x08#define BYTE_BIT4 0x10#define BYT

16、E_BIT5 0x20#define BYTE_BIT6 0x40#define BYTE_BIT7 0x80/ , 具体细节请参考相关电路图FYTOOv NRFDemo2401.SchDoc(用PortelDXP打开)sbit PWR_UP = P26;sbit CE = P22;/ sbit DR2 = P35; /暂时没有用到/ sbit CLK2 = P34;/ sbit OUT2 = P33;sbit CS = P21;sbit DR1 = P20;sbit CLK1 = P37;sbit DATA = P33;/* RF2401 Configuration * 保存2401的配置信

17、息 */*=*/芯片测试用,无需修改#define TEST_2 0x8E /MSB D143D136#define TEST_1 0x08 / D135D128#define TEST_0 0x1C / D127D120/* 注意: DATAx_W + ADDRx_W + CRC 的值必须小于256 ! 单个数据包的大小必须小于32字节(256位) */#define DATA2_W 0x10 /2字节 /频道2 数据长度(单位:Bit)#define DATA1_W 0x10 /28字节 /频道1 数据长度(单位:Bit)/频道2 接收地址(当前模块地址)#define ADDR2_4 0

18、x00#define ADDR2_3 0x1c#define ADDR2_2 0xcc#define ADDR2_1 0xcc#define ADDR2_0 0xcc/频道1 接收地址#define ADDR1_4 0xcc#define ADDR1_3 0xcc#define ADDR1_2 0xcc#define ADDR1_1 0xcc#define ADDR1_0 0xcc#define ADDR_W 0x10 /2字节 /接收地址宽度(单位:Bit)#define CRC_L 0x1 /CRC模式 0:8位 1:16#define CRC_EN 0x1 /CRC校验启用#define

19、 RX2_EN 0x0 /双频道功能启用#define CM 0x1 /0:Direct mode 1:ShockBurst mode#define RFDR_SB 0x0 /0:250kbps 1:1Mbps#define XO_F 0x3 /nRF2401晶振频率 000:4M 001:8M 010:12M 011:16M 100:20M#define RF_PWR 0x3 /0dBm 信号发射功率 00:-20dBm 01:-10dBm 10:-5dBm 11:0dBm#define RF_CH 0x2 /Channel RF 频率 channel=2400Mhz+RF-CH*1.0Mh

20、z#define RXEN 0x0 /0:Tx 1:Rx 程序会通过SetTxMode和SetRxMode重新设置此参数#define RFConfig_Byte0 TEST_2#define RFConfig_Byte1 TEST_1#define RFConfig_Byte2 TEST_0#define RFConfig_Byte3 DATA2_W#define RFConfig_Byte4 DATA1_W#define RFConfig_Byte5 ADDR2_4#define RFConfig_Byte6 ADDR2_3#define RFConfig_Byte7 ADDR2_2#de

21、fine RFConfig_Byte8 ADDR2_1#define RFConfig_Byte9 ADDR2_0#define RFConfig_Byte10 ADDR1_4#define RFConfig_Byte11 ADDR1_3#define RFConfig_Byte12 ADDR1_2#define RFConfig_Byte13 ADDR1_1#define RFConfig_Byte14 ADDR1_0#define RFConfig_Byte15 (ADDR_W2 | CRC_L1 | CRC_EN)#define RFConfig_Byte16 (RX2_EN7 | CM

22、6 | RFDR_SB5 | XO_F 2 | RF_PWR)#define RFConfig_Byte17 (RF_CH1 | RXEN)unsigned char code nRF2401_Conf18 = RFConfig_Byte0, RFConfig_Byte1, RFConfig_Byte2, RFConfig_Byte3, RFConfig_Byte4, RFConfig_Byte5, RFConfig_Byte6, RFConfig_Byte7, RFConfig_Byte8, RFConfig_Byte9, RFConfig_Byte10, RFConfig_Byte11,

23、RFConfig_Byte12, RFConfig_Byte13, RFConfig_Byte14, RFConfig_Byte15, RFConfig_Byte16, RFConfig_Byte17;void Delay100(void) unsigned int i; for(i=0;i100;i+);void Delay(uchar n) uint i; while(n-) for(i=0;i80;i+); bdata unsigned char DATA_BUF;#define DATA7 (DATA_BUF & BYTE_BIT7) != 0) /最高位为1#define DATA0

24、 (DATA_BUF & BYTE_BIT0) != 0) /最低位为1unsigned char Spi_ByteRead(void) unsigned char i = 0; for (i=0; i8; i+) DATA_BUF = DATA_BUF 1; CLK1 = 1; DATA = 1; /设置为输入状态 if (DATA) /读取最高位,保存至最末尾,通过左移位完成整个字节 DATA_BUF |= BYTE_BIT0; else DATA_BUF &= BYTE_BIT0; CLK1 = 0; return DATA_BUF;void Spi_ByteWrite(unsigned char send) unsigned char i; DATA_BUF = send; CLK1 = 0; for (i=0; i8; i+) if (DATA7) /总是发送最高位 DATA = 1; else DATA = 0; CLK1 = 1; DATA_BUF = DATA_BUF 1; CLK1 = 0; void Config2401(void) unsigned int i = 0;

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2