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

Post on 09-Jul-2020

6 views 0 download

transcript

Networking with Zigbeeand Emergent Behavior

5XID0, Week 2

ZigBee

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

– “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

IEEE 802 wireless protocols

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

IEEE 802.15.4

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

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

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

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 …”

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!

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

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

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

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

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

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

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)

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.)

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?

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

Emergent Behaviour

Emergent behaviour

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

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

flocking

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

ant colonies

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

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

Conway’s game of life

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

Mathematical, fractals

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

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