@@ -16,13 +16,14 @@ Arduino library for I2C GY521 accelerometer-gyroscope sensor a.k.a. MCU-6050.
1616
1717## Description
1818
19- Experimental library for GY521 a.k.a. MCU-6050.
19+ ** Experimental** library for GY521 a.k.a. MCU-6050.
2020
2121Library is work in progress, in fact it is extracted and extended from an old project.
2222It needs to be tested a lot more.
2323
2424See changelog.md for latest updates.
2525
26+
2627#### 0.5.0 Breaking change
2728
2829Version 0.5.0 introduced a breaking change.
@@ -35,12 +36,25 @@ before calling **begin()**.
3536#### Examples
3637
3738- ** GY521_angle** read angleX, angleY, angleZ.
39+ - ** GY521_performance_calibrate.ino** determine calibration performance.
3840- ** GY521_performance** measure performance.
3941- ** GY521_pitch_roll_yaw** to get pitch roll yaw.
40- - ** GY521_readCalibration_1** read calibration values / errors for a flat sensor.
42+ - ** GY521_raw_cooked** make a table of raw measurements and derived data
43+ for analysis e.g. in a spreadsheet.
44+ - ** GY521_readCalibration_1** read calibration values / errors for a "flat" sensor.
4145- ** GY521_readCalibration_2** generate calibration code snippet.
4246- ** GY521_test_1** test working of the sensor.
43- - ** GY521_test_2** test set/get functions.
47+ - ** GY521_test_2** test set/get functions (sort of unit test).
48+ - ** GY521_two_sensors** demo for two sensors.
49+
50+
51+ #### Related
52+
53+ - https://invensense.tdk.com/wp-content/uploads/2015/02/MPU-6000-Datasheet1.pdf
54+ - https://cdn.sparkfun.com/datasheets/Sensors/Accelerometers/RM-MPU-6000A.pdf register map.
55+ - https://github.com/RobTillaart/Angle
56+ - https://github.com/RobTillaart/AngleConverter
57+
4458
4559
4660## Breakout board
@@ -67,6 +81,16 @@ AD0 connected to VCC => 0x69
6781
6882## Calibration (short version for now)
6983
84+ Since version 0.5.2 the library has a build in ** void calibrate(times)** function which
85+ can be called instead of manual calibration.
86+ This function overwrites the values of axe aye aze gxe gye gze.
87+ ** calibrate()** must be called after ** setAccelSensitivity(as)** and ** setGyroSensitivity(gs)** .
88+
89+ Note the ** calibrate()** function takes time, depending on the number of times.
90+
91+
92+ #### Manual calibration
93+
70941 . load and run calibration example
7195 it shows a header containing 6 numbers and 10 lines of 8 numbers
72961 . wait until the middle 6 of the longer lines stabilize (should all be 0)
@@ -90,6 +114,18 @@ Note call **Wire.begin()** before **begin()**.
90114- ** bool wakeUp()** idem.
91115
92116
117+ ### Calibrate
118+
119+ - ** void calibrate(uint16_t times)** This function overwrites the values of axe aye aze gxe gye gze.
120+ To get "quality error" offsets, the GY521 sensor should not move during the calibration.
121+ The parameter times determines the number of measurements made.
122+ Typical values are 100 or more.
123+ Please note this is a time consuming function.
124+
125+ Ideal the function ** calibrate()** should continue until it is stable (how to define) for n reads.
126+ Drawback is that this would make the duration unpredictable.
127+
128+
93129### Throttle
94130
95131- ** void setThrottle(bool throttle = true)** throttle to force "delay" between reads.
@@ -112,7 +148,8 @@ Note call **Wire.begin()** before **begin()**.
112148
113149#### Actual read
114150
115- - ** int16_t read()** returns status = GY521_OK on success.
151+ - ** int16_t read()** reads all core measurements.
152+ returns status = GY521_OK on success.
116153- ** int16_t readAccel()** read accelerometer only to speed up interaction. This call does update the throttle timer.
117154returns status = GY521_OK on success.
118155- ** int16_t readGyro()** read gyroscope only to speed up interaction. This call does update the throttle timer.
@@ -132,7 +169,8 @@ In version 0.4.0 the normalization of pitch, roll and yaw is fixed and made cond
132169
133170#### Calls after read
134171
135- Note that multiple calls will return the same value. One must explicitly call ** read()** to get new values.
172+ Note that multiple calls will return the same value.
173+ One must explicitly call ** read()** to get new values.
136174
137175- ** float getAccelX()** idem.
138176- ** float getAccelY()** idem.
@@ -144,6 +182,12 @@ Note that multiple calls will return the same value. One must explicitly call **
144182- ** float getGyroX()** idem.
145183- ** float getGyroY()** idem.
146184- ** float getGyroZ()** idem.
185+
186+
187+ #### Experimental Pitch Roll and Yaw
188+
189+ Pitch Roll and Yaw is work in progress and should not be used for projects yet.
190+
147191- ** float getPitch()** idem. May return any number.
148192If ** setNormalize(true)** return value will be 0-359.999
149193- ** float getRoll()** idem. May return any number.
@@ -160,34 +204,76 @@ Read the register PDF for the specific value and meaning of registers.
160204- ** uint8_t getRegister(uint8_t reg)**
161205
162206
163- ## documents
207+ ## Documents
208+
209+ - check details registers - MPU-6000-Register-Map1.pdf
210+
211+
212+ #### Error codes
213+
214+ | Error code | value | notes |
215+ | :----------------------------| :-------:| :-------:|
216+ | GY521_OK | 0 | not an error
217+ | GY521_THROTTLED | 1 | not an error
218+ | GY521_ERROR_READ | -1 |
219+ | GY521_ERROR_WRITE | -2 |
220+ | GY521_ERROR_NOT_CONNECTED | -3 |
221+
164222
165- - check details - MPU-6000-Register-Map1.pdf
223+ #### Sensitivity Acceleration
224+
225+ unit g = gravity == 9.81 m/s^2
226+
227+ | Acceleration | value | notes |
228+ | :--------------| :-------:| :-------:|
229+ | 2 g | 0 | default
230+ | 4 g | 1 |
231+ | 8 g | 2 |
232+ | 16 g | 3 |
233+
234+
235+ #### Sensitivity Gyroscope
236+
237+ unit dps = degrees per second.
238+
239+ | Gyroscope | value | notes |
240+ | :--------------| :-------:| :-------:|
241+ | 250 dps | 0 | default
242+ | 500 dps | 1 |
243+ | 1000 dps | 2 |
244+ | 2000 dps | 3 |
166245
167246
168247## Operation
169248
170- See examples, use with care
249+ See examples, use with care.
171250
172251
173252## Future
174253
175254#### Must
176255
256+ - time
177257- improve documentation
178- - add tables where appropriate
179- - sensitivity, error codes etc
258+ - investigate Pitch Roll and Yaw math in detail.
259+ - investigate math needed.
260+ - implementation.
261+ - when?
180262- test test and test ...(ESP too)
181263
182264#### Should
183265
184- - add performance sketch
266+ - test ** calibrate() ** function for different sensitivities.
185267
186268#### Could
187269
188- - calibrate sketch could print code snippet to include...
189270- add examples
190271- improve unit tests?
272+ - reorder code in read(), would that save some micros.?
273+ - first all ax, then ay etc
274+ - footprint / performance gain?
275+ - make enum for sensitivity Accel?
276+ - make enum for sensitivity Gyro?
191277
192278#### Wont
193279
@@ -196,6 +282,9 @@ See examples, use with care
196282 - other ideas affect accuracy, so unless new ideas arise.
197283- calibrate function in the lib
198284 - not as lib will grow too large.
285+ - defaults value for functions?
286+ - user must set function parameters explicit
287+
199288
200289## Support
201290
0 commit comments