0.1.4 AS5600

This commit is contained in:
rob tillaart 2022-06-27 11:27:48 +02:00
parent e601c94a0c
commit 4c4b842086
11 changed files with 438 additions and 88 deletions

View File

@ -6,15 +6,19 @@
// DATE: 2022-05-28
// URL: https://github.com/RobTillaart/AS5600
// 0.1.0 2022-05-28 initial version
// 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
// 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-xx 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.
// TODO
@ -22,43 +26,42 @@
// check Timing Characteristics
#include "AS5600.h"
// CONFIGURATION REGISTERS
#define AS5600_ZMCO 0x00
#define AS5600_ZPOS 0x01 // + 0x02
#define AS5600_MPOS 0x03 // + 0x04
#define AS5600_MANG 0x05 // + 0x06
#define AS5600_CONF 0x07 // + 0x08
const uint8_t AS5600_ZMCO = 0x00;
const uint8_t AS5600_ZPOS = 0x01; // + 0x02
const uint8_t AS5600_MPOS = 0x03; // + 0x04
const uint8_t AS5600_MANG = 0x05; // + 0x06
const uint8_t AS5600_CONF = 0x07; // + 0x08
// CONFIGURATION BIT MASKS - byte level
#define AS5600_CONF_POWER_MODE 0x03
#define AS5600_CONF_HYSTERESIS 0x0C
#define AS5600_CONF_OUTPUT_MODE 0x30
#define AS5600_CONF_PWM_FREQUENCY 0xC0
#define AS5600_CONF_SLOW_FILTER 0x03
#define AS5600_CONF_FAST_FILTER 0x1C
#define AS5600_CONF_WATCH_DOG 0x20
const uint8_t AS5600_CONF_POWER_MODE = 0x03;
const uint8_t AS5600_CONF_HYSTERESIS = 0x0C;
const uint8_t AS5600_CONF_OUTPUT_MODE = 0x30;
const uint8_t AS5600_CONF_PWM_FREQUENCY = 0xC0;
const uint8_t AS5600_CONF_SLOW_FILTER = 0x03;
const uint8_t AS5600_CONF_FAST_FILTER = 0x1C;
const uint8_t AS5600_CONF_WATCH_DOG = 0x20;
// UNKNOWN REGISTERS 0x09-0x0A
// OUTPUT REGISTERS
#define AS5600_RAW_ANGLE 0x0C // + 0x0D
#define AS5600_ANGLE 0x0E // + 0x0F
const uint8_t AS5600_RAW_ANGLE = 0x0C; // + 0x0D
const uint8_t AS5600_ANGLE = 0x0E; // + 0x0F
// STATUS REGISTERS
#define AS5600_STATUS 0x0B
#define AS5600_AGC 0x1A
#define AS5600_MAGNITUDE 0x1B // + 0x1C
#define AS5600_BURN 0xFF
const uint8_t AS5600_STATUS = 0x0B;
const uint8_t AS5600_AGC = 0x1A;
const uint8_t AS5600_MAGNITUDE = 0x1B; // + 0x1C
const uint8_t AS5600_BURN = 0xFF;
// STATUS BITS
#define AS5600_MAGNET_HIGH 0x08
#define AS5600_MAGNET_LOW 0x10
#define AS5600_MAGNET_DETECT 0x20
const uint8_t AS5600_MAGNET_HIGH = 0x08;
const uint8_t AS5600_MAGNET_LOW = 0x10;
const uint8_t AS5600_MAGNET_DETECT = 0x20;
AS5600::AS5600(TwoWire *wire)
@ -68,7 +71,7 @@ AS5600::AS5600(TwoWire *wire)
#if defined (ESP8266) || defined(ESP32)
bool AS5600::begin(int dataPin, int clockPin, int directionPin)
bool AS5600::begin(int dataPin, int clockPin, uint8_t directionPin)
{
_directionPin = directionPin;
pinMode(_directionPin, OUTPUT);
@ -87,7 +90,7 @@ bool AS5600::begin(int dataPin, int clockPin, int directionPin)
#endif
bool AS5600::begin(int directionPin)
bool AS5600::begin(uint8_t directionPin)
{
_directionPin = directionPin;
pinMode(_directionPin, OUTPUT);
@ -131,60 +134,52 @@ uint8_t AS5600::getZMCO()
void AS5600::setZPosition(uint16_t value)
{
writeReg(AS5600_ZPOS, (value >> 8) & 0x0F);
writeReg(AS5600_ZPOS + 1, value & 0xFF);
writeReg2(AS5600_ZPOS, value & 0x0FFF);
}
uint16_t AS5600::getZPosition()
{
uint16_t value = (readReg(AS5600_ZPOS) & 0x0F) << 8;
value += readReg(AS5600_ZPOS + 1);
uint16_t value = readReg2(AS5600_ZPOS) & 0x0FFF;
return value;
}
void AS5600::setMPosition(uint16_t value)
{
writeReg(AS5600_MPOS, (value >> 8) & 0x0F);
writeReg(AS5600_MPOS + 1, value & 0xFF);
writeReg2(AS5600_MPOS, value & 0x0FFF);
}
uint16_t AS5600::getMPosition()
{
uint16_t value = (readReg(AS5600_MPOS) & 0x0F) << 8;
value += readReg(AS5600_MPOS + 1);
uint16_t value = readReg2(AS5600_MPOS) & 0x0FFF;
return value;
}
void AS5600::setMaxAngle(uint16_t value)
{
writeReg(AS5600_MANG, (value >> 8) & 0x0F);
writeReg(AS5600_MANG + 1, value & 0xFF);
writeReg2(AS5600_MANG, value & 0x0FFF);
}
uint16_t AS5600::getMaxAngle()
{
uint16_t value = (readReg(AS5600_MANG) & 0x0F) << 8;
value += readReg(AS5600_MANG + 1);
uint16_t value = readReg2(AS5600_MANG) & 0x0FFF;
return value;
}
void AS5600::setConfigure(uint16_t value)
{
writeReg(AS5600_CONF, (value >> 8) & 0x2F);
writeReg(AS5600_CONF + 1, value & 0xFF);
writeReg2(AS5600_CONF, value & 0x2FFF);
}
uint16_t AS5600::getConfigure()
{
uint16_t value = (readReg(AS5600_CONF) & 0x2F) << 8;
value += readReg(AS5600_CONF + 1);
uint16_t value = readReg2(AS5600_CONF) & 0x2FFF;
return value;
}
@ -367,7 +362,11 @@ float AS5600::getAngularSpeed(uint8_t mode)
_lastMeasurement = now;
_lastAngle = angle;
// return degrees or radians
if (mode == 1) return speed * AS5600_RAW_TO_RADIANS;
if (mode == AS5600_MODE_RADIANS)
{
return speed * AS5600_RAW_TO_RADIANS;
}
// default return degrees
return speed * AS5600_RAW_TO_DEGREES;
}
@ -412,6 +411,17 @@ uint8_t AS5600::writeReg(uint8_t reg, uint8_t value)
}
uint8_t AS5600::writeReg2(uint8_t reg, uint16_t value)
{
_wire->beginTransmission(_address);
_wire->write(reg);
_wire->write(value >> 8);
_wire->write(value & 0xFF);
_error = _wire->endTransmission();
return _error;
}
// -- END OF FILE --

View File

@ -2,7 +2,7 @@
//
// FILE: AS5600.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.3
// VERSION: 0.1.4
// PURPOSE: Arduino library for AS5600 magnetic rotation meter
// DATE: 2022-05-28
// URL: https://github.com/RobTillaart/AS5600
@ -12,14 +12,42 @@
#include "Wire.h"
#define AS5600_LIB_VERSION (F("0.1.3"))
#define AS5600_LIB_VERSION (F("0.1.4"))
#define AS5600_CLOCK_WISE 0 // LOW
#define AS5600_COUNTERCLOCK_WISE 1 // HIGH
// setDirection
const uint8_t AS5600_CLOCK_WISE = 0; // LOW
const uint8_t AS5600_COUNTERCLOCK_WISE = 1; // HIGH
// 0.0879120879120879121;
const float AS5600_RAW_TO_DEGREES = 360.0 / 4095.0;
// 0.00153435538636864138630654133494;
const float AS5600_RAW_TO_RADIANS = PI * 2.0 / 4095.0;
// getAngularSpeed
const uint8_t AS5600_MODE_DEGREES = 0;
const uint8_t AS5600_MODE_RADIANS = 1;
// setOutputMode
const uint8_t AS5600_OUTMODE_ANALOG_100 = 0;
const uint8_t AS5600_OUTMODE_ANALOG_90 = 1;
const uint8_t AS5600_OUTMODE_PWM = 2;
// setPowerMode
const uint8_t AS5600_POWERMODE_NOMINAL = 0;
const uint8_t AS5600_POWERMODE_LOW1 = 1;
const uint8_t AS5600_POWERMODE_LOW2 = 2;
const uint8_t AS5600_POWERMODE_LOW3 = 3;
// setPWMFrequency
const uint8_t AS5600_PWM_115 = 0;
const uint8_t AS5600_PWM_230 = 1;
const uint8_t AS5600_PWM_460 = 2;
const uint8_t AS5600_PWM_920 = 3;
// setWatchDog
const uint8_t AS5600_WATCHDOG_OFF = 0;
const uint8_t AS5600_WATCHDOG_ON = 1;
#define AS5600_RAW_TO_DEGREES (0.0879120879120879121)
#define AS5600_RAW_TO_RADIANS (0.00153435538636864138630654133494)
class AS5600
@ -28,9 +56,9 @@ public:
AS5600(TwoWire *wire = &Wire);
#if defined (ESP8266) || defined(ESP32)
bool begin(int sda, int scl, int directionPin = AS5600_CLOCK_WISE);
bool begin(int sda, int scl, uint8_t directionPin);
#endif
bool begin(int directionPin = AS5600_CLOCK_WISE);
bool begin(uint8_t directionPin);
bool isConnected();
uint8_t getAddress() { return _address; }; // 0x36
@ -68,7 +96,7 @@ public:
// 0 = analog 0-100%
// 1 = analog 10-90%
// 2 = PWM
// 2 = PWM
void setOutputMode(uint8_t outputMode); // 0..2
uint8_t getOutputMode();
@ -111,22 +139,23 @@ public:
// approximation of the angular speed in rotations per second.
// mode == 1: radians /second
// mode == 0: degrees /second (default)
float getAngularSpeed(uint8_t mode = 0);
float getAngularSpeed(uint8_t mode = AS5600_MODE_DEGREES);
private:
uint8_t readReg(uint8_t reg);
uint16_t readReg2(uint8_t reg);
uint8_t writeReg(uint8_t reg, uint8_t value);
uint8_t writeReg2(uint8_t reg, uint16_t value);
const uint8_t _address = 0x36;
uint8_t _directionPin;
uint8_t _error = 0;
TwoWire* _wire;
uint32_t _lastMeasurement = 0;
uint16_t _lastAngle = 0;
uint16_t _lastAngle = 0;
};

View File

@ -15,23 +15,58 @@ Arduino library for AS5600 magnetic rotation meter.
### AS5600
**AS5600** is a library for a AS5600 magnetic rotation meter.
**AS5600** is a library for an AS5600 based magnetic rotation meter.
**Warning: experimental - not tested yet**
**Warning: experimental - not tested**
TODO: buy hardware to test the library.
The sensor can measure a full rotation in 4096 steps.
The precision is therefore limited to 0.1°.
Noise levels unknown, but one might expect it to be effected by electric
and or magnetic signals in the environment.
Also unknown is the influence of metals near the sensor or an unstable or fluctuating power supply.
TODO: buy hardware to test the library and get hands on experience with the sensor.
### I2C Address
The I2C address of the **AS5600** is always 0x36.
To use more than one **AS5600** on one I2C bus, one needs an I2C multiplexer,
e.g. https://github.com/RobTillaart/TCA9548
To use more than one **AS5600** on one I2C bus, see Multiplexing below.
### OUT pin
Not tested.
The sensor has an output pin named **OUT**.
This pin can be used for an analogue or PWM output signal.
Examples are added to show how to use this pin with **setOutputMode()**.
### GPO pin
### PGO pin
TODO
Not tested.
PGO stand for Programming Option, it is used to calibrate / 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.
See also **Make configuration persistent** below.
## Hardware connection
The sensor should connect the I2C lines SDA and SCL and the
VCC and GND to communicate with the processor.
The DIR (direction) pin of the sensor should be connected to:
- GND = fixed clockwise
- VCC = fixed counter clock wise
- a free IO pin of the processor = library control.
In the latter setup the library can control the direction of counting by initializing this pin in **begin(pin)**, followed by **setDirection(direction)**. For the direction the library defines two constants named:
- **AS5600_CLOCK_WISE (0)**
- **AS5600_COUNTERCLOCK_WISE (1)**
## Interface
@ -39,15 +74,43 @@ TODO
The I2C address of the **AS5600** is always 0x36.
### Constants
### Defines
**NOT** to be adjusted.
To be adjusted via command line (or in AS5600.h file)
```cpp
// setDirection
const uint8_t AS5600_CLOCK_WISE = 0; // LOW
const uint8_t AS5600_COUNTERCLOCK_WISE = 1; // HIGH
- **AS5600_CLOCK_WISE 1**
- **AS5600_COUNTERCLOCK_WISE 0**
- **AS5600_RAW_TO_DEGREES 0.0879120879120879121**
- **AS5600_RAW_TO_RADIANS 0.00153435538636864138630654133494**
const float AS5600_RAW_TO_DEGREES = 360.0 / 4095.0; // 0.0879120879120879121;
const float AS5600_RAW_TO_RADIANS = 2 * PI / 4095.0; // 0.00153435538636864138630654133494;
// getAngularSpeed
const uint8_t AS5600_MODE_DEGREES = 0;
const uint8_t AS5600_MODE_RADIANS = 1;
// setOutputMode
const uint8_t AS5600_OUTMODE_ANALOG_100 = 0;
const uint8_t AS5600_OUTMODE_ANALOG_90 = 1;
const uint8_t AS5600_OUTMODE_PWM = 2;
// setPowerMode
const uint8_t AS5600_POWERMODE_NOMINAL = 0;
const uint8_t AS5600_POWERMODE_LOW1 = 1;
const uint8_t AS5600_POWERMODE_LOW2 = 2;
const uint8_t AS5600_POWERMODE_LOW3 = 3;
// setPWMFrequency
const uint8_t AS5600_PWM_115 = 0;
const uint8_t AS5600_PWM_230 = 1;
const uint8_t AS5600_PWM_460 = 2;
const uint8_t AS5600_PWM_920 = 3;
// setWatchDog
const uint8_t AS5600_WATCHDOG_OFF = 0;
const uint8_t AS5600_WATCHDOG_ON = 1;
```
### Constructor + I2C
@ -108,15 +171,15 @@ This is the one most used.
### Angular Speed
- **getAngularSpeed(uint8_t mode = 0)** is an experimental function that returns
- **getAngularSpeed(uint8_t mode = AS5600_MODE_DEGREES)** is an experimental function that returns
an approximation of the angular speed in rotations per second.
The function needs to be called at least **four** times per rotation
to get a reasonably accuracy.
(0.1.3 added mode parameter).
- mode == 1: radians /second
- mode == 0: degrees /second (default)
- mode == ?: degrees /second
- mode == AS5600_MODE_RADIANS (1): radians /second
- mode == AS5600_MODE_DEGREES (0): degrees /second (default)
- mode other => degrees /second
Negative values indicate reverse rotation.
What that means depends on the setup of your project.
@ -172,6 +235,20 @@ You can only burn a new Angle maximum **THREE** times to the AS5600.
You can write this only **ONE** time to the AS5600.
## Multiplexing
The I2C address of the **AS5600** is always 0x36.
To use more than one **AS5600** on one I2C bus, one needs an I2C multiplexer,
e.g. https://github.com/RobTillaart/TCA9548.
Alternative could be the use of a AND port for the I2C clock line to prevent
the sensor from listening to signals on the I2C bus.
Finally the sensor has an analogue output **OUT**.
This output could be used to connect multiple sensors to different analog ports of the processor.
**Warning**: If and how well this analog option works is not verified or tested. (TODO)
## Operational
@ -208,17 +285,17 @@ Some ideas are kept here so they won't get lost.
### high prio
- improve documentation
- improve performance (I2C issue)
- get hardware to test.
- improve documentation
- investigate PGO programming pin.
- investigate OUT output pin.
- PWM, analog_90 and analog_100
- write examples
- as5600_calibration.ino ?
- add functions
- **setOutputMode()** + constants.
- **setPowerMode()** + constants
- **magnetStrength()**
- add constants for remaining configure functions
- hysteresis, fast / slow filter
- investigate **magnetStrength()**
- combination of AGC and MD, ML and MH flags?
- do we need **ANGLE_FACTOR** = 0.0879121
### low prio

View File

@ -0,0 +1,39 @@
//
// FILE: AS5600_demo_radians.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo
#include "AS5600.h"
#include "Wire.h"
AS5600 as5600; // use default Wire
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("AS5600_LIB_VERSION: ");
Serial.println(AS5600_LIB_VERSION);
Wire.begin();
as5600.begin(4); // set direction pin.
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
}
void loop()
{
Serial.print(millis());
Serial.print("\t");
Serial.print(as5600.readAngle());
Serial.print("\t");
Serial.println(as5600.rawAngle() * AS5600_RAW_TO_RADIANS);
delay(1000);
}
// -- END OF FILE --

View File

@ -0,0 +1,42 @@
//
// FILE: AS5600_outmode_analog_100.ino
// AUTHOR: Rob Tillaart
// PURPOSE: experimental demo
// connect the OUT pin to the analog port of the processor
#include "AS5600.h"
#include "Wire.h"
AS5600 as5600; // use default Wire
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("AS5600_LIB_VERSION: ");
Serial.println(AS5600_LIB_VERSION);
Wire.begin();
as5600.begin(4); // set direction pin.
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
as5600.setOutputMode(AS5600_OUTMODE_ANALOG_100);
}
void loop()
{
Serial.print(millis());
Serial.print("\t");
Serial.print(as5600.readAngle());
Serial.print("\t");
Serial.println(analogRead(A0));
delay(1000);
}
// -- END OF FILE --

View File

@ -0,0 +1,42 @@
//
// FILE: AS5600_outmode_analog_90.ino
// AUTHOR: Rob Tillaart
// PURPOSE: experimental demo
// connect the OUT pin to the analog port of the processor
#include "AS5600.h"
#include "Wire.h"
AS5600 as5600; // use default Wire
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("AS5600_LIB_VERSION: ");
Serial.println(AS5600_LIB_VERSION);
Wire.begin();
as5600.begin(4); // set direction pin.
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
as5600.setOutputMode(AS5600_OUTMODE_ANALOG_90);
}
void loop()
{
Serial.print(millis());
Serial.print("\t");
Serial.print(as5600.readAngle());
Serial.print("\t");
Serial.println(analogRead(A0));
delay(1000);
}
// -- END OF FILE --

View File

@ -0,0 +1,49 @@
//
// FILE: AS5600_outmode_analog_pwm.ino
// AUTHOR: Rob Tillaart
// PURPOSE: experimental
// connect the OUT pin to the analog port of the processor
// use a resistor and a capacitor to create a low pass filter
// so the PWM behave a bit like a analog signal
//
// alternative one can read the PWM with interrupt pin and
// determine the duty cycle
#include "AS5600.h"
#include "Wire.h"
AS5600 as5600; // use default Wire
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("AS5600_LIB_VERSION: ");
Serial.println(AS5600_LIB_VERSION);
Wire.begin();
as5600.begin(4); // set direction pin.
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
as5600.setOutputMode(AS5600_OUTMODE_PWM);
as5600.setPWMFrequency(AS5600_PWM_920);
}
void loop()
{
Serial.print(millis());
Serial.print("\t");
Serial.print(as5600.readAngle());
Serial.print("\t");
Serial.println(analogRead(A0));
delay(1000);
}
// -- END OF FILE --

View File

@ -19,8 +19,10 @@ setZPosition KEYWORD2
getZPosition KEYWORD2
setMPosition KEYWORD2
getMPosition KEYWORD2
setMaxAngle KEYWORD2
getMaxAngle KEYWORD2
setConfigure KEYWORD2
getConfigure KEYWORD2
@ -30,6 +32,7 @@ readAngle KEYWORD2
readStatus KEYWORD2
readAGC KEYWORD2
readMagnitude KEYWORD2
detectMagnet KEYWORD2
burnAngle KEYWORD2
burnSetting KEYWORD2
@ -37,11 +40,50 @@ burnSetting KEYWORD2
getAngularSpeed KEYWORD2
# CONFIGURATION FIELDS
setPowerMode KEYWORD2
getPowerMode KEYWORD2
setHysteresis KEYWORD2
getHysteresis KEYWORD2
setOutputMode KEYWORD2
getOutputMode KEYWORD2
setPWMFrequency KEYWORD2
getPWMFrequency KEYWORD2
setSlowFilter KEYWORD2
getSlowFilter KEYWORD2
setFastFilter KEYWORD2
getFastFilter KEYWORD2
setWatchDog KEYWORD2
getWatchDog KEYWORD2
# Constants (LITERAL1)
AS5600_LIB_VERSION LITERAL1
AS5600_CLOCK_WISE LITERAL1
AS5600_COUNTERCLOCK_WISE LITERAL1
AS5600_RAW_TO_DEGREES LITERAL1
AS5600_RAW_TO_RADIANS LITERAL1
AS5600_MODE_DEGREES LITERAL1
AS5600_MODE_RADIANS LITERAL1
AS5600_OUTMODE_ANALOG_100 LITERAL1
AS5600_OUTMODE_ANALOG_90 LITERAL1
AS5600_OUTMODE_PWM LITERAL1
AS5600_POWERMODE_NOMINAL LITERAL1
AS5600_POWERMODE_LOW1 LITERAL1
AS5600_POWERMODE_LOW2 LITERAL1
AS5600_POWERMODE_LOW3 LITERAL1
AS5600_PWM_115 LITERAL1
AS5600_PWM_230 LITERAL1
AS5600_PWM_460 LITERAL1
AS5600_PWM_920 LITERAL1
AS5600_WATCHDOG_OFF LITERAL1
AS5600_WATCHDOG_ON LITERAL1

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/AS5600.git"
},
"version": "0.1.3",
"version": "0.1.4",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=AS5600
version=0.1.3
version=0.1.4
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for AS5600 magnetic rotation meter

View File

@ -50,8 +50,28 @@ unittest(test_constants)
{
assertEqual(0, AS5600_CLOCK_WISE);
assertEqual(1, AS5600_COUNTERCLOCK_WISE);
assertEqual(0, AS5600_MODE_DEGREES);
assertEqual(1, AS5600_MODE_RADIANS);
assertEqualFloat(360.0/4095, AS5600_RAW_TO_DEGREES, 0.0001);
assertEqualFloat(PI*2.0/4095, AS5600_RAW_TO_RADIANS, 0.0001);
assertEqualFloat((PI*2.0)/4095, AS5600_RAW_TO_RADIANS, 0.0001);
assertEqual(0, AS5600_OUTMODE_ANALOG_100);
assertEqual(1, AS5600_OUTMODE_ANALOG_90);
assertEqual(2, AS5600_OUTMODE_PWM);
assertEqual(0, AS5600_POWERMODE_NOMINAL);
assertEqual(1, AS5600_POWERMODE_LOW1);
assertEqual(2, AS5600_POWERMODE_LOW2);
assertEqual(3, AS5600_POWERMODE_LOW3);
assertEqual(0, AS5600_PWM_115);
assertEqual(1, AS5600_PWM_230);
assertEqual(2, AS5600_PWM_460);
assertEqual(3, AS5600_PWM_920);
assertEqual(0, AS5600_WATCHDOG_OFF);
assertEqual(1, AS5600_WATCHDOG_ON);
}
@ -78,7 +98,7 @@ unittest(test_direction)
AS5600 as5600;
as5600.begin(4);
as5600.setDirection();
assertEqual(AS5600_CLOCK_WISE, as5600.getDirection());