Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
389285f
Initial commit
Candas1 Oct 17, 2023
a881a7c
Fix from charizardrekt
Candas1 Oct 18, 2023
a87a722
Fix
Candas1 Oct 18, 2023
e5013e5
Fix
Candas1 Oct 19, 2023
f58725c
Update
Candas1 Oct 21, 2023
eb77697
Use Ualpha and Ubeta
Candas1 Oct 21, 2023
c3feef0
Bemf Threshold
Candas1 Oct 23, 2023
25e7db7
Regular atan2
Candas1 Oct 23, 2023
1a27345
Fix for Clarke transform and faster atan2
Candas1 Nov 12, 2023
bb0ed89
Remove sqrt2 for kv and use getABcurrents function
Candas1 Dec 2, 2023
2079b91
Fix bemf threshold
Candas1 Jan 23, 2024
202ba0c
Update FluxObserverSensor.h
Candas1 Jun 7, 2024
b984271
Update README.md
Candas1 Jun 7, 2024
df7209e
Rename the sensor
Candas1 Jul 1, 2024
031a4dd
Update readme
Candas1 Jul 1, 2024
4f42deb
Update MXLEMMINGObserverSensor.cpp
Candas1 Jul 16, 2024
946df15
Update README.md
Candas1 Jul 17, 2024
9045e6c
Update MXLEMMINGObserverSensor.cpp
Candas1 Jul 17, 2024
0010b2c
Cleanup
Candas1 Jul 20, 2024
da830c2
Merge pull request #1 from Candas1/dev
Candas1 Jul 21, 2024
6226e81
Merge pull request #2 from Candas1/dev
Candas1 Jul 21, 2024
4a091f0
Clean up
Candas1 Jul 27, 2024
5065c84
Merge pull request #48 from Candas1/flux_observer
runger1101001 Jul 31, 2024
778f92b
Update AS5600.cpp
zbas Aug 7, 2024
4a722f7
Merge pull request #49 from zbas/patch-1
runger1101001 Aug 12, 2024
5274eef
prepare for next release (1.0.9)
runger1101001 Aug 12, 2024
5ed156f
AS5600 with fast mode
runger1101001 Aug 24, 2024
6eed46c
fix compile error on some cores which don't define multi-byte reads
runger1101001 Nov 16, 2024
bcf9f21
add support for Nano Matter
runger1101001 Nov 16, 2024
67ef2af
change c file to cpp, required for compilation on some cores
runger1101001 Nov 16, 2024
3211304
add support for Arduino Nano Matter
runger1101001 Nov 16, 2024
7399601
remove multi-byte read, not supported on some platforms
runger1101001 Nov 16, 2024
359f220
remove c file
runger1101001 Nov 16, 2024
67f9e12
Type casting bug in STM32HWEncoder fixed
AntonEvmenenko Dec 16, 2024
8818ad9
Improvements to SmoothingSensor and LinearHall
dekutree64 Jan 10, 2025
6d96569
Merge pull request #53 from dekutree64/dev
runger1101001 Jan 10, 2025
189a54c
wip
askuric Mar 10, 2025
f185099
a good state of the calibraiton code
askuric Mar 11, 2025
cec679d
a bit more info about the saving and loading of the LUT
askuric Mar 11, 2025
bec6406
resize the example
askuric Mar 11, 2025
ab90dba
some init issues
askuric Mar 11, 2025
cab7af5
calibration update
askuric Mar 12, 2025
e174615
memory issues
askuric Mar 12, 2025
98edcc5
due variable size issue
askuric Mar 12, 2025
01cde01
added info to README + removed prints
askuric Mar 12, 2025
b4a3262
typon in the readme
askuric Mar 12, 2025
6eba4b0
rename hybridstepper to old
askuric Mar 12, 2025
59fc94e
Merge pull request #54 from simplefoc/feat_stepper_calib
runger1101001 Mar 12, 2025
05f458e
Merge pull request #55 from simplefoc/feat_hybridstepper_to_main
runger1101001 Mar 12, 2025
0cf2fde
Merge remote-tracking branch 'origin/dev' into feat_hybridstepper_to_…
askuric Apr 3, 2025
e96c5b8
CalibratedSensor: settle time as parameter
schnili May 15, 2025
08b36cc
Merge remote-tracking branch 'origin/dev' into feat_pwm_input_update
askuric May 27, 2025
22be810
update of the PWM sensor
askuric May 27, 2025
e0e1db1
Merge pull request #57 from simplefoc/feat_pwm_input_update
runger1101001 May 28, 2025
0ba0840
Merge pull request #56 from Schnilz/dev
runger1101001 May 28, 2025
58e82d4
Merge pull request #52 from AntonEvmenenko/dev
runger1101001 May 28, 2025
5dc0563
CalibratedSensor: allow saving of lut at runtime
schnili Jun 16, 2025
c7ba2f5
merge index handling code
runger1101001 Jul 16, 2025
0323dbb
[BUG] ESP32 crash when using multiple ESP32HWEncoder(s) #59
runger1101001 Jul 16, 2025
9b47aa9
Merge remote-tracking branch 'origin/dev' into dev
runger1101001 Jul 16, 2025
f1c1d0f
Merge pull request #58 from Schnilz/dev
runger1101001 Jul 16, 2025
0a50329
change to use arduino/compile-sketches in github action
runger1101001 Jul 27, 2025
e5e446c
correct syntax of github action
runger1101001 Jul 27, 2025
4102103
fix typo in github action
runger1101001 Jul 27, 2025
341ca43
add the local path for our own library...
runger1101001 Jul 27, 2025
6447540
restrict the sketches compiled for each arch
runger1101001 Jul 27, 2025
46bd320
pico fqbn update
runger1101001 Jul 27, 2025
3c0d922
restrict sketches compiled for atmega
runger1101001 Jul 27, 2025
29aa12c
fix pico fqbn
runger1101001 Jul 27, 2025
8823712
fix stm32f1 fqbn
runger1101001 Jul 27, 2025
518d3c5
fix avr and sam sketches compiled
runger1101001 Jul 27, 2025
8e6db74
fix pico fqbn
runger1101001 Jul 27, 2025
649ca63
fix sketches compiled for avr
runger1101001 Jul 27, 2025
f0061de
remove smoothing sketch from sam compile
runger1101001 Jul 27, 2025
7f5decc
remove non-compiling sketches from tests
runger1101001 Jul 27, 2025
f19b55d
report size deltas on PRs
runger1101001 Jul 27, 2025
e6e5c37
add a name to workflow report size deltas
runger1101001 Jul 27, 2025
5c5d6ee
update README before release
runger1101001 Jul 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 107 additions & 55 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,64 +13,116 @@ jobs:
name: Test compile
runs-on: ubuntu-latest
strategy:
matrix:
arduino-boards-fqbn:
- arduino:avr:nano # arudino nano
- arduino:sam:arduino_due_x # arduino due
- arduino:samd:nano_33_iot # samd21
- adafruit:samd:adafruit_metro_m4 # samd51
- esp32:esp32:esp32 # esp32
- esp32:esp32:esp32s2 # esp32s2
- STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8 # stm32 bluepill
- STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_F411RE # stm32 nucleo
- arduino:mbed_rp2040:pico # rpi pico
include:
- arduino-boards-fqbn: arduino:avr:nano
sketches-exclude: calibrated mt6816_spi smoothing simplefocnano_torque_voltage
required-libraries: Simple FOC
- arduino-boards-fqbn: arduino:sam:arduino_due_x
required-libraries: Simple FOC
sketches-exclude: calibrated smoothing simplefocnano_torque_voltage simplefocnano_atmega
- arduino-boards-fqbn: arduino:samd:nano_33_iot
required-libraries: Simple FOC
sketches-exclude: calibrated smoothing
- arduino-boards-fqbn: arduino:mbed_rp2040:pico
required-libraries: Simple FOC
sketches-exclude: calibrated smoothing simplefocnano_torque_voltage simplefocnano_atmega
- arduino-boards-fqbn: adafruit:samd:adafruit_metro_m4
platform-url: https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
required-libraries: Simple FOC
sketches-exclude: calibrated smoothing simplefocnano_torque_voltage simplefocnano_atmega
# - arduino-boards-fqbn: esp32:esp32:esp32doit-devkit-v1
# platform-url: https://dl.espressif.com/dl/package_esp32_index.json
# required-libraries: Simple FOC
# sketch-names: '**.ino'
- arduino-boards-fqbn: esp32:esp32:esp32 # esp32
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
required-libraries: Simple FOC
sketches-exclude: calibrated smoothing simplefocnano_torque_voltage simplefocnano_atmega linearhall
- arduino-boards-fqbn: esp32:esp32:esp32s2 # esp32s2
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
required-libraries: Simple FOC
sketches-exclude: calibrated smoothing simplefocnano_torque_voltage simplefocnano_atmega
- arduino-boards-fqbn: STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
required-libraries: Simple FOC
sketches-exclude: calibrated mt6816_spi smoothing simplefocnano_torque_voltage simplefocnano_atmega
- arduino-boards-fqbn: STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_F411RE
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
required-libraries: Simple FOC
sketches-exclude: smoothing simplefocnano_torque_voltage simplefocnano_atmega
# Do not cancel all jobs / architectures if one job fails
fail-fast: false
matrix:
board:
- fqbn: arduino:avr:nano # arudino nano
platforms: |
- name: arduino:avr
sketch-paths: |
- examples/drivers/simplefocnano/simplefocnano_atmega
- examples/encoders/linearhall
report-name-suffix: arduino_avr_nano
- fqbn: arduino:sam:arduino_due_x # arduino due
platforms: |
- name: arduino:sam
sketch-paths: |
- examples/drivers/drv8316
- examples/encoders/calibrated_sensor/calibration_save
- examples/encoders/linearhall
- examples/encoders/mt6816
report-name-suffix: arduino_sam_due
- fqbn: arduino:samd:nano_33_iot # samd21
platforms: |
- name: arduino:samd
sketch-paths: |
- examples/drivers/drv8316
- examples/encoders/calibrated_sensor/calibration_save
- examples/encoders/linearhall
- examples/encoders/mt6816
report-name-suffix: arduino_samd_nano_33_iot
- fqbn: adafruit:samd:adafruit_metro_m4 # samd51
platforms: |
- name: adafruit:samd
source-url: "https://adafruit.github.io/arduino-board-index/package_adafruit_index.json"
sketch-paths: |
- examples/drivers/drv8316
- examples/encoders/calibrated_sensor/calibration_save
- examples/encoders/linearhall
- examples/encoders/mt6816
report-name-suffix: adafruit_samd_metro_m4
- fqbn: esp32:esp32:esp32 # esp32
platforms: |
- name: esp32:esp32
source-url: "https://espressif.github.io/arduino-esp32/package_esp32_index.json"
sketch-paths: |
- examples/drivers/drv8316
- examples/encoders/calibrated_sensor/calibration_save
- examples/encoders/mt6816
report-name-suffix: esp32_esp32
- fqbn: esp32:esp32:esp32s2 # esp32s2
platforms: |
- name: esp32:esp32
source-url: "https://espressif.github.io/arduino-esp32/package_esp32_index.json"
sketch-paths: |
- examples/drivers/drv8316
- examples/encoders/calibrated_sensor/calibration_save
- examples/encoders/linearhall
- examples/encoders/mt6816
report-name-suffix: esp32_esp32s2
- fqbn: STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8 # stm32 bluepill
platforms: |
- name: STMicroelectronics:stm32
source-url: "https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json"
sketch-paths: |
- examples/drivers/drv8316
- examples/encoders/calibrated_sensor/calibration_save
- examples/encoders/linearhall
report-name-suffix: stm32_genf1_bluepill_f103c8
- fqbn: STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_F411RE # stm32 nucleo
platforms: |
- name: STMicroelectronics:stm32
source-url: "https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json"
sketch-paths: |
- examples/drivers/drv8316
- examples/encoders/calibrated_sensor
- examples/encoders/linearhall
- examples/encoders/mt6816
report-name-suffix: stm32_nucleo_f411re
- fqbn: rp2040:rp2040:rpipico # rpi pico
platforms: |
- name: rp2040:rp2040
source-url: "https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json"
sketch-paths: |
- examples/drivers/drv8316
- examples/encoders/calibrated_sensor/calibration_save
- examples/encoders/linearhall
- examples/encoders/mt6816
report-name-suffix: arduino_mbed_rp2040_pico
steps:
- name: Checkout
uses: actions/checkout@master
- name: Compile all examples
uses: ArminJo/arduino-test-compile@master
uses: arduino/compile-sketches@v1
with:
fqbn: ${{ matrix.board.fqbn }}
platforms: ${{ matrix.board.platforms }}
libraries: |
- name: "Arduino-FOC"
source-url: "https://github.com/simplefoc/Arduino-FOC.git"
version: dev
- name: "Arduino-FOC-Drivers"
source-path: .
sketch-paths: ${{ matrix.board.sketch-paths || 'examples' }}
enable-deltas-report: true
sketches-report-path: sketches-reports
- name: Upload sketches reports
uses: actions/upload-artifact@v4
with:
arduino-board-fqbn: ${{ matrix.arduino-boards-fqbn }}
required-libraries: ${{ matrix.required-libraries }}
platform-url: ${{ matrix.platform-url }}
sketch-names: ${{ matrix.sketch-names }}
sketches-exclude: ${{ matrix.sketches-exclude }}
name: sketches-report-${{ matrix.board.report-name-suffix }}
path: sketches-reports
report:
runs-on: ubuntu-latest
steps:
- name: Report size deltas
uses: arduino/report-size-deltas@v1
11 changes: 11 additions & 0 deletions .github/workflows/report-size-deltas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Report Size Deltas
on:
schedule:
- cron: "*/5 * * * *"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: arduino/report-size-deltas@v1
with:
sketches-reports-source: ^sketches-report-.+
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ The intent is to keep the core of SimpleFOC clean, and thus easy to maintain, un

## New Release

v1.0.8 - Released July 2024, for Simple FOC 2.3.4 or later
v1.0.9 - Released July 2025, for Simple FOC 2.3.5 or later


What's changed since 1.0.7?
- MA735 driver thanks to [@techyrobot](https://github.com/techy-robot)
- ESP32HWEncoder driver thanks to [@mcells](https://github.com/mcells)
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=milestone%3A1.0.8+)
What's changed since 1.0.8?
- FluxObserverSensor for sensorless FOC thanks to [@Candas1](https://github.com/Candas1)
- AS5600 fast mode support
- Improvements to SmoothingSensor and LinearHall thanks to [@dekutree64](https://github.com/dekutree64)
- Improvements to CalibratedSensor and HybridStepper thanks to [@askuric](https://github.com/askuric)
- AS5600 driver bugfix thanks to [@zbas](https://github.com/zbas)
- Calibrated sensor improvements thanks to [@Schnilz](https://github.com/Schnilz)
- ESP32HWEncoder bugfix thanks to [@AndBindStyle](https://github.com/AndBondStyle)
- STM32HWEncoder fix thanks to [@AntonEvmenenko](https://github.com/AntonEvmenenko)
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=milestone%3A1.0.9)


## What is included
Expand Down Expand Up @@ -116,6 +122,11 @@ Find out more information about the Arduino SimpleFOC project on the [docs websi

## Release History

What's changed since 1.0.7?
- MA735 driver thanks to [@techyrobot](https://github.com/techy-robot)
- ESP32HWEncoder driver thanks to [@mcells](https://github.com/mcells)
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=milestone%3A1.0.8)

What's changed since 1.0.6?
- Improvements to LinearHall driver, thanks to dekutree
- Fix for ESP32 compiler warning, thanks to Yannik Stradmann
Expand All @@ -126,14 +137,14 @@ What's changed since 1.0.6?
- Refactored settings storage code
- Refactored I2CCommander
- New utility class for simple trapezoidal motion profiles
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=milestone%3A1.0.7+)
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=milestone%3A1.0.7)

What's changed since 1.0.5?
- Added STSPIN32G4 driver
- Added STM32G4 CORDIC code, for greatly accellerated trig functions on supported MCUs
- Added STM32FlashSettingsStorage driver, supporting STM32G4 MCUs
- Improvements in the MT6835 sensor driver
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=is%3Aissue+milestone%3A1.0.6+)
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=is%3Aissue+milestone%3A1.0.6)

What's changed since 1.0.4?
- Added smoothing sensor by [@dekutree64](https://github.com/dekutree64)
Expand All @@ -143,7 +154,7 @@ What's changed since 1.0.4?
- New Settings driver: SAMDNVMSettingsStorage
- SimpleFOCRegisters abstraction, mapping SimpleFOC parameters to virtual "Registers"
- Updated I2CCommander to use the new registers abstraction
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=is%3Aissue+milestone%3A1.0.5+)
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=is%3Aissue+milestone%3A1.0.5)

What's changed since 1.0.3?
- New Comms/Input: STM32SpeedDirCommander
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
/**
* Torque control example using voltage control loop.
*
* Most of the low-end BLDC driver boards doesn't have current measurement therefore SimpleFOC offers
* you a way to control motor torque by setting the voltage to the motor instead hte current.
*
* This makes the BLDC motor effectively a DC motor, and you can use it in a same way.
* The example demonstrates the usage of the calibrated sensor object.
*/
#include <SimpleFOC.h>
#include <SimpleFOCDrivers.h>
Expand All @@ -16,6 +11,8 @@ MagneticSensorSPI sensor = MagneticSensorSPI(AS5048_SPI, PB6);
BLDCMotor motor = BLDCMotor(11);
BLDCDriver3PWM driver = BLDCDriver3PWM(PB4,PC7,PB10,PA9);
// instantiate the calibrated sensor object
// argument 1 - sensor object
// argument 2 - number of samples in the LUT (default 200)
CalibratedSensor sensor_calibrated = CalibratedSensor(sensor);

// voltage set point variable
Expand Down Expand Up @@ -58,6 +55,7 @@ void setup() {
// set voltage to run calibration
sensor_calibrated.voltage_calibration = 6;
// Running calibration
// it will ouptut the LUT and the zero electrical angle to the serial monitor !!!!
sensor_calibrated.calibrate(motor);

//Serial.println("Calibrating Sensor Done.");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/**
* The example demonstrates the calibration of the magnetic sensor with the calibration procedure and saving the calibration data.
* So that the calibration procedure does not have to be run every time the motor is powered up.
*
* 1. Run this Sketch as is and wait for the calibration data to be generated and printed over Serial.
* 2. Then copy the output from Serial to calibrationLut, zero_electric_angle and sensor_direction
* 3. Change values_provided to true and run the Sketch again to see the motor skipping the calibration.
*/

#include <SimpleFOC.h>
#include <SimpleFOCDrivers.h>
#include "encoders/calibrated/CalibratedSensor.h"

// fill this array with the calibration values outputed by the calibration procedure
float calibrationLut[50] = {0};
float zero_electric_angle = 0;
Direction sensor_direction = Direction::UNKNOWN;

const bool values_provided = false;

// magnetic sensor instance - SPI
MagneticSensorSPI sensor = MagneticSensorSPI(AS5147_SPI, 14);
// Stepper motor & driver instance
StepperMotor motor = StepperMotor(50);
StepperDriver4PWM driver = StepperDriver4PWM(10, 9, 5, 6,8);
// instantiate the calibrated sensor object
// instantiate the calibrated sensor object
// argument 1 - sensor object
// argument 2 - number of samples in the LUT (default 200)
// argument 3 - pointer to the LUT array (defualt nullptr)
CalibratedSensor sensor_calibrated = CalibratedSensor(
sensor, sizeof(calibrationLut) / sizeof(calibrationLut[0]));

// voltage set point variable
float target_voltage = 2;

// instantiate the commander
Commander command = Commander(Serial);

void doTarget(char* cmd) { command.scalar(&target_voltage, cmd); }

void setup() {

sensor.init();
// Link motor to sensor
motor.linkSensor(&sensor);
// power supply voltage
driver.voltage_power_supply = 20;
driver.init();
motor.linkDriver(&driver);
// aligning voltage
motor.voltage_sensor_align = 8;
motor.voltage_limit = 20;
// set motion control loop to be used
motor.controller = MotionControlType::torque;

// use monitoring with serial
Serial.begin(115200);
// comment out if not needed
motor.useMonitoring(Serial);
motor.monitor_variables = _MON_VEL;
motor.monitor_downsample = 10; // default 10

// initialize motor
motor.init();

if(values_provided) {
motor.zero_electric_angle = zero_electric_angle;
motor.sensor_direction = sensor_direction;
} else {
// Running calibration
sensor_calibrated.calibrate(motor);
}

// Linking sensor to motor object
motor.linkSensor(&sensor_calibrated);

// calibrated init FOC
motor.initFOC();

// add target command T
command.add('T', doTarget, "target voltage");

Serial.println(F("Motor ready."));

Serial.println(F("Set the target voltage using serial terminal:"));
_delay(1000);
}

void loop() {

motor.loopFOC();
motor.move(target_voltage);
command.run();
motor.monitor();

}
7 changes: 4 additions & 3 deletions examples/encoders/smoothing/smoothing.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/**
*
* Hall sensor velocity motion control example, modified to demonstrate usage of SmoothingSensor
* Hall sensor velocity motion control example, modified to demonstrate usage of SmoothingSensor.
* The only changes are the declaration of the SmoothingSensor, passing it to motor.linkSensor
* instead of the HallSensor instance, and the added Commander code to switch between the two.
*
* Steps:
* 1) Configure the motor and sensor
* 2) Run the code
Expand Down Expand Up @@ -63,8 +66,6 @@ void setup() {
sensor.enableInterrupts(doA, doB); //, doC);
// software interrupts
PciManager.registerListener(&listenerIndex);
// set SmoothingSensor phase correction for hall sensors
smooth.phase_correction = -_PI_6;
// link the SmoothingSensor to the motor
motor.linkSensor(&smooth);

Expand Down
Loading
Loading