L3G4200D needs constant reset [UPDATE - uncommunicative supplier]

What is spinning at high speed ?
If you hold it in your hand, you can achieve only very little spin.
If you hit it on a table, the g-forces are no problem for most sensors.

A few basic questions:

  • Which Arduino board are you using ?
  • How did you connect the sensor, at 5V or 3.3V ?
  • Which library did you use ?

I can't tell you actual RPM but its 'finger spinning fast' = pretty speedy :slight_smile:

Using 3.3v
Arduino Mega2560
Code is not using a library apart from 'Wire'. Essential elements taken from a number of sources.

Basic set up from Sparkfun/Jim Linblom

void GyroSetup(int scale){
  //From  Jim Lindblom of Sparkfun's code

    // Enable x, y, z and turn off power down:
  writeRegister(GyroAddress, CTRL_REG1, 0b00001111);

  // If you'd like to adjust/use the HPF, you can edit the line below to configure CTRL_REG2:
  writeRegister(GyroAddress, CTRL_REG2, 0b00000000);

  // Configure CTRL_REG3 to generate data ready interrupt on INT2
  // No interrupts used on INT1, if you'd like to configure INT1
  // or INT2 otherwise, consult the datasheet:
  writeRegister(GyroAddress, CTRL_REG3, 0b00001000);

  // CTRL_REG4 controls the full-scale range, among other things:

  if(scale == 250){
    writeRegister(GyroAddress, CTRL_REG4, 0b00000000);
  }
  else if(scale == 500){
    writeRegister(GyroAddress, CTRL_REG4, 0b00010000);
  }
  else{
    writeRegister(GyroAddress, CTRL_REG4, 0b00110000);
  }

  // CTRL_REG5 controls high-pass filtering of outputs, use it
  // if you'd like:
  writeRegister(GyroAddress, CTRL_REG5, 0b00000000);
  return;
}

I'm checking the status register as well to see if I can find anything useful but nothing I can identify yet.

Have noted that the propensity is dependent upon Serial speed - more likely at lower ie 4800 that 115200. Also a delay in the loop of 50 millis reduces it.

Cheers Alan

After a period of inactivity I picked up the kit and spun it and the 'sticky' values are around these -32768 32752 -32534... Hmmm

I have not heard of the values sticking to the min and max.
So it might be the wiring or the sketch.
You use interrupts ?
Perhaps you can make a new minimal sketch, that does only the basic things.
It is very common (for me) to use about 4 or 5 different sketches to get something working.

The Mega has onboard 10k pull-up resistors on the SDA and SCL lines to 5V. That will lift the levels of the I2C too high for the sensor. Could you use an Arduino Uno or Arduino Leonardo ?
Or perhaps you should use an I2C level shifter.

This seems nice clean code, but the author writes about random values, http://bildr.org/2011/06/l3g4200d-arduino/

I'll try a UNO tomorrow.

My code is essentially the same as in http://bildr.org/2011/06/l3g4200d-arduino/ which is basically a loop that reads the gyro and prints out the values - I think my code has come from basically the same source. Can't make it any simpler.

The problem is observed when all three sensors 'stick'. There are occasions when consecutive readings produce the same as the previous loop but its not that often (thanks to the 'noise'/chaos that's happening) but I do some checks to see how many loops that the readings don't change and it is obvious when something has gone wrong.

I don't have an issue with a sensor maxing out but it should recover on its own.

Okay, tried the UNO and same problem.

I tested the sensor recently with sparkfuns SPI-based sketch on a Arduino nano. I've experienced a lot of sensor drift, but never a lockup.
SPI uses the Int2 ( labelled DR on my board ) .

L3G4200D.rar (38.3 KB)

acboother, I have no idea what could be wrong.
You could try another sensor. Perhaps this one is broken (I don't think that is likely).
Could you post a link to the sensor breakout board you have, or make a photo of it ?

Here is the link to the eBay purchase...

http://www.ebay.co.uk/itm/140987205970?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649

I am reluctant to spend nearly £17 just to find out if the sensor is faulty :frowning:

Here is more information about the GY-80, http://www.uctronics.com/gy-80-bmp085-axis-magnetic-acceleration-gyroscope-atmospheric-pressure-module-p-1493.html

That one has a voltage regulator and I2C level shifters and pull-up resistors for the I2C.
So there is no problem connecting it to a Uno or Mega.
When connected to the Uno or the Mega, use 5V for VCC_IN.
Don't use the VCC_3.3V.

Can you run the i2c_scanner for an hour or so ?
http://playground.arduino.cc/Main/I2cScanner
If that is stable, it might be a damaged sensor.
If you accidently have connected the VCC_3.3V pin to 5V, that could damage it.

Here is more information about the GY-80, http://www.uctronics.com/gy-80-bmp085-axis-magnetic-acceleration-gyroscope-atmospheric-pressure-module-p-1493.html

I can't see what additional information this link supplies. Can you tell me what I missed?

I don't think I've mis-connected the 3.3 and 5v

How does running the scanner for an hour successfully show or not the correct functioning of the device. What would I be looking for in the scanner output? Obviously I'm not going to log and look through 1 hours output so I would filter the output to something useful - what would that be? I'm thinking of the simple i2c_scanner.pde that just tries to find the devices with

    Wire.beginTransmission(address);
    error = Wire.endTransmission();

The other devices on the breakout board seem to be fine (accel, compass, pressure). I'm beginning to favour that the gyro device is faulty in the absence of some rational explanation as to why 'sticking' is working as designed (albeit not what I would design it to do). What do others think?

The page in the link has a schematic.

I mentioned the i2c_scanner to test the I2C bus.
If the other sensors are okay, the I2C bus is probably good.

It seems indeed that the sensor has a problem.
You could buy another one to compare.

I don't know what tests you could do to determine if it is faulty or how to fix it. Sorry.

The MPU-6050 is cheaper, but it is a complicated chip. If software and using libraries is no problem for you, you could use the MPU-6050 with the I2Cdevlib.
http://www.i2cdevlib.com/

Poor old device seems unwell :frowning:

I had the similar problem, due to accidentally enabling the sleep mode due to improper conversion from binary to hex. Be very carefull to check that you are setting the registers that controll the power management functions by reading the datasheet sections on the ctrl_regX.

peterjam:
I had the similar problem, due to accidentally enabling the sleep mode due to improper conversion from binary to hex. Be very carefull to check that you are setting the registers that controll the power management functions by reading the datasheet sections on the ctrl_regX.

Thanks, that looks a promising line to follow...

The sample code does set the sleep mode so perhaps I have also copied this into my sketch/library. I'll check later and try to understand more about how sleep activates/deactivates to see how valuable it is to me.

Did you actually connect both the 5V and the 3.3V ? If you did, it looks like you didn't read the instructions. And if you paid 17 pounds for one of these, well, silly you.

michinyon:
Did you actually connect both the 5V and the 3.3V ? If you did, it looks like you didn't read the instructions. And if you paid 17 pounds for one of these, well, silly you.

What makes you think I connected the 5v?

I'm connecting to the L3G4200D through SPI. I tried many modes, register options but all I get is the gyro repeating the same values all the time too. Could you fix the problem?

Please see this post:

https://my.st.com/public/STe2ecommunities/mems_sensors/Lists/Gyroscopes/Flat.aspx?RootFolder=/public/STe2ecommunities/mems_sensors/Lists/Gyroscopes/L3G4200D%20giving%20constant%20values%20for%20x,%20y%20and%20z&currentviews=6

I could solve the output of constant values problem.