1. The position and acceleration data output from R_Plotrawdata3_test.ino are float. In the arduino ide a float is 4 bytes. The API packets require bytes, not float values.
2. There are two ways to send the data:
a. Multiply the float data by 10000 and convert to an int, then convert to two bytes in the arduino code. Then convert back in the receiving code.
b. Use the C union structure. Here's an example - note that this structure uses 7 bytes, we'd only use 4 bytes, but it's good to see if you want other info included. Also note that they are using Andrew Rapp's xbee library for series 2 xbees when they make the call with ZBTxRequest. We'd change that to the series 1 call.:
typedef union {
typedef struct{
uint16_t t_count; //2 byte
byte year; //1 byte
float myfloat; //4 byte
} LOG_DATA_STRUCTURE;
LOG_DATA_STRUCTURE vals;
uint8_t xbeePl[7]; //7 bytes same a vals
} MYPACKET;
// declare a variable type MYPACKET
MYPACKET exbee;
...
exbee.vals.t_count = x;
exbee.vals.year = y;
exbee.vals.myfloat = z;
ZBTxRequest zbTx = ZBTxRequest(addr64, exbee.xbeePl, sizeof(exbee.xbeePl));
ZBTxStatusResponse txStatus = ZBTxStatusResponse();
xbee.send(zbTx);
3. The BNO055.cpp library converts the 6 bytes of data that it receives from the BNO055 to float. How can we get these bytes before the conversion? Seems silly to have the code convert to float and back to bytes, taking extra processor time. To do: learn more about the BNO055 libraries. Maybe we can get the 6 byte data before it is converted in the getVector() function. Here's the function from the BNO055.cpp library:
/**************************************************************************/
/*!
@brief Gets a vector reading from the specified source
*/
/**************************************************************************/
imu::Vector<3> Adafruit_BNO055::getVector(adafruit_vector_type_t vector_type)
{
imu::Vector<3> xyz;
uint8_t buffer[6];
memset (buffer, 0, 6);
int16_t x, y, z;
x = y = z = 0;
/* Read vector data (6 bytes) */
readLen((adafruit_bno055_reg_t)vector_type, buffer, 6);
x = ((int16_t)buffer[0]) | (((int16_t)buffer[1]) << 8);
y = ((int16_t)buffer[2]) | (((int16_t)buffer[3]) << 8);
z = ((int16_t)buffer[4]) | (((int16_t)buffer[5]) << 8);
/* Convert the value to an appropriate range (section 3.6.4) */
/* and assign the value to the Vector type */
switch(vector_type)
{
case VECTOR_MAGNETOMETER:
/* 1uT = 16 LSB */
xyz[0] = ((double)x)/16.0;
xyz[1] = ((double)y)/16.0;
xyz[2] = ((double)z)/16.0;
break;
case VECTOR_GYROSCOPE:
/* 1rps = 900 LSB */
xyz[0] = ((double)x)/900.0;
xyz[1] = ((double)y)/900.0;
xyz[2] = ((double)z)/900.0;
break;
case VECTOR_EULER:
/* 1 degree = 16 LSB */
xyz[0] = ((double)x)/16.0;
xyz[1] = ((double)y)/16.0;
xyz[2] = ((double)z)/16.0;
break;
case VECTOR_ACCELEROMETER:
case VECTOR_LINEARACCEL:
case VECTOR_GRAVITY:
/* 1m/s^2 = 100 LSB */
xyz[0] = ((double)x)/100.0;
xyz[1] = ((double)y)/100.0;
xyz[2] = ((double)z)/100.0;
break;
}
return xyz;
}
Here's a site that talks about it specifically for the arduino and xbee and the xbee.h library:
http://forum.arduino.cc/index.php?topic=123432.0
4. The BNO055 has a UART mode. Can remove the arduino on the end device and send API packets with the serial data? Then we can run the BNO055 library on an arduino attached to the coordinator and host computer.
No comments:
Post a Comment