Page 1 of 1

Datalogger for gyroscope and orientation

Posted: Fri Oct 06, 2017 7:17 am
by mrshim1101
Hi!

I got a Freematics ONE+ recently and modifying datalogger code to collect gyroscope and orientation data.

However, the collected gyroscope showed weird values. It was 0, changed to 200, and stuck.

I modified code like below not for changing other parameters in header files.( When I changed some parameter such as ENABLE_ORIENTATION, MEMS_MODE, OR ENABLE_DMP, I could not upload the code on the dongle).

Thanks!

#if MEMS_MODE
if (one.state & STATE_MEMS_READY) {
float acc[3];
float gyr[3];
bool updated;
#if ENABLE_ORIENTATION
ORIENTATION ori;
#if !ENABLE_DMP
//float mag[3];
updated = mems.memsRead(acc, gyr, 0, 0, &ori);
#else
updated = mems.memsRead(acc, gyr, 0, 0, &ori);
#endif
if (updated) {
Serial.print("Orientation: ");
Serial.print(ori.yaw, 2);
Serial.print(' ');
Serial.print(ori.pitch, 2);
Serial.print(' ');
Serial.println(ori.roll, 2);
one.log(PID_ACC, (int16_t)(acc[0] * 100), (int16_t)(acc[1] * 100), (int16_t)(acc[2] * 100));
one.log(PID_ORIENTATION, (int16_t)(ori.yaw * 100), (int16_t)(ori.pitch * 100), (int16_t)(ori.roll * 100));
one.log(PID_GYRO, (int16_t)(gyr[0] * 100), (int16_t)(gyr[1] * 100), (int16_t)(gyr[2] * 100));
}
#else
updated = mems.memsRead(acc, gyr, 0, 0, &ori);
if (updated) {
one.log(PID_ACC, (int16_t)(acc[0] * 100), (int16_t)(acc[1] * 100), (int16_t)(acc[2] * 100));
one.log(PID_ORIENTATION, (int16_t)(ori.yaw * 100), (int16_t)(ori.pitch * 100), (int16_t)(ori.roll * 100));
one.log(PID_GYRO, (int16_t)(gyr[0] * 100), (int16_t)(gyr[1] * 100), (int16_t)(gyr[2] * 100));
}

Re: Datalogger for gyroscope and orientation

Posted: Fri Oct 06, 2017 10:23 pm
by stanley
Which class is used for "mems" or how was it defined?

Re: Datalogger for gyroscope and orientation

Posted: Sat Oct 07, 2017 5:23 am
by mrshim1101
I define MEMS_MODE as MEMS_DMP

and ENABLE_ORIENTATION 1

ans ENABLE_DMP as 0 because of !ENABLE_DMP in ino file.

I just checked orientation , now it is working but still I don't get any data from gyro.

Re: Datalogger for gyroscope and orientation

Posted: Sun Oct 08, 2017 7:55 pm
by stanley
DMP mode does not work well with Freematics ONE's ATmega328p (due to very limited memory) so you need to define it as MEMS_MPU9250.

Re: Datalogger for gyroscope and orientation

Posted: Tue Oct 10, 2017 6:02 am
by mrshim1101
Hi!

In config.h in datalogger on Freematics ONE+(v5),

I changed the mems mode to 9DOF and it worked well.

Thanks!