You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Depending on if you want to use this library as the plug and play Arduino library or you want to get insight in the algorithm and make changes there are two ways to install this code.
* An example to find out the raw max and min count to be provided to the constructor
5
+
* Spin your motor/sensor/magnet to see what is the maximum output of the sensor and what is the minimum value
6
+
* And replace values 14 and 1020 with new values. Once when you replace them make sure there is no jump in the angle reading sensor.getAngle().
7
+
* If there is a jump that means you can still find better values.
8
+
*/
9
+
10
+
/**
11
+
* Magnetic sensor reading analog voltage on pin A1. This voltage is proportional to rotation position.
12
+
* Tested on AS5600 magnetic sensor running in 'analog mode'. Note AS5600 works better in 'i2C mode' (less noise) but only supports one sensor per i2c bus.
13
+
*
14
+
* MagneticSensorAnalog(uint8_t _pinAnalog, int _min, int _max)
15
+
* - pinAnalog - the pin that is reading the pwm from magnetic sensor
16
+
* - min_raw_count - the smallest expected reading. Whilst you might expect it to be 0 it is often ~15. Getting this wrong results in a small click once per revolution
17
+
* - max_raw_count - the largest value read. whilst you might expect it to be 2^10 = 1023 it is often ~ 1020. Note ESP32 will be closer to 4096 with its 12bit ADC
Copy file name to clipboardExpand all lines: examples/utils/sensor_test/magnetic_sensors/magnetic_sensor_analog_example/magnetic_sensor_analog/magnetic_sensor_analog.ino
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
#include<SimpleFOC.h>
2
2
3
3
4
+
4
5
/**
5
6
* Magnetic sensor reading analog voltage on pin A1. This voltage is proportional to rotation position.
6
7
* Tested on AS5600 magnetic sensor running in 'analog mode'. Note AS5600 works better in 'i2C mode' (less noise) but only supports one sensor per i2c bus.
Copy file name to clipboardExpand all lines: examples/utils/sensor_test/magnetic_sensors/magnetic_sensor_pwm_example/find_raw_min_max/find_raw_min_max.ino
+16-3Lines changed: 16 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -22,9 +22,22 @@ void setup() {
22
22
_delay(1000);
23
23
}
24
24
25
+
int max_pulse= 0;
26
+
int min_pulse = 10000;
27
+
25
28
voidloop() {
26
-
// display the angle and the angular velocity to the terminal
0 commit comments