Difference between revisions of "ECE497 Project: XBee"

From eLinux.org
Jump to: navigation, search
(update links and milestones/work)
m
Line 189: Line 189:
 
The pinout and visual implementation are shown below.
 
The pinout and visual implementation are shown below.
  
[[File:Bone_P9_pinout.jpg|x400px]]     [[File:XBee_and_Adafruit_Joystick.jpg|x400px]]
+
[[File:Bone_P9_pinout.jpg|x400px]] [[File:XBee_and_Adafruit_Joystick.jpg|x400px]]
  
 
On the second BeagleBone, wire the XBee exactly as the first XBee (as described in the table above).
 
On the second BeagleBone, wire the XBee exactly as the first XBee (as described in the table above).
Line 207: Line 207:
 
== General Usage ==
 
== General Usage ==
 
These instructions are a general how-to for using the XBee with any sensor.
 
These instructions are a general how-to for using the XBee with any sensor.
 
<span style="color:red">(You need two sets of instructions, one for how to use your code for a given sensor.  The other for adapting your code to another sensor.)</span>
 
 
TO DO: How to use the send and receive functions. Include screenshots.
 
  
 
After cloning our repository to your favorite location, include the necessary header file, <code>XBee.h</code> (not created yet). In your <code>main.c</code> file or your program, first run: <pre>initializeXbee();</pre> which sets the pins we will need to communicate to the XBee. Then in your main.c call: <pre>sendIntXbee(int yourInt);</pre> with chars as a string characters you choose. On your 2nd BeagleBone, call: <pre>receiveIntXbee();</pre> which will return the integers which were sent through <code>sendIntXbee(int yourInt)</code> on the 1st board.  
 
After cloning our repository to your favorite location, include the necessary header file, <code>XBee.h</code> (not created yet). In your <code>main.c</code> file or your program, first run: <pre>initializeXbee();</pre> which sets the pins we will need to communicate to the XBee. Then in your main.c call: <pre>sendIntXbee(int yourInt);</pre> with chars as a string characters you choose. On your 2nd BeagleBone, call: <pre>receiveIntXbee();</pre> which will return the integers which were sent through <code>sendIntXbee(int yourInt)</code> on the 1st board.  
Line 250: Line 246:
  
 
=== Completed Work ===
 
=== Completed Work ===
 
<span style="color:red">(It doesn't look like you've done much so far.  I'm looking forward to seeing the final project.)</span>
 
  
 
* Soldering XBee's - Matt Moravec
 
* Soldering XBee's - Matt Moravec
Line 262: Line 256:
 
=== To Do ===
 
=== To Do ===
  
* Sensor implementation: starting with the sensors that we interfaced earlier in the class
+
* Update documentation - All
* Wiki pages
+
* Joystick demo - Matt
 +
* Clone repo from scratch and test make
 
<!--
 
<!--
 
List the major tasks in your project and who did what.
 
List the major tasks in your project and who did what.

Revision as of 16:16, 10 November 2012

thumb‎ Embedded Linux Class by Mark A. Yoder


Team members: Stephen Shinn, Matt Moravec, Josh Dugan.

Grading Template

I'm using the following template to grade. Each slot is 10 points. 0 = Missing, 5=OK, 10=Wow!

00 Executive Summary
05 Installation Instructions 
01 User Instructions
00 Highlights
00 Theory of Operation
00 Work Breakdown
00 Future Work
00 Conclusions
00 Demo
00 Late
Comments: I'm looking forward to seeing this.

Score:  06/100

Executive Summary

The XBee project involves taking two series-one XBee modules and interfacing them with the various sensors that have been documented in our ECE497 group. Our goal is to create wiki pages which expand on the sensors to include sample wireless communication documentation and source code.

Right now the various sensors have been documented and are working. We've received the XBee modules and soldered them as required. So far we've been able to send and receive messages from an XBee connected to a Windows PC to one connected to a Bone, and vice versa. We've started development on C code which is used to send and receive commands on the Bone. When finished, we'll have a library of methods for communication.

Our next step is to move to Bone-to-Bone communication and to be able to control our sensors wirelessly from one Bone to the other.

In conclusion, we're using XBee modules to communicate from one Bone to another. A protocol is in development and will be used for controlling sensors wirelessly.

General Installation Instructions

Hardware

The very first step is to solder your XBee module, see the instructions here. Once the module is assembled, you may wire-up the XBee module to the BeagleBone's serial ports. The table below describes how to hook up the module to UART2 on the Bone:

XBee Bone, P9 header
GND Ground, port 1
3V 3.3V, port 3
TX RX, port 22
RX TX, port 21

The image below shows the configuration:

XBee module connected to a BeagleBone.

Software

Our git repo for this project is available here: https://github.com/duganje/ECE497_XBEE.git (Use 'Git Read-Only' address). To begin, download the XBee.c (XBee.c? Give some more comments in your code. It looks like you are setting the pin MUX.) file which houses our communication methods. You are now able to send data wirelessly using the SendIntXbee() and ReceiveIntXbee() functions. Repeat this procedure on a separate BeagleBone and use the same functions to receive and reply data.

0.5" Force Sensitive Resistor

These instructions are for interfacing the 0.5" Force Sensitive Resistor with the XBee.

Required Items

Hardware

First we will connect the force-sensitive resistor to the Bone (P9 header). A 27kΩ resistor is used to connect the 3.3V source (pin 3) from the Bone to one pin of the force-sensitive resistor. Then, the other pin of the force-sensitive resistor is connected to ground (pin 1). An analog pin (AIN) on the Bone connects to the node containing both resistors, and values can be read off of that AIN. AIN5 (pin 36) is being used to read values on the Bone.

Next we will connect the XBee module to the Bone. The table below describes the necessary wiring.

XBee Bone, P9 header
GND Ground, port 1
3V 3.3V, port 3
TX RX, port 22
RX TX, port 21

With everything wired-up, your connections should match the image below. Click on the image to view the full resolution.

Picture of connection

Software

We're going to start with these two pieces of code as a reference and combine them:

Running the code for the force sensitive resistor produces a value from 0 to 4096 depending on how much pressure is applied to the resistor. The harder the resistor is squeezed, the lower this value is. On line 46 of the force sensitive resistor code, analogValue is constantly updated and stores this number.

The instructions now fork depending on whether you're setting up the sending XBee code or the receiving XBee code. When you're done you will have two C programs, one running on each Bone.

Sending

Start with the resistor code as a base and add the following include to the top of the file:

#include "XBee.h"

Next, add a call to initializeXbee() in main of the resistor code before the while loop begins.

In the while loop after the value of analogValue is updated, add this line:

sendIntXbee(analogValue);

This will send the integer analog value to the receiving XBee. Now the number is constantly being sent in the while loop.

Receiving

Start with the XBee code as a base and create a main function. First in main, add a call to initializeXbee() to setup the Bone to use the module.

Next, add a while loop to main which continuously receives the integer analog value from the other Bone using the receiveIntXbee() function. Once the integer value is received, you're free to use that information for whatever purpose you wish. The example code below should give you an idea of how this is done:

void main(int argc, char **argv, char **envp) {
	// Initialize XBee
	initializeXbee();

	// Keep going
	while (1) {
	int analogValue = receiveIntXbee();

	// Do anything based on analog value
	if (analogValue < 1000)
		ButtonPressedFunction();
	}
}

Sample

Based on the instructions above, I've created a sample set of programs. Using two Bones, the send program runs on one and the receive program runs on another. The "send" Bone includes an XBee module and the force sensitive resistor, hooked-up as described here. The second Bone includes the XBee module hooked-up in the same way with the addition of an LED connected to pin 12 (GPIO1_28) of the Bone. Connect the ground pin of the LED to the Bone's ground (pin 1) using a 220Ω resistor.

Running both programs emulated the original function of the force resistor sample code, the only difference being that the data is now sent wirelessly from one Bone to another.

Wireless 2-Axis Thumb Joystick

These instructions are for interfacing the 2-Axis Thumb Joystick with the XBee. This application could be useful in a wireless controller setting.

Required Items

BeagleBone Wiring Instructions

On your first BeagleBone, wire pins 36 and 38 to your two analog inputs. Wire the Beagle's 1.8V VCC output, pin 32, to the VCC input of the Joystick. Finally, wire the select GPIO signal to the GPIO_7 pin or pin 42.

Wire the XBee as shown in the table below:

XBee Bone, P9 header
GND Ground, port 1
3V 3.3V, port 3
TX RX, port 22
RX TX, port 21

The pinout and visual implementation are shown below.

Bone P9 pinout.jpg XBee and Adafruit Joystick.jpg

On the second BeagleBone, wire the XBee exactly as the first XBee (as described in the table above).

Don't hook up any other hardware to the second XBee as it will be acting as an information hub.

Usage Instructions

On both BeagleBones, clone this repository:

Magnetometer

These instructions are for interfacing the HMC5883L Magnetometer with the XBee.

The goal is to have the two BeagleBones attached to XBee radios with the one connected to the Magnetometer taking data and transmitting this data to the other Bone which will print the measured data.

The XBee radios should be connected to both Beagles as shown in the hardware section above. The Magnetometer should be connected as shown in the hardware section of the Magnetometer page. Below is a picture of the Beagle connected to the Magnetometer and the XBee.

General Usage

These instructions are a general how-to for using the XBee with any sensor.

After cloning our repository to your favorite location, include the necessary header file, XBee.h (not created yet). In your main.c file or your program, first run:

initializeXbee();

which sets the pins we will need to communicate to the XBee. Then in your main.c call:

sendIntXbee(int yourInt);

with chars as a string characters you choose. On your 2nd BeagleBone, call:

receiveIntXbee();

which will return the integers which were sent through sendIntXbee(int yourInt) on the 1st board.

Highlights

Force Sensitive Resistor YouTube Demo

{{#ev:youtube|Ds_BWsrvy1I}}

Magnetometer YouTube Demo

{{#ev:youtube|99bFqE54UHM}}

Theory of Operation

The main theory of operation is based on Linux's use of files. With an XBee connected to the Bone's UART 2 as shown above, sent and received messages are written to /dev/ttyO2 (the O is an uppercase O, not a zero).(Should be /dev/ttyO2. How do you change serial ports?) Our code uses this and reads the file to receive a message and writes to the file to send a message. Any XBee's on the same network wil receive the message and we can do anything we want with it.

Work Breakdown

Milestones

  • Monday, 10/29 - XBee hardware received. (done)
  • Thursday, 11/1 - XBee Bones are connected and commands can be sent. (done)
  • Monday, 11/5 - Initial sensor implementation. (done)
  • Thursday, 11/8 - Package language implemented between Bones. (done)
  • Sunday, 11/11 - YouTube demo uploaded. (done)
  • Monday, 11/12 - All documentation complete.
  • Tuesday, 11/13 - Presentation day; PowerPoint complete.

Completed Work

  • Soldering XBee's - Matt Moravec
  • Initial communication methods - Stephen Shinn
  • Expanded communication methods - Josh Dugan
  • Force Sensitive Resistor implementation - Stephen Shinn
  • Magnetometer implementation - Josh Dugan
  • 2-Axis Thumb Joystick implementation - Matt Moravec

To Do

  • Update documentation - All
  • Joystick demo - Matt
  • Clone repo from scratch and test make

Future Work

TBD

Conclusions

TBD



thumb‎ Embedded Linux Class by Mark A. Yoder