The sensor works great out of the box and comes calibrated. If you are getting started, you can simply connect it to USB as described in the documentation (simply wire an USB cable, no additional electronics needed). For testing purposes, you can download an open source software suite which simulates the sensor in three dimensional space in real time. You can just most parameters, e.g. filter params, and learn about all the options available.
As a second step, I connected the sensor to UART I of the mbed (pins 9 and 10 of the mbed are tx and rx. I think in the 3-Space sensor the description of the pins is incorrect, for serial communication, you might need to swap tx and rx cables.
In order to establish a connection, first define a serial object prior to the main routine (in this example, i called it "device"):
Serial device(p9, p10); // tx, rx
Then I defined a routine which reads incoming data from the serial port (I am pretty sure that there is better code available for this task, I modified it from anywhere in the internet):
char data[33];
void get_data() {
int incount = 0;
if ( device.readable() )
{
while (device.readable()) {
data[incount++] = device.getc();
}
}
This function reads a certain number of characters
In the main routine, we communicate with the 3-space sensor. There are plenty of commands and requests available which are well documented in the PDF-manual. There you can find most info you need, and their tech-support is very helpfull.
There are two communication protocols available, I choosed the ASCII version. Each command starts with ":", followed by a number representing a byte value (0-255), and then specific parameters separated with a comma. After setting the baud rate, changing the led color of the sensor gives you a good indication if everything works. The command number is 238, followed by three float values (0-1.0) for each color channel:
int main() {
device.baud(115200);
device.printf(":238,1.00,0.00,0.00\n ");
wait(0.5);
device.printf(":238,0.00,1.00,0.00\n ");
wait(0.5);
If this works, you can start requesting sensor data. There are numerous options: You can request sensor raw data, filtered data, data processed by various algorithms, all by sending a simple command. You can find the documentation of the numerous commands available on YEIs homepage (http://tech.yostengineering.com/3-space-sensor/product-family/embedded/files/3-Space_Sensor_Users_Manual_Embedded_1.1_r13_28Feb2012.pdf).
One examble: command "0" does the following: "Read filtered, tared orientation (Quaternion)". So let's send the command over UART 1, utilizing our self-defined read function:
device.printf(":0\n ");
get_data();
Now the data buffer contains what has been received from the serial interface. Baud rates above 115200 don't seem to work so well. If fast communication/processing is necessary, you can use the binary packet format. In these cases, you will receive results as byte values, reducing the number of bytes transferred after each request significantly. I simply printed the data over an lc display:
lcd.printf(data);
wait (0.5);
Sending over USB also works.
I don't think that my experiences might be applicable for all possible situations. However, I wanted to have a simple and fast way of implementing IMU data in my application. This 3-space device simply works as described, no volatile memory needs to be filled at startup etc. However, if you are skilled and experienced regarding this stuff you might find much cheaper ways to implement IMU sensors.
Hope this helps, tell me if you need additional info. Sorry for my poor english...
Hello,
I'm starting to work on the MPU-6050 Motion Processing device from Invensense. From what I've seen it is a very nice device with 3-axis accelerometer and 3-axis gyroscopes. It is capable of computing Euler's angles internally hence the attractiveness. In order to be efficient I'm wondering if anybody has done this. If not, I'll be starting in a few days to port the API from the low level ARM code they provide and proceed to share it.