SparkFun Forums 

Where electronics enthusiasts find answers.

All things pertaining to wireless and RF links
By mjpcarbon
#180771
Here is what I have and would like some help if possible.
I built a small device which works well by using an IMU to control 3 servos Pitch,Yaw,Roll Is there anyone who can help me so that it will work wirelessly over XBees
By skimask
#180843
And how is anybody else supposed to know this? Telepathy?
There are plenty of analog as well as digital IMU's out there.
Ya know what might help...maybe if you showed what you've got so far...schematic, napkin drawing, pictures, maybe, oh, I dunno, anything...
By mjpcarbon
#180844
Your right, I will post up my sketch,wiring etc tonight. However I will say what I put up will be for the functioning setup without any xBee stuff because there I am lost. I have a basic success history with xBee but with this I need quite a bit of help.
By mjpcarbon
#180858
IMU wiring 5vVIN Gnd SCL-A5, SDA-A4 From UNO to servos Signal to servos 9,11,13

Again I dont know how to do this but thought it could be done one of two ways or both

1. Transmit the servo signals via xBee then have an UNO receive the signals and move the servos
2. Transmit the IMU data via xBee then have the UNO utilize the data and move the servos

Here is the code which works OK standalone
Code: Select all
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_LSM303_U.h>
#include <Adafruit_BMP085_U.h>
#include <Adafruit_10DOF.h>
#include <Servo.h>

/* Assign a unique ID to the sensors */
Adafruit_10DOF                dof   = Adafruit_10DOF();
Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(30301);
Adafruit_LSM303_Mag_Unified   mag   = Adafruit_LSM303_Mag_Unified(30302);
Adafruit_BMP085_Unified       bmp   = Adafruit_BMP085_Unified(18001);

/* Update this with the correct SLP for accurate altitude measurements */
float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA;

/**************************************************************************/
/*!
    @brief  Initialises all the sensors used by this example
*/
/**************************************************************************/
void initSensors()
{
  if(!accel.begin())
  {
    /* There was a problem detecting the LSM303 ... check your connections */
    Serial.println(F("Ooops, no LSM303 detected ... Check your wiring!"));
    while(1);
  }
  if(!mag.begin())
  {
    /* There was a problem detecting the LSM303 ... check your connections */
    Serial.println("Ooops, no LSM303 detected ... Check your wiring!");
    while(1);
  }
  if(!bmp.begin())
  {
    /* There was a problem detecting the BMP180 ... check your connections */
    Serial.println("Ooops, no BMP180 detected ... Check your wiring!");
    while(1);
  }
}

/**************************************************************************/
/*!

*/
/**************************************************************************/
int servoPin = 9;
    Servo servo;
    int pos = 0;
int servoPin2 = 13;
    Servo servo2;
    int pos2 = 0;
    
int servoPin3 = 11;
    Servo servo3;
    int pos3 = 0;
    
void setup(void)
{
  Serial.begin(9600);
  Serial.println(F("Adafruit 10 DOF Pitch/Roll/Heading Example")); Serial.println("");
  servo.attach(9);
  servo2.attach(13);
  servo3.attach(11);
  /* Initialise the sensors */
  initSensors();
}

/**************************************************************************/
/*!
    @brief  Constantly check the roll/pitch/heading/altitude/temperature
*/
/**************************************************************************/
void loop(void)
{
  sensors_event_t accel_event;
  sensors_event_t mag_event;
  sensors_event_t bmp_event;
  sensors_vec_t   orientation;

  /* Calculate pitch and roll from the raw accelerometer data */
  accel.getEvent(&accel_event);
  if (dof.accelGetOrientation(&accel_event, &orientation))
  {
    /* 'orientation' should have valid .roll and .pitch fields */
    Serial.print(F("Roll: "));
    Serial.print(orientation.roll);
    Serial.print(F("; "));
    Serial.print(F("Pitch: "));
    Serial.print(orientation.pitch);
    Serial.print(F("; "));
  
  /* Calculate the heading using the magnetometer */
  mag.getEvent(&mag_event);
  if (dof.magGetOrientation(SENSOR_AXIS_Z, &mag_event, &orientation))
  
  /* 'orientation' should have valid .heading data now */
    Serial.print(F("Heading: "));
    Serial.print(orientation.heading);
   
  
  
  Serial.println(F(""));
  delay(1);
  
  {
     int cameraPos = orientation.roll + 90;
     servo.write(cameraPos);
     int cameraPos2 = orientation.pitch + 90;
     servo2.write(cameraPos2);
     int cameraPos3 = orientation.heading - 180;
     servo3.write(cameraPos3);
     
  }}}
By Valen
#180925
You can't do I2C/TwoWire over the Xbee digital pins. Even sending pwm/servo pulses over the Xbee link as 'virtual wires' (Series 1 only) is unlikely to be reliable due to lag and stagnation in the transmission path. If the resolution of the sampling of the digital pin is good enough at all. So you'll need some sort of microcontroller on both sides of the Xbee link. One that interfaces with IMU to translate the data between I2C and Serial UART (which the Xbee can handle). And the other that takes the Serial UART data from the Xbee and translates it into PWM/servo signals with it's timers. The pulsewidth/dutycycle of the servo signals can be easily translated into a fixed number of bits/bytes. Just make sure you send all of them as a packet, and have a way to synchronise reading the beginning of it.
By mjpcarbon
#180926
I thought as much, and am prepared to have two UNOs one on each end however I am totally lost on the coding.
If affordable I would even be willing to pay for someones time
No doubt in my mind I am a Newbie and unable to do this on my own, I am happy I was able to get this far. I have a basic understanding of the Xbee and have done some fundamental projects using them but this is quite a bit more difficult