Introduction: Rowan University Mechatronics Project. Wireless Car/Xbee Series 2 Section and Xbee Multiple Potentiometer Control

When choosing xbees, you must decide between series 1 and series 2. Series 1 xbees use point to point communication. This makes programming them simple since a series 1 xbee can only talk to one other series 1 xbee and not more then one. The series 2 xbee is a much more versatile tool. It can be used within a network of countless xbees all be controlled by one main xbee called the coordinator. The series 2 xbee pays for it’s versatility by being more complicated to code.

The coordinator has the ability to send signals to the other xbees. It can also receive messages from the router. As the main xbee, its job is also setting up the wireless network. The next xbee mode is the router. The router has the ability to receive messages from the coordinator and transmit them to the end device or back to the coordinator. The final xbee mode is the end device. The end device can receive messages but cannot send back a signal. Its advantage is that when not in use the end device will turn itself off until it receives the next signal in order to save energy.

For this project, an end device was not used. For some reason, the xbee network did not respond well to an end device so a router and coordinator were used instead.

This youtube link is one of five and is very informative for beginners. I would suggest only watching the first two lessons and then trying them out. Once those lessons are understood, the next three will be much easier to follow. I suggest PRACTICE, PRACTICE, PRACTICE.

https://www.youtube.com/watch?v=odekkumB3WQ

Step 1:

For this project, the coordinator was used as the device that received the signal and the router was the device used to send the signal. The reasoning behind this was that the coordinator created the network so be making it the receiving end, it had less work which would increase the speed of the network. This tip was given on one of the lessons and it seemed to work well.

When programming the xbee there are two main methods I used. One was using the xbee dongle. The next method was using the xbee shield while attached to the Arduino. The first method makes reseting the xbee, something you may need to do much simpler but the other method makes setting up and testing the system using the Arduinos much simpler and faster.

The program you will need is called XCTU. I used the mac version and I will be posting pictures of the process. The windows version has a different interface but the data that must be changed is the same so the process should be repeatable on either with a little exploring into the program.

XCTU Progam

http://www.digi.com/products/wireless-wired-embedded-solutions/zigbee-rf-modules/xctu

link to the download site

Step 2: Materials

1) XBees-There are many different types of xbees and many different websites that sell them at differing prices such as adafruit or digikey. This is a simple series 2 xbee. Another common one is the xbee pro. The difference between the two is that the xbee pro has a greater range.

http://www.adafruit.com/products/968?gclid=CJnxzM2...

2) USB Dongle-This is one method for connecting your xbee to the computer

http://www.karlssonrobotics.com/cart/XBee-Explorer...

3) Arduino Uno or Mega-This micro controller is the primary means of controlling the xbee

http://www.mouser.com/ProductDetail/Arduino/A00006...

4) Xbee/Arduino Shield-

Avoid series 1- it is faulty, can contain shorts that could destroy the xbee

Series 2 and series 3 shield normally work well, this is the shield I used, a series 3.

I bought my series 3 xbee shield on eBay and it works fantastically

Step 3: Initial Step With Arduino

Upload this code to your arduino if you are using the arduino and the shield with the xbee on it to program your xbee.

MAKE SURE YOUR SHIELD IS SWITCHED TO USB MODE, NOT MICRO/XBEE MODE.

If you are using the dongle, ignore this step.

Step 4: XCTU Program

Once your on the XCTU program this should be what you see.

Step 5: Finding the Xbee

On the top left corner of the xctu program, select the icon with the magnifine glass.

This will open up the popup menu containing serial ports.

Select a usb port and click next.

The next popup is the search criteria, most xbees use a 9600 baud rate so normally only select that one. Keep everything else the same.

Click finish.

Your xbee should come up, in this case we see my coordinator come up as it has a C on it's icon.

Click add selected device.

Step 6:

Your newly uploaded xbee should appear on the left of your screen in the side bar.

Click on it and all the xbee's setting will come up.

Step 7: Updating or Uploading Your Firmware

This button will allow you yo change you xbees settings, coordinator, router, or end device.

USE AT MODE. NOT API, unless you understand how to send code packages.

Step 8: Repair

If for some you attempted to find you xbee, the usb port comes up, but the xbee does not, do not despair. The wrench picture displayed above could be helpful. Select it, i drop down menu will appear. Click repair and select which settings you want your xbee to have, I always chose router, at version. Hopefully this will allow you to once again search for your xbee and find it this time.

Step 9: Coordinator Programming

For the beginner, the only things you must change are Pan ID , Scan Channels, DH and DL. Set them as they are in the picture.

The Pan ID acts as an address,

The Pan ID's must be the same.

The DH and DL act as high and low frequencies for the coordinator to search.

Step 10: Router/End Device Programming

As with the coordinator, copy the Pan ID , Scan Channels, DH and DL into your program.

The Pan ID's must be the same.

Set your DH and DL both to 0, this falls within the coordinators search range.

Step 11: Xbees Talking With Each Other

This step is only useful if you can connect both xbees at the same time. This can be done with another computer or the same computer. I had mine on the same computer.

Once all your settings have been finished, go to the top right corner and select the TV icon.

Click the plug icon for both xbees. It will plug in and turn green.

Try typping stuff, anything. It should come up blue.

Click to the other xbee, the message should appear red. If it does, your xbees are talking and ready for transmission, if not return to settings and make sure everything is correct.

If you are using the router, you can type back to the coordinator and it should also go though.

Step 12: Finally

You're xbees are now ready.

Put them on the shield and then the arduino if they are not already.

Make sure the shield is switched to USB mode and program your arduinos.

Keep track of which one is the coordinator and which aren't. This will make things simpler.

These links will provide other helpful tutorials

http://arduino.cc/en/Guide/ArduinoXbeeShield

http://arduino.cc/en/Guide/ArduinoWirelessShieldS2

This Code will allow you to wirelessly blink the led on you arduino

Coordinator:

void setup()
{ Serial.begin(9600); }

void loop() {

Serial.print('H');

delay(1000);

Serial.print('L');

delay(1000);

}

Router:

int num=0;
const int ledPin = 13;

// the pin that the LED is attached to int incomingByte;

// a variable to read incoming serial data into int fs =0;

void setup() {

// initialize serial communication:

Serial.begin(9600);

// initialize the LED pin as an output:

pinMode(ledPin, OUTPUT);

}

void loop() {

// see if there's incoming serial data:

if (Serial.available() > 0) {

// read the oldest byte in the serial buffer:

incomingByte = Serial.read();

// if it's a capital H (ASCII 72), turn on the LED:

if (incomingByte == 'H') {

digitalWrite(ledPin, HIGH);

//turn light on

}

// if it's an L (ASCII 76) turn off the LED:

else if (incomingByte == 'L') {

digitalWrite(ledPin, LOW);

//turn light off

}

}

}

Step 13: Multiple Potentiometers

After searching online, I found a library for arduino that will allow you to send multiple potentiometer values from 1 xbee/arduino combo to another. It is called the EasyTransfer Library.

http://www.billporter.info/2011/05/30/easytransfer...

An example of it being used is discussed in this forum

http://forum.arduino.cc/index.php?topic=152604.0

I have already tried it and have been able to control 3 potentiometers with both xbees in AT mode.

Below is the code I used for transmitting 3 potentiometer values wirelessly. I was able to make it using code from the second website listed on this page.

//Sender

#include <EasyTransfer.h>

EasyTransfer ET;

int potpin1 = A0;

int potpin2 = A1;

int potpin3 = A2;

struct SEND_DATA_STRUCTURE{

int servo1val;

int servo2val;

int servo3val; };

SEND_DATA_STRUCTURE txdata;

void setup(){

Serial.begin(9600);

ET.begin(details(txdata), &Serial);

pinMode(potpin1, INPUT);

pinMode(potpin2, INPUT);

pinMode(potpin3, INPUT);

}

void loop(){

txdata.servo1val = analogRead(potpin1);

txdata.servo2val = analogRead(potpin2);

txdata.servo3val = analogRead(potpin3);

ET.sendData();

delay(500);

}

This section receives the data from the potentiometers. For my own purposes, I wanted to run a test and have my Arduino print the values sent by three potentiometer.

//Reciever

#include <Servo.h>

#include <EasyTransfer.h>

EasyTransfer ET;

Servo myservo1;

Servo myservo2;

Servo myservo3;

int val1,val2,val3;

struct RECEIVE_DATA_STRUCTURE{

int servo1val;

int servo2val;

int servo3val;

};

RECEIVE_DATA_STRUCTURE txdata;

void setup(){

Serial.begin(9600);

ET.begin(details(txdata), &Serial);

myservo1.attach(9);

myservo2.attach(10);

myservo2.attach(12); }

void loop(){

if(ET.receiveData()){

val1=map(txdata.servo1val, 0, 1023, 0, 179);

val2=map(txdata.servo2val, 0, 1023, 0, 179);

val3=map(txdata.servo3val, 0, 1023, 0, 179);

Serial.println(val1);

Serial.println(val2);

Serial.println(val3);

// myservo1.write(val1);

//myservo2.write(val2);

}

}

Comments

author
gada888 (author)2015-04-01

Great instructable.There are dozens of Zigbee modules on the market.which seems cheaper and some of them carry great range,say 2 km.but i don't know if they compatible with X-CTU.

About This Instructable

4,324views

31favorites

License:

More by chris1205:Rowan University Mechatronics QuadcopterRowan University Mechatronics Project. Wireless Car/Xbee Series 2 Section and Xbee Multiple Potentiometer ControlCrabbing For Beginners
Add instructable to: