L3G4200D random spikes

I am filtering out the spikes. They are only single reading events so easy to spot and deal with.

Using the register filters or an additional filter once you receive the data?

My own code after reading the raw values.

I'm having some good luck (so far) with the following registers. I got desperate and started randomly changing register values with a 'what if' ideology, and now I'm not seeing the spike.

It's probably due to some filter change, but I'll keep slowly changing my registers back to the original to see what it was that's changed everything.

Give these a try and let me know how you get on:

GYRCTRLREG1, 0b01001111
GYRCTRLREG2, 0b00011001
GYRCTRLREG3, 0b00000000
GYRCTRLREG4, 0b10110000
GYRCTRLREG5, 0b00111111

I'm still on the accel and note that the spikes occur mostly when a sensor should be reading a nominal zero value.

I will hopefully be through this and onto the gyro again over the weekend.

OK, what I think I've got it down to:

  • Filtering is necessary, previously I just wanted raw data with the intent to filter it later, but now it's filtered with a HP of 0.02Hz, sampling at 200Hz, with a bandwidth of 12.5Hz.
  • What I think is probably most important, high pass filter mode in register 2 must be set to 'reference signal for filtering'. Normal mode or anything else doesn't cut it.
  • The bandwidth is important but the sampling rate doesn't seem to be. 12.5Hz bandwidth works for me, but I've also tested with 100Hz sampling rate and that seems to work good too. I'm sticking to 200Hz though.
  • As I'm not dealing with interrupts, all of reg 3 is low. Don't need to worry about that reg.
  • I don't think scale selection makes a difference, I'm running at 2000dps.
  • Reg 5 I have both HP and LP turned on. I don't think LP is necessary, but HP definitely is.

Basically in conclusion, the spike is some sort of low frequency noise. Maybe from fluorescent bulbs, the boards power supply, maybe I haven't got enough decoupling caps, I don't really know. All I can say is that the spike is noise lower than 0.02Hz (as that's what my HP is set to and I'm not seeing the spike any more) coming from somewhere, and the on-board filters can deal with it adequately.

As for your accelerometer (which as you know, I have the same of) I've not seen the spikes for that, I have seen it a little bit for my magnetometer though, which I'm not seeing any more as well (not sure why, I didn't change anything for the mag). I think you should try with pull up resistors, as I've read a lot around on how necessary they are; I'm using 1.2KOhm.

Here are the registers for my acc and mag, along with my final gyr, maybe they'll help:

ADXL345

0x31 (DATA_FORMAT) : 0b00001011
0x2D (POWER_CTL) : 0b00001000
0x2E (INT_ENABLE) : 0b00000000
0x2C (BW_RATE) : 0b00001010

L3G4200D

0x20 (GYRCTRLREG1) : 0b00001111
0x21 (GYRCTRLREG2) : 0b00011001
0x22 (GYRCTRLREG3) : 0b00000000
0x23 (GYRCTRLREG4) : 0b10110000
0x24 (GYRCTRLREG5) : 0b00010011

HMC5883L

0x00 (Configuration register A) : 0b00011000
0x01 (Configuration register B) : 0b00100000
0x02 (Mode register) : 0b00000000

All tested and working, no spikes in any of the sensors (also got the barometer working, but not using it, let me know if you need anything for that).

My tests with your register settings seem to indicate that the spike is removed when the dps is 500 (01) but returns when the dps is 250 (00).

I have the MPU and IG3 running concurrently on the same board and the MPU does not show a spike or anything at the same time as the IG3. I don't suspect that the spike is caused by motion of the sensor. In fact all the settings we fiddle about with should be to control external motion influences and not to get the sensor to work properly.

The only thing I can think of is that the sensor is being influenced by some airborne electromagnetic stuff... but that would make it a very fragile design as I don't imagine I have too much EM floating about but I will hunt for this in a bit.

At the moment I an looking into cutting out the spike in code. The accelerometer was easy as it was a relatively big spike and easy to identify and hence deal with. These spikes are only large compared to the nominal zero value but almost insignificant during rotation signal levels. Unfortunately at the point of no movement is when the spike will be most irritating... perhaps just a little smoothing filter will be enough.

I had the same problem with the L3G4200
The issue was fixed using the following registers:

CTRL_REG1, 0b00001111
CTRL_REG2, 0b00010000
CTRL_REG3, 0b00000000
CTRL_REG4, 0b10110000
CTRL_REG5, 0b00010011