forked from jonas-merkle/AS5047P
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrintAllSettings.ino
73 lines (59 loc) · 2.68 KB
/
PrintAllSettings.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* @file PrintAllSettings.ino
* @author Jonas Merkle [JJM] ([email protected])
* @brief This is a example prints out the settings of the AS5047P sensor.
* @version 2.1.5
* @date 2021-04-10
*
* @copyright Copyright (c) 2021 Jonas Merkle. This project is released under the GPL-3.0 License License.
*
* More Information can be found here:
* https://github.com/jonas-merkle/AS5047P
*/
// include the library for the AS5047P sensor.
#include <AS5047P.h>
// define a led pin.
#define LED_PIN 13
// define the chip select port.
#define AS5047P_CHIP_SELECT_PORT 9
// define the spi bus speed
#define AS5047P_CUSTOM_SPI_BUS_SPEED 100000
// initialize a new AS5047P sensor object.
AS5047P as5047p(AS5047P_CHIP_SELECT_PORT, AS5047P_CUSTOM_SPI_BUS_SPEED);
// arduino setup routine
void setup() {
// set the pinmode of the led pin to output.
pinMode(LED_PIN, OUTPUT);
// initialize the serial bus for the communication with your pc.
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// initialize the AS5047P sensor and hold if sensor can't be initialized.
Serial.println(F("Initializing AS5047P sensor..."));
while (!as5047p.initSPI()) {
Serial.println(F("Can't connect to the AS5047P sensor! Please check the connection..."));
delay(5000);
}
Serial.println(F("Initializing AS5047P sensor... Done!"));
}
// arduino loop routine
void loop() {
// read the settings from the sensor
auto settings1 = as5047p.read_SETTINGS1();
auto settings2 = as5047p.read_SETTINGS2();
// print the settings
Serial.print("SETTINGS1.values.FactorySetting: "); Serial.println(settings1.data.values.FactorySetting);
Serial.print("SETTINGS1.values.NOISESET: "); Serial.println(settings1.data.values.NOISESET);
Serial.print("SETTINGS1.values.DIR: "); Serial.println(settings1.data.values.DIR);
Serial.print("SETTINGS1.values.UVW_ABI: "); Serial.println(settings1.data.values.UVW_ABI);
Serial.print("SETTINGS1.values.DAECDIS: "); Serial.println(settings1.data.values.DAECDIS);
Serial.print("SETTINGS1.values.ABIBIN: "); Serial.println(settings1.data.values.ABIBIN);
Serial.print("SETTINGS1.values.Dataselect: "); Serial.println(settings1.data.values.Dataselect);
Serial.print("SETTINGS1.values.PWMon: "); Serial.println(settings1.data.values.PWMon);
Serial.print("SETTINGS2.values.UVWPP: "); Serial.println(settings2.data.values.UVWPP);
Serial.print("SETTINGS2.values.HYS: "); Serial.println(settings2.data.values.HYS);
Serial.print("SETTINGS2.values.ABIRES: "); Serial.println(settings2.data.values.ABIRES);
Serial.println("");
delay(5000);
}