pololu / l3g-arduino Goto Github PK
View Code? Open in Web Editor NEWArduino library for Pololu L3G4200D and L3GD20 boards
Home Page: http://www.pololu.com/catalog/product/2125
License: MIT License
Arduino library for Pololu L3G4200D and L3GD20 boards
Home Page: http://www.pololu.com/catalog/product/2125
License: MIT License
Hi, I've heard that the are issues with compatibility when it comes to the Arduino Due,
Will this work library work with one?
Thanks!
code compiles fine, but due to right shift operator gives wrong output on a 32bit arm platform.
Requires type cast, so the desired 16 bit signed integer is always used:
about line 107 in L3G.cpp
in function:
void L3G::read()
change:
g.x = xha << 8 | xla;
g.y = yha << 8 | yla;
g.z = zha << 8 | zla;
to:
g.x = (int16_t)(xha << 8 | xla);
g.y = (int16_t)(yha << 8 | yla);
g.z = (int16_t)(zha << 8 | zla);
Pololu, I appreciate your outstanding libraries for the l3g and the lsm303.
I'm using them both on the Arduino Due to build a drift compensated gyro with an experimental Newton-Cotes based numerical integration on the gyro.
The complication I ran into is that the Due has two I2C ports. The default is on pins 20/21 and are activated when you call Wire.begin(). However, more convenient for my build are the SCL1/SDA1 pins closer to the AREF pin that are activated when you call Wire1.begin().
You library uses direct calls to Wire throughout (i.e. Wire.write()
, Wire.beginTransmission()
, etc). So I rewrote the library to configure which I2C port users want their L3G or LSM303 objects to communicate through. To keep things simple for new Arduino users I set the default to the normal Wire library so all of your existing examples still work. The new constructor definition looks like this.
LSM303(I2C_port::port p = I2C_port::primary);
If you are interested in seeing this functionality, I can open a pull request and you can check it out.
In the function readReg(), there is a Wire.endTransmission() after the Wire.requestFrom(). That should not be there. The Wire.endTransmission() is only used when writing data.
In the function read(), there is a timeout after Wire.requestFrom(). That timeout is not needed. The Wire.requestFrom() waits until the I2C transmission has completely finished. After that, the received data is in a buffer in the Wire library. The Wire.available() shows how many bytes there are in that buffer.
The return value of Wire.requestFrom() or the Wire.available() could be be used to check if the correct number of bytes was received or if a bus error did occur.
This really isn't an issue with the l3g library. I have tested it with the arduino's (uno, mega, due), the Galileo and the Teensy 3.1. It works like a charm. I am using the Altimu-10 v3. My problem is I want to incorporate a copy of it into my Freeimu library (Freeimu-updates on Github) but it keeps coming up as a sub-module and when the library is downloaded it comes up empty when downloaded. Any help on getting it downloaded or linked would be appreciated.
Mike (mjs513)
The output of my gyroscope is not 0 ΒΊ/s when it is stationary. How could I calibrate it? I am using the following library : https://github.com/pololu/l3g-arduino
and the example that is attached to this file.
Thanks!
Hi, I'm not sure if this would be the right place to ask, but are the readings read from the gyro in degrees per second, or do they require some conversion? If they are in degrees per second, what is the maximum value for this? Thanks in advance.
Here is a sketch that "graphs" the accelerometer and gyroscope data coming from the pololu L3G and LSM303 libraries--by rapidly outputting graphically-arranged strings to the Arduino serial monitor. It's much easier than strings of numbers to look at and tell whether your sensors are working properly. I wasn't sure where to put it since it is set up to use both libraries at once, so here it is in an 'issue'.
#include <Wire.h>
#include <String.h>
#include <L3G.h>
#include <LSM303.h>
LSM303 compass;
L3G gyro;
void setup() {
Serial.begin(115200);
Wire.begin();
if (!gyro.init())
{
Serial.println("Failed to autodetect gyro type!");
while (1);
}
if (!compass.init())
{
Serial.println("Failed to initialize compass!");
while (1);
}
gyro.enableDefault();
compass.enableDefault();
}
void loop() {
static int barcounter = 0;
String spacestring = " ";
String barstring = "----------------------------------------------------------------";
String outstring;
barcounter++;
if(barcounter==10){
barcounter=0;
outstring=barstring;
outstring += millis()/100;
}
else outstring=spacestring;
gyro.read();
compass.read();
//gyro axes are drawn with thin lines, accelerometer are drawn with thick lines
outstring.setCharAt(11+((int)gyro.g.x)/3277, ':');
outstring.setCharAt(11+((int)compass.a.x)/3277, 'X');
outstring.setCharAt(32+((int)gyro.g.y)/3277, ':');
outstring.setCharAt(32+((int)compass.a.y)/3277, 'X');
outstring.setCharAt(53+((int)gyro.g.z)/3277, ':');
outstring.setCharAt(53+((int)compass.a.z)/3277, 'X');
Serial.println(outstring);
delay(20);
}
Hi,
First of all, thank you for your library.
I tested it with my arduino nano, it works well.
However, there might be some mistakes on your README.
I followed your connection advice to connect VCC to +5V, it all goes well until I accidentally touched my arduino nano board.
It was really hot! Thanks god I wasn't scalded. Moreover, the light on my arduino nano turns from green to orange.
After reading the L3G4200D datasheet, I noticed that its recommended voltage is 2.4V-3.6V. I used 3.3V to retest it. It works fine.
As a result, I strongly recommend you to modify your README and to tell users to refer to their own sensor board's datasheet to determine the correct input voltage.
Thank you
So the function enableDefault() sets the FS range to 250 dps. How can I manually change the default range to say 2000 dps?
So I navigated to the function enableDefault() inside the library and found out that we write a certain value to the CTRL4 register. Does anyone know what value can be changed there to make it switch to 2000 dps?
Hi, I'm trying to run the Serial example in the library, but I'm having issues. I've imported the library, I'm using an Arduino Uno, and the program compiles without issues. But when I run it, it stops when it encounters a function from the library. So, for example, it'll output basic Serial.println text outputs before any function from the library, and after a l3g function it doesn't output anything. Neither while(gyro.init()) nor while(!gyro.init()) loop will work for checking the detection, there's no text output inside the loop, it seems to just get stuck on the gyro.init. I've tried using the adafruit l3g20h code, and it works fine. I also noticed that if I manually enter (L3G::device_D20, L3G::sa0_high) into the function parameters then it gets past that function call, but since there are functions without any parameters, that can't always work. Does anyone know what the issue could be?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.