-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- fix #67, improve performance **getCumulativePosition()** and **getAngularSpeed()** - kudos to Chris-42 - add **AS5600_position_speed.ino** - update readme.md
- Loading branch information
1 parent
9e0fc03
commit 0d01e33
Showing
8 changed files
with
220 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// | ||
// FILE: AS5600_position_speed.ino | ||
// AUTHOR: Rob Tillaart | ||
// PURPOSE: demo compare performance with update flag | ||
// URL: https://github.com/RobTillaart/AS5600 | ||
// | ||
// Examples may use AS5600 or AS5600L devices. | ||
// Check if your sensor matches the one used in the example. | ||
// Optionally adjust the code. | ||
|
||
|
||
#include "AS5600.h" | ||
|
||
// select right class. | ||
// AS5600 as5600; // use default Wire | ||
AS5600L as5600; // use default Wire | ||
|
||
uint32_t start, stop; | ||
|
||
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. | ||
|
||
Serial.println(as5600.getAddress()); | ||
|
||
// as5600.setAddress(0x40); // AS5600L only | ||
|
||
int b = as5600.isConnected(); | ||
Serial.print("Connect: "); | ||
Serial.println(b); | ||
|
||
for (uint32_t speed = 100000; speed <= 800000; speed += 100000) | ||
{ | ||
Wire.setClock(speed); | ||
Serial.println(speed); | ||
delay(100); | ||
|
||
start = micros(); | ||
as5600.getCumulativePosition(); | ||
as5600.getAngularSpeed(); | ||
stop = micros(); | ||
Serial.print("update true: \t"); | ||
Serial.println(stop - start); | ||
delay(100); | ||
|
||
start = micros(); | ||
as5600.readAngle(); | ||
as5600.getCumulativePosition(false); | ||
as5600.getAngularSpeed(AS5600_MODE_DEGREES, false); | ||
stop = micros(); | ||
Serial.print("update false: \t"); | ||
Serial.println(stop - start); | ||
Serial.println(); | ||
delay(100); | ||
} | ||
|
||
/* | ||
about ~1% slower on AVR @100K | ||
start = micros(); | ||
as5600.getCumulativePosition(true); | ||
as5600.getAngularSpeed(AS5600_MODE_DEGREES, false); | ||
stop = micros(); | ||
Serial.print("update false: \t"); | ||
Serial.println(stop - start); | ||
Serial.println(); | ||
delay(100); | ||
*/ | ||
|
||
delay(2000); | ||
} | ||
|
||
|
||
void loop() | ||
{ | ||
static uint32_t lastTime = 0; | ||
|
||
if (millis() - lastTime >= 100) | ||
{ | ||
lastTime = millis(); | ||
as5600.readAngle(); | ||
Serial.print(as5600.getCumulativePosition(false)); | ||
Serial.print("\t"); | ||
Serial.println(as5600.getAngularSpeed(AS5600_MODE_DEGREES, false)); | ||
} | ||
} | ||
|
||
|
||
// -- END OF FILE -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
BOARD: UNO | ||
IDE: 1.8.19 | ||
SKETCH: AS5600_position_speed.ino | ||
|
||
|
||
AS5600_LIB_VERSION: 0.6.4 | ||
64 | ||
Connect: 1 | ||
100000 | ||
update true: 1208 | ||
update false: 640 | ||
|
||
200000 | ||
update true: 724 | ||
update false: 368 | ||
|
||
300000 | ||
update true: 552 | ||
update false: 316 | ||
|
||
400000 | ||
update true: 440 | ||
update false: 276 | ||
|
||
500000 | ||
update true: 432 | ||
update false: 224 | ||
|
||
600000 | ||
update true: 356 | ||
update false: 236 | ||
|
||
700000 | ||
update true: 372 | ||
update false: 192 | ||
|
||
800000 | ||
update true: 356 | ||
update false: 220 | ||
|
||
followed by lots of data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name=AS5600 | ||
version=0.6.3 | ||
version=0.6.4 | ||
author=Rob Tillaart <[email protected]> | ||
maintainer=Rob Tillaart <[email protected]> | ||
sentence=Arduino library for AS5600 and AS5600L magnetic rotation meter. | ||
|