CurieIMU output data rate

Hi,

I am trying to read data from the accelerometer, however I find that the maximum data rate appearing on the serial monitor is 25Hz. Ideally I would want to push it up to 1600Hz, but the data rate cannot exceed 25Hz. Is there a way of overcoming this?

Best regards,

Yi Han

Yes.
If you look in Arduino15\packages\Intel\hardware\arc32\1.0.5\libraries\CurieIMU\src\CurieIMU.h you will find some helpful functions.

// supported values: 25, 50, 100, 200, 400, 800, 1600, 3200 (Hz)
int getGyroRate();
void setGyroRate(int rate);

// supported values: 12.5, 25, 50, 100, 200, 400, 800, 1600 (Hz)
float getAccelerometerRate();
void setAccelerometerRate(float rate);

// supported values: 125, 250, 500, 1000, 2000 (degrees/second)
int getGyroRange();
void setGyroRange(int range);

// supported values: 2, 4, 8, 16 (G)
int getAccelerometerRange();
void setAccelerometerRange(int range);

So, what you need here is

CurieIMU.setAccelerometerRate(1600);

I haven't played with the IMU enough to know if the the gyro and accelerometer need to be set to the same rate. I guess it depends on your application.

Hey Dave,

I tried changing the output data rate using those functions, but the data output in the serial monitor can only go up to 25Hz, any higher and there would be information left out, do you have any idea how to overcome this?

Yi Han

Printing to screen is pretty slow, the rate will depend on the number of characters printed.
Are you passing this data to a program or another board? You should get better performance once you are not outputting it to the screen. Using Serial.write may be fastest.

I'm reading the data in CoolTerm and processing later with MATLAB. Would increasing the baud rate solve the latency of the Serial.print function?

It should help, since at 9600 bps you can only send ~40 strings composed by 30 chars every second (without considering the overhead).
Try configuring the Serial with 460800 as baudrate (the maximum reachable without any transmission error)

Thanks facchinm! I changed it to 460800 and it worked...the maximum data output is now at 100Hz, I don't suppose you know if there's anything else I can do to reduce the latency and make it display at 1600Hz?

Well, to display 1600Hz of 6 axis through a serial connection (let's suppose there is no overhead) you should:

  • pack your data to a binary format of choice (16bit raw data per sample should be enough) -> 1626 = 192bit
  • you want 1600Hz, so your channel should support at least 192*1600 = 307200 bit/s

Setting the serial to 460800 should be enough, but you should add at least a start and stop byte to the transmission.

From my experience, a 1Mb UART is ok for your purpose, but since the USB connection cannot reach this speed you should use Serial1 (pins 0/1) interfaced with an FTDI serial to USB converter

Hi facchinm, from what I understand USB2.0 has a theoretical maximum speed of 480Mbps, so shouldn’t 307200bps be acceptable? What is causing the bottleneck?

Also why did you multiply 16 by 2? Isn’t 16 the number of bits for each axis on the accelerometer/gyroscope?

from what I understand USB2.0 has a theoretical maximum speed of 480Mbps

~1.5Mbps "low speed"
~12Mbps "full speed"
~280Mbps "high speed"

I'd expect Curie to be a "full speed" device at best, and other factors might limit the reachable performance. It's only a 32MHz CPU, after all.