Arduino + Xbee Shield

Here I go .. and First of all sorry for my newbieness ,, i am an undergraduate trying to do a project ..

I have to control and power a two wheeled robot with DC motors and with line-following capability. The components I have :

2 x Arduino Duemilanove 2 x Xbee modules (Series 1) + Xbee Shield SN754410 half-bridge for motors QTR-1RC reflector sensors for line detection

I was asked to setup one board with its module (with shield) at the "base station" and the other placed on the robot.

To start with the project, i tried to establish the radio-link, and I think was succesful, I used X-CTU through Duemilanove with ATmega328 removed and jumper settings to USB. I just applied same PAN ID for both , MY = 7 and DH= 0 for Co-ordinator (Co-ordinator Enable 1) and MY=0 and DH= 7 for End point (Co-ordinator enable -0) . WIth just these setting i got the network and I saw characters fly from co-ordinator to end-point , whereas I am not sure about the other way around..

Assuming that my network is established, with Co-ordinator blinking once a second and END-point blinking twice a second, my next step is to transfer programs from one board to another..

how do i proceed ? Do i have to put back the ATmega328's back on boards ? Jumper position back to Xbee?

will the codes uploaded at the "base station" end be received at the other end , just by attaching the XBee module (shield)?

I want to control the motors from base station, and there are sensors at the robot end, I need to take values from them and give commands to motor controller (SN754410).. please help me

how do i proceed ? Do i have to put back the ATmega328's back on boards ? Jumper position back to Xbee?

Yes, you do.

will the codes uploaded at the "base station" end be received at the other end , just by attaching the XBee module (shield)?

By code, you mean the Arduino sketch that has been compiled and linked? If so, no. You need to program the Arduinos separately.

If by code, you mean serial data, then, yes.

I want to control the motors from base station, and there are sensors at the robot end, I need to take values from them and give commands to motor controller

The Arduino on the robot needs to read the sensors on the robot, and transmit that data, via XBee, to the other Arduino.

The other Arduino needs to read the serial data, and do something with it, to create motor control commands to send back. It needs to send them, via XBee.

The robot-based Arduino needs to read serial data, when it is present, and send appropriate signals to the motor controller.

Clearly, your first step is to verify that Arduino 1 can send data to, and receive data from Arduino 2.

can someone give me a good configuration to set up my Xbee ,,, like MY , DH? with my configuration, I assume I have only one way communication.

Is there anyone in Australia (Queensland) who can help me out with this and earn a few bucks ?

What I use is this. XBee 1: PAN ID: 8888 MY: 8001 DH: 0 DL: 8002 XBee 2: PAN ID: 8888 MY: 8002 DH: 0 DL: 8001

I get two-way communication between the XBees, with this setup.

Is there anyone in Australia (Queensland) who can help me out

I'm not even close, although I'd love to visit there, someday.

thanks Paul , I really appreciate it !! I got the Xbees working

As explained earlier, now I have to interface SN754410 motor controller and QTR-1RC pololu sensors. As u said, I need to get the values from sensors and send it to the other Arduino. I came across few codes online to read sensor values, but how do I send those through Xbee. I have the Xbee library installed for Arduino environment, but need help for the coding part.

Also, with SN754410, my schematic uses 2,3,7,8 pins from Arduino, does that mean I can vary speed with the PWM output pin 3 using analoguewrite() .. again need help with the coding part..

one more doubt, do i need to use a potentiometer to use PWM outputs and control the speed?

how do I send those through Xbee.

Data is made available to the sending XBee by using Serial.print(). The XBee is monitoring the serial port, so it transmits whatever is sent the serial port.

On the receiving side, anything that a XBee receives over the air is sent to the serial port, just as if the port was hardwired to a PC, so access the data using Serial.available() and Serial.read().

I'm not sure what role the potentiometer would have. The sensors create the values that are to be transmitted. On the receiving end, the data is captured, converted back to integers, and sent to a PWM pin using analogWrite.

thnks for the info paul …

i am not sure whether this is the right place to throw this doubt.

i am trying to get values from my sensors QTR-1RC pololu. the code i have used

#include <PololuQTRSensors.h>

// create an object for your type of sensor (RC or Analog)  
// in this example we have three sensors on analog inputs 0 - 2, a.k.a. digital pins 14 - 16  
PololuQTRSensorsRC qtr((unsigned char[]) {17}, 1);  
// PololuQTRSensorsA qtr((unsigned char[]) {0, 1, 2}, 3);  
  
void setup()  
{  
  // optional: wait for some input from the user, such as  a button press  
  
  // then start calibration phase and move the sensors over both  
  // reflectance extremes they will encounter in your application:  
  int i;  
  for (i = 0; i < 250; i++)  // make the calibration take about 5 seconds  
  {  
    qtr.calibrate();  
    delay(20);  
  }  
  
  // optional: signal that the calibration phase is now over and wait for further  
  // input from the user, such as a button press  
  
  Serial.begin(9600); 
}  

void loop()  
{  
  unsigned int sensors[1];  
  // get calibrated sensor values returned in the sensors array, along with the line position  
  // position will range from 0 to 2000, with 1000 corresponding to the line over the middle sensor  
  int position = qtr.readLine(sensors);  
  
// output to Serial monitor
Serial.print(sensors[3]); 
Serial.print(" ");

Serial.println();
}

i have used analogue pin 3 (17), but the values i get on serial monitor… are repeated constants without changes, eg: for this pin 17 , i get the value of 51340 constantly … any solution?

unsigned int sensors[1];
  // get calibrated sensor values returned in the sensors array, along with the line position
  // position will range from 0 to 2000, with 1000 corresponding to the line over the middle sensor
  int position = qtr.readLine(sensors);

// output to Serial monitor
Serial.print(sensors[3]);

sensors is defined as an array capable of holding one value. You do not specify what that value is before passing the array to qtr.readLine.

You then write the 4th value in the array. There is no 4th value, so you are writing garbage.

Not much of a surprise, then, that you are receiving garbage.

Are you able to send "Hey, there XBee!" and receive that string?

hey , I have used this code to successfully show the values of my sensors on serial monitor.

#include <PololuQTRSensors.h>

 // Six Analog Pins can be commonly referenced as:
 // analog 0 - Reference as: Pin 14
 // analog 1 - Reference as: Pin 15
 // analog 2 - Reference as: Pin 16
 // analog 3 - Reference as: Pin 17
 // analog 4 - Reference as: Pin 18
 // analog 5 - Reference as: Pin 19

// Create an object for your type of sensor (RC or Analog)  
// In this example we have three sensors on analog inputs 0 - 2, a.k.a. digital pins 14 - 16  
 PololuQTRSensorsRC qtr((unsigned char[]) {14,15}, 2); 
// PololuQTRSensorsAnalog qtr((unsigned char[]) {0, 1, 2}, 3); 
// Setup LedPin on Digital Pin 10
int ledPin = 10;
  
void setup()  
{   
  // Initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // Optional: wait for some input from the user, such as  a button press 


  // Start calibration phase and move the sensors over both  
  // reflectance extremes they will encounter in your application:  
  int i;  
  for (i = 0; i < 250; i++)  // make the calibration take about 5 seconds  
  {  
    qtr.calibrate();  
    delay(20);  
  }  
  // Optional: signal that the calibration phase is now over and wait for further  
  // input from the user, such as a button press 
  // Initialize Serial Communication:
  Serial.begin(9600); 
}

void loop()  
{  
  unsigned int sensors[1];  
  // Get calibrated sensor values returned in the sensors array, along with the line position  
  // position will range from 0 to 2000, with 1000 corresponding to the line over the middle sensor .
  int position = qtr.readLine(sensors);
  //Output to Serial
  Serial.print(sensors[0]); 
  Serial.print(" ");
  Serial.print(sensors[1]); 
  Serial.print(" ");
  Serial.println();
  // If all three sensors see very low reflectance, take some appropriate action for this situation  
  if (sensors[0] < 750)
  {  
    // Turn on the LED if we get a High Reflectance.    
    digitalWrite(ledPin, HIGH); 
    // Do something.  Maybe this means we're at the edge of a course or about to fall off a table,  
    // in which case, we might want to stop moving, back up, and turn around.  
    return;  
  } 
  // Turn off the LED if we have a Low Reflectance.
  else digitalWrite(ledPin, LOW);  
}

Now, I desperately need the code to show these values on the other end of Xbee, through serial monitor. I used some examples using Serial.read and Serial.available, but wasnt succesfull.

HELP !!!

Try this two website may help :

http://www.ladyada.net/make/xbee/arduino.html https://sites.google.com/site/xbeetutorial/

Good Luck