EasyTransfer library compatability

Hi there!

Is the EasyTransfer library compatible with Xbees in AT mode? When I run the my program the rx and tx LEDs on the arduino board don't flash. I am using an arduino uno and also have a ps2 controller connected through spi using the bill porter psx library. I can print the values of the controller to the computer via USB but I can't seem to get them to be sent through the xbees. Any incites or suggestions?

Thanks!!

Walter

Any incites or suggestions?

Post your code. Describe which XBees you are using, and how they are configured.

You've given us nothing to go on. That amounts to whining. You're allowed to do that ONCE.

Hi Paul,

I can assure you I was not trying to whine to anyone. Here is some information that will hopefully be of use.

I am using an Arduino Uno Rev3 and an Arduino Mega.
I am using two XBee 900Pro XSC s3b modems running the latest firmware(3111) in AT mode (they do not support API). I can confirm that the modems are talking to each other properly.
The PS2 controller is connected to the Uno and information is to be passed from the Uno to the Mega.
I have been able to send data from the Uno to the X-CTU terminal window; however it showed up as jibberish(because the terminal was using hex).

My issue could very well lie in the code as I cannot describe myself as anything above beginner skill level. Code for Uno:

//11/26/14

#include <PS2X_lib.h>  //for v1.6
#include <EasyTransfer.h>

//create two objects
EasyTransfer ETin, ETout; 

struct SEND_DATA_STRUCTURE{
  //put your variable definitions here for the data you want to receive
  //THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
  int RightStickY;
  int RightStickX;
};

SEND_DATA_STRUCTURE txdata;


PS2X ps2x; // create PS2 Controller Class

int error = 0; 
byte type = 0;
byte vibrate = 0;
; 


void setup()
{
  Serial.begin(19200);
  //start the library, pass in the data details and the name of the serial port. Can be Serial, Serial1, Serial2, etc.
  ETout.begin(details(txdata), &Serial);

  Serial.begin(57600);

  error = ps2x.config_gamepad(13,11,10,12, true, true);   //setup pins and settings:  GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error

  if(error == 0)
    Serial.println("Controller found! You may now send commands");

  else if(error == 1)
    Serial.println("No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips");

  else if(error == 2)
    Serial.println("Controller found but not accepting commands. see readme.txt to enable debug. Visit www.billporter.info for troubleshooting tips");

  else if(error == 3)
    Serial.println("Controller refusing to enter Pressures mode, may not support it. ");

  type = ps2x.readType(); 
  switch(type) 
  {
  case 0:
    Serial.println("Unknown Controller type");
    break;
  case 1:
    Serial.println("DualShock Controller Found");
    break;
  }
}
//My sabortooth motordriver can use the two signals 1000us-2000us to control the two motors
void loop()
{
  if(error == 1) //skip loop if no controller found
  {
    return;
  }
  else 
  {
    ps2x.read_gamepad(false, 0);


    txdata.RightStickY = ps2x.Analog(PSS_RY);
    txdata.RightStickX = ps2x.Analog(PSS_RX);
      ETout.sendData();
  
    delay(8);
  }
}

Code for Mega:

#include <Servo.h>
#include <EasyTransfer.h>

// create two objects
EasyTransfer ETin, ETout; 


struct RECEIVE_DATA_STRUCTURE{
  //put your variable definitions here for the data you want to receive
  //THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
  int RightStickY;
  int RightStickX;
};


//give a name to the group of data
RECEIVE_DATA_STRUCTURE rxdata;

Servo Pan;
Servo Tilt;
int panVar = 1500;
int tiltVar = 1500;




void setup(){
  Serial.begin(19200);
  ETin.begin(details(rxdata), &Serial2);

  Pan.attach(6);
  Tilt.attach(7);

}
//My sabortooth motordriver can use the two signals 1000us-2000us to control the two motors
void loop()
{

  for(int i=0; i<5; i++){
    //remember, you could use an if() here to check for new data, this time it's not needed.
    ETin.receiveData();
    
  tiltVar = map(rxdata.RightStickY, 0, 255, 2000, 1000);
  Tilt.writeMicroseconds(tiltVar);
  Serial.print("Tilt");
  Serial.println(rxdata.RightStickY);

  panVar = map(rxdata.RightStickX, 0, 255, 2000, 1000);
  Pan.writeMicroseconds(panVar);
  Serial.print("Pan");
  Serial.println(rxdata.RightStickX);

  delay(8);
}
}

Please let me know if any other specific information could offer an incite.

Thanks
Walter

  Serial.begin(19200);
  //start the library, pass in the data details and the name of the serial port. Can be Serial, Serial1, Serial2, etc.
  ETout.begin(details(txdata), &Serial);

  Serial.begin(57600);

Maybe you need a few more calls Serial.begin(), at a few more different baud rates, until you finally make up your mind.

  if(error == 1) //skip loop if no controller found
  {
    return;
  }
  else

I hate code like this. There is no reason to exit setup() if there is no controller. Even if you do, it is not necessary to return from loop(), since it will simply get called again.

Dealing with the fact that there might not be a controller is a good idea, but

void loop()
{
   if(error == 0)
   {
       // there is a controller; use it
   }
}

is much cleaner code, in my opinion.

Why do both code contain an unused instance of EasyTransfer?

void setup(){
  Serial.begin(19200);
  ETin.begin(details(rxdata), &Serial2);

  Pan.attach(6);
  Tilt.attach(7);

}

Starting Serial2 would be a good idea, wouldn't it?

    ETin.receiveData();

Doesn't this return a value? Checking that you got data before using it feels like a good idea.

Thanks for all the suggestions! Your information helped out a lot, but I eventually decided to try a different approach which seems to be more effective/ easier to set up.

There is still one thing I'm curious about though. Is there away to run an SPI device(such as the ps2 controller) and another serial device through the UART, each at different baud rates? Is there a way to achieve this on the same board?

Thanks!!

Walter

Is there away to run an SPI device(such as the ps2 controller) and another serial device through the UART

Does SPI use the UART ?

No it doesn't. The spi device interfaces using 4 digital pins. The xbee uses the uart(rx,tx,gnd,5v).

Walter

Walter103: No it doesn't. The spi device interfaces using 4 digital pins. The xbee uses the uart(rx,tx,gnd,5v).

Walter

Then why did you ask

Is there away to run an SPI device(such as the ps2 controller) and another serial device through the UART