Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 115 lines (84 sloc) 7.665 kB
e3ea552 @kevin-pololu updated readme and copyright date
kevin-pololu authored
1 h1. Arduino library for Pololu L3G boards
b1962ec @kevin-pololu added Serial example, license, and readme
kevin-pololu authored
2
a329ba5 @kevin-pololu updated readme and added notes in example sketch comments; also minor…
kevin-pololu authored
3 Version: 2.0.0
4 Release Date: 2015-02-05
02b8362 @kevin-pololu turned Pololu website url into link in readme
kevin-pololu authored
5 "www.pololu.com":http://www.pololu.com/
b1962ec @kevin-pololu added Serial example, license, and readme
kevin-pololu authored
6
7 h2. Summary
8
e3ea552 @kevin-pololu updated readme and copyright date
kevin-pololu authored
9 This is a library for the "Arduino":http://pololu.com/catalog/product/2191 that interfaces with L3GD20H, L3GD20, and L3G4200D gyros on Pololu boards. It makes it simple to read the raw gyro data from these boards:
67f52a2 @kevin-pololu Update master
kevin-pololu authored
10
e3ea552 @kevin-pololu updated readme and copyright date
kevin-pololu authored
11 * "L3GD20H 3-axis gyro carrier":http://www.pololu.com/catalog/product/2129
fc86435 @kevin-pololu updated readme
kevin-pololu authored
12 * "L3GD20 3-axis gyro carrier":http://www.pololu.com/catalog/product/2125
a329ba5 @kevin-pololu updated readme and added notes in example sketch comments; also minor…
kevin-pololu authored
13 * "MinIMU-9 v3 <notextile>(L3GD20H and LSM303D carrier)</notextile>":http://www.pololu.com/catalog/product/2468
14 * "AltIMU-10 v4 <notextile>(L3GD20H, LSM303D, and LPS25H carrier)</notextile>":http://www.pololu.com/catalog/product/2470
15 * "AltIMU-10 v3 <notextile>(L3GD20H, LSM303D, and LSM331AP carrier)</notextile>":http://www.pololu.com/catalog/product/2469
c2b9fd7 @kevin-pololu readme: indicate 4200D discontinued
kevin-pololu authored
16 * "L3G4200D 3-axis gyro carrier":http://www.pololu.com/catalog/product/1272 (discontinued)
71cd3d6 @kevin-pololu readme fixes/clarifications
kevin-pololu authored
17 * "MinIMU-9 v2 <notextile>(L3GD20 and LSM303DLHC carrier)</notextile>":http://www.pololu.com/catalog/product/1268 (discontinued)
e3ea552 @kevin-pololu updated readme and copyright date
kevin-pololu authored
18 * "MinIMU-9 <notextile>(L3G4200D and LSM303DLM carrier)</notextile>":http://www.pololu.com/catalog/product/1265 (discontinued)
19 * "MinIMU-9 <notextile>(L3G4200D and LSM303DLH carrier)</notextile>":http://www.pololu.com/catalog/product/1264 (discontinued)
a329ba5 @kevin-pololu updated readme and added notes in example sketch comments; also minor…
kevin-pololu authored
20 * "AltIMU-10 <notextile>(L3GD20, LSM303DLHC, and LPS331AP carrier)</notextile>":http://www.pololu.com/catalog/product/1269 (discontinued)
b1962ec @kevin-pololu added Serial example, license, and readme
kevin-pololu authored
21
22 h2. Getting Started
23
24 h3. Software
25
6462df3 @kevin-pololu replace tabs with spaces
kevin-pololu authored
26 Download the archive from "GitHub":https://github.com/pololu/L3G, decompress it, and move the "L3G" folder into the "libraries" subdirectory inside your Arduino sketchbook directory. You can view your sketchbook location by selecting File->Preferences in the Arduino environment; if there is not already a "libraries" folder in that location, you should create it yourself. After installing the library, restart the Arduino environment so it can find the L3G library and its example.
b1962ec @kevin-pololu added Serial example, license, and readme
kevin-pololu authored
27
28 h3. Hardware
29
e3ea552 @kevin-pololu updated readme and copyright date
kevin-pololu authored
30 Make the following connections with wires between the Arduino and the L3G board:
31
32 h4. Arduino Uno R3, Leonardo, Mega 2560
33
34 pre. Arduino L3G board
35 ----------------------
36 5V -> VIN
37 GND -> GND
38 SDA -> SDA
39 SCL -> SCL
40
41 h4. Arduino Micro
42
43 pre. Arduino L3G board
44 ----------------------
45 5V -> VIN
46 GND -> GND
47 2 -> SDA
48 3 -> SCL
b1962ec @kevin-pololu added Serial example, license, and readme
kevin-pololu authored
49
e3ea552 @kevin-pololu updated readme and copyright date
kevin-pololu authored
50 h4. Arduino Uno (up to R2), Duemilanove, etc.
b1962ec @kevin-pololu added Serial example, license, and readme
kevin-pololu authored
51
e3ea552 @kevin-pololu updated readme and copyright date
kevin-pololu authored
52 pre. Arduino L3G board
53 ----------------------
54 5V -> VIN
55 GND -> GND
56 A4 -> SDA
57 A5 -> SCL
b1962ec @kevin-pololu added Serial example, license, and readme
kevin-pololu authored
58
98b2d30 @kevin-pololu updated readme; changed Serial example to print readings as ints
kevin-pololu authored
59 h2. Example Programs
b1962ec @kevin-pololu added Serial example, license, and readme
kevin-pololu authored
60
b46cba9 @kevin-pololu added keywords.txt; updated readme
kevin-pololu authored
61 Open an example code sketch by selecting File->Examples->L3G->example_name
b1962ec @kevin-pololu added Serial example, license, and readme
kevin-pololu authored
62
98b2d30 @kevin-pololu updated readme; changed Serial example to print readings as ints
kevin-pololu authored
63 h3. Serial
b1962ec @kevin-pololu added Serial example, license, and readme
kevin-pololu authored
64
98b2d30 @kevin-pololu updated readme; changed Serial example to print readings as ints
kevin-pololu authored
65 This program continuously reads the gyro, communicating the readings over the serial interface. You can display the readings with the Arduino Serial Monitor.
b1962ec @kevin-pololu added Serial example, license, and readme
kevin-pololu authored
66
98b2d30 @kevin-pololu updated readme; changed Serial example to print readings as ints
kevin-pololu authored
67 Example output:
b1962ec @kevin-pololu added Serial example, license, and readme
kevin-pololu authored
68
98b2d30 @kevin-pololu updated readme; changed Serial example to print readings as ints
kevin-pololu authored
69 pre. G X: 188 Y: -10 Z: -47
70 G X: 138 Y: -40 Z: -26
71 G X: 110 Y: -55 Z: 4
b1962ec @kevin-pololu added Serial example, license, and readme
kevin-pololu authored
72
a329ba5 @kevin-pololu updated readme and added notes in example sketch comments; also minor…
kevin-pololu authored
73 See the comments in this sketch for some notes on how to convert the raw sensor values to units of dps (degrees per second).
74
1019ea3 @kevin-pololu Update README.textile
kevin-pololu authored
75 h2. Other Library Applications
76
a329ba5 @kevin-pololu updated readme and added notes in example sketch comments; also minor…
kevin-pololu authored
77 These programs make use of the L3G library but are not included in the library archive or repository.
1019ea3 @kevin-pololu Update README.textile
kevin-pololu authored
78
79 - "MinIMU-9 + Arduino AHRS":https://github.com/pololu/minimu-9-ahrs-arduino := This sketch allows an Arduino connected to a MinIMU-9 or AltIMU-10 to function as an attitude and heading reference system, calculating estimated roll, pitch, and yaw angles from sensor readings that can be visualized with a 3D test program on a PC. It is based on the work of Jordi Munoz, William Premerlani, Jose Julio, and Doug Weibel.
80 - "Pololu_Open_IMU":https://github.com/mikeshub/Pololu_Open_IMU/tree/master/Pololu_Open_IMU by mikeshub := This is an alternative AHRS implementation that uses the "Madgwick algorithm":http://www.x-io.co.uk/open-source-imu-and-ahrs-algorithms/.
81 - "ascii_graph":https://gist.github.com/drewtm/9081341 by drewtm := This sketch outputs a text-based graph of LSM303 accelerometer and L3G gyro data, providing a quick way to check whether the sensors are working as expected.
82
98b2d30 @kevin-pololu updated readme; changed Serial example to print readings as ints
kevin-pololu authored
83 h2. Library Reference
b1962ec @kevin-pololu added Serial example, license, and readme
kevin-pololu authored
84
a329ba5 @kevin-pololu updated readme and added notes in example sketch comments; also minor…
kevin-pololu authored
85 - @vector<int16_t> g@ := The last values read from the gyro.
86 - @byte last_status@ := The status of the last I2C transmission. See the "@Wire.endTransmission()@ documentation":http://arduino.cc/en/Reference/WireEndTransmission for return values.
87
88 - @L3G(void)@ := Constructor.
89 - @bool init(byte device, byte sa0)@ := Initializes the library with the device being used (@device_4200D@, @device_D20@, @device_D20H@, or @device_auto@) and the state of the SA0 pin (@sa0_low@, @sa0_high@, or @sa0_auto@), which determines the least significant bit of the I²C slave address. Constants for these arguments are defined in L3G.h. Both of these arguments are optional; if they are not specified, the library will try to automatically detect the device and slave address, and it will return a boolean indicating whether the type of L3G device was successfully determined (if necessary).
90 *Note:* Automatic detection of the device type currently does not work with the Arduino Due because of issues with its Wire library. To work around this, specify the device and SA0 state manually (e.g. @init(L3G::device_D20, L3G::sa0_high)@).
91 - @byte getDeviceType(void)@ := Returns the device type specified to or detected by @init()@.
92 - @void enableDefault(void)@ := Turns on the gyro and enables a consistent set of default settings.
93 This function will set the gyro's full scale to be +/-250 dps (degrees per second), which means that a reading of 114 corresponds to approximately 1 dps. See the comments in L3G.cpp for a full explanation of these settings.
94 - @void writeReg(byte reg, byte value)@ := Writes a gyro register with the given value. Register address constants are defined by the regAddr enumeration type in L3G.h.
95 Example use: @gyro.writeReg(L3G::CTRL_REG1, 0x6F);@
98b2d30 @kevin-pololu updated readme; changed Serial example to print readings as ints
kevin-pololu authored
96 - @byte readReg(byte reg)@ := Reads a gyro register and returns the value read.
e023519 @kevin-pololu Arduino 1.0 compatibility
kevin-pololu authored
97 - @void read(void)@ := Takes a reading from the gyro and stores the values in the vector @g@.
a329ba5 @kevin-pololu updated readme and added notes in example sketch comments; also minor…
kevin-pololu authored
98 - @void setTimeout(unsigned int timeout)@ := Sets a timeout period for @read()@, in milliseconds, after which it will abort if no data is received. A value of 0 disables the timeout.
99 - @unsigned int getTimeout(void)@ := Returns the current timeout period setting.
100 - @bool timeoutOccurred(void)@ := Returns a boolean indicating whether a call to @read()@ has timed out since the last call to @timeoutOccurred()@.
67f52a2 @kevin-pololu Update master
kevin-pololu authored
101
e023519 @kevin-pololu Arduino 1.0 compatibility
kevin-pololu authored
102 h2. Version History
103
a329ba5 @kevin-pololu updated readme and added notes in example sketch comments; also minor…
kevin-pololu authored
104 * 2.0.0 (2015-02-05): Major rewrite, making library more consistent with LSM303 library. List of significant changes:
105 ** @enableDefault()@ behavior changed to be more explicit and consistent across devices.
106 ** Library constants converted to enums.
107 ** L3GD20H is now detected as a distinct device (instead of being treated as an L3GD20) and constants have been added for the register names specified in its datasheet.
108 ** Added timeout functions from LSM303 library.
e3ea552 @kevin-pololu updated readme and copyright date
kevin-pololu authored
109 * 1.2.2 (2014-02-05): Added support for L3GD20H.
fc86435 @kevin-pololu updated readme
kevin-pololu authored
110 * 1.2.1 (2012-10-31): Cast sensor readings to 16-bit ints for better portability.
111 * 1.2.0 (2012-07-06): Renamed library to L3G and added support for L3GD20.
71cd3d6 @kevin-pololu readme fixes/clarifications
kevin-pololu authored
112 ** Besides the name change, the main difference from the L3G4200D library as originally released is that you need to call the @init()@ function before using any of the other library functions, typically from within the Arduino @setup()@ function. While the older library only works with the Pololu boards' default gyro slave address of 1101001b, the new library allows you to specify the slave address with the @init()@ function.
e023519 @kevin-pololu Arduino 1.0 compatibility
kevin-pololu authored
113 * 1.1.0 (2011-12-12): Arduino 1.0 compatibility.
206647b @yazug Whitespace cleanup in README
yazug authored
114 * 1.0.0 (2011-09-14): Original release of L3G4200D library.
Something went wrong with that request. Please try again.