[Zigbee] 奥特曼Zigbee读书日记(一)

吸铁石上   2010-4-15 22:10 楼主
[导言]
  本人做过几年单片机的开发工作,主要用的是8051内核的和瑞萨740系列的,在这个ARM大行其道的时代,也曾经试着接触过,不过很容易在复杂的内核中迷失了自己~~~一直对这种能全局掌控的小系统痴迷,一个国外朋友无意间提到Zigbee这种技术,从百度百科开始了解,然后疯狂搜集资料,对这种技术甚是感兴趣,加上最近媒体对“物联网”的吹捧,终于坐不住了,买书,买开发板,动工啦~~~~

  此笔记将从零开始,记录本人的学习过程里遇到的问题及答案,希望对大家能有所帮助,也希望得到高手的指点。

[问题记录]
1. 买开发板之前的先略去不写了,以后有空补上。第一个问题就是开发板到手了,从哪开始?
  毕竟对单片机有些了解,基础实验只是大概跑了下看了看结果,心里大概对开发板的外设有个底。然后进入最关键的通信部分,不知道有没有“大跃进”了,后面如果学起来有难度,再把课补上。下载了“数据传输实验”的程序到开发板,看了下运行结果,然后下一步就是读程序,看下这个结果是如何产生的?

2. 用source insight如何阅读IAR的项目源码?
   答案见本版“如何用source insight编辑IAR项目源码?”及“IAR的workspace文件组织”

3. 多年来学习单片机的习惯,从"main"函数开始,但是"main"在哪里?
..\Projects\zstack\ZMain\TI2430DB\ZMain.c

4. "ROOT"是什么意思?
以下是“8051 IAR Assembler”中对此的解释:
NOROOT, ROOT
NOROOT means that the segment part may be discarded by the linker
if no symbols in this segment part are referred to. Normally all
segment parts except startup code and interrupt vectors should set this
flag. The default mode is ROOT which indicates that the segment part
must not be discarded.
简单翻译下:
NOROOT表示如果此部分代码从来没有被调用到,那么这部分代码会被linker抛弃。一般来讲,除了startup和中断的代码都应该设为NOROOT。默认的模式为ROOT,即linker不会抛弃。
--by outman from zigbeetech 2010.4.7

5. 到底学习zigbee应该从哪开始?
  走马观花地看过一本入门书,本以为买了开发板,调试一下里面的通信程序就能快速入门了。昨天看了一天的程序才发现这种想法太急功近利了,有句古话怎么讲来着--“欲速则不达”,古人的话还是有道理的,于是决定调整思路,放平心态。但是到底从哪开始呢?国内Zigbee方面的书寥寥无几,大多数又总感觉有种功利色彩。罢了,读英文的吧(借机感谢下我大学良师albert,亏着他当时的提点,现在读英文书还不算吃力)。近期准备从两个地方下手,一个是TI的Zstack手册,另外一个是国外的朋友推荐的一本叫Newnes.ZigBee.Wireless.Networks.and.Transceivers的电子书,不想读电子版的,只是在深圳的书店还没找到。这是一本360多页的大部头,个人比较欣赏国外这种风格的书,往往深入浅出,让一个没太有基础的人也容易读得懂,不用搞一大堆书去看同一个东西。国内的大部头也不少,但很多感觉像我小时候写作文的风格--扯远了,抓紧时间吧~~~
--by outman from zigbeetech  2010.4.8

6. cc2430后面的的DB,BB,EB代表什么意思?
BB: Battery Board
DB: Development Board
EB: Evaluation Board
分别对应TI公司开发的三种板型,其功能按上顺序依次变强。可以参看"Z-Stack User's Guide for CC2430"的图片,以获得直观认识(具体位置在:开始==》程序==》Texas Instruments ==》ZStack-1.4.3-1.2.1)
--by outman 2010.4.8
                    


         


               



7. Coordinator, Router与End Device有什么区别?
好本与烂书的区别在于,好书在开头的时候就知道你在想什么,而烂书呢,到读到最后你也不知道他在想什么。。。
这个问题的答案在那本英文“大部头”的前面章节:
1.7 Device Types
There are two types of devices in an IEEE 802.15.4 wireless network: full-function devices (FFDs) and reduced-function devices (RFDs). An FFD is capable of performing all the duties described in the IEEE 802.15.4 standard and can accept any role in the network. An RFD, on the other hand, has limited capabilities. For example, an FFD can communicate with any other device in a network, but an RFD can talk only with an FFD device. RFD devices are intended for very simple applications such as turning on or off a switch. The processing power and memory size of RFD devices are normally less than those of FFD devices.

1.8 Device Roles
In an IEEE 802.15.4 network, an FFD device can take three different roles: coordinator, PAN coordinator, and device. A coordinator is an FFD device that is capable of relaying messages. If the coordinator is also the principal controller of a personal area network (PAN), it is called a PAN coordinator . If a device is not acting as a coordinator, it is simply called a device .

The ZigBee standard uses slightly different terminology (see Figure 1.5 ). A ZigBee coordinator is an IEEE 802.15.4 PAN coordinator. A ZigBee router is a device that can act as an IEEE 802.15.4 coordinator. Finally, a ZigBee end device is a device that is neither a coordinator nor a router. A ZigBee end device has the least memory size and fewest processing capabilities and features. An end device is normally the least expensive device in the network.
   



咦,那位同学举手干吗?~~~什么?翻译一下?唉,都说了让你上学的时候读好英文的~~~
那好吧,不过俺也是非专业水平,写得不好别扔砖啊。。。。

1.7 设备类型
IEEE 802.15.4无线网络协议中定义了两种设备:全功能设备(FFDs)和半功能设备(RFDs)。FFD可以执行IEEE 802.15.4标准中的所有功能,并且可以在网络中扮演任何角色,那反过来讲,RFD就有功能限制啦。比如FFD能与网络中的任何设备“说话”,而RFD就只能和FFD“私聊”啦。RFD设备的用途是为了做一些简单功能的应用,比如做个开关之类的。而其功耗与内存大小都比FFD要小很多。

1.8 设备角色
IEEE 802.15.4网络中,一个FFD可以扮演三个角色-协调器(Coordinator)、PAN协调器(PAN coordinator)和设备(device),其中协调器是一个全功能设备(FFD),它可以在网络中传递信息(做传话筒)。如果一个协调器在一个PAN(personal area network,个人区域网络)网络中做主控制器(老大的位置呃),那我们把它叫做PAN协调器。除此之外,就不用多说啦,就叫设备(你我一样的平头百姓)

Zigbee协议中的定义与IEEE 802.15.4的定义大同小异,Zigbee中的“Coordinator”是IEEE 802.15.4中的“PAN Coordinator";Zigbee中的“router”就是IEEE 802.15.4中的“Coordinator”,而“end device”就是指上面的平头百姓“device”啦。。。end device的内存、处理能力及功能都是最小的,当然也是网络中最便宜的了--这不是说我吗~~~
--by outman from zigbeetech  2010.4.8

回复评论 (9)

8. 网络拓扑结构这算是个问题吗?星形、网形、树形。。。很多人是不是能脱口而出?对于俺们这些非网络专家又对这个有点了解的人来说,脑子里好像总有那么点印象,又有点模糊。“学问来不得半点虚假”,这是谁说的来?我们可是要做网络专家的人哪,来一起把它弄清楚吧。。。上“葵花宝典”第一式第9节(“大部头”有新名字了,这本书写得真不错,免费打个广告~~)再扯一句,这个世界本来没有规则,规则都是上级定的~End device==>Router==>Coordinator==>人==>?言归正传:网络结构是由zigbee网络层来管理的,它必须是IEEE 802.15.4中规定的两种(知道谁是上级了~)--星形和点对点形(这个名字怎么没太听过。。。)图1.6所示的星形结构中,每个节点都只能和PAN Coordinator(以后这种名字都不叫中文了,作为一个程序员见得多的其实是英文)通讯。一个典型的星形网络构建过程是这样的:一个被注入PAN coordinator程序(软件)的FFD(硬件)开始工作后,开始着手构建网络,他要做的第一件事就是要在他无线电波所覆盖到的空间区域内,先选择一个唯一的PAN网络标识号--他也有上级啊,不能乱搞~~,这个标识号一定要是附近其他网络没用到的。在图1.7所示的“点对点”形的拓扑结构中,任意两个节点只要靠得足够近,都可以建立连接并通讯。在点对点形的网络结构中,任何FFD都可以扮演PAN coordinator的角色,大家都是老大?那到底谁是真正的老大呢?那就看谁是这个网络的创史人了--谁第一个建的这个网络,谁就是老大!在点对点网络中,所有担任“传话筒”的设备都是FFD,因为RFD没有这个功能(被阉割了嘛~),但RFD也可以作为网络的一员,他只能和指定设备(coordinator或者 router)通讯。一个“点对点”的网络可以通过限制设备的一些功能,实现不同“形状”的网络。如果完全没有限制,那就是一个“网状”拓扑,另外一种是图1.8所示的“树状”拓扑,在这种结构中,Zigbee coordinator搭建了原始网络,router形成了树枝进行信息传递(传话筒),end device就是最后的树叶了,不能往下级传递信息了(它本来就是最下级嘛)。而router可以扩展coordinator所搭建的网络。图1.8也展示了router是如何扩展网络,甚至如何绕过障碍物的。比如A想和B说话,但是中间有墙挡的,信号强度又穿透不了,这个时候树形的网络结构就可以通过其它router传递信息,并最终到达B。我们有时把这种方式叫“多次反射”(multihopping),因为信息从一个节点反射到另外一个节点,最终到达目的地。这样就扩大了整个网络的信息覆盖面。在一个IEEE 802.15.4网络中,无论是哪种拓扑结构,网络总是由PAN coordinator来创建,PAN coordinator控制整个网络,并至少完成以下任务:
●给本网络中每个设备指定一个16位或者64位的地址
●通过网络发起、结束和传递信息
●为本网络选定唯一的PAN网络标识号,这个标识号允许本网络内的设备使用16位的短地址方式,并且可以与其他的独立网络进行通讯在整个网络中,只有一个PAN coordinator,所以PAN coordinator往往需要长时间在工作状态,所以它常需要连接稳压电源,而不是电池。但其他设备往往都是用电池来供电的,一个最小的网络包括两个设备,一个PAN coordinator与一个device.-- by outman 2010.4.8 from zigbeetech

附英文原文:1.9 ZigBee Networking TopologiesThe network formation is managed by the ZigBee networking layer. The network must be in one of two networking topologies specified in IEEE 802.15.4: star and peer-to-peer. In the star topology , shown in Figure 1.6 , every device in the network can communicate only with the PAN coordinator. A typical scenario in a star network formation is that an FFD, programmed to be a PAN coordinator, is activated and starts establishing its network. The first thing this PAN coordinator does is select a unique PAN identifier that is not used by any other network in its radio sphere of influence —the region around the device in which its radio can successfully communicate with other radios. In other words, it ensures that the PAN identifier is not used by any other nearby network.In a peer-to-peer topology (see Figure 1.7 ), each device can communicate directly with any other device if the devices are placed close enough together to establish a successful communication link. Any FFD in a peer-to-peer network can play the role of the PAN coordinator. One way to decide which device will be the PAN coordinator is to pick the first FFD device that starts communicating as the PAN coordinator. In a peer-to-peer network, all the devices that participate in relaying the messages are FFDs because RFDs are not capable of relaying the messages. However, an RFD can be part of the network and communicate only with one particular device (a coordinator or a router) in the network.                    

A peer-to-peer network can take different shapes by defining restrictions on the devices that can communicate with each other. If there is no restriction, the peer-to-peer network is known as a mesh topology . Another form of peer-to-peer network ZigBee supports is a treetopology (see Figure 1.8 ). In this case, a ZigBee coordinator (PAN coordinator) establishes the initial network. ZigBee routers form the branches and relay the messages. ZigBee end devices act as leaves of the tree and do not participate in message routing. ZigBee routerscan grow the network beyond the initial network established by the ZigBee coordinator.Figure 1.8 also shows an example of how relaying a message can help extend the range of the network and even go around barriers. For example, device A needs to send a message to device B, but there is a barrier between them that is hard for the signal to penetrate. The tree topology helps by relaying the message around the barrier and reach device B. This is sometimes referred to as multihopping because a message hops from one node to another until it reaches its destination. This higher coverage comes at the expense of potential high message latency.An IEEE 802.15.4 network, regardless of its topology, is always created by a PAN coordinator. The PAN coordinator controls the network and performs the following minimum duties:
● Allocate a unique address (16-bit or 64-bit) to each device in the network.
● Initiate, terminate, and route the messages throughout the network.
● Select a unique PAN identifier for the network. This PAN identifier allows the devices within a network to use the 16-bit short-addressing method and still be able to communicate with other devices across independent networks.There is only one PAN coordinator in the entire network. A PAN coordinator may need to have long active periods; therefore, it is usually connected to a main supply rather than a battery. All other devices are normally battery powered. The smallest possible network includes two devices: a PAN coordinator and a device.
点赞  2010-4-15 22:10
哈哈,楼主写得不错,收益了!!
点赞  2010-4-16 11:31
谢谢楼主分享
点赞  2011-1-17 11:25
求楼主指教一二,本人初学者,要做cc2430数据采集系统,不知道终端发送到协调器代码怎么写,求指教。。。。QQ601765796,不胜感激
点赞  2011-5-23 09:47
嗯,不错
点赞  2011-5-26 16:38
谢谢分享 ,又学到知识了
点赞  2011-6-21 21:51
楼主的讲解很仔细,连我这样的完全小白都能看懂。
点赞  2012-2-15 19:30
最喜欢这样的解说了,狂赞盼继续!
点赞  2013-1-10 10:12
楼主,我想请教您一下关于网络拓扑的知识,如何设置一个网络的网络拓扑结构?比如我想设置我的网络拓扑结构为树型,该怎么设置?
点赞  2014-4-2 11:09
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复