mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-09-20 00:55:58 -04:00
0.3.2 AS5600
This commit is contained in:
parent
89bf078d48
commit
fa85fad22b
@ -1,3 +1,18 @@
|
|||||||
|
platforms:
|
||||||
|
rpipico:
|
||||||
|
board: rp2040:rp2040:rpipico
|
||||||
|
package: rp2040:rp2040
|
||||||
|
gcc:
|
||||||
|
features:
|
||||||
|
defines:
|
||||||
|
- ARDUINO_ARCH_RP2040
|
||||||
|
warnings:
|
||||||
|
flags:
|
||||||
|
|
||||||
|
packages:
|
||||||
|
rp2040:rp2040:
|
||||||
|
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||||
|
|
||||||
compile:
|
compile:
|
||||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||||
platforms:
|
platforms:
|
||||||
@ -7,5 +22,7 @@ compile:
|
|||||||
# - leonardo
|
# - leonardo
|
||||||
- m4
|
- m4
|
||||||
- esp32
|
- esp32
|
||||||
# - esp8266
|
- esp8266
|
||||||
# - mega2560
|
# - mega2560
|
||||||
|
- rpipico
|
||||||
|
|
||||||
|
@ -1,43 +1,12 @@
|
|||||||
//
|
//
|
||||||
// FILE: AS56000.cpp
|
// FILE: AS56000.cpp
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// VERSION: 0.3.1
|
// VERSION: 0.3.2
|
||||||
// PURPOSE: Arduino library for AS5600 magnetic rotation meter
|
// PURPOSE: Arduino library for AS5600 magnetic rotation meter
|
||||||
// DATE: 2022-05-28
|
// DATE: 2022-05-28
|
||||||
// URL: https://github.com/RobTillaart/AS5600
|
// URL: https://github.com/RobTillaart/AS5600
|
||||||
|
|
||||||
// 0.1.0 2022-05-28 initial version.
|
|
||||||
// 0.1.1 2022-05-31 Add readReg2() to speed up reading 2 byte values.
|
|
||||||
// Fix clock wise and counter clock wise.
|
|
||||||
// Fix shift-direction @ getZPosition, getMPosition,
|
|
||||||
// getMaxAngle and getConfigure.
|
|
||||||
// 0.1.2 2022-06-02 Add getAngularSpeed().
|
|
||||||
// 0.1.3 2022-06-26 Add AS5600_RAW_TO_RADIANS.
|
|
||||||
// Add getAngularSpeed() mode parameter.
|
|
||||||
// Fix #8 bug in configure.
|
|
||||||
// 0.1.4 2022-06-27 Fix #7 use readReg2() to improve I2C performance.
|
|
||||||
// define constants for configuration functions.
|
|
||||||
// add examples - especially OUT pin related.
|
|
||||||
// Fix default parameter of the begin function.
|
|
||||||
//
|
//
|
||||||
// 0.2.0 2022-06-28 add software based direction control.
|
// HISTORY: see changelog.md
|
||||||
// add examples
|
|
||||||
// define constants for configuration functions.
|
|
||||||
// fix conversion constants (4096 based)
|
|
||||||
// add get- setOffset(degrees) functions. (no radians yet)
|
|
||||||
// 0.2.1 notreleased add bool return to set() functions.
|
|
||||||
// update Readme (analog / PWM out)
|
|
||||||
//
|
|
||||||
// 0.3.0 2022-07-07 fix #18 invalid mask setConfigure().
|
|
||||||
// 0.3.1 2022-08-11 add support for AS5600L (I2C address)
|
|
||||||
// add magnetTooStrong() + magnetTooWeak();
|
|
||||||
// add / update examples
|
|
||||||
// update documentation
|
|
||||||
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
// Power-up time 1 minute (need HW)
|
|
||||||
// check Timing Characteristics
|
|
||||||
|
|
||||||
|
|
||||||
#include "AS5600.h"
|
#include "AS5600.h"
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// FILE: AS5600.h
|
// FILE: AS5600.h
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// VERSION: 0.3.1
|
// VERSION: 0.3.2
|
||||||
// PURPOSE: Arduino library for AS5600 magnetic rotation meter
|
// PURPOSE: Arduino library for AS5600 magnetic rotation meter
|
||||||
// DATE: 2022-05-28
|
// DATE: 2022-05-28
|
||||||
// URL: https://github.com/RobTillaart/AS5600
|
// URL: https://github.com/RobTillaart/AS5600
|
||||||
@ -12,7 +12,7 @@
|
|||||||
#include "Wire.h"
|
#include "Wire.h"
|
||||||
|
|
||||||
|
|
||||||
#define AS5600_LIB_VERSION (F("0.3.1"))
|
#define AS5600_LIB_VERSION (F("0.3.2"))
|
||||||
|
|
||||||
// setDirection
|
// setDirection
|
||||||
const uint8_t AS5600_CLOCK_WISE = 0; // LOW
|
const uint8_t AS5600_CLOCK_WISE = 0; // LOW
|
||||||
|
58
libraries/AS5600/CHANGELOG.md
Normal file
58
libraries/AS5600/CHANGELOG.md
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# Change Log AS5600
|
||||||
|
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.2] - 2022-10-16
|
||||||
|
- add CHANGELOG.md
|
||||||
|
- update readme.md
|
||||||
|
- update build-CI to support RP2040
|
||||||
|
|
||||||
|
## [0.3.1] - 2022-08-11
|
||||||
|
- add support for AS5600L (I2C address)
|
||||||
|
- add magnetTooStrong() + magnetTooWeak();
|
||||||
|
- add / update examples
|
||||||
|
- update documentation
|
||||||
|
|
||||||
|
## [0.3.0] - 2022-07-07
|
||||||
|
- fix #18 invalid mask setConfigure().
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
## [0.2.1] - not released
|
||||||
|
- add bool return to set() functions.
|
||||||
|
- update Readme (analog / PWM out)
|
||||||
|
|
||||||
|
## [0.2.0] - 2022-06-28
|
||||||
|
- add software based direction control.
|
||||||
|
- add examples
|
||||||
|
- define constants for configuration functions.
|
||||||
|
- fix conversion constants (4096 based)
|
||||||
|
- add get- setOffset(degrees) functions. (no radians yet)
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
## [0.1.4] - 2022-06-27
|
||||||
|
- fix #7 use readReg2() to improve I2C performance.
|
||||||
|
- define constants for configuration functions.
|
||||||
|
- add examples - especially OUT pin related.
|
||||||
|
- fix default parameter of the begin function.
|
||||||
|
|
||||||
|
## [0.1.3] - 2022-06-26
|
||||||
|
- add AS5600_RAW_TO_RADIANS.
|
||||||
|
- add getAngularSpeed() mode parameter.
|
||||||
|
- fix #8 bug in configure.
|
||||||
|
|
||||||
|
## [0.1.2] - 2022-06-02
|
||||||
|
- add getAngularSpeed().
|
||||||
|
|
||||||
|
## [0.1.1] - 2022-05-31
|
||||||
|
- add readReg2() to speed up reading 2 byte values.
|
||||||
|
- fix clock wise and counter clock wise.
|
||||||
|
- fix shift-direction @ getZPosition, getMPosition,
|
||||||
|
getMaxAngle and getConfigure.
|
||||||
|
|
||||||
|
## [0.1.0] - 2022-05-28
|
||||||
|
- initial version
|
||||||
|
|
@ -39,28 +39,46 @@ Possible interesting related libraries.
|
|||||||
- https://github.com/RobTillaart/runningAngle
|
- https://github.com/RobTillaart/runningAngle
|
||||||
|
|
||||||
|
|
||||||
### I2C Address
|
## Hardware connection
|
||||||
|
|
||||||
| sensor | address | changeable |
|
The I2C address of the **AS5600** is always 0x36.
|
||||||
|:--------:|:---------:|:-------------|
|
|
||||||
| AS5600 | 0x36 | NO |
|
|
||||||
| AS5600L | 0x40 | YES, check setAddress() |
|
|
||||||
|
|
||||||
To use more than one **AS5600** on one I2C bus, see Multiplexing below.
|
The AS5600 datasheet states it supports Fast-Mode == 400 KHz
|
||||||
|
and Fast-Mode-Plus == 1000 KHz.
|
||||||
|
Tests with a AS5600L failed at 400 KHz (needs investigation).
|
||||||
|
|
||||||
The **AS5600L** supports the change of I2C address, optionally permanent.
|
The sensor should connect the I2C lines SDA and SCL and the
|
||||||
Check the **setAddress()** function for non-permanent change.
|
VCC and GND to communicate with the processor.
|
||||||
|
|
||||||
|
|
||||||
### I2C performance
|
### DIR pin
|
||||||
|
|
||||||
| board | sensor | results |
|
From datasheet, page 30 - Direction (clockwise vs. counter-clockwise)
|
||||||
|:-----------:|:---------:|:--------------------|
|
|
||||||
| Arduino UNO | AS5600 | not tested |
|
|
||||||
| Arduino UNO | AS5600L | work up to 300 KHz. |
|
|
||||||
|
|
||||||
|
_**The AS5600 allows controlling the direction of the magnet
|
||||||
|
rotation with the DIR pin. If DIR is connected to GND (DIR = 0)
|
||||||
|
a clockwise rotation viewed from the top will generate an
|
||||||
|
increment of the calculated angle. If the DIR pin is connected
|
||||||
|
to VDD (DIR = 1) an increment of the calculated angle will
|
||||||
|
happen with counter-clockwise rotation.**_
|
||||||
|
|
||||||
More tests are needed
|
This AS5600 library offers a 3rd option for the DIR (direction) pin of the sensor:
|
||||||
|
|
||||||
|
1. Connect to **GND** ==> fixed clockwise(\*). This is the default.
|
||||||
|
1. Connect to **VCC** ==> fixed counter-clockwise.
|
||||||
|
1. Connect to an IO pin of the processor == Hardware Direction Control by library.
|
||||||
|
|
||||||
|
In the 3rd configuration the library controls the direction of counting by initializing
|
||||||
|
this pin in **begin(directionPin)**, followed by **setDirection(direction)**.
|
||||||
|
For the parameter direction the library defines two constants named:
|
||||||
|
|
||||||
|
- **AS5600_CLOCK_WISE (0)**
|
||||||
|
- **AS5600_COUNTERCLOCK_WISE (1)**
|
||||||
|
|
||||||
|
(\*) if **begin()** is called without **directionPin** or with this
|
||||||
|
parameter set to **255**, Software Direction Control is enabled.
|
||||||
|
|
||||||
|
See Software Direction Control below for more information.
|
||||||
|
|
||||||
|
|
||||||
### OUT pin
|
### OUT pin
|
||||||
@ -73,6 +91,8 @@ See **Analogue Pin** and **PWM Pin** below.
|
|||||||
|
|
||||||
Examples are added to show how to use this pin with **setOutputMode()**.
|
Examples are added to show how to use this pin with **setOutputMode()**.
|
||||||
|
|
||||||
|
See more in the sections Analog OUT and PWM OUT below.
|
||||||
|
|
||||||
|
|
||||||
### PGO pin
|
### PGO pin
|
||||||
|
|
||||||
@ -86,34 +106,27 @@ See datasheet for a detailed list of steps to be done.
|
|||||||
See **Make configuration persistent** below.
|
See **Make configuration persistent** below.
|
||||||
|
|
||||||
|
|
||||||
## Hardware connection
|
## I2C
|
||||||
|
|
||||||
The I2C address of the **AS5600** is always 0x36.
|
### Address
|
||||||
|
|
||||||
The AS5600 datasheet states it supports Fast-Mode == 400 KHz
|
| sensor | address | changeable |
|
||||||
and Fast-Mode-Plus == 1000 KHz.
|
|:--------:|:---------:|:-------------|
|
||||||
Tests with a AS5600L failed at 400 KHz (needs investigation).
|
| AS5600 | 0x36 | NO |
|
||||||
|
| AS5600L | 0x40 | YES, check setAddress() |
|
||||||
|
|
||||||
The sensor should connect the I2C lines SDA and SCL and the
|
To use more than one **AS5600** on one I2C bus, see Multiplexing below.
|
||||||
VCC and GND to communicate with the processor.
|
|
||||||
The DIR (direction) pin of the sensor should be connected to:
|
|
||||||
|
|
||||||
- **GND** = fixed clockwise(\*)
|
The **AS5600L** supports the change of I2C address, optionally permanent.
|
||||||
- **VCC** = fixed counter clock wise
|
Check the **setAddress()** function for non-permanent change.
|
||||||
- a free floating IO pin of the processor = under library control.
|
|
||||||
|
|
||||||
In the latter setup the library can control the direction of
|
|
||||||
counting by initializing this pin in **begin(directionPin)**,
|
|
||||||
followed by **setDirection(direction)**. For the direction the
|
|
||||||
library defines two constants named:
|
|
||||||
|
|
||||||
- **AS5600_CLOCK_WISE (0)**
|
### Performance
|
||||||
- **AS5600_COUNTERCLOCK_WISE (1)**
|
|
||||||
|
|
||||||
(\*) if **begin()** is called without **directionPin** or with this
|
| board | sensor | results | notes |
|
||||||
parameter set to **255**, software direction control is enabled.
|
|:-----------:|:---------:|:----------------|:---------|
|
||||||
|
| Arduino UNO | AS5600 | up to 900 KHz. | see #22 |
|
||||||
See Software Direction Control below for more information.
|
| Arduino UNO | AS5600L | up to 300 KHz. | |
|
||||||
|
|
||||||
|
|
||||||
## Interface
|
## Interface
|
||||||
@ -168,6 +181,8 @@ To define in which way the sensor counts up.
|
|||||||
- **uint8_t getDirection()** returns AS5600_CLOCK_WISE (0) or
|
- **uint8_t getDirection()** returns AS5600_CLOCK_WISE (0) or
|
||||||
AS5600_COUNTERCLOCK_WISE (1).
|
AS5600_COUNTERCLOCK_WISE (1).
|
||||||
|
|
||||||
|
See Software Direction Control below for more information.
|
||||||
|
|
||||||
|
|
||||||
### Configuration registers
|
### Configuration registers
|
||||||
|
|
||||||
@ -196,7 +211,7 @@ Returns false if parameter is out of range.
|
|||||||
Please read datasheet for details.
|
Please read datasheet for details.
|
||||||
|
|
||||||
| Bit | short | Description | Values |
|
| Bit | short | Description | Values |
|
||||||
|:-----:|:------|:-------------:|:------------------------------------------------------|
|
|:-----:|:------|:--------------|:------------------------------------------------------|
|
||||||
| 0-1 | PM | Power mode | 00 = NOM, 01 = LPM1, 10 = LPM2, 11 = LPM3 |
|
| 0-1 | PM | Power mode | 00 = NOM, 01 = LPM1, 10 = LPM2, 11 = LPM3 |
|
||||||
| 2-3 | HYST | Hysteresis | 00 = OFF, 01 = 1 LSB, 10 = 2 LSB, 11 = 3 LSB |
|
| 2-3 | HYST | Hysteresis | 00 = OFF, 01 = 1 LSB, 10 = 2 LSB, 11 = 3 LSB |
|
||||||
| 4-5 | OUTS | Output Stage | 00 = analog (0-100%), 01 = analog (10-90%), 10 = PWM |
|
| 4-5 | OUTS | Output Stage | 00 = analog (0-100%), 01 = analog (10-90%), 10 = PWM |
|
||||||
@ -330,16 +345,18 @@ Normally one controls the direction of the sensor by connecting the DIR pin
|
|||||||
to one of the available IO pins of the processor.
|
to one of the available IO pins of the processor.
|
||||||
This IO pin is set in the library as parameter of the **begin(directionPin)** function.
|
This IO pin is set in the library as parameter of the **begin(directionPin)** function.
|
||||||
|
|
||||||
The directionPin is default set to 255, which defines a software direction control.
|
The directionPin is default set to 255, which defines a **Software Direction Control**.
|
||||||
To have this working one has to connect the DIR pin of the sensor to GND.
|
|
||||||
This puts the sensor in a hardware clock wise mode, so it is up to the library
|
To have this working one has to connect the **DIR pin of the sensor to GND**.
|
||||||
|
This puts the sensor in a hardware clockwise mode. Then it is up to the library
|
||||||
to do the additional math so the **readAngle()** and **rawAngle()** behave as
|
to do the additional math so the **readAngle()** and **rawAngle()** behave as
|
||||||
if the DIR pin was connected to the processor IO pin.
|
if the DIR pin was connected to a processor IO pin.
|
||||||
|
|
||||||
The gain is that the user does not need an IO pin for this,
|
The user still calls **setDirection()** as before to change the direction
|
||||||
which makes connecting the sensor a bit easier.
|
of the increments and decrements.
|
||||||
|
|
||||||
The user still calls **setDirection()** as before to change the direction.
|
The advantage is one does not need that extra IO pin from the processor.
|
||||||
|
This makes connecting the sensor a bit easier.
|
||||||
|
|
||||||
TODO: measure performance impact.
|
TODO: measure performance impact.
|
||||||
|
|
||||||
@ -478,7 +495,8 @@ UPDT = update page 30 - AS5600L
|
|||||||
- **bool setI2CUPDT(uint8_t value)**
|
- **bool setI2CUPDT(uint8_t value)**
|
||||||
- **uint8_t getI2CUPDT()**
|
- **uint8_t getI2CUPDT()**
|
||||||
|
|
||||||
These functions seems to have only a function in relation to **setAddress()** so possibly obsolete in the future. If you got other insights on these functions please let me know.
|
These functions seems to have only a function in relation to **setAddress()** so possibly obsolete in the future.
|
||||||
|
If you got other insights on these functions please let me know.
|
||||||
|
|
||||||
|
|
||||||
## Operational
|
## Operational
|
||||||
@ -512,16 +530,17 @@ See examples.
|
|||||||
## Future
|
## Future
|
||||||
|
|
||||||
Some ideas are kept here so they won't get lost.
|
Some ideas are kept here so they won't get lost.
|
||||||
priority is relative
|
priority is relative.
|
||||||
|
|
||||||
|
|
||||||
#### high priority
|
#### high priority
|
||||||
|
|
||||||
- fix for AS5600L does not support analog OUT
|
- fix for AS5600L as it does not support analog OUT.
|
||||||
- type field?
|
- type field?
|
||||||
- other class hierarchy?
|
- other class hierarchy? base class with commonalities?
|
||||||
- just ignore?
|
- just ignore?
|
||||||
|
|
||||||
|
|
||||||
#### medium priority
|
#### medium priority
|
||||||
|
|
||||||
- investigate **readMagnitude()**
|
- investigate **readMagnitude()**
|
||||||
@ -539,10 +558,14 @@ priority is relative
|
|||||||
- different configuration options
|
- different configuration options
|
||||||
- add mode parameter to offset functions.
|
- add mode parameter to offset functions.
|
||||||
- see getAngularSpeed()
|
- see getAngularSpeed()
|
||||||
|
- check / verify Power-up time
|
||||||
|
- 1 minute (need HW)
|
||||||
|
- check Timing Characteristics (datasheet)
|
||||||
|
- is there improvement possible.
|
||||||
|
|
||||||
|
|
||||||
#### low priority
|
#### low priority
|
||||||
|
|
||||||
- add error handling
|
- add error handling
|
||||||
- investigate PGO programming pin.
|
- investigate PGO programming pin.
|
||||||
- create **changeLog.md**
|
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/RobTillaart/AS5600.git"
|
"url": "https://github.com/RobTillaart/AS5600.git"
|
||||||
},
|
},
|
||||||
"version": "0.3.1",
|
"version": "0.3.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"frameworks": "arduino",
|
"frameworks": "arduino",
|
||||||
"platforms": "*",
|
"platforms": "*",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name=AS5600
|
name=AS5600
|
||||||
version=0.3.1
|
version=0.3.2
|
||||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
sentence=Arduino library for AS5600 and AS5600L magnetic rotation meter.
|
sentence=Arduino library for AS5600 and AS5600L magnetic rotation meter.
|
||||||
|
Loading…
Reference in New Issue
Block a user