mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.5.0 AD5600
This commit is contained in:
parent
95adf18cb4
commit
60c9575c7a
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FILE: AS56000.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.4.1
|
||||
// VERSION: 0.5.0
|
||||
// PURPOSE: Arduino library for AS5600 magnetic rotation meter
|
||||
// DATE: 2022-05-28
|
||||
// URL: https://github.com/RobTillaart/AS5600
|
||||
@ -55,56 +55,6 @@ AS5600::AS5600(TwoWire *wire)
|
||||
}
|
||||
|
||||
|
||||
#if defined (ESP8266) || defined(ESP32)
|
||||
|
||||
bool AS5600::begin(int dataPin, int clockPin, uint8_t directionPin)
|
||||
{
|
||||
_directionPin = directionPin;
|
||||
if (_directionPin != AS5600_SW_DIRECTION_PIN)
|
||||
{
|
||||
pinMode(_directionPin, OUTPUT);
|
||||
}
|
||||
setDirection(AS5600_CLOCK_WISE);
|
||||
|
||||
if ((dataPin < 255) && (clockPin < 255))
|
||||
{
|
||||
_wire->begin(dataPin, clockPin);
|
||||
} else {
|
||||
_wire->begin();
|
||||
}
|
||||
if (! isConnected()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined (ARDUINO_ARCH_STM32)
|
||||
|
||||
bool AS5600::begin(int dataPin, int clockPin, uint8_t directionPin)
|
||||
{
|
||||
_directionPin = directionPin;
|
||||
if (_directionPin != AS5600_SW_DIRECTION_PIN)
|
||||
{
|
||||
pinMode(_directionPin, OUTPUT);
|
||||
}
|
||||
setDirection(AS5600_CLOCK_WISE);
|
||||
|
||||
if ((dataPin < 255) && (clockPin < 255))
|
||||
{
|
||||
_wire->setSDA(dataPin);
|
||||
_wire->setSCL(clockPin);
|
||||
_wire->begin();
|
||||
} else {
|
||||
_wire->begin();
|
||||
}
|
||||
if (! isConnected()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
bool AS5600::begin(uint8_t directionPin)
|
||||
{
|
||||
_directionPin = directionPin;
|
||||
@ -114,7 +64,6 @@ bool AS5600::begin(uint8_t directionPin)
|
||||
}
|
||||
setDirection(AS5600_CLOCK_WISE);
|
||||
|
||||
_wire->begin();
|
||||
if (! isConnected()) return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: AS5600.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.4.1
|
||||
// VERSION: 0.5.0
|
||||
// PURPOSE: Arduino library for AS5600 magnetic rotation meter
|
||||
// DATE: 2022-05-28
|
||||
// URL: https://github.com/RobTillaart/AS5600
|
||||
@ -12,7 +12,7 @@
|
||||
#include "Wire.h"
|
||||
|
||||
|
||||
#define AS5600_LIB_VERSION (F("0.4.1"))
|
||||
#define AS5600_LIB_VERSION (F("0.5.0"))
|
||||
|
||||
// default addresses
|
||||
const uint8_t AS5600_DEFAULT_ADDRESS = 0x36;
|
||||
@ -89,15 +89,11 @@ class AS5600
|
||||
public:
|
||||
AS5600(TwoWire *wire = &Wire);
|
||||
|
||||
#if defined (ESP8266) || defined(ESP32) || defined(ARDUINO_ARCH_STM32)
|
||||
// AS5600_SW_DIRECTION_PIN is software controlled direction pin
|
||||
bool begin(int dataPin, int clockPin, uint8_t directionPin = AS5600_SW_DIRECTION_PIN);
|
||||
#endif
|
||||
|
||||
bool begin(uint8_t directionPin = AS5600_SW_DIRECTION_PIN);
|
||||
bool isConnected();
|
||||
|
||||
// address = 0x36 for AS5600, 0x40 for AS5600L
|
||||
// address = fixed 0x36 for AS5600,
|
||||
// = default 0x40 for AS5600L
|
||||
uint8_t getAddress();
|
||||
|
||||
|
||||
|
@ -5,12 +5,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [0.5.0] - 2023-12-07
|
||||
- refactor API, begin()
|
||||
- update readme.md
|
||||
- update examples
|
||||
- add examples
|
||||
- patch library.properties => category=Sensors
|
||||
|
||||
----
|
||||
|
||||
## [0.4.1] - 2023-09-16
|
||||
- fix #45 support STM32 set I2C pins ARDUINO_ARCH_STM32
|
||||
- update readme badges
|
||||
- minor edits
|
||||
|
||||
|
||||
## [0.4.0] - 2023-06-27
|
||||
- fix #39 support for Wire2 on ESP32
|
||||
- update readme.md
|
||||
|
@ -36,6 +36,15 @@ or fluctuating power supply.
|
||||
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.
|
||||
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()**.
|
||||
|
||||
|
||||
#### Related libraries
|
||||
|
||||
- https://github.com/RobTillaart/Angle
|
||||
@ -159,11 +168,17 @@ When polling the AS5600 with an ESP32 to measure RPM an issue has been reported.
|
||||
See https://github.com/RobTillaart/AS5600/issues/28
|
||||
|
||||
The problem is that the ESP32 can be blocking for up to one second if there is a
|
||||
problem in the connection with the sensor. Using **setWireTimeout()** does not seem
|
||||
to solve the problem (2023-01-31). In the issue the goal was to measure the turns
|
||||
of a rotating device at around 3800 RPM. To do this one need roughly 1 angle measurement
|
||||
per 5 milliseconds.
|
||||
which
|
||||
problem in the connection with the sensor.
|
||||
Using **setWireTimeout()** does not seem to solve the problem (2023-01-31).
|
||||
In the issue the goal was to measure the turns of a rotating device at around 3800 RPM.
|
||||
|
||||
3800 RPM == 64 rounds / second.
|
||||
|
||||
To measure speed one need at least 3 angle measurements per rotation.
|
||||
This results in at least 192 measurements per second which is about 1 per 5 milliseconds.
|
||||
|
||||
Given that the ESP32 can block for a second, it can not be guaranteed to be up to date.
|
||||
Not for speed, but also not for total number of rotations.
|
||||
|
||||
|
||||
## Interface
|
||||
|
@ -2,7 +2,6 @@
|
||||
// FILE: AS5600L_set_address.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo
|
||||
// DATE: 2022-08-30
|
||||
|
||||
|
||||
#include "AS5600.h"
|
||||
@ -21,7 +20,7 @@ void setup()
|
||||
Wire.begin();
|
||||
|
||||
ASL.begin(4); // set direction pin.
|
||||
ASL.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
ASL.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
int b = ASL.isConnected();
|
||||
Serial.print("Connect: ");
|
||||
Serial.println(b);
|
||||
@ -48,4 +47,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -2,18 +2,18 @@
|
||||
// FILE: AS5600_I2C_frequency.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo
|
||||
// DATE: 2022-05-28
|
||||
|
||||
|
||||
#include "AS5600.h"
|
||||
#include "Wire.h"
|
||||
|
||||
AS5600 as5600; // use default Wire
|
||||
AS5600L as5600; // use default Wire
|
||||
|
||||
uint32_t clk = 0;
|
||||
|
||||
uint32_t start, stop;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
@ -23,13 +23,10 @@ void setup()
|
||||
|
||||
Wire.begin();
|
||||
|
||||
// UNO
|
||||
as5600.begin(4); // set direction pin.
|
||||
// ESP32
|
||||
// as5600.begin(14, 15); // no direction pin.
|
||||
// as5600.setAddress(0x40); // AS5600L only
|
||||
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
int b = as5600.isConnected();
|
||||
Serial.print("Connect: ");
|
||||
Serial.println(b);
|
||||
|
@ -2,13 +2,12 @@
|
||||
// FILE: AS5600_angular_speed.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo
|
||||
// DATE: 2022-06-02
|
||||
|
||||
|
||||
#include "AS5600.h"
|
||||
#include "Wire.h"
|
||||
|
||||
AS5600 as5600; // use default Wire
|
||||
AS5600L as5600; // use default Wire
|
||||
|
||||
|
||||
void setup()
|
||||
@ -21,7 +20,7 @@ void setup()
|
||||
Wire.begin();
|
||||
|
||||
as5600.begin(4); // set direction pin.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
|
||||
Serial.println(as5600.getAddress());
|
||||
|
||||
@ -39,10 +38,10 @@ void loop()
|
||||
{
|
||||
// Serial.print("\ta = ");
|
||||
// Serial.print(as5600.readAngle());
|
||||
Serial.print("\tω = ");
|
||||
// Serial.print("\tω = ");
|
||||
Serial.println(as5600.getAngularSpeed());
|
||||
delay(100);
|
||||
delay(25);
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -2,7 +2,6 @@
|
||||
// FILE: AS5600_angular_speed_RPM.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo
|
||||
// DATE: 2022-06-02
|
||||
|
||||
|
||||
#include "AS5600.h"
|
||||
@ -19,13 +18,13 @@ void setup()
|
||||
Serial.println(AS5600_LIB_VERSION);
|
||||
|
||||
Wire.begin();
|
||||
// as5600.begin(14,15);
|
||||
|
||||
as5600.begin(4); // set direction pin.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
|
||||
Serial.println(as5600.getAddress());
|
||||
|
||||
// as5600.setAddress(0x40); // AS5600L only
|
||||
// as5600.setAddress(0x40); // AS5600L only
|
||||
|
||||
int b = as5600.isConnected();
|
||||
Serial.print("Connect: ");
|
||||
@ -45,4 +44,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -2,7 +2,6 @@
|
||||
// FILE: AS5600_burn_conf_mang.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo (not tested yet - see issue #38)
|
||||
// DATE: 2023-06-18
|
||||
|
||||
|
||||
// WARNING
|
||||
@ -31,11 +30,10 @@ void setup()
|
||||
Serial.print("AS5600_LIB_VERSION: ");
|
||||
Serial.println(AS5600_LIB_VERSION);
|
||||
|
||||
// ESP32
|
||||
// as5600.begin(14, 15);
|
||||
// AVR
|
||||
Wire.begin();
|
||||
|
||||
as5600.begin(4); // set direction pin.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
|
||||
if (as5600.isConnected())
|
||||
{
|
||||
@ -172,4 +170,4 @@ void burn_mang()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -2,7 +2,6 @@
|
||||
// FILE: AS5600_burn_zpos.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo (not tested yet - see issue #38)
|
||||
// DATE: 2023-06-18
|
||||
|
||||
|
||||
// WARNING
|
||||
@ -31,11 +30,10 @@ void setup()
|
||||
Serial.print("AS5600_LIB_VERSION: ");
|
||||
Serial.println(AS5600_LIB_VERSION);
|
||||
|
||||
// ESP32
|
||||
// as5600.begin(14, 15);
|
||||
// AVR
|
||||
Wire.begin();
|
||||
|
||||
as5600.begin(4); // set direction pin.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
|
||||
if (as5600.isConnected())
|
||||
{
|
||||
@ -111,4 +109,4 @@ void burn_zpos()
|
||||
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -2,13 +2,12 @@
|
||||
// FILE: AS5600_demo.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo
|
||||
// DATE: 2022-05-28
|
||||
|
||||
|
||||
#include "AS5600.h"
|
||||
#include "Wire.h"
|
||||
|
||||
AS5600 as5600; // use default Wire
|
||||
AS5600L as5600; // use default Wire
|
||||
|
||||
|
||||
void setup()
|
||||
@ -17,12 +16,11 @@ void setup()
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("AS5600_LIB_VERSION: ");
|
||||
Serial.println(AS5600_LIB_VERSION);
|
||||
|
||||
Wire.begin();
|
||||
|
||||
// ESP32
|
||||
// as5600.begin(14,15);
|
||||
// AVR
|
||||
as5600.begin(4); // set direction pin.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
int b = as5600.isConnected();
|
||||
Serial.print("Connect: ");
|
||||
Serial.println(b);
|
||||
@ -43,4 +41,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
28
libraries/AS5600/examples/AS5600_demo_ESP32/.arduino-ci.yml
Normal file
28
libraries/AS5600/examples/AS5600_demo_ESP32/.arduino-ci.yml
Normal file
@ -0,0 +1,28 @@
|
||||
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:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
# - uno
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
# - m4
|
||||
- esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
||||
# - rpipico
|
||||
|
@ -0,0 +1,44 @@
|
||||
//
|
||||
// FILE: AS5600_demo.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo
|
||||
|
||||
|
||||
#include "AS5600.h"
|
||||
#include "Wire.h"
|
||||
|
||||
AS5600L as5600; // use default Wire
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("AS5600_LIB_VERSION: ");
|
||||
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();
|
||||
Serial.print("Connect: ");
|
||||
Serial.println(b);
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Serial.print(millis());
|
||||
// Serial.print("\t");
|
||||
Serial.print(as5600.readAngle());
|
||||
Serial.print("\t");
|
||||
Serial.println(as5600.rawAngle());
|
||||
// Serial.println(as5600.rawAngle() * AS5600_RAW_TO_DEGREES);
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
28
libraries/AS5600/examples/AS5600_demo_RP2040/.arduino-ci.yml
Normal file
28
libraries/AS5600/examples/AS5600_demo_RP2040/.arduino-ci.yml
Normal file
@ -0,0 +1,28 @@
|
||||
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:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
# - uno
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
# - m4
|
||||
# - esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
||||
- rpipico
|
||||
|
@ -0,0 +1,46 @@
|
||||
//
|
||||
// FILE: AS5600_demo.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo
|
||||
|
||||
|
||||
#include "AS5600.h"
|
||||
#include "Wire.h"
|
||||
|
||||
AS5600L as5600; // use default Wire
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("AS5600_LIB_VERSION: ");
|
||||
Serial.println(AS5600_LIB_VERSION);
|
||||
|
||||
Wire.setSDA(14);
|
||||
Wire.setSCL(15);
|
||||
Wire.begin();
|
||||
|
||||
as5600.begin(4); // set direction pin.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
int b = as5600.isConnected();
|
||||
Serial.print("Connect: ");
|
||||
Serial.println(b);
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Serial.print(millis());
|
||||
// Serial.print("\t");
|
||||
Serial.print(as5600.readAngle());
|
||||
Serial.print("\t");
|
||||
Serial.println(as5600.rawAngle());
|
||||
// Serial.println(as5600.rawAngle() * AS5600_RAW_TO_DEGREES);
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
28
libraries/AS5600/examples/AS5600_demo_STM32/.arduino-ci.yml
Normal file
28
libraries/AS5600/examples/AS5600_demo_STM32/.arduino-ci.yml
Normal file
@ -0,0 +1,28 @@
|
||||
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:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
# - uno
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
# - m4
|
||||
# - esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
||||
# - rpipico
|
||||
|
@ -0,0 +1,47 @@
|
||||
//
|
||||
// FILE: AS5600_demo.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo
|
||||
//
|
||||
// tested compilation with Nucleo-64
|
||||
|
||||
#include "AS5600.h"
|
||||
#include "Wire.h"
|
||||
|
||||
AS5600L as5600; // use default Wire
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("AS5600_LIB_VERSION: ");
|
||||
Serial.println(AS5600_LIB_VERSION);
|
||||
|
||||
Wire.setSDA(14);
|
||||
Wire.setSCL(15);
|
||||
Wire.begin();
|
||||
|
||||
as5600.begin(4); // set direction pin.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
int b = as5600.isConnected();
|
||||
Serial.print("Connect: ");
|
||||
Serial.println(b);
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Serial.print(millis());
|
||||
// Serial.print("\t");
|
||||
Serial.print(as5600.readAngle());
|
||||
Serial.print("\t");
|
||||
Serial.println(as5600.rawAngle());
|
||||
// Serial.println(as5600.rawAngle() * AS5600_RAW_TO_DEGREES);
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
@ -20,7 +20,7 @@ void setup()
|
||||
Wire.begin();
|
||||
|
||||
as5600.begin(4); // set direction pin.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
}
|
||||
|
||||
|
||||
@ -45,4 +45,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -19,9 +19,8 @@ void setup()
|
||||
|
||||
Wire.begin();
|
||||
|
||||
// as5600.begin(11, 12, 4); // test for STM32 or ESP32
|
||||
as5600.begin(4); // set direction pin.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
}
|
||||
|
||||
|
||||
@ -37,4 +36,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -4,7 +4,7 @@
|
||||
// PURPOSE: demo software direction control
|
||||
|
||||
|
||||
// connect the DIR pin of teh AS5600 to GND
|
||||
// connect the DIR pin of the AS5600 to GND
|
||||
|
||||
|
||||
#include "AS5600.h"
|
||||
@ -24,7 +24,7 @@ void setup()
|
||||
Wire.begin();
|
||||
|
||||
as5600.begin(); // set software direction control. default param = 255
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
}
|
||||
|
||||
|
||||
@ -48,4 +48,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -2,7 +2,6 @@
|
||||
// FILE: AS5600_demo_status.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo
|
||||
// DATE: 2022-05-28
|
||||
|
||||
|
||||
#include "AS5600.h"
|
||||
@ -21,7 +20,7 @@ void setup()
|
||||
Wire.begin();
|
||||
|
||||
as5600.begin(4); // set direction pin.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
}
|
||||
|
||||
|
||||
@ -47,4 +46,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -2,11 +2,11 @@
|
||||
// FILE: AS5600_demo_two_I2C.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo two I2C busses
|
||||
// DATE: 2023-03-07
|
||||
//
|
||||
// Works only if Wire1 bus is present
|
||||
// Works only if Wire1 bus is present e.g.
|
||||
// - nano33 ble
|
||||
// - teensy 4.1
|
||||
// - RP2040
|
||||
|
||||
|
||||
#include "AS5600.h"
|
||||
@ -23,6 +23,9 @@ void setup()
|
||||
Serial.print("AS5600_LIB_VERSION: ");
|
||||
Serial.println(AS5600_LIB_VERSION);
|
||||
|
||||
Wire.begin();
|
||||
Wire1.begin();
|
||||
|
||||
as5600_0.begin(4); // set direction pin.
|
||||
as5600_0.setDirection(AS5600_CLOCK_WISE);
|
||||
Serial.print("Connect device 0: ");
|
||||
|
@ -22,7 +22,7 @@ void setup()
|
||||
Wire.begin();
|
||||
|
||||
as5600.begin(4); // set direction pin.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
as5600.setOutputMode(AS5600_OUTMODE_ANALOG_100);
|
||||
}
|
||||
|
||||
@ -39,4 +39,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -22,7 +22,7 @@ void setup()
|
||||
Wire.begin();
|
||||
|
||||
as5600.begin(4); // set direction pin.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
as5600.setOutputMode(AS5600_OUTMODE_ANALOG_90);
|
||||
}
|
||||
|
||||
@ -39,4 +39,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -28,7 +28,7 @@ void setup()
|
||||
Wire.begin();
|
||||
|
||||
as5600.begin(4); // set direction pin.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
as5600.setOutputMode(AS5600_OUTMODE_PWM);
|
||||
as5600.setPWMFrequency(AS5600_PWM_920);
|
||||
}
|
||||
@ -46,4 +46,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -2,7 +2,6 @@
|
||||
// FILE: AS5600_outmode_pwm_interrupt.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo
|
||||
// DATE: 2022-05-28
|
||||
|
||||
|
||||
#include "AS5600.h"
|
||||
@ -57,4 +56,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -0,0 +1,98 @@
|
||||
// FILE: AS5600_plus_AS5600L.ino
|
||||
// AUTHOR: laptophead
|
||||
// PURPOSE: showing working of a AS5600 and AS5600L side by side
|
||||
// URL: https://github.com/RobTillaart/AS5600
|
||||
// URL: https://github.com/RobTillaart/AS5600/issues/48
|
||||
|
||||
|
||||
#include "AS5600.h"
|
||||
#include "Wire.h"
|
||||
|
||||
AS5600 as5600_R; // uses default Wire
|
||||
AS5600L as5600_L; // uses default Wire
|
||||
|
||||
int Raw_R;
|
||||
int Raw_Prev;
|
||||
|
||||
float Deg_R, Deg_L;
|
||||
float Deg_Prev_R, Deg_Prev_L;
|
||||
|
||||
static uint32_t lastTime = 0;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(230400);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("AS5600_LIB_VERSION: ");
|
||||
Serial.println(AS5600_LIB_VERSION);
|
||||
|
||||
Wire.begin();
|
||||
|
||||
// as5600_L.setAddress(0x40); // AS5600L only
|
||||
as5600_L.begin(15); // set direction pin.
|
||||
as5600_L.setDirection(AS5600_CLOCK_WISE); //
|
||||
delay(1000);
|
||||
|
||||
as5600_R.begin(14); // set direction pin.
|
||||
as5600_R.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
|
||||
delay(1000);
|
||||
Serial.print ("Address For AS5600 R ");
|
||||
Serial.println(as5600_R.getAddress());
|
||||
Serial.print ("Address For AS5600 L ");
|
||||
Serial.println(as5600_L.getAddress());
|
||||
|
||||
Serial.print("Connect_R: ");
|
||||
Serial.println(as5600_R.isConnected() ? "true" : "false");
|
||||
|
||||
Serial.print("Connect device LEFT: ");
|
||||
Serial.println(as5600_L.isConnected() ? "true" : "false");
|
||||
|
||||
delay(1000);
|
||||
as5600_R.resetPosition();
|
||||
as5600_L.resetPosition();
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
Deg_R = convertRawAngleToDegrees(as5600_R.getCumulativePosition());
|
||||
Deg_L = convertRawAngleToDegrees(as5600_L.getCumulativePosition());
|
||||
// update every 100 ms
|
||||
// should be enough up to ~200 RPM
|
||||
if (millis() - lastTime >= 100 and Deg_R != Deg_Prev_R)
|
||||
{
|
||||
lastTime = millis();
|
||||
|
||||
Serial.println("REV R: " + String(as5600_R.getRevolutions()));
|
||||
Serial.println("REV L: " + String(as5600_L.getRevolutions()));
|
||||
Serial.println("DEG R= " + String(Deg_R, 0) + "°" );
|
||||
Serial.println("DEG L= " + String(Deg_L, 0) + "°" );
|
||||
Deg_Prev_R = Deg_R;
|
||||
}
|
||||
|
||||
// just to show how reset can be used
|
||||
if (as5600_R.getRevolutions() >= 1 )
|
||||
{
|
||||
as5600_R.resetPosition();
|
||||
|
||||
if ( as5600_R.getRevolutions() <= -1 )
|
||||
{
|
||||
as5600_R.resetPosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float convertRawAngleToDegrees(uint32_t newAngle)
|
||||
{
|
||||
/* Raw data reports 0 - 4095 segments, which is 0.087890625 of a degree */
|
||||
float retVal = newAngle * 0.087890625;
|
||||
retVal = round(retVal);
|
||||
// retVal=retVal/10;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
@ -2,7 +2,6 @@
|
||||
// FILE: AS5600_position.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo
|
||||
// DATE: 2022-12-20
|
||||
|
||||
|
||||
#include "AS5600.h"
|
||||
@ -18,15 +17,14 @@ void setup()
|
||||
Serial.print("AS5600_LIB_VERSION: ");
|
||||
Serial.println(AS5600_LIB_VERSION);
|
||||
|
||||
// ESP32
|
||||
// as5600.begin(14, 15);
|
||||
// AVR
|
||||
Wire.begin();
|
||||
|
||||
as5600.begin(4); // set direction pin.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
|
||||
Serial.println(as5600.getAddress());
|
||||
|
||||
// as5600.setAddress(0x40); // AS5600L only
|
||||
// as5600.setAddress(0x40); // AS5600L only
|
||||
|
||||
int b = as5600.isConnected();
|
||||
Serial.print("Connect: ");
|
||||
@ -61,4 +59,4 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
@ -13,7 +13,13 @@ AS5600L as5600; // use default Wire
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
as5600.begin(14, 15); // ESP32
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("AS5600_LIB_VERSION: ");
|
||||
Serial.println(AS5600_LIB_VERSION);
|
||||
|
||||
Wire.begin(14, 15); // ESP32
|
||||
|
||||
as5600.begin();
|
||||
as5600.setAddress(0x40); // AS5600L has address
|
||||
|
||||
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/AS5600.git"
|
||||
},
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"license": "MIT",
|
||||
"frameworks": "*",
|
||||
"platforms": "*",
|
||||
|
@ -1,10 +1,10 @@
|
||||
name=AS5600
|
||||
version=0.4.1
|
||||
version=0.5.0
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for AS5600 and AS5600L magnetic rotation meter.
|
||||
paragraph=
|
||||
category=Data Processing
|
||||
category=Sensors
|
||||
url=https://github.com/RobTillaart/AS5600
|
||||
architectures=*
|
||||
includes=AS5600.h
|
||||
|
@ -111,6 +111,9 @@ unittest(test_constants_configuration)
|
||||
unittest(test_constructor)
|
||||
{
|
||||
AS5600 as5600;
|
||||
|
||||
Wire.begin();
|
||||
|
||||
as5600.begin(4);
|
||||
assertTrue(as5600.isConnected()); // keep CI happy
|
||||
|
||||
@ -123,6 +126,9 @@ unittest(test_constructor)
|
||||
unittest(test_address)
|
||||
{
|
||||
AS5600 as5600;
|
||||
|
||||
Wire.begin();
|
||||
|
||||
as5600.begin(4);
|
||||
assertEqual(0x36, as5600.getAddress());
|
||||
|
||||
@ -140,6 +146,8 @@ unittest(test_hardware_direction)
|
||||
{
|
||||
AS5600 as5600;
|
||||
|
||||
Wire.begin();
|
||||
|
||||
as5600.begin(4);
|
||||
assertEqual(AS5600_CLOCK_WISE, as5600.getDirection());
|
||||
|
||||
@ -158,6 +166,8 @@ unittest(test_software_direction)
|
||||
{
|
||||
AS5600 as5600;
|
||||
|
||||
Wire.begin();
|
||||
|
||||
as5600.begin(255);
|
||||
assertEqual(AS5600_CLOCK_WISE, as5600.getDirection());
|
||||
|
||||
@ -176,6 +186,8 @@ unittest(test_offset)
|
||||
{
|
||||
AS5600 as5600;
|
||||
|
||||
Wire.begin();
|
||||
|
||||
as5600.begin();
|
||||
|
||||
for (int of = 0; of < 360; of += 40)
|
||||
@ -202,6 +214,8 @@ unittest(test_failing_set_commands)
|
||||
{
|
||||
AS5600 as5600;
|
||||
|
||||
Wire.begin();
|
||||
|
||||
as5600.begin();
|
||||
|
||||
assertFalse(as5600.setZPosition(4096));
|
||||
@ -219,7 +233,7 @@ unittest(test_failing_set_commands)
|
||||
}
|
||||
|
||||
|
||||
// FOR REMAINING ONE NEED A STUB
|
||||
// FOR REMAINING ONE NEED A STUB
|
||||
|
||||
|
||||
unittest_main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user