XBeeについて
趣味と仕事でXBeeを扱ったので
備忘録を書いておく。
XBeeはDigi社が開発/販売している製品
ZigBeeは通信規格(プロトコル)
ZigBeeをOSI構造で表記すると以下のようになる。ZigBeeは物理層とデータリンク層に相当する部分はIEEE802.15.4を採用しており、それより上位のレイヤーにZigBeeプロトコルが在る。通常、XBeeを取り扱っている限りにおいては、アプリケーション層以外のインタフェースは意識しなくても取り扱えるよう設計されている。
| No |
OSI |
WiFi |
ZigBee |
| 7 |
Application |
Any |
Any |
| 6 |
Presentation |
Any |
Application support layer(ZigBee) |
| 5 |
Session |
Any |
Application support layer(ZigBee) |
| 4 |
Transport |
TCP |
Network Layer(ZigBee) |
| 3 |
Network |
IP routing |
Network Layer(ZigBee) |
| 2 |
Data link |
WiFi802.11 |
802.15.4 |
| 1 |
Physical |
WiFi802.11 |
802.15.4 |
XBeeの設定項目
よく設定項目がなんなのかわからなくなるのでメモ。
COかRTかEDによっては、設定できたりなくなったりするので注意。
Networking
| 略称 |
名称 |
説明 |
| ID |
PAN ID |
TCP/IPでいえばサブネットマスクみたいな?同じ番号のもの同士しか通信できない |
| SC |
Scan Channels |
使用する周波数帯域 |
| SD |
Scan Duration |
Duration of the active scan and energy scan during coordinator initialization.Scan Time=SC*(2^SD)*15.36ms. (SC=# channels) |
| ZS |
ZigBee Stack Profile |
よくわからないけど、0でOK |
| NJ |
Node Join Time |
×1sec |
Addressing
| 略称 |
名称 |
説明 |
| DH |
Destination Address High |
親機なら0でOK、子機なら親機のアドレスを設定する |
| DL |
Destination Address Low |
|
| NI |
Node Identifier |
ASCIIで好きな名前を入力できる.識別する時に便利 |
| NH |
Maximum Hops |
最大ホップ数、デフォ値は0x1E |
| BH |
Broadcast Radius |
0はどこまででもの意味 |
| AR |
Many-to-one Route Broadcast Time |
×10sec |
| DD |
Device Type Identifier |
|
| NT |
Node Discovery Backoff |
3C=6000msec,This sets the maximum delay for Node Discovery responses to be sent.×100msec |
| NO |
Node Discovery Options |
よくわからないけど、0でOK |
| CR |
PAN Conflict Threshold |
Set/read threshold for the number of PAN id conflict reports that must be received by the network manager within one minute to trigger a PAN id change. |
RF Interfacing
XBeeが出力する電波強度を調整できる。通常は一番強くてOK。干渉やら狭いエリアでネットワークを組みたい場合などに使用する。
| 略称 |
名称 |
説明 |
| PL |
Power Level |
4:Highest~0:Lowest |
| PM |
Power Mode |
1:Boost Mode Enabled,0:Disabled |
Security
| 略称 |
名称 |
説明 |
| EE |
Encryption Enable |
よくわからない |
| EO |
Encryption Options |
よくわからない |
Serial Interfacing
| 略称 |
名称 |
説明 |
| BD |
Baud Rate |
通信速度 3:9600,5:38400,7:115200 |
| NB |
Parity |
パリティ |
| SB |
Stop Bits |
ストップビット |
| D7 |
DIO7 Configuration |
|
| D6 |
DIO6 Configuration |
|
| AP |
API Enable |
1:Enables API mode 通常は1でOK、バイトスタッフィングしたい場合は2にする.2にするとヘッダ以外の0x7Eが置換される. |
| AO |
API Output Mode |
0: Native,1:Ecplicit,3 - Same as 1, plus received ZDO requests are passed out the UART.よくわからないが、通常のパケットが0だと0x92フレーム、1だとt0x91フレームになる |
Sleep Modes
| 略称 |
名称 |
説明 |
| SM |
Sleep Mode |
0:No Sleep, 4:CYCLIC SLEEP RTは0が選べる。EDは選べない(EDは必ずSleepする)。 |
| SP |
Cyclic Sleep Period |
0x20(320msec)~0xAF0(28sec)Set SP on parent (Coordinator or Router) to match the largest SP of its end device children. On a router or coordinator, SP determines the transmission timeout when sending to a sleeping end device. SP also determines how long the parent will buffer a message for a sleeping child.この項目だけで設定できる最長スリープは28秒 |
| SN |
Number of Cyclic Sleep Period |
Set/read the number of cyclic sleep periods used to calculate end device poll timeout. If an end device does not send a poll request to its parent coordinator or router within the poll timeout, the end device is removed from the child table. The poll timeout is calculated in milliseconds as (3 * SN * (SP * 10ms)), minimum of 5 seconds. i.e. if SN=15, SP=0x64, the timeout is 45 seconds. |
| SO |
Sleep Options |
Bitfield options include: 0x02 - Wake for ST time on each cyclic wake (after sleeping for SN sleep periods), 0x04 - Enable extended cyclic sleep (sleep for entire SN*SP time - possible data loss). All other option bits should be set to 0. |
| ST |
Time before Sleep |
time period of inactivity (no serial or RF data is sent or received) before activating Sleep Mode. The ST parameter is used only with Cyclic Sleep settings (SM=4-5).スリープから復帰後の起きている時間の設定。短過ぎると通信できないので注意。 |
I/O Settings
面倒なので省略
RTとかで、I/Oサンプリングを行うには、IR設定を0から0x1F5などとする。
XBeeエクスプローラーについて
XBeeのファームウェア(上記の設定)を書き込むのに必要なデバイス。市販品もあるし自作することも可能。
ただし、必ずリセットスイッチありのものを買うべき(か作るべき)。
おすすめ品
XBeeのペリフェラルについて
XBee単体のペリフェラルは、UARTx1 / ADCx4 / DIOx5になる。
ADCも入力範囲が狭く0~1.2V
DIOも+3V入出力(+5Vトレラントではない!注意)
UARTも最速は115200bpsまで、しかも一度に送れるデータ量は実効上40Byteくらいまで。
XBeeのペリフェラルはかなり貧弱といわざるを得ない。
よく雑誌で「XBeeだけでセンサデータ取得!」という見出しがあるけれど、これは嘘だなと思う。
実際のセンサは、SPI/I2Cが多いのでマイコンを導入する必要があるし、
電圧出力型のセンサであれば、1.2Vの範囲に納まるようにOPアンプ(分圧抵抗?)が必要になる。
(回路規模が大きくなる。
ちなみに、裏技的にXBeeのDIOだけで
I2Cを行う方法もある。
が、非常にCLKが遅くなるので1サンプリングデータの取得に数分を要することになる。
XBee+センサだけの構成にできれば非常に回路規模を簡単化できて良いのだが、実用性は低い。温度とかが精々。
XBee+マイコン+センサの構成が一番実用性が高い構成といえそう。XBeeは単純に通信機として扱う。
XBeeのFAQ
- XBeeのネットワーク層以下のパケットを見るには?
通常のUSBエクスプローラー接続では不可能。
Sniffer製品を利用するとパケットをモニタリングすることができる。
XCTUを利用する。
XCTUを利用する。
XCTUを利用する。
最終更新:2016年04月09日 00:13