Skip to content

Improvements to LinearHall#96

Merged
runger1101001 merged 2 commits into
simplefoc:devfrom
dekutree64:dev
Jul 3, 2026
Merged

Improvements to LinearHall#96
runger1101001 merged 2 commits into
simplefoc:devfrom
dekutree64:dev

Conversation

@dekutree64

@dekutree64 dekutree64 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor
  • Added calibration for difference in the total range of each sensor from XieMaster's version, optimized to a single multiply.
  • Added option for 60° and 120° sensor spacing.
  • Added wait for first valid sensor readings in init, for some custom ADC setups.
  • Changed private to protected and moved getSensorAngle there, better matching other sensor classes.
  • Moved documentation from the header to a readme file.

Tested by o_lampe and myself.

* Added calibration for difference in the total range of each sensor from XieMaster's version, optimized to a single multiply.
* Added option for 60° and 120° sensor spacing.
* Added wait for first valid sensor readings in init, for some custom ADC setups.
* Changed private to protected and moved getSensorAngle there, better matching other sensor classes.
* Moved documentation from the header to a readme file.
@github-actions

Copy link
Copy Markdown

Memory usage change @ 6a4290f

Board flash % RAM for global variables %
adafruit:samd:adafruit_metro_m4 🔺 0 - +408 0.0 - +0.08 N/A N/A
rp2040:rp2040:rpipico 🔺 0 - +408 0.0 - +0.02 🔺 0 - +8 0.0 - 0.0
arduino:sam:arduino_due_x 🔺 0 - +408 0.0 - +0.08 N/A N/A
arduino:samd:nano_33_iot 🔺 0 - +408 0.0 - +0.16 🔺 0 - +8 0.0 - +0.02
esp32:esp32:esp32 🔺 +24 - +24 0.0 - 0.0 0 - 0 0.0 - 0.0
esp32:esp32:esp32s2 🔺 +24 - +444 0.0 - +0.03 🔺 0 - +8 0.0 - 0.0
STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8 🔺 0 - +416 0.0 - +0.63 🔺 0 - +8 0.0 - +0.04
STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_F411RE 🔺 0 - +400 0.0 - +0.08 🔺 0 - +8 0.0 - +0.01
Click for full report table
Board examples/drivers/drv8316/drv8316_3pwm
flash
% examples/drivers/drv8316/drv8316_3pwm
RAM for global variables
% examples/drivers/drv8316/drv8316_6pwm
flash
% examples/drivers/drv8316/drv8316_6pwm
RAM for global variables
% examples/encoders/calibrated_sensor/calibration_save
flash
% examples/encoders/calibrated_sensor/calibration_save
RAM for global variables
% examples/encoders/linearhall
flash
% examples/encoders/linearhall
RAM for global variables
% examples/encoders/mt6816/mt6816_spi
flash
% examples/encoders/mt6816/mt6816_spi
RAM for global variables
% examples/encoders/calibrated_sensor/calibrated
flash
% examples/encoders/calibrated_sensor/calibrated
RAM for global variables
%
adafruit:samd:adafruit_metro_m4 0 0.0 N/A N/A 0 0.0 N/A N/A 0 0.0 N/A N/A 408 0.08 N/A N/A 0 0.0 N/A N/A
rp2040:rp2040:rpipico 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 408 0.02 8 0.0 0 0.0 0 0.0
arduino:sam:arduino_due_x 0 0.0 N/A N/A 0 0.0 N/A N/A 0 0.0 N/A N/A 408 0.08 N/A N/A 0 0.0 N/A N/A
arduino:samd:nano_33_iot 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 408 0.16 8 0.02 0 0.0 0 0.0
esp32:esp32:esp32 24 0.0 0 0.0 24 0.0 0 0.0 24 0.0 0 0.0 24 0.0 0 0.0
esp32:esp32:esp32s2 24 0.0 0 0.0 24 0.0 0 0.0 24 0.0 0 0.0 444 0.03 8 0.0 24 0.0 0 0.0
STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 416 0.63 8 0.04
STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_F411RE 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 400 0.08 8 0.01 0 0.0 0 0.0 0 0.0 0 0.0
Click for full report CSV
Board,examples/drivers/drv8316/drv8316_3pwm<br>flash,%,examples/drivers/drv8316/drv8316_3pwm<br>RAM for global variables,%,examples/drivers/drv8316/drv8316_6pwm<br>flash,%,examples/drivers/drv8316/drv8316_6pwm<br>RAM for global variables,%,examples/encoders/calibrated_sensor/calibration_save<br>flash,%,examples/encoders/calibrated_sensor/calibration_save<br>RAM for global variables,%,examples/encoders/linearhall<br>flash,%,examples/encoders/linearhall<br>RAM for global variables,%,examples/encoders/mt6816/mt6816_spi<br>flash,%,examples/encoders/mt6816/mt6816_spi<br>RAM for global variables,%,examples/encoders/calibrated_sensor/calibrated<br>flash,%,examples/encoders/calibrated_sensor/calibrated<br>RAM for global variables,%
adafruit:samd:adafruit_metro_m4,0,0.0,N/A,N/A,0,0.0,N/A,N/A,0,0.0,N/A,N/A,408,0.08,N/A,N/A,0,0.0,N/A,N/A
rp2040:rp2040:rpipico,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,408,0.02,8,0.0,0,0.0,0,0.0
arduino:sam:arduino_due_x,0,0.0,N/A,N/A,0,0.0,N/A,N/A,0,0.0,N/A,N/A,408,0.08,N/A,N/A,0,0.0,N/A,N/A
arduino:samd:nano_33_iot,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,408,0.16,8,0.02,0,0.0,0,0.0
esp32:esp32:esp32,24,0.0,0,0.0,24,0.0,0,0.0,24,0.0,0,0.0,,,,,24,0.0,0,0.0
esp32:esp32:esp32s2,24,0.0,0,0.0,24,0.0,0,0.0,24,0.0,0,0.0,444,0.03,8,0.0,24,0.0,0,0.0
STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,416,0.63,8,0.04,,,,
STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_F411RE,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,400,0.08,8,0.01,0,0.0,0,0.0,0,0.0,0,0.0

One more tidbit of insurance for custom ADC setups to not get a bad first reading, e.g. if you have a DMA buffer full of data, change the sampling sequence, and then call this function immediately before the buffer has been overwritten with samples in the new order.
@github-actions

Copy link
Copy Markdown

Memory usage change @ eb8796f

Board flash % RAM for global variables %
adafruit:samd:adafruit_metro_m4 🔺 0 - +408 0.0 - +0.08 N/A N/A
rp2040:rp2040:rpipico 🔺 0 - +416 0.0 - +0.02 🔺 0 - +8 0.0 - 0.0
arduino:sam:arduino_due_x 🔺 0 - +416 0.0 - +0.08 N/A N/A
arduino:samd:nano_33_iot 🔺 0 - +416 0.0 - +0.16 🔺 0 - +8 0.0 - +0.02
esp32:esp32:esp32 🔺 +24 - +24 0.0 - 0.0 0 - 0 0.0 - 0.0
esp32:esp32:esp32s2 🔺 +24 - +444 0.0 - +0.03 🔺 0 - +8 0.0 - 0.0
STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8 🔺 0 - +424 0.0 - +0.65 🔺 0 - +8 0.0 - +0.04
STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_F411RE 🔺 0 - +408 0.0 - +0.08 🔺 0 - +8 0.0 - +0.01
Click for full report table
Board examples/drivers/drv8316/drv8316_3pwm
flash
% examples/drivers/drv8316/drv8316_3pwm
RAM for global variables
% examples/drivers/drv8316/drv8316_6pwm
flash
% examples/drivers/drv8316/drv8316_6pwm
RAM for global variables
% examples/encoders/calibrated_sensor/calibration_save
flash
% examples/encoders/calibrated_sensor/calibration_save
RAM for global variables
% examples/encoders/linearhall
flash
% examples/encoders/linearhall
RAM for global variables
% examples/encoders/mt6816/mt6816_spi
flash
% examples/encoders/mt6816/mt6816_spi
RAM for global variables
% examples/encoders/calibrated_sensor/calibrated
flash
% examples/encoders/calibrated_sensor/calibrated
RAM for global variables
%
adafruit:samd:adafruit_metro_m4 0 0.0 N/A N/A 0 0.0 N/A N/A 0 0.0 N/A N/A 408 0.08 N/A N/A 0 0.0 N/A N/A
rp2040:rp2040:rpipico 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 416 0.02 8 0.0 0 0.0 0 0.0
arduino:sam:arduino_due_x 0 0.0 N/A N/A 0 0.0 N/A N/A 0 0.0 N/A N/A 416 0.08 N/A N/A 0 0.0 N/A N/A
arduino:samd:nano_33_iot 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 416 0.16 8 0.02 0 0.0 0 0.0
esp32:esp32:esp32 24 0.0 0 0.0 24 0.0 0 0.0 24 0.0 0 0.0 24 0.0 0 0.0
esp32:esp32:esp32s2 24 0.0 0 0.0 24 0.0 0 0.0 24 0.0 0 0.0 444 0.03 8 0.0 24 0.0 0 0.0
STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 424 0.65 8 0.04
STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_F411RE 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 408 0.08 8 0.01 0 0.0 0 0.0 0 0.0 0 0.0
Click for full report CSV
Board,examples/drivers/drv8316/drv8316_3pwm<br>flash,%,examples/drivers/drv8316/drv8316_3pwm<br>RAM for global variables,%,examples/drivers/drv8316/drv8316_6pwm<br>flash,%,examples/drivers/drv8316/drv8316_6pwm<br>RAM for global variables,%,examples/encoders/calibrated_sensor/calibration_save<br>flash,%,examples/encoders/calibrated_sensor/calibration_save<br>RAM for global variables,%,examples/encoders/linearhall<br>flash,%,examples/encoders/linearhall<br>RAM for global variables,%,examples/encoders/mt6816/mt6816_spi<br>flash,%,examples/encoders/mt6816/mt6816_spi<br>RAM for global variables,%,examples/encoders/calibrated_sensor/calibrated<br>flash,%,examples/encoders/calibrated_sensor/calibrated<br>RAM for global variables,%
adafruit:samd:adafruit_metro_m4,0,0.0,N/A,N/A,0,0.0,N/A,N/A,0,0.0,N/A,N/A,408,0.08,N/A,N/A,0,0.0,N/A,N/A
rp2040:rp2040:rpipico,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,416,0.02,8,0.0,0,0.0,0,0.0
arduino:sam:arduino_due_x,0,0.0,N/A,N/A,0,0.0,N/A,N/A,0,0.0,N/A,N/A,416,0.08,N/A,N/A,0,0.0,N/A,N/A
arduino:samd:nano_33_iot,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,416,0.16,8,0.02,0,0.0,0,0.0
esp32:esp32:esp32,24,0.0,0,0.0,24,0.0,0,0.0,24,0.0,0,0.0,,,,,24,0.0,0,0.0
esp32:esp32:esp32s2,24,0.0,0,0.0,24,0.0,0,0.0,24,0.0,0,0.0,444,0.03,8,0.0,24,0.0,0,0.0
STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,424,0.65,8,0.04,,,,
STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_F411RE,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,408,0.08,8,0.01,0,0.0,0,0.0,0,0.0,0,0.0

@runger1101001 runger1101001 merged commit 05d51da into simplefoc:dev Jul 3, 2026
10 of 11 checks passed
@runger1101001 runger1101001 added this to the 1.1.0 milestone Jul 3, 2026
@runger1101001 runger1101001 self-assigned this Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants