L3G4200D random spikes

Do you have any idea what could be the cause? I'll check my registers against yours in a bit to see if I have any differences.

The board you speak of, is it the GY-80? If so, I used the exact same one. I'm not getting any noise on the accelerometers, but my magnetometer is also experiencing a bit of noise like the gyroscope.

Yep its GY-80.

I note that the accel spikes are when it is nearly horizontal so z <> 0 but x and y will be zero or thereabouts… fits in with something going wrong ‘inside’ the chip/board to me. By observation the spikes are about 256…

I had my suspicions about the board and contacted the supplier who simply stuck two fingers back at me and went to ground not responding to messages. I think they have no idea what they buy in from China and certainly don’t test the stuff if they are just a re-boxer.

By the way, what tool do you use for tracing?

I’ll fiddle with the mag again soon but it may not do what I want anyway as it is too sensitive to iron/steel etc in the vicinity irrespective of any reading issues :frowning:

Not terribly satisfactory I’m afraid :frowning:

Although my prototyping was done with an Arduino, my made up board is using a PIC and I'm debugging and testing using MPLAB.

My original Arudino + GY80 has this spike problem, but my made up board I made myself was following the datasheet for the gyroscope, accelerometer, and magnetometer, and using the components they recommended, which also matched the GY80. So basically, I don't think it's the GY80's fault, as I have compared the schematic for both the GY80 and my interpretation of the sensors combined on a i2c rail and they're almost identical, plus they both have the error.

All this tells me that whatever problem I'm having, it's probably software related.

I have run the simple sketch using the LG3 and ADXL on the GY-80 board and isolated the spikes. The sensors are 'still' and horizontal.

The following are raw values prior to any offset.

XA is the X accelerometer, YA, the Y and XG the gyro etc

Interesting to see the range of values rather than a specific pattern (or I can't see it). Only YA, XG and ZG spiked

    YA-243
    YA247
    YA248
            XG-255
                    ZG-249
    YA247
            XG255
    YA-243
    YA-243
    YA246
    YA-243
            XG202
                    ZG-238
                    ZG-251
                    ZG238
    YA248
    YA248
    YA247
    YA247
    YA-243
    YA-243
            XG238
    YA-243
    YA247
    YA-243
            XG252
            XG231
    YA248
    YA248
                    ZG235
    YA248
    YA-243
                    ZG-245
    YA-243
    YA-243
    YA248
    YA248
            XG-224
            XG246
    YA247
    YA248
    YA247
    YA-243
    YA247
            XG253
    YA-243
    YA-243
    YA-243
            XG255
    YA-243
    YA247
    YA-243
    YA248
    YA247
    YA-243
    YA-243
    YA-243
            XG-246
            XG236
    YA-243
    YA-243
            XG-217
    YA248
            XG-248
    YA-243
    YA247
    YA-243
    YA-243
                    ZG-243
    YA248
    YA248
    YA-243
    YA247
    YA248
    YA247
    YA-243
            XG-230
    YA247
    YA-243
            XG-234
            XG245
    YA-243
    YA-243
                    ZG238
    YA248
    YA-243
    YA247
            XG-234
            XG249
    YA-243
    YA-243
            XG255
            XG251
            XG255
    YA-243
    YA-243
    YA248
                    ZG-255
            XG226
            XG-227
    YA-243
    YA248
    YA-243
    YA-243
    YA248
            XG-233
    YA248
    YA247
            XG-220
    YA247
    YA-243
    YA248
    YA-243
            XG-248
    YA-243
    YA-243
    YA-243
    YA-243
                    ZG-248
    YA248
            XG-248
            XG255
    YA-243
            XG235
    YA-243
    YA248
    YA-243
    YA-243
    YA-243
    YA-243
    YA248
    YA-243
    YA-243
    YA247
    YA247
    YA-243
    YA248
    YA-243
    YA-243
    YA248
            XG-247
    YA-243
    YA248
                    ZG-250
            XG-234
    YA248
    YA-243

All this tells me that whatever problem I'm having, it's probably software related.

I'd put my money on the sensor being at fault.

Well, I have three of them, one pre-built in the GY80 breakout, and two SMD components I had mounted myself; they've all got the problem.

Statistically I would have to be very unlucky for them all to have a problem, especially as so many people don't have this issue.

See my other post to see how I got a bad lot of NRF24s...

If many suppliers were buying and distributing from the same supply source then they may all have the same fault... or they are sensors that have failed the quality checks and made their way onto the 'cheapo' market to purchased by people who don't normally dig in and check what they've bought.

Have you been using the interrupt pins or the FIFO registers? I haven't, and it would be interesting to see if you are using them and still seeing this issue.

No and no. Hoped I wouldn't have to do this.

Have you made any progress?

Afraid not. Trying all sorts.

Currently I'm doing multiple byte read from the gyro, so I'm now trying to get it to work by doing single byte reads. Changing the registers doesn't solve any problems, neither does changing the sampling rate or the i2c speed.

I'll let you know if I find anything. I even messaged STMicroelectronics to see if they could help but no word back. It's not an uncommon problem, I'm finding people all over the net seeing this.

Maybe it's not a problem, maybe it's just expected noise? I don't know...

I still don't think it's a faulty sensor, though. Crappy sensors to start with, maybe, but I don't think I have faulty ones.

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