+ All Categories
Home > Documents > Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic...

Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic...

Date post: 09-Jul-2020
Category:
Upload: others
View: 6 times
Download: 0 times
Share this document with a friend
27
Networking with Zigbee and Emergent Behavior 5XID0, Week 2
Transcript
Page 1: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

Networking with Zigbeeand Emergent Behavior

5XID0, Week 2

Page 2: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

ZigBee

• Communication standard for Sensor Networks• Based on the IEEE 802.15.4 standard • Developed by the ZigBee Alliance, www.zigbee.org

Page 3: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

– “the software” – Network, Security &

Application layers– Brand management

IEEE 802.15.4– “the hardware” – Physical & Media Access

Control layers

IEEE 802.15.4 & ZigBee In Context

PHY868MHz / 915MHz / 2.4GHz

MAC

NetworkStar / Mesh / Cluster-Tree

Security32- / 64- / 128-bit encryption

Application

API

ZigBeeAlliance

IEEE 802.15.4

Customer

Silicon Stack App

Source: http://www.zigbee.org/resources/documents/IWAS_presentation_Mar04_Designing_with_802154_and_zigbee.ppt

Page 4: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

IEEE 802 wireless protocols

Source: http://www.zigbee.org/en/resources/

Page 5: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

IEEE 802.15.4

• PHY (pysical layer): 2.4GHz radio• MAC: CSMA Carrier Sense Multiple Acces

Page 6: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

ZigBee

The protool coordinates:• Topologies

– Star– Cluster Tree– Mesh

• Network coordinator, routers, end devices

• Security• Application

http://en.wikipedia.org/wiki/IEEE_802.15.4-2006

Page 7: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

Your Robots

• Have a Zigbee module of Maxstream / Digi (Xbee)• Serial link to Arduino board / Atmel processor• Tranparant mode works as a serial link• API modes, ‘manual’ sending data packetspast experience: harder to work with, serial mode is easier

• PAN , multiple independent networks in the same area• Channel determines which frequency channel is used• Broadcast or send to specific target• Assume that data will get lost and possibly corrupted! Redundancy, error detection / correction

Page 8: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

Your Robots

• The bad news:at the end of this week you may think“Xbee just doesn’t work…”

• The good news:at the end of the course you will think“Xbee works quite well and is easy to use. Hard to understand why we had so manyproblems in the beginning …”

Page 9: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

Important Note

• Each team must use its own PAN ID.Use for Team n:

#define PAN_ID "A00n"

• Preferably also use your own channel (0B‐1A), for instance: Team 1: 0B, Team 2: 10.

• Note that the code examples need to beadapted for that!

Page 10: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

Zigbee Configuration

• PAN ID  0000‐FFFF  (0‐65535)• Channel ID   0B‐1A (11‐26)• MY ID 0000‐FFFF (0‐65535)• Destination address

– 0x0000FFFF is broadcast

Page 11: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

X‐CTU

• Simple tool for Xbee module• Configure Zigbee module connected to dongle• Terminal for input and output of serial data• Serial parameters: set baud rate to 57600 baud, rest standaard

Page 12: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

Note

• Robot has two serial connections, USB andXbee

• Arduino has only one serial interface• Switch on the robot switches Xbee on/off.• Wrong setting may lead to problems withwireless communication and/or programming of the Arduino

Page 13: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

Code example: xbee_bcast

• Ropbot broadcast its own ID with a sequencenumber on the Zigbee channel

• Can be received by the laptop with Xbeedongle and X‐CTU terminal

• Multiple robots can do this simultaneously• Note that the defined constant ADMOVEO_SELF needs to be adapted in the code for each Admoveo / Arduino

Page 14: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

Code example: xbee_xbcast

• Robot sends its own ID with a sequencenumber on the Zigbee channel to otherrobots. LED lights on reception of messagesfrom other robots

• Change the constant ADMOVEO_SELF, ADMOVEO_OTHER_A andADMOVEO_OTHER_B in the code for eachrobot

Page 15: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

Dynamic configuration of XBee

xbee_init(void){    Serial.begin(9600); delay(1000);Serial.print("+++");delay(1000);Serial.print("ATCH " CHANNEL_ID "\r");Serial.print("ATID " PAN_ID "\r");Serial.print("ATMY " TOSTRING(ADMOVEO_SELF) "\r");Serial.print("ATDH 0000\rATDL FFFF\r");Serial.print("ATBD 3\r");  // set baud rate to 9600Serial.print("ATCN\r");     // exit command mode

Page 16: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

Assignment

• Make a Zigbee netwerk with three robotsYou may monitor Zigbee communication on the laptop, but not communicate from the laptop to the robots

• Use the same software for each robot(Possibly with exception of changing the robot ID)

Page 17: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

Assignment• Three robots move around randomly• Both robots are programmed with the same software, except for one line:

#define ADMOVEO_SELF     27(you are allowed to send the ID across the network, but not to execute different pieces of code)

• At the start one of your robots should light its LED and the others shouldnot

• Whenever the robots meets another of your robots it should ‘transfer the light’ to the other robot. The other robot should now become the onlyone of your robots to have its LED lit.

• Visualise the ongoing transfer of the light during 3 seconds, for instance byflshing the LEDs

• The playing field is outlined by white tape on the floor that may not becrossed.

• (We may also test it by placing all 6 robots, of both teams, in the field.)

Page 18: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

Oefeningen

• Robust communication with Xbee– Prevent buffer overflowscheck for new data regularly; do not send too frequently

– Anticipate data loss and data corruption– Use short messages

• Robust protocolswhat happens if something does fail? Will your system recover or fail forever?

Page 19: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

Project web page

• Instructions on using XBee• Some experiences met Xbee• Maual “How to restore a bricked XBee”• Example code• Advice from previous year students: advice from last year:operate at baud rate 9600 instead of 57k6

Page 20: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

Emergent Behaviour

Page 21: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

Emergent behaviour

• http://www.youtube.com/watch?v=Suugn‐p5C1M

• http://www.youtube.com/watch?v=RjrEQaG5jPM

Page 22: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

flocking

• http://www.youtube.com/watch?v=qJjeHLcbQJ0

Page 23: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

ant colonies

• http://www.youtube.com/watch?v=GtRNBHM3DR0

• http://www.youtube.com/watch?v=ozkBd2p2piU

Page 24: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

Conway’s game of life

• Artificial emergent behavior• http://www.youtube.com/watch?v=XcuBvj0pw‐E

Page 25: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

Mathematical, fractals

Page 26: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

In the football stadium

• Clappen synchronouslyWho’s in charge?What do we really do to synchronise?

• Wave in a football stadiumSpeed of the wave turns out to be verypredictable

Page 27: Networking with Zigbee and Emergent Behavior · X‐CTU •Simple tool for Xbee module ... Dynamic configurationof XBee xbee_init ... • Both robots are programmedwiththe same software,

Assignment

• Cooperative between both teams• Make robots follow each other in a line.• Without colliding• Think about simple and robust rules that mayrealise this behavior

• Test together early and see i you can teak andimprove the rules

• No Zigbee communication is allowed in thisassignment

• All robots of a team use the same software


Recommended