Shop OBEX P1 Docs P2 Docs Learn Events
Parallax L3G4200D gyroscope with Arduino Due — Parallax Forums

Parallax L3G4200D gyroscope with Arduino Due

chughtai538chughtai538 Posts: 3
edited 2014-09-24 02:46 in General Discussion
Hi

I'm working on an autopilot unit for fixed wing RC aircraft. I'm using the parallax L3G4200D to determine my angular rates, the board I'm using for the MCU, is the Arduino Due. I'm having trouble getting data from the gyro. My pin connections seem okay:

Gyro-->Due

SCL-->Pin 21(SCL)
SDA-->Pin 20(SDA)
Vin--> 5 V
GND--> GND

Im using the code for Arduino as posted here on the bottom of this page:
http://learn.parallax.com/KickStart/27911

Im getting a semi strange output in the Serial window. The rates seem correct when rotated in the CCW direction but when rotated CW, instead of getting a negative rate i get a rate in the range of 500-600 degrees/second.

Is anybody else having the same issue with this board? I've tried this sensor with the arduino uno and it works like a charm so the sensor itself is fine. Any help would be appreciated.

Comments

  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2014-09-22 11:36
    Vin--> 5 V

    The Due is a 3.3V device. As noted on their pages*, it is not 5V tolerant. The specs say that the 4200D can be operated at 3.3V, so there is no need to operate it at 5V.

    * The warning regarding I/O voltage is here:

    http://arduino.cc/en/Main/arduinoBoardDue

    Unfortunately, you may have already damaged your board. Try another circuit and sketch to check.

    Should your board check out, you could try adding pullups to both I2C lines. Something on the order of 1.8K to 4.7K is often recommended.
  • chughtai538chughtai538 Posts: 3
    edited 2014-09-23 08:17
    Thanks for the reply Gordon. I tried a different sketch, different sensor, compass(3-Axis HMC5883L), this time, with the Vin-->3.3V, I'm still getting really high and unreasonable values with the Due, whereas the Uno seems to give correct values with the same sensor. The funny thing here is that apart from i2C communication, the Due seems to be working fine. I tried some basic examples like 'BlinkWithoutDelay' and it worked.

    So have I just damaged the i2C line on my Due? I don't think the pins 20, and 21 need pull ups, they have them built in
  • Mark_TMark_T Posts: 1,981
    edited 2014-09-23 09:47
    No they need pullups - try 4k7. Built in pull ups on the SAM3X8E are far far too weak for I2C. But perhaps
    the module already have pull-ups? Should be possible to check with a hand lens if the schematic's ellusive.
  • ChrisGaddChrisGadd Posts: 300
    edited 2014-09-23 10:09
    The module has pullups built in. The problem is that the values returned from the gyroscope are 16-bit 2's complement. That value needs to be sign-extended in order to read negative values. Dunno how to do that with a SAM3X8E, but my Propeller object gives readings in the 500 range if I comment out the ~~ extender.
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2014-09-23 11:48
    Supposedly the 42000 already has the pullups. I just read that the Due already has 1K (1,000 ohm) pullups, which is pretty strong. I'm wondering if that's a typo? If it's true, then the pullups on the module and the pullups on the Due might be parallelling to some lower combined value. In any case, I don't think that's your problem, as the sensor works in one direction, but not the other.

    If there's been damage to the Due it'll probably show up as problems with I/O 20 and 21 in general, so a basic LED and switch circuit on those pins might work. There are software I2C libraries for the Arduino if you'd like to try other pins. In any case, by your description of what's happening I don't think your Due was damaged. In the future, be sure not to apply 5V to any pin without level translation!

    If there's an issue with the format of the return values, as ChrisGadd notes, it doesn't appear to happen on the Uno. Someone with a Due, which is based on a completely different chip than the AVR-based Arduinos (and therefore the Wire implementation may vary), will hopefully chime in. I don't have one to test.
  • chughtai538chughtai538 Posts: 3
    edited 2014-09-24 02:46
    Thanks for the help guys, really appreciate it. The issue with the return values does make sense. It would explain why it works in one direction. I guess this is more of a software issue. I'll start playing around with my code, but if somebody who has experience with this board could fill in that would be great.
Sign In or Register to comment.