mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.3.9 GY521
This commit is contained in:
parent
d76ec06877
commit
76e831d569
@ -6,7 +6,7 @@ jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: arduino/arduino-lint-action@v1
|
||||
with:
|
||||
library-manager: update
|
||||
|
@ -8,7 +8,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.6
|
||||
|
@ -10,7 +10,7 @@ jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
|
@ -5,8 +5,16 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [0.3.8] - 2022-10-07
|
||||
|
||||
## [0.3.9] - 2023-01-27
|
||||
- update GitHub actions
|
||||
- update license 2023
|
||||
- edit changelog.md
|
||||
- update readme.md
|
||||
- minor edits
|
||||
|
||||
|
||||
## [0.3.8] - 2022-10-07
|
||||
- added CHANGELOG.md
|
||||
- fix #36 - limit values of pitch() roll() yaw() to 0..360 range.
|
||||
- rename three constants, move to .h.
|
||||
@ -16,83 +24,68 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- updated documentation a bit.
|
||||
|
||||
## [0.3.7] - 2022-07-26
|
||||
|
||||
- add partial reads readAccel(), readGyro() and readTemperature()
|
||||
- rename + add GY521_LIB_VERSION to examples.
|
||||
|
||||
## [0.3.6] - 2021-12-18
|
||||
|
||||
- update library.json, license, minor edits
|
||||
|
||||
## [0.3.5] - 2021-10-20
|
||||
|
||||
- update build-CI, badges
|
||||
- fix #28 add wakeup to begin().
|
||||
|
||||
## [0.3.4] - 2021-07-12
|
||||
|
||||
- fix #24 improve precision
|
||||
|
||||
## [0.3.3] - 2021-07-05
|
||||
|
||||
- fix #22 improve maths
|
||||
|
||||
## [0.3.2] - 2021-07-05
|
||||
|
||||
- fix #20 support multiWire
|
||||
|
||||
## [0.3.1] - 2021-06-13
|
||||
|
||||
- added more unit test
|
||||
- some initialization
|
||||
|
||||
## [0.3.0] - 2021-04-07
|
||||
|
||||
- fix #18 acceleration error correction (kudo's to Merkxic)
|
||||
|
||||
## [0.2.3] - 2021-01-26
|
||||
----
|
||||
|
||||
## [0.2.3] - 2021-01-26
|
||||
- align version numbers (oops)
|
||||
|
||||
## [0.2.2] - 2021-01-24
|
||||
|
||||
- add interface part to readme.md
|
||||
- add GY521_registers.h
|
||||
|
||||
## [0.2.1] - 2020-12-24
|
||||
|
||||
- add Arduino-CI build
|
||||
- add unit tests
|
||||
|
||||
## [0.2.0] - 2020-11-03
|
||||
|
||||
- improve error handling
|
||||
|
||||
## [0.1.5] - 2020-09-29
|
||||
----
|
||||
|
||||
## [0.1.5] - 2020-09-29
|
||||
- fix #6 fix maths for Teensy
|
||||
|
||||
## [0.1.4] - 2020-09-29
|
||||
|
||||
- fix #5 missing ;
|
||||
|
||||
## [0.1.3] - 2020-08-07
|
||||
|
||||
- fix ESP support
|
||||
- add pitch roll yaw demo
|
||||
|
||||
## [0.1.2] - 2020-08-06
|
||||
|
||||
- fix setAccelSensitivity
|
||||
- add getters
|
||||
|
||||
## [0.1.1] - 2020-07-09
|
||||
|
||||
- refactor
|
||||
- initial release
|
||||
|
||||
## [0.1.0] - 2017-11-20
|
||||
|
||||
- initial version
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FILE: GY521.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.3.8
|
||||
// VERSION: 0.3.9
|
||||
// PURPOSE: Arduino library for I2C GY521 accelerometer-gyroscope sensor
|
||||
// URL: https://github.com/RobTillaart/GY521
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: GY521.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.3.8
|
||||
// VERSION: 0.3.9
|
||||
// PURPOSE: Arduino library for I2C GY521 accelerometer-gyroscope sensor
|
||||
// URL: https://github.com/RobTillaart/GY521
|
||||
//
|
||||
@ -12,12 +12,12 @@
|
||||
#include "Wire.h"
|
||||
|
||||
|
||||
#define GY521_LIB_VERSION (F("0.3.8"))
|
||||
#define GY521_LIB_VERSION (F("0.3.9"))
|
||||
|
||||
|
||||
// THROTTLE TIMING
|
||||
#ifndef GY521_THROTTLE_TIME
|
||||
#define GY521_THROTTLE_TIME 10 // milliseconds
|
||||
#define GY521_THROTTLE_TIME 10 // milliseconds
|
||||
#endif
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
class GY521
|
||||
{
|
||||
public:
|
||||
GY521(uint8_t address = 0x69, TwoWire *wire = &Wire); // 0x68 or 0x69
|
||||
GY521(uint8_t address = 0x69, TwoWire *wire = &Wire); // 0x68 or 0x69
|
||||
|
||||
|
||||
#if defined (ESP8266) || defined(ESP32)
|
||||
@ -140,4 +140,4 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
|
||||
// keep names in sync with BIG MPU6050 lib
|
||||
// keep names in sync with BIG MPU6050 lib
|
||||
|
||||
|
||||
#define GY521_XG_OFFS_TC 0x00
|
||||
@ -141,5 +141,5 @@
|
||||
#define GY521_WHO_AM_I 0x75
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017-2022 Rob Tillaart
|
||||
Copyright (c) 2017-2023 Rob Tillaart
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -21,27 +21,29 @@ It needs to be tested a lot more.
|
||||
|
||||
#### Examples
|
||||
|
||||
- calibration example to determine the offsets needed
|
||||
- example to read values.
|
||||
- test sketch to test get / set values.
|
||||
- example to get pitch roll yaw.
|
||||
- performance sketch.
|
||||
- **GY521_angle** read angleX, angleY, angleZ.
|
||||
- **GY521_performance** measure performance.
|
||||
- **GY521_pitch_roll_yaw** to get pitch roll yaw.
|
||||
- **GY521_readCalibration_1** read calibration values / errors for a flat sensor.
|
||||
- **GY521_readCalibration_2** generate calibration code snippet.
|
||||
- **GY521_test_1** test working of the sensor.
|
||||
- **GY521_test_2** test set/get functions.
|
||||
|
||||
|
||||
## Breakout board
|
||||
|
||||
From left to right
|
||||
|
||||
| pin | pinName | description |
|
||||
|:----:|:--------|:----------------|
|
||||
| 0 | VCC | +5V |
|
||||
| 1 | GND | ground |
|
||||
| 2 | SCL | I2C clock |
|
||||
| 3 | SDA | I2C data |
|
||||
| 4 | XDA | auxiliary data | see datasheet
|
||||
| 5 | XCL | auxiliary clock | see datasheet
|
||||
| 6 | AD0 | address |
|
||||
| 7 | INT | interrupt |
|
||||
| pin | pinName | description | notes |
|
||||
|:-----:|:---------:|:------------------|:-------:|
|
||||
| 0 | VCC | +5V |
|
||||
| 1 | GND | ground |
|
||||
| 2 | SCL | I2C clock |
|
||||
| 3 | SDA | I2C data |
|
||||
| 4 | XDA | auxiliary data | see datasheet
|
||||
| 5 | XCL | auxiliary clock | see datasheet
|
||||
| 6 | AD0 | address |
|
||||
| 7 | INT | interrupt |
|
||||
|
||||
|
||||
#### Address
|
||||
@ -60,6 +62,9 @@ AD0 connected to VCC => 0x69
|
||||
|
||||
## Interface
|
||||
|
||||
```cpp
|
||||
#include "GY521.h"
|
||||
```
|
||||
|
||||
### Constructor
|
||||
|
||||
@ -80,7 +85,7 @@ AD0 connected to VCC => 0x69
|
||||
- **uint16_t getThrottleTime()** returns throttle time set.
|
||||
|
||||
|
||||
### READ
|
||||
### Read
|
||||
|
||||
#### Set before read
|
||||
|
||||
@ -104,7 +109,7 @@ returns status = GY521_OK on success.
|
||||
|
||||
Since version 0.3.8 the **read()** and **readGyro()** function is updated to keep the range of **getPitch()**,
|
||||
**getRoll()** and **getYaw()** in the range 0..360 degrees. (Issue #36).
|
||||
Problem is that with continuous roatation in a same direction internal variables will overflow and new
|
||||
Problem is that with continuous rotation in a same direction internal variables will overflow and new
|
||||
movements (angles) will get lost as insignificant digits.
|
||||
|
||||
|
||||
@ -147,13 +152,22 @@ See examples, use with care
|
||||
|
||||
## Future
|
||||
|
||||
**Should**
|
||||
- test test and test ...(ESP too)
|
||||
#### Must
|
||||
|
||||
- improve documentation
|
||||
- look for maths optimizations (atan, hypot, performance)
|
||||
|
||||
#### Should
|
||||
|
||||
- test test and test ...(ESP too)
|
||||
|
||||
#### Could
|
||||
|
||||
**Could**
|
||||
- calibrate function in the lib ? (think not as lib might grow?)
|
||||
- calibrate sketch could print code snippet to include...
|
||||
|
||||
#### Wont
|
||||
|
||||
- look for maths optimizations (atan, hypot, performance)
|
||||
- ==> hypot optimized.
|
||||
- other ideas affect accuracy, so unless new ideas arise.
|
||||
- calibrate function in the lib
|
||||
- not as lib will grow too large.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FILE: GY521_angle.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo pitch roll yaw
|
||||
// PURPOSE: read angleX, angleY, angleZ
|
||||
// DATE: 2022-06-06
|
||||
|
||||
|
||||
@ -29,13 +29,13 @@ void setup()
|
||||
Serial.println("\tCould not connect to GY521");
|
||||
delay(1000);
|
||||
}
|
||||
sensor.setAccelSensitivity(2); // 8g
|
||||
sensor.setGyroSensitivity(1); // 500 degrees/s
|
||||
sensor.setAccelSensitivity(2); // 8g
|
||||
sensor.setGyroSensitivity(1); // 500 degrees/s
|
||||
|
||||
sensor.setThrottle();
|
||||
Serial.println("start...");
|
||||
|
||||
// set calibration values from calibration sketch.
|
||||
// set calibration values from calibration sketch.
|
||||
sensor.axe = 0.574;
|
||||
sensor.aye = -0.002;
|
||||
sensor.aze = -1.043;
|
||||
@ -54,11 +54,11 @@ void loop()
|
||||
|
||||
if (counter % 10 == 0)
|
||||
{
|
||||
// Serial.println("\nCNT\tX\tY\tZ");
|
||||
// Serial.println("\nCNT\tX\tY\tZ");
|
||||
}
|
||||
|
||||
//Serial.print(counter);
|
||||
//Serial.print('\t');
|
||||
// Serial.print(counter);
|
||||
// Serial.print('\t');
|
||||
Serial.print(x, 1);
|
||||
Serial.print('\t');
|
||||
Serial.print(y, 1);
|
||||
@ -70,5 +70,5 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -30,12 +30,12 @@ void setup()
|
||||
{
|
||||
Serial.println("Could not connect to GY521");
|
||||
}
|
||||
// adjust when needed.
|
||||
sensor.setAccelSensitivity(0); // 2g
|
||||
sensor.setGyroSensitivity(0); // 250 degrees/s
|
||||
// adjust when needed.
|
||||
sensor.setAccelSensitivity(0); // 2g
|
||||
sensor.setGyroSensitivity(0); // 250 degrees/s
|
||||
sensor.setThrottle(false);
|
||||
|
||||
// set all calibration errors to zero
|
||||
// set all calibration errors to zero
|
||||
sensor.axe = 0;
|
||||
sensor.aye = 0;
|
||||
sensor.aze = 0;
|
||||
@ -113,7 +113,7 @@ void loop()
|
||||
Serial.print(t * 0.01, 2);
|
||||
Serial.println();
|
||||
}
|
||||
// adjust calibration errors so table should get all zero's.
|
||||
// adjust calibration errors so table should get all zero's.
|
||||
sensor.axe += ax * 0.01;
|
||||
sensor.aye += ay * 0.01;
|
||||
sensor.aze += az * 0.01;
|
||||
@ -126,4 +126,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -29,13 +29,13 @@ void setup()
|
||||
Serial.println("\tCould not connect to GY521");
|
||||
delay(1000);
|
||||
}
|
||||
sensor.setAccelSensitivity(0); // 2g
|
||||
sensor.setGyroSensitivity(0); // 250 degrees/s
|
||||
sensor.setAccelSensitivity(0); // 2g
|
||||
sensor.setGyroSensitivity(0); // 250 degrees/s
|
||||
|
||||
sensor.setThrottle();
|
||||
Serial.println("start...");
|
||||
|
||||
// set calibration values from calibration sketch.
|
||||
// set calibration values from calibration sketch.
|
||||
sensor.axe = 0;
|
||||
sensor.aye = 0;
|
||||
sensor.aze = 0;
|
||||
@ -84,5 +84,5 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -66,7 +66,7 @@ void setup()
|
||||
Serial.println("\tThrot err:\tfalse");
|
||||
}
|
||||
|
||||
for (uint16_t n = 0; n < 1000; n++) // 0 - 1 second.
|
||||
for (uint16_t n = 0; n < 1000; n++) // 0 - 1 second.
|
||||
{
|
||||
sensor.setThrottleTime(n);
|
||||
if (sensor.getThrottleTime() != n)
|
||||
@ -85,5 +85,5 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/GY521.git"
|
||||
},
|
||||
"version": "0.3.8",
|
||||
"version": "0.3.9",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=GY521
|
||||
version=0.3.8
|
||||
version=0.3.9
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for GY521 angle measurement
|
||||
|
@ -155,4 +155,5 @@ unittest(test_initial_calibration_errors)
|
||||
|
||||
unittest_main()
|
||||
|
||||
// --------
|
||||
// -- END OF FILE --
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user