MinIMU-9 L3G4200D and LSM3 - Changing the sample rate

Hi,

I know this product is already obsolete, I’m just wondering if I can still get some tech support on this.

I am actually comparing two different sensors for motion control operation so I would like their sample rate to be identical. The other sensor I have can sample at about 200Hz and faster. According to the datasheet of L3G4200D and LSM303DLH, I know they can support the same sample rate too. However according to the arduino sample sketch, the main loop only runs at 50Hz, which is shown below:

"

[code]void loop() //Main Loop
{
if((millis()-timer)>=20) // Main loop runs at 50Hz
{
counter++;
timer_old = timer;
timer=millis();
if (timer>timer_old)
G_Dt = (timer-timer_old)/1000.0; // Real time of loop run. We use this on the DCM algorithm (gyro integration time)
else
G_Dt = 0;

// *** DCM algorithm
// Data adquisition
Read_Gyro();   // This read gyro data
Read_Accel();     // Read I2C accelerometer

if (counter > 5)  // Read compass data at 10Hz... (5 loop runs)
  {
  counter=0;
  Read_Compass();    // Read I2C magnetometer
  Compass_Heading(); // Calculate magnetic heading  
  }

// Calculations...
Matrix_update(); 
Normalize();
Drift_correction();
Euler_angles();
// ***

printdata();

}

}[/code]
"

How do I change the loop so I can print out data at faster rate?

Thanks,
Dao.

Hello, Dao.

In your main loop you, might try reducing the 20 in "if((millis()-timer)>=20) " by a factor of 4 (or more) to get a four (or more) times faster sample rate. Just make sure the sensors themselves can be sampled meaningfully at that rate, and that the main loop isn’t taking too long.

-Jon

Thanks for your reply Jon! I will give this a try.