Skip to content

Commit

Permalink
improve getCumulativePosition()
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart committed Mar 31, 2024
1 parent cd55341 commit b40e714
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# These are supported funding model platforms

github: RobTillaart
github: RobTillaart
custom: "https://www.paypal.me/robtillaart"

3 changes: 2 additions & 1 deletion .github/workflows/arduino-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: arduino/arduino-lint-action@v1
with:
library-manager: update
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/arduino_test_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ on: [push, pull_request]
jobs:
runTest:
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: |
# sudo sysctl vm.mmap_rnd_bits=28
gem install arduino_ci
arduino_ci.rb
5 changes: 3 additions & 2 deletions .github/workflows/jsoncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ on:
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: json-syntax-check
uses: limitusus/json-syntax-check@v1
uses: limitusus/json-syntax-check@v2
with:
pattern: "\\.json$"

3 changes: 2 additions & 1 deletion AS5600.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: AS56000.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.6.0
// VERSION: 0.6.1
// PURPOSE: Arduino library for AS5600 magnetic rotation meter
// DATE: 2022-05-28
// URL: https://github.com/RobTillaart/AS5600
Expand Down Expand Up @@ -463,6 +463,7 @@ float AS5600::getAngularSpeed(uint8_t mode)
int32_t AS5600::getCumulativePosition()
{
int16_t value = readReg2(AS5600_ANGLE) & 0x0FFF;
if (_error != AS5600_OK) return _position;

// whole rotation CW?
// less than half a circle
Expand Down
4 changes: 2 additions & 2 deletions AS5600.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// FILE: AS5600.h
// AUTHOR: Rob Tillaart
// VERSION: 0.6.0
// VERSION: 0.6.1
// PURPOSE: Arduino library for AS5600 magnetic rotation meter
// DATE: 2022-05-28
// URL: https://github.com/RobTillaart/AS5600
Expand All @@ -12,7 +12,7 @@
#include "Wire.h"


#define AS5600_LIB_VERSION (F("0.6.0"))
#define AS5600_LIB_VERSION (F("0.6.1"))


// default addresses
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.6.1] - 2024-03-31
- improve **getCumulativePosition()**, catch I2C error, see #62
- update readme.md (incl reorder future work).
- update GitHub actions
- minor edits


## [0.6.0] - 2024-01-25
- add experimental error handling
- add **int lastError()** so user can check the status of last I2C actions.
Expand Down
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Arduino library for AS5600 and AS5600L magnetic rotation meter.

**AS5600** is a library for an AS5600 / AS5600L based magnetic **rotation** meter.
More exact, it measures the angle (rotation w.r.t. reference) and not RPM.
Multiple angle measurements allows one to calculate / estimate the RPM.
Multiple angle measurements allows one to calculate or estimate the RPM.

The AS5600 and AS5600L sensors are pin compatible (always check datasheet).
The AS5600 and AS5600L sensors are pin compatible (always check your model's datasheet).

**Warning: experimental**

Expand All @@ -39,10 +39,10 @@ Please share your experiences.
#### 0.5.0 Breaking change

Version 0.5.0 introduced a breaking change.
You cannot set the pins in **begin()** any more.
You cannot set the SDA and SCL pins in **begin()** any more.
This reduces the dependency of processor dependent Wire implementations.
The user has to call **Wire.begin()** and can optionally set the Wire pins
before calling **begin()**.
The user has to call **Wire.begin()** and can optionally set the I2C pins
before calling **AS5600.begin()**.


#### Related libraries
Expand All @@ -64,6 +64,7 @@ Do not forget to add the pull up resistors to improve the I2C signals.
The AS5600 datasheet states it supports Fast-Mode == 400 KHz
and Fast-Mode-Plus == 1000 KHz.


#### Pull ups

I2C performance tests with an AS5600L with an UNO failed at 400 KHz.
Expand Down Expand Up @@ -128,7 +129,7 @@ This resistor needs to be removed to use the **OUT** pin.

Not tested. ==> Read the datasheet!

PGO stands for Programming Option, it is used to calibrate / program the sensor.
PGO stands for ProGramming Option, it is used to calibrate and program the sensor.
As the sensor can be programmed only a few times one should
use this functionality with extreme care.
See datasheet for a detailed list of steps to be done.
Expand Down Expand Up @@ -731,38 +732,37 @@ priority is relative.

#### Should

- implement extended error handling in public functions.
- will increase footprint !! how much?
- **call writeReg() only if readReg() is OK** ==> prevent incorrect writes
- ```if (_error != 0) return false;```
- idem readReg2()
- set AS5600_ERROR_PARAMETER e.g. setZPosition()
- a derived class with extended error handling?
- investigate **readMagnitude()**
- combination of AGC and MD, ML and MH flags?
- investigate OUT behaviour in practice
- investigate **OUT** behaviour in practice
- analogue
- PWM
- need AS5600 on breakout with support
- write examples:
- as5600_calibration.ino (needs HW and lots of time)
- different configuration options
- check / verify Power-up time
- 1 minute (need HW)
- check Timing Characteristics (datasheet)
- is there improvement possible.



#### Could

- investigate PGO programming pin.
- investigate **PGO** programming pin.
- check for compatible devices
- AS5200 ?
- investigate performance
- basic performance per function
- I2C improvements
- software direction
- implement extended error handling in public functions.
- will increase footprint !! how much?
- writeReg() only if readReg() is OK ==> prevent incorrect writes
- ```if (_error != 0) return false;```
- set AS5600_ERROR_PARAMETER e.g. setZPosition()
- a derived class with extended error handling?

- write examples:
- as5600_calibration.ino (needs HW and lots of time)
- different configuration options

#### Wont (unless)

Expand Down
2 changes: 1 addition & 1 deletion examples/AS5600_burn_conf_mang/AS5600_burn_conf_mang.ino
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void burn_mang()
const uint16_t FASTFILTER = 0;
const uint16_t WATCHDOG = 0;
const uint16_t MAXANGLE = 0;

bool OK = true;
OK = OK && as5600.setPowerMode(POWERMODE);
OK = OK && (POWERMODE == as5600.getPowerMode());
Expand Down
2 changes: 1 addition & 1 deletion examples/AS5600_demo/AS5600_demo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void setup()
Serial.println(__FILE__);
Serial.print("AS5600_LIB_VERSION: ");
Serial.println(AS5600_LIB_VERSION);

Wire.begin();

as5600.begin(4); // set direction pin.
Expand Down
2 changes: 1 addition & 1 deletion examples/AS5600_demo_ESP32/AS5600_demo_ESP32.ino
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void setup()
Serial.println(AS5600_LIB_VERSION);

Wire.begin(14, 15);

as5600.begin(4); // set direction pin.
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
int b = as5600.isConnected();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void setup()

Wire.begin();

as5600.begin(); // set software direction control. default param = 255
as5600.begin(); // set software direction control. default parameter == 255
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
}

Expand All @@ -39,7 +39,7 @@ void loop()
if (counter < 10) as5600.setDirection(AS5600_CLOCK_WISE);
else as5600.setDirection(AS5600_COUNTERCLOCK_WISE);
if (counter >= 20) counter = 0;

Serial.print(millis());
Serial.print("\t");
Serial.print(as5600.getDirection());
Expand Down
2 changes: 1 addition & 1 deletion examples/AS5600_demo_two_I2C/AS5600_demo_two_I2C.ino
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void setup()
Serial.print("Connect device 0: ");
Serial.println(as5600_0.isConnected() ? "true" : "false");
delay(1000);

as5600_1.begin(5); // set direction pin.
as5600_1.setDirection(AS5600_COUNTERCLOCK_WISE);
Serial.print("Connect device 1: ");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// FILE: AS5600_resetCumulativeCounter.ino
// AUTHOR: Daniel-Frenkel, (slightly by Rob Tillaart)
// AUTHOR: Daniel-Frenkel, (slightly modified by Rob Tillaart)
// PURPOSE: demo - see issue #30
// URL: https://github.com/RobTillaart/AS5600
//
Expand All @@ -21,7 +21,7 @@ void setup()
Serial.println(__FILE__);
Serial.print("AS5600_LIB_VERSION: ");
Serial.println(AS5600_LIB_VERSION);

Wire.begin(14, 15); // ESP32

as5600.begin();
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/AS5600.git"
},
"version": "0.6.0",
"version": "0.6.1",
"license": "MIT",
"frameworks": "*",
"platforms": "*",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=AS5600
version=0.6.0
version=0.6.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for AS5600 and AS5600L magnetic rotation meter.
Expand Down

0 comments on commit b40e714

Please sign in to comment.