Skip to content

Commit 4971ab4

Browse files
formatting test
1 parent 5303f50 commit 4971ab4

File tree

21 files changed

+1224
-45
lines changed

21 files changed

+1224
-45
lines changed

README.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
SparkFun <PRODUCT NAME> Arduino Library
1+
SparkFun LSM6DS3 Arduino Library
22
========================================
33

4-
![SparkFun Part Name](URL for picture of part)
4+
![LSM6DS3 Breakout](URL for picture of part)
55

6-
[*SparkFun Part Name (SKU)*](URL for product on Sparkfun.com)
6+
[*SparkFun Part Name (SKU)*](https://cdn.sparkfun.com/assets/learn_tutorials/4/1/6/perspective.jpg)
77

8-
<Basic description of the library.>
8+
This is an arduino IDE library to control the LSM6DS3. It can be configured to use I2C or SPI with 2 instances per I2C channel or any number of SPI instances. The top-level driver, class LSM6DS3, contains an inner driver LSM6DS3Core, a settings struct, and float-based math functions for conversion from raw to meaningful numbers.
9+
10+
This has been tested with Arduino Uno and Teensy 3.1 architectures.
911

1012
Repository Contents
1113
-------------------
@@ -16,24 +18,34 @@ Repository Contents
1618
* **keywords.txt** - Keywords from this library that will be highlighted in the Arduino IDE.
1719
* **library.properties** - General library properties for the Arduino package manager.
1820

21+
Example Briefs
22+
--------------
23+
24+
* FifoExample - Demonstrates using the built-in buffer to burst-collect data - **Good demonstration of settings**
25+
* InterruptFreeFall - Embedded function demonstrating free-fall detection
26+
* InterruptHWTapConfig - Embedded function demonstrating tap and double-tap detection
27+
* LowLevelExample - Demonstrates using only the core driver without math and settings overhead
28+
* MinimalistExample - The **easiest** configuration
29+
* MultiI2C - Using two LSM6DS3s over I2C
30+
* MultiSPI - Using two LSM6DS3s over SPI
31+
* Pedometer - Embedded function demonstrating step-counting feature
32+
1933
Documentation
2034
--------------
2135

2236
* **[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)** - Basic information on how to install an Arduino library.
23-
* **[Product Repository](GitHub Product URL)** - Main repository (including hardware files) for the <PRODUCT NAME>.
24-
* **[Hookup Guide](Learn.SparkFun URL)** - Basic hookup guide for the <PRODUCT NAME>.
37+
* **[Product Repository](https://github.com/sparkfun/LSM6DS3_Breakout/)** - Main repository (including hardware files) for the LSM5DS3 Breakout.
38+
* **[Hookup Guide](https://learn.sparkfun.com/tutorials/lsm6ds3-breakout-hookup-guide)** - Basic hookup guide for the LSM5DS3 Breakout.
2539

2640
Products that use this Library
2741
---------------------------------
2842

29-
* [Part SKU](SparkFun part URL)- Basic part and short description here
30-
* [Part SKU](SparkFun part URL)- Basic part and short description here
43+
* [BOB-13339](https://www.sparkfun.com/products/13339)- LSM6DS3 Breakout board
3144

3245
Version History
3346
---------------
3447

35-
* [vExxFxxZxxHxxLxxSxx](URL for tag specific to this version) - Description
36-
* [vEyyFyyZyyHyyLyySyy](URL for tag specific to this version) - Description
48+
* [v1.0.0](URL for tag specific to this version) - Description
3749

3850
License Information
3951
-------------------
@@ -48,4 +60,3 @@ Distributed as-is; no warranty is given.
4860

4961
- Your friends at SparkFun.
5062

51-
_<COLLABORATION CREDIT>_

examples/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
SparkFun Arduino Examples
2+
==========================
3+
4+
Example Briefs
5+
--------------
6+
7+
* FifoExample - Demonstrates using the built-in buffer to burst-collect data - **Good demonstration of settings**
8+
* InterruptFreeFall - Embedded function demonstrating free-fall detection
9+
* InterruptHWTapConfig - Embedded function demonstrating tap and double-tap detection
10+
* LowLevelExample - Demonstrates using only the core driver without math and settings overhead
11+
* MinimalistExample - The **easiest** configuration
12+
* MultiI2C - Using two LSM6DS3s over I2C
13+
* MultiSPI - Using two LSM6DS3s over SPI
14+
* Pedometer - Embedded function demonstrating step-counting feature

extras/LICENSE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
License Information
3+
-------------------
4+
5+
The hardware is released under [Creative Commons Share-alike 3.0](http://creativecommons.org/licenses/by-sa/3.0/).
6+
7+
All other code is open source so please feel free to do anything you want with it; you buy me a beer if you use this and we meet someday ([Beerware license](http://en.wikipedia.org/wiki/Beerware)).
8+
9+
->Additional Licenses and attributions to original authors as needed.<-
10+

extras/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Any extra documentation that should accompany the library.
2+
3+
This directory is ignored by the Arduino Package manager, so do not place vital files in here!

extras/README22.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
SparkFun <PRODUCT NAME> Arduino Library
2+
========================================
3+
4+
![SparkFun Part Name](URL for picture of part)
5+
6+
[*SparkFun Part Name (SKU)*](URL for product on Sparkfun.com)
7+
8+
<Basic description of the library.>
9+
10+
Repository Contents
11+
-------------------
12+
13+
* **/examples** - Example sketches for the library (.ino). Run these from the Arduino IDE.
14+
* **/extras** - Additional documentation for the user. These files are ignored by the IDE.
15+
* **/src** - Source files for the library (.cpp, .h).
16+
* **keywords.txt** - Keywords from this library that will be highlighted in the Arduino IDE.
17+
* **library.properties** - General library properties for the Arduino package manager.
18+
19+
Documentation
20+
--------------
21+
22+
* **[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)** - Basic information on how to install an Arduino library.
23+
* **[Product Repository](GitHub Product URL)** - Main repository (including hardware files) for the <PRODUCT NAME>.
24+
* **[Hookup Guide](Learn.SparkFun URL)** - Basic hookup guide for the <PRODUCT NAME>.
25+
26+
Products that use this Library
27+
---------------------------------
28+
29+
* [Part SKU](SparkFun part URL)- Basic part and short description here
30+
* [Part SKU](SparkFun part URL)- Basic part and short description here
31+
32+
Version History
33+
---------------
34+
35+
* [vExxFxxZxxHxxLxxSxx](URL for tag specific to this version) - Description
36+
* [vEyyFyyZyyHyyLyySyy](URL for tag specific to this version) - Description
37+
38+
License Information
39+
-------------------
40+
41+
This product is _**open source**_!
42+
43+
The **code** is beerware; if you see me (or any other SparkFun employee) at the local, and you've found our code helpful, please buy us a round!
44+
45+
Please use, reuse, and modify these files as you see fit. Please maintain attribution to SparkFun Electronics and release anything derivative under the same license.
46+
47+
Distributed as-is; no warranty is given.
48+
49+
- Your friends at SparkFun.
50+
51+
_<COLLABORATION CREDIT>_

extras/class diagrams.odg

12.7 KB
Binary file not shown.

extras/class diagrams.odt

7.16 KB
Binary file not shown.
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
/******************************************************************************
2+
Marshall Taylor @ SparkFun Electronics
3+
May 20, 2015
4+
https://github.com/sparkfun/LSM6DS3_Breakout
5+
6+
7+
FifoExample.ino
8+
9+
Example using the FIFO over SPI.
10+
11+
The FIFO is configured to take readings at 50Hz. When 100 samples have
12+
accumulated (when the "watermark" is reached), the sketch dumps the float values to the serial terminal.
13+
14+
The FIFO can sample much faster but the serial port isn't fast enough to get
15+
that data out before another 100 samples get queued up. There is a 10ms delay
16+
placed after each line ("1.40,-4.41,-3.22,-0.01,0.01,0.99") so that the
17+
internal serial buffer is guaranteed to empty and not overflow.
18+
19+
Cranking the sample rate up to 800Hz will result in the FIFO dumping routine
20+
never getting the FIFO back down to zero.
21+
22+
Removing the 10ms delay allows the FIFO to be emptied, but then too much data
23+
gets placed in the serial write buffer and stability suffers.
24+
25+
26+
Resources:
27+
Uses Wire.h for I2C operation
28+
Uses SPI.h for SPI operation
29+
Either can be omitted if not used
30+
31+
Development environment specifics:
32+
Arduino IDE 1.6.4
33+
Teensy loader 1.23
34+
35+
Hardware connections
36+
***CAUTION -- SPI pins can not be connected directly to 5V IO***
37+
38+
Connect SDA/SDI line to pin 11 through a level shifter (MOSI)
39+
Connect SCL pin line to pin 13 through a level shifter (SCLK)
40+
Connect SDO/SA0 line to pin 12 through a level shifter (MISO)
41+
Connect CS to a free pin through a level shifter. This example uses pin 10.
42+
Connect GND and ***3.3v*** power to the IMU. The sensors are not 5v tolerant.
43+
44+
This code is beerware; if you see me (or any other SparkFun employee) at the
45+
local, and you've found our code helpful, please buy us a round!
46+
Distributed as-is; no warranty is given.
47+
******************************************************************************/
48+
#include "SparkFunLSM6DS3.h"
49+
#include "Wire.h"
50+
#include "SPI.h"
51+
52+
LSM6DS3 myIMU( SPI_MODE, 10 );
53+
54+
void setup( void ) {
55+
//Over-ride default settings if desired
56+
myIMU.settings.gyroEnabled = 1; //Can be 0 or 1
57+
myIMU.settings.gyroRange = 2000; //Max deg/s. Can be: 125, 245, 500, 1000, 2000
58+
myIMU.settings.gyroSampleRate = 833; //Hz. Can be: 13, 26, 52, 104, 208, 416, 833, 1666
59+
myIMU.settings.gyroBandWidth = 200; //Hz. Can be: 50, 100, 200, 400;
60+
myIMU.settings.gyroFifoEnabled = 1; //Set to include gyro in FIFO
61+
myIMU.settings.gyroFifoDecimation = 1; //set 1 for on /1
62+
63+
myIMU.settings.accelEnabled = 1;
64+
myIMU.settings.accelRange = 16; //Max G force readable. Can be: 2, 4, 8, 16
65+
myIMU.settings.accelSampleRate = 833; //Hz. Can be: 13, 26, 52, 104, 208, 416, 833, 1666, 3332, 6664, 13330
66+
myIMU.settings.accelBandWidth = 200; //Hz. Can be: 50, 100, 200, 400;
67+
myIMU.settings.accelFifoEnabled = 1; //Set to include accelerometer in the FIFO
68+
myIMU.settings.accelFifoDecimation = 1; //set 1 for on /1
69+
myIMU.settings.tempEnabled = 1;
70+
71+
//Non-basic mode settings
72+
myIMU.settings.commMode = 1;
73+
74+
//FIFO control settings
75+
myIMU.settings.fifoThreshold = 100; //Can be 0 to 4096 (16 bit bytes)
76+
myIMU.settings.fifoSampleRate = 50; //Hz. Can be: 10, 25, 50, 100, 200, 400, 800, 1600, 3300, 6600
77+
myIMU.settings.fifoModeWord = 6; //FIFO mode.
78+
//FIFO mode. Can be:
79+
// 0 (Bypass mode, FIFO off)
80+
// 1 (Stop when full)
81+
// 3 (Continuous during trigger)
82+
// 4 (Bypass until trigger)
83+
// 6 (Continous mode)
84+
85+
86+
Serial.begin(57600); // start serial for output
87+
delay(1000); //relax...
88+
Serial.println("Processor came out of reset.\n");
89+
90+
//Call .begin() to configure the IMUs
91+
if( myIMU.begin() != 0 )
92+
{
93+
Serial.println("Problem starting the sensor with CS @ Pin 10.");
94+
}
95+
else
96+
{
97+
Serial.println("Sensor with CS @ Pin 10 started.");
98+
}
99+
100+
Serial.print("Configuring FIFO with no error checking...");
101+
myIMU.fifoBegin();
102+
Serial.print("Done!\n");
103+
104+
Serial.print("Clearing out the FIFO...");
105+
myIMU.fifoClear();
106+
Serial.print("Done!\n");
107+
108+
}
109+
110+
111+
void loop()
112+
{
113+
float temp; //This is to hold read data
114+
uint16_t tempUnsigned;
115+
116+
while( ( myIMU.fifoGetStatus() & 0x8000 ) == 0 ) {}; //Wait for watermark
117+
118+
//Now loop until FIFO is empty. NOTE: As the FIFO is only 8 bits wide,
119+
//the channels must be synchronized to a known position for the data to align
120+
//properly. Emptying the fifo is one way of doing this (this example)
121+
while( ( myIMU.fifoGetStatus() & 0x1000 ) == 0 ) {
122+
123+
temp = myIMU.calcGyro(myIMU.fifoRead());
124+
Serial.print(temp);
125+
Serial.print(",");
126+
127+
temp = myIMU.calcGyro(myIMU.fifoRead());
128+
Serial.print(temp);
129+
Serial.print(",");
130+
131+
temp = myIMU.calcGyro(myIMU.fifoRead());
132+
Serial.print(temp);
133+
Serial.print(",");
134+
135+
temp = myIMU.calcAccel(myIMU.fifoRead());
136+
Serial.print(temp);
137+
Serial.print(",");
138+
139+
temp = myIMU.calcAccel(myIMU.fifoRead());
140+
Serial.print(temp);
141+
Serial.print(",");
142+
143+
temp = myIMU.calcAccel(myIMU.fifoRead());
144+
Serial.print(temp);
145+
Serial.print("\n");
146+
147+
delay(10); //Wait for the serial buffer to clear (~50 bytes worth of time @ 57600baud)
148+
149+
}
150+
151+
tempUnsigned = myIMU.fifoGetStatus();
152+
Serial.print("\nFifo Status 1 and 2 (16 bits): 0x");
153+
Serial.println(tempUnsigned, HEX);
154+
Serial.print("\n");
155+
156+
}

0 commit comments

Comments
 (0)