mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.5.3 GY521
This commit is contained in:
parent
5670e6f1b8
commit
a869cfa834
@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [0.5.3] - 2024-05-08
|
||||
- fix #52, add **uint8_t getAddrress()**
|
||||
- fix #51, add **bool setDLPFMode(uint8_t mode)** and **uint8_t getDLPFMode()**
|
||||
- add const float GRAVITY=9.80655;
|
||||
- minor edits
|
||||
|
||||
|
||||
## [0.5.2] - 2024-01-16
|
||||
- fix #48, use float variables in example GY521_test_1.ino
|
||||
- add **void calibrate(uint16_t times)** to API
|
||||
@ -17,7 +24,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- add some tables
|
||||
- minor edits in examples
|
||||
|
||||
|
||||
## [0.5.1] - 2023-12-11
|
||||
- redo initialization order.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FILE: GY521.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.5.2
|
||||
// VERSION: 0.5.3
|
||||
// PURPOSE: Arduino library for I2C GY521 accelerometer-gyroscope sensor
|
||||
// URL: https://github.com/RobTillaart/GY521
|
||||
|
||||
@ -53,6 +53,12 @@ bool GY521::isConnected()
|
||||
}
|
||||
|
||||
|
||||
uint8_t GY521::getAddress()
|
||||
{
|
||||
return _address;
|
||||
}
|
||||
|
||||
|
||||
void GY521::reset()
|
||||
{
|
||||
setThrottleTime(GY521_THROTTLE_TIME);
|
||||
@ -476,6 +482,30 @@ uint8_t GY521::getGyroSensitivity()
|
||||
}
|
||||
|
||||
|
||||
// CONFIGURATION
|
||||
// Digital Low Pass Filter datasheet P13-reg26
|
||||
bool GY521::setDLPFMode(uint8_t mode)
|
||||
{
|
||||
if (mode > 6)
|
||||
{
|
||||
_error = GY521_ERROR_PARAMETER;
|
||||
return false;
|
||||
}
|
||||
uint8_t value = getRegister(GY521_CONFIG);
|
||||
value &= 0xF8;
|
||||
value |= mode;
|
||||
return (setRegister(GY521_CONFIG, value) == GY521_OK);
|
||||
}
|
||||
|
||||
|
||||
uint8_t GY521::getDLPFMode()
|
||||
{
|
||||
uint8_t val = getRegister(GY521_CONFIG);
|
||||
return val & 0x07;
|
||||
}
|
||||
|
||||
|
||||
// GENERIC
|
||||
uint8_t GY521::setRegister(uint8_t reg, uint8_t value)
|
||||
{
|
||||
_wire->beginTransmission(_address);
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: GY521.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.5.2
|
||||
// VERSION: 0.5.3
|
||||
// PURPOSE: Arduino library for I2C GY521 accelerometer-gyroscope sensor
|
||||
// URL: https://github.com/RobTillaart/GY521
|
||||
|
||||
@ -11,7 +11,9 @@
|
||||
#include "Wire.h"
|
||||
|
||||
|
||||
#define GY521_LIB_VERSION (F("0.5.2"))
|
||||
#define GY521_LIB_VERSION (F("0.5.3"))
|
||||
|
||||
const float GRAVITY = 9.80655;
|
||||
|
||||
|
||||
// THROTTLE TIMING
|
||||
@ -26,6 +28,7 @@
|
||||
#define GY521_ERROR_READ -1
|
||||
#define GY521_ERROR_WRITE -2
|
||||
#define GY521_ERROR_NOT_CONNECTED -3
|
||||
#define GY521_ERROR_PARAMETER -4
|
||||
|
||||
|
||||
// CONVERSION CONSTANTS
|
||||
@ -42,6 +45,7 @@ public:
|
||||
|
||||
bool begin();
|
||||
bool isConnected();
|
||||
uint8_t getAddress();
|
||||
void reset();
|
||||
|
||||
// EXPERIMENTAL
|
||||
@ -105,6 +109,10 @@ public:
|
||||
// last time sensor is actually read.
|
||||
uint32_t lastTime() { return _lastTime; };
|
||||
|
||||
// CONFIGURATION
|
||||
// Digital Low Pass Filter - datasheet P13-reg26
|
||||
bool setDLPFMode(uint8_t mode); // returns false if mode > 6
|
||||
uint8_t getDLPFMode();
|
||||
|
||||
// generic worker to get access to all functionality
|
||||
uint8_t setRegister(uint8_t reg, uint8_t value);
|
||||
|
@ -56,7 +56,6 @@ for analysis e.g. in a spreadsheet.
|
||||
- https://github.com/RobTillaart/AngleConverter
|
||||
|
||||
|
||||
|
||||
## Breakout board
|
||||
|
||||
From left to right
|
||||
@ -142,8 +141,8 @@ Drawback is that this would make the duration unpredictable.
|
||||
- **uint8_t getAccelSensitivity()** returns 0, 1, 2, 3
|
||||
- **bool setGyroSensitivity(uint8_t gs)** gs = 0,1,2,3 ==> 250, 500, 1000, 2000 degrees/second
|
||||
- **uint8_t getGyroSensitivity()** returns 0, 1, 2, 3
|
||||
= **void setNormalize(bool normalize = true)** normalizes pitch roll yaw or not. Default true.
|
||||
= **bool getNormalize()** returns flag.
|
||||
- **void setNormalize(bool normalize = true)** normalizes pitch roll yaw or not. Default true.
|
||||
- **bool getNormalize()** returns flag.
|
||||
|
||||
|
||||
#### Actual read
|
||||
@ -196,7 +195,25 @@ If **setNormalize(true)** return value will be 0-359.999
|
||||
If **setNormalize(true)** return value will be 0-359.999
|
||||
|
||||
|
||||
### Register access
|
||||
#### Digital Low Pass Filter
|
||||
|
||||
See datasheet P13-reg26
|
||||
|
||||
- **bool setDLPFMode(uint8_t mode)** mode = 0..6, returns false if mode > 6.
|
||||
- **uint8_t getDLPFMode()** returns the current (set) mode.
|
||||
|
||||
| Mode | Acc bandwidth | delay | Gyro bandwidth | delay | Fs |
|
||||
|:----:|:-------------:|:------:|:--------------:|:------:|:-----:|
|
||||
| 0 | 260 Hz | 0.0 | 256 Hz | 1.0 | 8 kHz |
|
||||
| 1 | 184 Hz | 2.0 | 188 Hz | 1.9 | 1 kHz |
|
||||
| 2 | 94 Hz | 3.0 | 98 Hz | 2.8 | 1 kHz |
|
||||
| 3 | 44 Hz | 4.9 | 42 Hz | 4.8 | 1 kHz |
|
||||
| 4 | 21 Hz | 8.5 | 20 Hz | 8.3 | 1 kHz |
|
||||
| 5 | 10 Hz | 13.8 | 10 Hz | 13.4 | 1 kHz |
|
||||
| 6 | 5 Hz | 19.0 | 5 Hz | 18.6 | 1 kHz |
|
||||
|
||||
|
||||
#### Generic Register Access
|
||||
|
||||
Read the register PDF for the specific value and meaning of registers.
|
||||
|
||||
@ -222,26 +239,31 @@ Read the register PDF for the specific value and meaning of registers.
|
||||
|
||||
#### Sensitivity Acceleration
|
||||
|
||||
unit g = gravity == 9.81 m/s^2
|
||||
The strength of Earth's gravity varies with latitude (equator = 0°, poles = 90°).
|
||||
The standard value for gravity (gn) is 9.80665 m/s^2 (often 9.81 m/s^2)
|
||||
At the equator the gravity (ge) is 9.78033 m/s^2.
|
||||
|
||||
| Acceleration | value | notes |
|
||||
|:--------------|:-------:|:-------:|
|
||||
| 2 g | 0 | default
|
||||
| 4 g | 1 |
|
||||
| 8 g | 2 |
|
||||
| 16 g | 3 |
|
||||
The library provides the constant GRAVITY = 9.80655
|
||||
|
||||
|
||||
| value | Acceleration | m/s2 | notes |
|
||||
|:-------:|:--------------|:----------:|:-------:|
|
||||
| 0 | 2 g | 19.6131 | default
|
||||
| 1 | 4 g | 39.2262 |
|
||||
| 2 | 8 g | 78.4524 |
|
||||
| 3 | 16 g | 156.9048 |
|
||||
|
||||
|
||||
#### Sensitivity Gyroscope
|
||||
|
||||
unit dps = degrees per second.
|
||||
|
||||
| Gyroscope | value | notes |
|
||||
|:--------------|:-------:|:-------:|
|
||||
| 250 dps | 0 | default
|
||||
| 500 dps | 1 |
|
||||
| 1000 dps | 2 |
|
||||
| 2000 dps | 3 |
|
||||
| value | Gyroscope | radians/sec | notes |
|
||||
|:-------:|:------------|:-------------:|:-------:|
|
||||
| 0 | 250 dps | 4.36332313 | default
|
||||
| 1 | 500 dps | 8.72664626 |
|
||||
| 2 | 1000 dps | 17.45329252 |
|
||||
| 3 | 2000 dps | 34.90658504 |
|
||||
|
||||
|
||||
## Operation
|
||||
@ -251,6 +273,9 @@ See examples, use with care.
|
||||
|
||||
## Future
|
||||
|
||||
There is no intention to implement getters and setters for all registers.
|
||||
However if one specific is needed, please open an issue.
|
||||
|
||||
#### Must
|
||||
|
||||
- time
|
||||
|
@ -8,6 +8,7 @@ GY521 KEYWORD1
|
||||
# Methods and Functions (KEYWORD2)
|
||||
begin KEYWORD2
|
||||
isConnected KEYWORD2
|
||||
getAddress KEYWORD2
|
||||
reset KEYWORD2
|
||||
wakeup KEYWORD2
|
||||
|
||||
@ -43,8 +44,13 @@ getRoll KEYWORD2
|
||||
getYaw KEYWORD2
|
||||
|
||||
lastTime KEYWORD2
|
||||
|
||||
setDLPFMode KEYWORD2
|
||||
getDLPFMode KEYWORD2
|
||||
|
||||
setRegister KEYWORD2
|
||||
getRegister KEYWORD2
|
||||
|
||||
getError KEYWORD2
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/GY521.git"
|
||||
},
|
||||
"version": "0.5.2",
|
||||
"version": "0.5.3",
|
||||
"license": "MIT",
|
||||
"frameworks": "*",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=GY521
|
||||
version=0.5.2
|
||||
version=0.5.3
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for GY521 angle measurement
|
||||
|
Loading…
Reference in New Issue
Block a user