版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、zigbee综合实践课程设计:基于zigbee的火灾报警系统计算机科学与技术学院ZigBee综合实践课程设计报告设计题目: 基于zigbee的火灾报警系统 设计人员:程 念 学号:123921036 指导教师: 王 忠 友 2015年4月 目录摘要IABSTRACTII1设计目标12设计内容13设计方案24实验所需器件35实验各模块电路设计35.1 核心板模块35.2 传感器模块46实验设计66.1目的66.2 系统原理图66.3完成实物图97调试与结果107.1核心代码107.2上位机测试128设计总结:(成员作用与体会)139附件1310成绩报告24基于zigbee的火灾报警系统摘要随着经
2、济的发展,高层建筑、地下建筑以及大型综合性建筑日益增多火灾隐患也随之增加,火灾发生的数量及其造成的损失都呈逐年上升趋势,因此,火灾报警系统成为保障人生命财产安全的重要因素。而目前我国的火灾报警系统主要是总线型报警系统,由于外界环境因素的影响不可避免的会存在一定的误报率和漏报率,而且安装和维修成本很高。伴随着ZigBee技术的出现和发展,它使无线型火灾报警系统成为了可能,基于网络化的火灾报警系统具有成本低、安装方便、稳定性高的特点。ZigBee具有短时延和数据传输可靠的独特优势,它更适合于火灾报警系统中。本设计以CC2530为核心控制芯片,采用Z-Stack协议栈作为协议平台组成一个小型的Zig
3、Bee网络,系统由一个协调器设备和一个终端设备组成一个小型网络。终端设备作为传感器节点采集温度、烟雾数据,将终端设备放在室内的不同地方,将采集到的数据无线传输到协调器节点,通过串口将各个传感器节点的信息传输到上位机,上位机用VB编写,完成数据的显示和储存,基本上实现了家庭火灾报警系统所应有的功能。【关键词】 ZigBee 火灾报警 CC2530Z-Stack协议栈 IIABSTRACTWith the development of economy, high-rise buildings, underground structures and increasingly large compre
4、hensive buildings, the fire hazard also will increase, the number of fires and the damage caused by rising trend year by year, as a result, fire alarm system become the important factor of people life and property security. And fire alarm system in our country at present is mainly form alarm system,
5、 because of the influence of the external environment factors, there are inevitably some non-response rates and the rate of false positives, and installation and maintenance cost is very high. Accompanied by the emergence and development of ZigBee technology, it makes no linear fire alarm system, fi
6、re alarm system based on network has characteristics of low cost, easy installation, high stability. ZigBee has the unique advantages of short time delay and data transmission is reliable, it is more suitable for fire alarm system. CC2530 this design as the core control chip, using Z - Stack protoco
7、l Stack as deal platform, forming a small ZigBee network and system consists of a coordinator and a terminal equipment of a small network. Terminal equipment as the data collection temperature, smoke sensor node, terminal equipment in different parts of the interior, the collected data wireless tran
8、smission to the coordinator node, through a serial port to transmit information of each sensor node to PC, PC written in LabVIEW software, complete the data display and storage, basically realized the function of fire alarm system of the family should have.【Keywords】ZigBee , Fire alarm ,CC2530 Z - S
9、tack protocol Stack; II1设计目标本次设计要求能通过zigbee终端节点上火焰传感器采集火警信息,并将采集数据实时发送给协调器,检测是否有火灾发生,并且通过VB上位机显示出来;同时要求学生对CC2530芯片编程和zigbee协议栈有相当程度的理解以及熟练的应用,熟悉ZigBee串口以及中断的使用,会基本的C语言熟练掌握IAR FOR 8051软件的使用与程序下载。2设计内容(1) 利用zigbee核心板,用AD设计好电路板,搭建好硬件环境,调试好火焰传感器;(2) 将火焰传感器作为节点采用广播方式加入到zigbee协调器网络中;(3) 编写并调试程序,并分别下载到协调器和
10、终端节点,并将协调器串口链接到电脑,实现VB上位机显示火警状态,设计完成。开始传感器,串口初始化检测串口受到数据否是保持监听协调器判断传感器状态(是:有火灾 否:无火灾)发往上层2.1系统组成框图3设计方案(1) CC2530芯片做接收信息设备和控制设备。(2) ZigBee终端设备和协调器组网成功通信。(3) 终端设备监测传感器状态,并实时传给协调器。(4) 协调器获取传感器状态,并做出处理,同时VB上位机展示。4实验所需器件(1) 核心板,此处采用CC2530核心板(2) 火焰传感器模块,及各种常用元器件(3) ZigBee核心板和JLINK下载模块及其相关的驱动(4) 杜邦线若干,电池若
11、干(最好是可以充电的)5实验各模块电路设计5.1 核心板模块(1)芯片的选择:CC2530(2)芯片的介绍:*高性能、低功耗的 8051 微控制器内核; *适应 2.4GHz IEEE 802.15.4的RF 收发器; *电源电压范围宽(2.03.6V); *看门狗、电池监视器和温度传感器; *具有 8 路输入 814 位 ADC; *2 个支持多种串行通信协议的 USART, 1 个红外发生电路; *1 个通用的 16 位和 2 个 8 位定时器; 图 5.1.3(4)实物图: 图 传感器模块(1)所用传感器:火焰传感器 (2) 特点:1、 可以检测火焰或者波长在760纳米1
12、100纳米范围内的光源,打火机测试火焰距离为80cm,对火焰越大,测试距离越远2、 探测角度60度左右,对火焰光谱特别灵敏3 、灵敏度可调(图中蓝色数字电位器调节)4、比较器输出,信号干净,波形好,驱动能力强,超过15mA5、配可调精密电位器调节灵敏度6、工作电压3.3V-5V7、输出形式 :数字开关量输出(0和1)8、设有固定螺栓孔,方便安装9、小板PCB尺寸:3.2cm x 1.4cm10、使用宽电压LM393比较器(3传感器使用说明:1 .火焰传感器对火焰最敏感,对普通光也是有反应的,一般用做火焰报警等用途。2. 小板输出接口可以与单片机IO口直接相连,有火灾输出低电平正常输出高电平3.
13、传感器与火焰要保持一定距离,以免高温损坏传感器,对打火机测试火焰距离 为80cm,对火焰越大,测试距离越远 图5.2.3(4)实物图: 图 5.2.46实验设计6.1目的熟悉基于zigbee的控制系统的使用,为今后进一步学习物联网无线传感网打下基础。6.2 系统原理图图6.2.1终端节点原理图图6.2.2 终端节点PCB图6.2.3协调器原理图6.2.4协调器PCB图6.3完成实物图图6.3.1 正视图图6.3.2底面图7调试与结果7.1核心代码7.1.1 初始化部分,串口初始化,登记串口任务号,传感器接口初始化7.1.2 火灾判断部分7.1.3 发送部分7.1.4 接收并串口打印部分7.2上
14、位机测试(1)班级总控界面如下,在程念组里面就可以实时观察火焰传感器状态。图 7.28设计总结:通过这次实践课程,通过亲自动手,从最初确定课题,到画设计PCB,到印刷电路板,到焊接元器件,到测试电路,到调试程序,经过了反复的修改和实践,终于完成课题,一路走来,确实很不易。画PCB,制板,编程,调试等各方面能力都得到了提升.9附件应用层源码:#include OSAL.h#include ZGlobals.h#include AF.h#include aps_groups.h#include ZDApp.h#include SampleApp.h#include SampleAppHw.h#in
15、clude OnBoard.h/* HAL */#include hal_lcd.h#include hal_led.h#include hal_key.h#include MT_UART.h /此处用于串口/定义IO#define LED1 P0_0 /LED提醒#define fire P0_6 /传感器检测口/* * MACROS */* * CONSTANTS */* * TYPEDEFS */* * GLOBAL VARIABLES */ This list should be filled with Application specific Cluster IDs.const cI
16、d_t SampleApp_ClusterListSAMPLEAPP_MAX_CLUSTERS = SAMPLEAPP_PERIODIC_CLUSTERID, SAMPLEAPP_FLASH_CLUSTERID;const SimpleDescriptionFormat_t SampleApp_SimpleDesc = SAMPLEAPP_ENDPOINT, / int Endpoint; SAMPLEAPP_PROFID, / uint16 AppProfId2; SAMPLEAPP_DEVICEID, / uint16 AppDeviceId2; SAMPLEAPP_DEVICE_VERS
17、ION, / int AppDevVer:4; SAMPLEAPP_FLAGS, / int AppFlags:4; SAMPLEAPP_MAX_CLUSTERS, / uint8 AppNumInClusters; (cId_t *)SampleApp_ClusterList, / uint8 *pAppInClusterList; SAMPLEAPP_MAX_CLUSTERS, / uint8 AppNumInClusters; (cId_t *)SampleApp_ClusterList / uint8 *pAppInClusterList;/ This is the Endpoint/
18、Interface description. It is defined here, but/ filled-in in SampleApp_Init(). Another way to go would be to fill/ in the structure here and make it a const (in code space). The/ way its defined in this sample app it is define in RAM.endPointDesc_t SampleApp_epDesc;/* * EXTERNAL VARIABLES */* * EXTE
19、RNAL FUNCTIONS */* * LOCAL VARIABLES */uint8 SampleApp_TaskID; / Task ID for internal task/event processing / This variable will be received when / SampleApp_Init() is called.devStates_t SampleApp_NwkState;uint8 SampleApp_TransID; / This is the unique message ID (counter)afAddrType_t SampleApp_Perio
20、dic_DstAddr;/广播afAddrType_t SampleApp_Flash_DstAddr; /组播afAddrType_t Point_To_Point_DstAddr;/网蜂点对点通信定义aps_Group_t SampleApp_Group;uint8 SampleAppPeriodicCounter = 0;uint8 SampleAppFlashCounter = 0;/* * LOCAL FUNCTIONS */void SampleApp_HandleKeys( uint8 shift, uint8 keys );void SampleApp_MessageMSGCB
21、( afIncomingMSGPacket_t *pckt );void SampleApp_SendPeriodicMessage( void );void SampleApp_SendFlashMessage( uint16 flashTime );void SampleApp_SendPeriodicMessage1( void ); /正常 周期性广播函数声明void SampleApp_SendPeriodicMessage2( void ); /有火灾!/void SampleApp_SendPeriodicMessage3( void ); /void SampleApp_Sen
22、dPeriodicMessage4( void ); /* * NETWORK LAYER CALLBACKS */* * PUBLIC FUNCTIONS */* * fn SampleApp_Init * * brief Initialization function for the Generic App Task. * This is called during initialization and should contain * any application specific initialization (ie. hardware * initialization/setup,
23、 table initialization, power up * notificaiton . ). * * param task_id - the ID assigned by OSAL. This ID should be * used to send messages and set timers. * * return none */void SampleApp_Init( uint8 task_id ) SampleApp_TaskID = task_id;/ task_id is Pointer to location of the Application task ID. Sa
24、mpleApp_NwkState = DEV_INIT; SampleApp_TransID = 0; / This is the unique message ID (counter) MT_UartInit();/串口初始化 MT_UartRegisterTaskID(task_id);/登记任务号 /*火灾探测传感器电路初始化*/ P0SEL &= 0X40; /设置P0.6为普通IO口 P0DIR &= 0X40; / 在P0.6口,设置为输入模式 P0INP &= 0x40; /打开P0.6上拉电阻 / Device hardware initialization can be ad
25、ded here or in main() (Zmain.c). / If the hardware is application specific - add it here. / If the hardware is other parts of the device add it in main(). #if defined ( BUILD_ALL_DEVICES ) / The Demo target is setup to have BUILD_ALL_DEVICES and HOLD_AUTO_START / We are looking at a jumper (defined
26、in SampleAppHw.c) to be jumpered / together - if they are - we will start up a coordinator. Otherwise, / the device will start as a router. if ( readCoordinatorJumper() ) zgDeviceLogicalType = ZG_DEVICETYPE_COORDINATOR; else zgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;#endif / BUILD_ALL_DEVICES#if de
27、fined ( HOLD_AUTO_START ) / HOLD_AUTO_START is a compile option that will surpress ZDApp / from starting the device and wait for the application to / start the device. ZDOInitDevice(0);#endif / Setup for the periodic messages destination address / Broadcast to everyone 广播参数配置 SampleApp_Periodic_DstA
28、ddr.addrMode = (afAddrMode_t)AddrBroadcast; SampleApp_Periodic_DstAddr.endPoint = SAMPLEAPP_ENDPOINT; SampleApp_Periodic_DstAddr.addr.shortAddr = 0xFFFF; /*0xFFFF数据包将被传送到网络上的所有设备, 包括睡眠中的设备。对于睡眠中的设备,数据包将被保留在其父亲节点直到查询 到它,或者消息超时。 0xFFFD数据包将被传送到网络上的所有在空闲时 打开接收的设备(RXONWHENIDLE),也就是说,除了睡眠中的所有设备。 0xFFFC数据包
29、发送给所有的路由器,包括协调器。*/ / Setup for the flash commands destination address - Group 1 组播 SampleApp_Flash_DstAddr.addrMode = (afAddrMode_t)afAddrGroup; SampleApp_Flash_DstAddr.endPoint = SAMPLEAPP_ENDPOINT; SampleApp_Flash_DstAddr.addr.shortAddr = SAMPLEAPP_FLASH_GROUP; / Fill out the endpoint description.
30、 SampleApp_epDesc.endPoint = SAMPLEAPP_ENDPOINT; SampleApp_epDesc.task_id = &SampleApp_TaskID; SampleApp_epDesc.simpleDesc = (SimpleDescriptionFormat_t *)&SampleApp_SimpleDesc; SampleApp_epDesc.latencyReq = noLatencyReqs; / Register the endpoint description with the AF afRegister( &SampleApp_epDesc
31、); / Register for all key events - This app will handle all key events RegisterForKeys( SampleApp_TaskID ); / By default, all devices start out in Group 1 SampleApp_Group.ID = 0x0001; osal_memcpy( SampleApp_G, Group 1, 7 ); aps_AddGroup( SAMPLEAPP_ENDPOINT, &SampleApp_Group );#if defined (
32、LCD_SUPPORTED ) HalLcdWriteString( SampleApp, HAL_LCD_LINE_1 );#endif/* * fn SampleApp_ProcessEvent * * brief Generic Application Task event processor. This function * is called to process all events for the task. Events * include timers, messages and any other user defined events. * * param task_id
33、 - The OSAL assigned task ID. * param events - events to process. This is a bit map and can * contain more than one event. * * return none */uint16 SampleApp_ProcessEvent( uint8 task_id, uint16 events ) afIncomingMSGPacket_t *MSGpkt; (void)task_id; / Intentionally unreferenced parameter if ( events
34、& SYS_EVENT_MSG ) MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( SampleApp_TaskID ); while ( MSGpkt ) switch ( MSGpkt-hdr.event ) / Received when a key is pressed case KEY_CHANGE:/按键触发事件 SampleApp_HandleKeys( (keyChange_t *)MSGpkt)-state, (keyChange_t *)MSGpkt)-keys ); break; / Received when a
35、messages is received (OTA) for this endpoint case AF_INCOMING_MSG_CMD:/接收数据事件 SampleApp_MessageMSGCB( MSGpkt ); break; / Received whenever the device changes state in the network case ZDO_STATE_CHANGE:/设备状态变化事件 SampleApp_NwkState = (devStates_t)(MSGpkt-hdr.status); if ( (SampleApp_NwkState = DEV_ZB_
36、COORD)| /协调器、路由器 (SampleApp_NwkState = DEV_ROUTER) /或者终端都执行 | (SampleApp_NwkState = DEV_END_DEVICE) ) / Start sending the periodic message in a regular interval. osal_start_timerEx( SampleApp_TaskID, SAMPLEAPP_SEND_PERIODIC_MSG_EVT, SAMPLEAPP_SEND_PERIODIC_MSG_TIMEOUT ); else / Device is no longer i
37、n the network break; default: break; / Release the memory释放Flash osal_msg_deallocate( (uint8 *)MSGpkt ); / Next - if one is available MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( SampleApp_TaskID ); / return unprocessed events return (events SYS_EVENT_MSG); / Send a message out - This event i
38、s generated by a timer / (setup in SampleApp_Init(). if ( events & SAMPLEAPP_SEND_PERIODIC_MSG_EVT ) /周期性发送函数 if(fire=1) SampleApp_SendPeriodicMessage1(); /正常,无火灾 else if(fire=0) SampleApp_SendPeriodicMessage2(); /有火灾! / Send the periodic message / SampleApp_SendPeriodicMessage(); / Setup to send me
39、ssage again in normal period (+ a little jitter) osal_start_timerEx( SampleApp_TaskID, SAMPLEAPP_SEND_PERIODIC_MSG_EVT, (SAMPLEAPP_SEND_PERIODIC_MSG_TIMEOUT + (osal_rand() & 0x00FF) ); / return unprocessed events return (events SAMPLEAPP_SEND_PERIODIC_MSG_EVT); / Discard unknown events return 0;/* *
40、 Event Generation Functions */* * fn SampleApp_HandleKeys * * brief Handles all key events for this device. * * param shift - true if in shift/alt. * param keys - bit field for key events. Valid entries: * HAL_KEY_SW_2 * HAL_KEY_SW_1 * * return none */void SampleApp_HandleKeys( uint8 shift, uint8 ke
41、ys ) (void)shift; / Intentionally unreferenced parameter if ( keys & HAL_KEY_SW_1 ) /* This key sends the Flash Command is sent to Group 1. * This device will not receive the Flash Command from this * device (even if it belongs to group 1). */ SampleApp_SendFlashMessage( SAMPLEAPP_FLASH_DURATION );/
42、向flash发送数据 if ( keys & HAL_KEY_SW_2 ) /* The Flashr Command is sent to Group 1. * This key toggles this device in and out of group 1. * If this device doesnt belong to group 1, this application * will not receive the Flash command sent to group 1. */ aps_Group_t *grp; grp = aps_FindGroup( SAMPLEAPP_
43、ENDPOINT, SAMPLEAPP_FLASH_GROUP ); if ( grp ) / Remove from the group aps_RemoveGroup( SAMPLEAPP_ENDPOINT, SAMPLEAPP_FLASH_GROUP ); else / Add to the flash group aps_AddGroup( SAMPLEAPP_ENDPOINT, &SampleApp_Group ); /* * LOCAL FUNCTIONS */* * fn SampleApp_MessageMSGCB * * brief Data message processo
44、r callback. This function processes * any incoming data - probably from other devices. So, based * on cluster ID, perform the intended action. * * param none * * return none */void SampleApp_MessageMSGCB( afIncomingMSGPacket_t *pkt )/接收一个信息包 uint16 flashTime; switch ( pkt-clusterId ) case SAMPLEAPP_CHENGNIAN_ID:/默认接收接收ID为自定义广播传输编号 / HalUARTWrite(0,Welcome to the Fir
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 酒店大堂的安保措施介绍
- 旅游科普服务合同
- 艺术涂料施工协议
- 市政环卫洒水车租赁合同
- 退休硬件工程师维护合同
- 租赁GPS车辆安全监控系统合同
- 临时检验员聘用合同模板
- 城市规划光纤铺设合同
- 古董家具修复喷漆协议
- 空调维修工程师聘用合同年薪制
- 2.1 充分发挥市场在资源配置中的决定性作用(课件) 2024-2025学年高中政治 必修2 经济与社会
- 外立面改造项目脚手架施工专项方案
- ASTMD638-03中文版塑料拉伸性能测定方法
- 统编版(2024新版)七年级上册道德与法治期中模拟试卷(含答案)
- 砌筑实训课程设计
- 译林版(2024新版)七年级上册英语期中复习:完型及阅读 练习题汇编(含答案)
- 保安人员配置方案
- 食材配送实施方案(适用于学校、医院、酒店、企事业单位食堂等食材采购)投标方案(技术方案)
- 期中练习(试题)-2024-2025学年人教PEP版英语六年级上册
- 2024-2025学年五年级科学上册第二单元《地球表面的变化》测试卷(教科版)
- 学校厨房设备投标方案(技术标)
评论
0/150
提交评论