Networking with Zigbee and Emergent Behavior 5XID0, Week 2 ZigBee - - PowerPoint PPT Presentation
Networking with Zigbee and Emergent Behavior 5XID0, Week 2 ZigBee - - PowerPoint PPT Presentation
Networking with Zigbee and 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 IEEE 802.15.4 & ZigBee In Context
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
PHY
868MHz / 915MHz / 2.4GHz
MAC Network
Star / Mesh / Cluster-Tree
Security
32- / 64- / 128-bit encryption
Application API
ZigBee Alliance 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 packets
past 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 many problems 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 be
adapted 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 and
Xbee
- Arduino has only one serial interface
- Switch on the robot switches Xbee on/off.
- Wrong setting may lead to problems with
wireless communication and/or programming of the Arduino
Code example: xbee_bcast
- Ropbot broadcast its own ID with a sequence
number on the Zigbee channel
- Can be received by the laptop with Xbee
dongle 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 sequence
number on the Zigbee channel to other
- robots. LED lights on reception of messages
from other robots
- Change the constant ADMOVEO_SELF,
ADMOVEO_OTHER_A and ADMOVEO_OTHER_B in the code for each robot
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 9600 Serial.print("ATCN\r"); // exit command mode }
Assignment
- Make a Zigbee netwerk with three robots
You 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 should
not
- Whenever the robots meets another of your robots it should ‘transfer the
light’ to the other robot. The other robot should now become the only
- ne of your robots to have its LED lit.
- Visualise the ongoing transfer of the light during 3 seconds, for instance by
flshing the LEDs
- The playing field is outlined by white tape on the floor that may not be
crossed.
- (We may also test it by placing all 6 robots, of both teams, in the field.)
Oefeningen
- Robust communication with Xbee
– Prevent buffer overflows check for new data regularly; do not send too frequently – Anticipate data loss and data corruption – Use short messages
- Robust protocols
what 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:
- perate 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=RjrEQaG5j
PM
flocking
- http://www.youtube.com/watch?v=qJjeHLcbQ
J0
ant colonies
- http://www.youtube.com/watch?v=GtRNBHM
3DR0
- http://www.youtube.com/watch?v=ozkBd2p2
piU
Conway’s game of life
- Artificial emergent behavior
- http://www.youtube.com/watch?v=XcuBvj0p
w‐E
Mathematical, fractals
In the football stadium
- Clappen synchronously
Who’s in charge? What do we really do to synchronise?
- Wave in a football stadium
Speed of the wave turns out to be very predictable
Assignment
- Cooperative between both teams
- Make robots follow each other in a line.
- Without colliding
- Think about simple and robust rules that may
realise this behavior
- Test together early and see i you can teak and
improve the rules
- No Zigbee communication is allowed in this
assignment
- All robots of a team use the same software