I am using arduino nano iot33, the output data rate is at 104Hz. Please guru, expects and newbie like me, is there any way I can increase this to KHz?
What does the unnamed IMU's datasheet say?
Accelerometer power modes
In the LSM6DS3, the accelerometer can be configured in four different operating modes:
power-down, low-power, normal mode and high-performance mode. The operating mode
selected depends on the value of the XL_HM_MODE bit in CTRL6_C (15h). If
XL_HM_MODE is set to ‘0’, high-performance mode is valid for all ODRs (from 12.5 Hz up
to 6.66 kHz).
To enable the low-power and normal mode, the XL_HM_MODE bit has to be set to ‘1’. Lowpower mode is available for lower ODRs (12.5, 26, 52 Hz) while normal mode is available
for ODRs equal to 104 and 208 Hz.
Set the ODR (Output Data Rate) register to the desired rate.
#include <Arduino_LSM6DS3.h>
void setup() {
Serial.begin(9600);
while (!Serial);
if (!IMU.begin()) {
Serial.println("Failed to initialize IMU!");
while (1);
}
Serial.print("Accelerometer sample rate = ");
Serial.print(IMU.accelerationSampleRate());
Serial.println(" Hz");
Serial.println();
Serial.println("Acceleration in m/s*2");
Serial.println("X\t Y\t Z");
}
void loop() {
float x, y, z;
if (IMU.accelerationAvailable()) {
IMU.readAcceleration(x, y, z);
Serial.print(x);
Serial.print(',');
Serial.print(y);
Serial.print(',');
Serial.println(z);
}
}
This is an example code of the IMU. Please where do I modify or input in the code to achieve the 6.66kHz
There may be a function in the library you are using to set the ODR. Have you checked the library code or documentation?
We can't, because you forgot to tell us which library you are using.
I am using the Arduino_LSM6DS3.h simpleAccelerometer library to access the Arduino nano iot33 IMU.
Try a different library, or modify the one you've got
When you looked at the library documentation page
did you happen to notice that the library offers routines with these rather suggestive names?
accelerationSampleRate()
gyroscopeSampleRate()
Take a look at the library code to see how it sets the sample rate, and modify that, if you like.
Sadly getter, not setter.
Still struggling to set my Accelerometer sample rate to 6.66khz. I have uploaded the datasheet, I got hooked up at page 52.
Please help me using the sample code I upload earlier.
LSM6DS3 datasheet.pdf (1.4 MB)
Did you try what I suggested in post #8?
"Struggling" isn't very descriptive - tell us what you actually have tried.
You will have to modify the library, as it does not offer an option to change the data rate.
Or use the Sparkfun library, which does have that option: SparkFun_LSM6DS3_Arduino_Library/src at master · sparkfun/SparkFun_LSM6DS3_Arduino_Library · GitHub
I tried sparkfun LSM6DS3 breakout library (minimalist example). Please help modify it.
I can't really add anything to that
You don't have to modify the Sparkfun library. Just call the function to set the rate, with one of the defined parameters.
/*******************************************************************************
* Register : CTRL1_XL
* Address : 0X10
* Bit Group Name: ODR_XL
* Permission : RW
*******************************************************************************/
typedef enum {
LSM6DS3_ACC_GYRO_ODR_XL_POWER_DOWN = 0x00,
LSM6DS3_ACC_GYRO_ODR_XL_13Hz = 0x10,
LSM6DS3_ACC_GYRO_ODR_XL_26Hz = 0x20,
LSM6DS3_ACC_GYRO_ODR_XL_52Hz = 0x30,
LSM6DS3_ACC_GYRO_ODR_XL_104Hz = 0x40,
LSM6DS3_ACC_GYRO_ODR_XL_208Hz = 0x50,
LSM6DS3_ACC_GYRO_ODR_XL_416Hz = 0x60,
LSM6DS3_ACC_GYRO_ODR_XL_833Hz = 0x70,
LSM6DS3_ACC_GYRO_ODR_XL_1660Hz = 0x80,
LSM6DS3_ACC_GYRO_ODR_XL_3330Hz = 0x90,
LSM6DS3_ACC_GYRO_ODR_XL_6660Hz = 0xA0,
LSM6DS3_ACC_GYRO_ODR_XL_13330Hz = 0xB0,
} LSM6DS3_ACC_GYRO_ODR_XL_t;
Please can anyone help me with the code, call the function. I am totally new to programming.
You are trying to run before you have learned to crawl. Teach yourself some basic programming skills first. What good will changing the sample rate do you, if you don't have the skills to collect and use the data?
There are plenty of beginner tutorials for Arduino the C/C++ programming language on line, and lots of simple examples come with the Arduino IDE.
Or, post on Jobs and Paid Collaborations forum section, and have someone write the code.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.