basic circuits – lab 5 wireless networking xmedia spring 2011

6
Basic Circuits – Lab 5 Wireless Networking Xmedia Spring 2011

Upload: giles-butler

Post on 18-Jan-2018

221 views

Category:

Documents


0 download

DESCRIPTION

Xbee – Setup Command Mode and AT Commands Serial Terminal – Coolterm (mac, windows)macwindows +++Enter Command Mode ATIDPersonal Area Network ID – shared by all xbees on the network ATDLDestination Address – what Xbee this one sends data to ATMYSource address – what DL refers to ATWRWrite values to memory ATCNExit Command Mode

TRANSCRIPT

Page 1: Basic Circuits – Lab 5 Wireless Networking Xmedia Spring 2011

Basic Circuits – Lab 5Wireless Networking

XmediaSpring 2011

Page 2: Basic Circuits – Lab 5 Wireless Networking Xmedia Spring 2011

Agenda

• Xbee– Setup

• Arduino– Soft Serial

• Arduino and Processing– Protocol– OSC Messages

Page 3: Basic Circuits – Lab 5 Wireless Networking Xmedia Spring 2011

Xbee – Setup• Command Mode and AT Commands• Serial Terminal – Coolterm (mac, windows)

+++ Enter Command Mode

ATID Personal Area Network ID – shared by all xbees on the network

ATDL Destination Address – what Xbee this one sends data to

ATMY Source address – what DL refers to

ATWR Write values to memory

ATCN Exit Command Mode

Page 4: Basic Circuits – Lab 5 Wireless Networking Xmedia Spring 2011

Arduino – Soft Serial#include <SoftwareSerial.h>

//SoftwareSerial mySerial(rxPin, txPin);

SoftwareSerial mySerial(2, 3);

void setup() { Serial.begin(9600); Serial.println("Goodnight moon!"); // set the data rate for the SoftwareSerial port

mySerial.begin(9600); mySerial.println("Hello, world?");}

void loop(){

if (mySerial.available()>0) {

int inData = mySerial.read();Serial.println(“Data Received” +

inData);mySerial.println(“Soft Serial”);

}}

• Connect rx (receive) from xbee to Arduino Pin 3 (transmit)• Connect tx (transmit) from xbee to Arduino Pin 2 (receive)• New soft serial library -

http://arduiniana.org/2011/01/newsoftserial-11-beta/

Page 5: Basic Circuits – Lab 5 Wireless Networking Xmedia Spring 2011

Arduino and Processing – Protocol

1. Processing broadcasts a string to all puppets.2. Puppets check the string to see if it is their

address.3. If the string refers to the puppet, the puppet

sends its data to the computer.4. Processing constructs an OSC message from

the data from the puppet.5. Processing sends the OSC message to Unity.6. Processing requests data from the next

puppet.

Page 6: Basic Circuits – Lab 5 Wireless Networking Xmedia Spring 2011

Protocol – Sample Arduino Codevoid loop(){ if (mySerial.available()>0) { while (mySerial.available() > 0) { addressChar = char(mySerial.read()); address += addressChar; } Serial.println(address);

if (address.equals("One")) {

mySerial.print("Xbee1"); } } address = ""; delay(100);}