Skip to content

Commit cec679d

Browse files
committed
a bit more info about the saving and loading of the LUT
1 parent f185099 commit cec679d

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

src/encoders/calibrated/README.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,44 @@ void setup() {
8181

8282
Please see the more complete [example](https://github.com/simplefoc/Arduino-FOC-drivers/blob/master/examples/encoders/calibrated/sensor_calibration.ino) in our examples directory.
8383

84+
## EDIT March 2025
8485

85-
## Roadmap
86+
The code has been rewritten to reduce its memory footprint and allow more flexible Lookup table (LUT) sizing.
87+
Additionally, the calibrated sensor class now supports providing the saved LUT as a parameter to the constructor. This allows you to save the LUT and load it on startup to avoid recalibration on each startup.
8688

87-
Possible future improvements we've thought about:
89+
The LUT and sensor's zero angle and direction are outputed by the calibration process to the Serial terminal. So you can copy and paste them into your code.
8890

89-
- Improve memory usage and performance
90-
- Make calibration able to be saved/restored
91+
Your code will look something like this:
9192

93+
```c++
94+
95+
// number of LUT entries
96+
const N_LUT = 100;
97+
// Lookup table that has been ouptut from the calibration process
98+
float calibrationLut[N_LUT] = {...};
99+
100+
// provide the sensor class and the number of points in the LUT
101+
CalibratedSensor sensor_calibrated = CalibratedSensor(sensor, N_LUT, calibrationLut);
102+
103+
...
104+
105+
void setup() {
106+
...
107+
// as LUT is provided this function does not need to be called
108+
sensor_calibrated.calibrate(motor);
109+
...
110+
111+
motor.linkSensor(&sensor_calibrated);
112+
113+
114+
// write the sensor direction and zero electrical angle outputed by the calibration
115+
motor.sensor_direction = Direction::CW; // replace with the value outputed by the calibration
116+
motor.zero_electric_angle = 0.0; // replace with the value outputed by the calibration
117+
118+
...
119+
motor.initFOC();
120+
....
121+
}
122+
123+
124+
```

0 commit comments

Comments
 (0)