Skip to content

Commit ed05aa1

Browse files
Merge pull request #60 from simplefoc/dev
Release PR for 1.0.9 release
2 parents f7a91fa + 5c5d6ee commit ed05aa1

38 files changed

+943
-352
lines changed

.github/workflows/ccpp.yml

Lines changed: 107 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -13,64 +13,116 @@ jobs:
1313
name: Test compile
1414
runs-on: ubuntu-latest
1515
strategy:
16-
matrix:
17-
arduino-boards-fqbn:
18-
- arduino:avr:nano # arudino nano
19-
- arduino:sam:arduino_due_x # arduino due
20-
- arduino:samd:nano_33_iot # samd21
21-
- adafruit:samd:adafruit_metro_m4 # samd51
22-
- esp32:esp32:esp32 # esp32
23-
- esp32:esp32:esp32s2 # esp32s2
24-
- STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8 # stm32 bluepill
25-
- STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_F411RE # stm32 nucleo
26-
- arduino:mbed_rp2040:pico # rpi pico
27-
include:
28-
- arduino-boards-fqbn: arduino:avr:nano
29-
sketches-exclude: calibrated mt6816_spi smoothing simplefocnano_torque_voltage
30-
required-libraries: Simple FOC
31-
- arduino-boards-fqbn: arduino:sam:arduino_due_x
32-
required-libraries: Simple FOC
33-
sketches-exclude: calibrated smoothing simplefocnano_torque_voltage simplefocnano_atmega
34-
- arduino-boards-fqbn: arduino:samd:nano_33_iot
35-
required-libraries: Simple FOC
36-
sketches-exclude: calibrated smoothing
37-
- arduino-boards-fqbn: arduino:mbed_rp2040:pico
38-
required-libraries: Simple FOC
39-
sketches-exclude: calibrated smoothing simplefocnano_torque_voltage simplefocnano_atmega
40-
- arduino-boards-fqbn: adafruit:samd:adafruit_metro_m4
41-
platform-url: https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
42-
required-libraries: Simple FOC
43-
sketches-exclude: calibrated smoothing simplefocnano_torque_voltage simplefocnano_atmega
44-
# - arduino-boards-fqbn: esp32:esp32:esp32doit-devkit-v1
45-
# platform-url: https://dl.espressif.com/dl/package_esp32_index.json
46-
# required-libraries: Simple FOC
47-
# sketch-names: '**.ino'
48-
- arduino-boards-fqbn: esp32:esp32:esp32 # esp32
49-
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
50-
required-libraries: Simple FOC
51-
sketches-exclude: calibrated smoothing simplefocnano_torque_voltage simplefocnano_atmega linearhall
52-
- arduino-boards-fqbn: esp32:esp32:esp32s2 # esp32s2
53-
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
54-
required-libraries: Simple FOC
55-
sketches-exclude: calibrated smoothing simplefocnano_torque_voltage simplefocnano_atmega
56-
- arduino-boards-fqbn: STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8
57-
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
58-
required-libraries: Simple FOC
59-
sketches-exclude: calibrated mt6816_spi smoothing simplefocnano_torque_voltage simplefocnano_atmega
60-
- arduino-boards-fqbn: STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_F411RE
61-
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
62-
required-libraries: Simple FOC
63-
sketches-exclude: smoothing simplefocnano_torque_voltage simplefocnano_atmega
64-
# Do not cancel all jobs / architectures if one job fails
6516
fail-fast: false
17+
matrix:
18+
board:
19+
- fqbn: arduino:avr:nano # arudino nano
20+
platforms: |
21+
- name: arduino:avr
22+
sketch-paths: |
23+
- examples/drivers/simplefocnano/simplefocnano_atmega
24+
- examples/encoders/linearhall
25+
report-name-suffix: arduino_avr_nano
26+
- fqbn: arduino:sam:arduino_due_x # arduino due
27+
platforms: |
28+
- name: arduino:sam
29+
sketch-paths: |
30+
- examples/drivers/drv8316
31+
- examples/encoders/calibrated_sensor/calibration_save
32+
- examples/encoders/linearhall
33+
- examples/encoders/mt6816
34+
report-name-suffix: arduino_sam_due
35+
- fqbn: arduino:samd:nano_33_iot # samd21
36+
platforms: |
37+
- name: arduino:samd
38+
sketch-paths: |
39+
- examples/drivers/drv8316
40+
- examples/encoders/calibrated_sensor/calibration_save
41+
- examples/encoders/linearhall
42+
- examples/encoders/mt6816
43+
report-name-suffix: arduino_samd_nano_33_iot
44+
- fqbn: adafruit:samd:adafruit_metro_m4 # samd51
45+
platforms: |
46+
- name: adafruit:samd
47+
source-url: "https://adafruit.github.io/arduino-board-index/package_adafruit_index.json"
48+
sketch-paths: |
49+
- examples/drivers/drv8316
50+
- examples/encoders/calibrated_sensor/calibration_save
51+
- examples/encoders/linearhall
52+
- examples/encoders/mt6816
53+
report-name-suffix: adafruit_samd_metro_m4
54+
- fqbn: esp32:esp32:esp32 # esp32
55+
platforms: |
56+
- name: esp32:esp32
57+
source-url: "https://espressif.github.io/arduino-esp32/package_esp32_index.json"
58+
sketch-paths: |
59+
- examples/drivers/drv8316
60+
- examples/encoders/calibrated_sensor/calibration_save
61+
- examples/encoders/mt6816
62+
report-name-suffix: esp32_esp32
63+
- fqbn: esp32:esp32:esp32s2 # esp32s2
64+
platforms: |
65+
- name: esp32:esp32
66+
source-url: "https://espressif.github.io/arduino-esp32/package_esp32_index.json"
67+
sketch-paths: |
68+
- examples/drivers/drv8316
69+
- examples/encoders/calibrated_sensor/calibration_save
70+
- examples/encoders/linearhall
71+
- examples/encoders/mt6816
72+
report-name-suffix: esp32_esp32s2
73+
- fqbn: STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8 # stm32 bluepill
74+
platforms: |
75+
- name: STMicroelectronics:stm32
76+
source-url: "https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json"
77+
sketch-paths: |
78+
- examples/drivers/drv8316
79+
- examples/encoders/calibrated_sensor/calibration_save
80+
- examples/encoders/linearhall
81+
report-name-suffix: stm32_genf1_bluepill_f103c8
82+
- fqbn: STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_F411RE # stm32 nucleo
83+
platforms: |
84+
- name: STMicroelectronics:stm32
85+
source-url: "https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json"
86+
sketch-paths: |
87+
- examples/drivers/drv8316
88+
- examples/encoders/calibrated_sensor
89+
- examples/encoders/linearhall
90+
- examples/encoders/mt6816
91+
report-name-suffix: stm32_nucleo_f411re
92+
- fqbn: rp2040:rp2040:rpipico # rpi pico
93+
platforms: |
94+
- name: rp2040:rp2040
95+
source-url: "https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json"
96+
sketch-paths: |
97+
- examples/drivers/drv8316
98+
- examples/encoders/calibrated_sensor/calibration_save
99+
- examples/encoders/linearhall
100+
- examples/encoders/mt6816
101+
report-name-suffix: arduino_mbed_rp2040_pico
66102
steps:
67103
- name: Checkout
68104
uses: actions/checkout@master
69105
- name: Compile all examples
70-
uses: ArminJo/arduino-test-compile@master
106+
uses: arduino/compile-sketches@v1
107+
with:
108+
fqbn: ${{ matrix.board.fqbn }}
109+
platforms: ${{ matrix.board.platforms }}
110+
libraries: |
111+
- name: "Arduino-FOC"
112+
source-url: "https://github.com/simplefoc/Arduino-FOC.git"
113+
version: dev
114+
- name: "Arduino-FOC-Drivers"
115+
source-path: .
116+
sketch-paths: ${{ matrix.board.sketch-paths || 'examples' }}
117+
enable-deltas-report: true
118+
sketches-report-path: sketches-reports
119+
- name: Upload sketches reports
120+
uses: actions/upload-artifact@v4
71121
with:
72-
arduino-board-fqbn: ${{ matrix.arduino-boards-fqbn }}
73-
required-libraries: ${{ matrix.required-libraries }}
74-
platform-url: ${{ matrix.platform-url }}
75-
sketch-names: ${{ matrix.sketch-names }}
76-
sketches-exclude: ${{ matrix.sketches-exclude }}
122+
name: sketches-report-${{ matrix.board.report-name-suffix }}
123+
path: sketches-reports
124+
report:
125+
runs-on: ubuntu-latest
126+
steps:
127+
- name: Report size deltas
128+
uses: arduino/report-size-deltas@v1
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Report Size Deltas
2+
on:
3+
schedule:
4+
- cron: "*/5 * * * *"
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: arduino/report-size-deltas@v1
10+
with:
11+
sketches-reports-source: ^sketches-report-.+

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@ The intent is to keep the core of SimpleFOC clean, and thus easy to maintain, un
1010

1111
## New Release
1212

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

1515

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

2127

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

117123
## Release History
118124

125+
What's changed since 1.0.7?
126+
- MA735 driver thanks to [@techyrobot](https://github.com/techy-robot)
127+
- ESP32HWEncoder driver thanks to [@mcells](https://github.com/mcells)
128+
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=milestone%3A1.0.8)
129+
119130
What's changed since 1.0.6?
120131
- Improvements to LinearHall driver, thanks to dekutree
121132
- Fix for ESP32 compiler warning, thanks to Yannik Stradmann
@@ -126,14 +137,14 @@ What's changed since 1.0.6?
126137
- Refactored settings storage code
127138
- Refactored I2CCommander
128139
- New utility class for simple trapezoidal motion profiles
129-
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=milestone%3A1.0.7+)
140+
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=milestone%3A1.0.7)
130141

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

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

148159
What's changed since 1.0.3?
149160
- New Comms/Input: STM32SpeedDirCommander

examples/encoders/calibrated/calibrated.ino renamed to examples/encoders/calibrated_sensor/calibrated/calibrated.ino

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
/**
2-
* Torque control example using voltage control loop.
3-
*
4-
* Most of the low-end BLDC driver boards doesn't have current measurement therefore SimpleFOC offers
5-
* you a way to control motor torque by setting the voltage to the motor instead hte current.
6-
*
7-
* This makes the BLDC motor effectively a DC motor, and you can use it in a same way.
2+
* The example demonstrates the usage of the calibrated sensor object.
83
*/
94
#include <SimpleFOC.h>
105
#include <SimpleFOCDrivers.h>
@@ -16,6 +11,8 @@ MagneticSensorSPI sensor = MagneticSensorSPI(AS5048_SPI, PB6);
1611
BLDCMotor motor = BLDCMotor(11);
1712
BLDCDriver3PWM driver = BLDCDriver3PWM(PB4,PC7,PB10,PA9);
1813
// instantiate the calibrated sensor object
14+
// argument 1 - sensor object
15+
// argument 2 - number of samples in the LUT (default 200)
1916
CalibratedSensor sensor_calibrated = CalibratedSensor(sensor);
2017

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

6361
//Serial.println("Calibrating Sensor Done.");
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/**
2+
* The example demonstrates the calibration of the magnetic sensor with the calibration procedure and saving the calibration data.
3+
* So that the calibration procedure does not have to be run every time the motor is powered up.
4+
*
5+
* 1. Run this Sketch as is and wait for the calibration data to be generated and printed over Serial.
6+
* 2. Then copy the output from Serial to calibrationLut, zero_electric_angle and sensor_direction
7+
* 3. Change values_provided to true and run the Sketch again to see the motor skipping the calibration.
8+
*/
9+
10+
#include <SimpleFOC.h>
11+
#include <SimpleFOCDrivers.h>
12+
#include "encoders/calibrated/CalibratedSensor.h"
13+
14+
// fill this array with the calibration values outputed by the calibration procedure
15+
float calibrationLut[50] = {0};
16+
float zero_electric_angle = 0;
17+
Direction sensor_direction = Direction::UNKNOWN;
18+
19+
const bool values_provided = false;
20+
21+
// magnetic sensor instance - SPI
22+
MagneticSensorSPI sensor = MagneticSensorSPI(AS5147_SPI, 14);
23+
// Stepper motor & driver instance
24+
StepperMotor motor = StepperMotor(50);
25+
StepperDriver4PWM driver = StepperDriver4PWM(10, 9, 5, 6,8);
26+
// instantiate the calibrated sensor object
27+
// instantiate the calibrated sensor object
28+
// argument 1 - sensor object
29+
// argument 2 - number of samples in the LUT (default 200)
30+
// argument 3 - pointer to the LUT array (defualt nullptr)
31+
CalibratedSensor sensor_calibrated = CalibratedSensor(
32+
sensor, sizeof(calibrationLut) / sizeof(calibrationLut[0]));
33+
34+
// voltage set point variable
35+
float target_voltage = 2;
36+
37+
// instantiate the commander
38+
Commander command = Commander(Serial);
39+
40+
void doTarget(char* cmd) { command.scalar(&target_voltage, cmd); }
41+
42+
void setup() {
43+
44+
sensor.init();
45+
// Link motor to sensor
46+
motor.linkSensor(&sensor);
47+
// power supply voltage
48+
driver.voltage_power_supply = 20;
49+
driver.init();
50+
motor.linkDriver(&driver);
51+
// aligning voltage
52+
motor.voltage_sensor_align = 8;
53+
motor.voltage_limit = 20;
54+
// set motion control loop to be used
55+
motor.controller = MotionControlType::torque;
56+
57+
// use monitoring with serial
58+
Serial.begin(115200);
59+
// comment out if not needed
60+
motor.useMonitoring(Serial);
61+
motor.monitor_variables = _MON_VEL;
62+
motor.monitor_downsample = 10; // default 10
63+
64+
// initialize motor
65+
motor.init();
66+
67+
if(values_provided) {
68+
motor.zero_electric_angle = zero_electric_angle;
69+
motor.sensor_direction = sensor_direction;
70+
} else {
71+
// Running calibration
72+
sensor_calibrated.calibrate(motor);
73+
}
74+
75+
// Linking sensor to motor object
76+
motor.linkSensor(&sensor_calibrated);
77+
78+
// calibrated init FOC
79+
motor.initFOC();
80+
81+
// add target command T
82+
command.add('T', doTarget, "target voltage");
83+
84+
Serial.println(F("Motor ready."));
85+
86+
Serial.println(F("Set the target voltage using serial terminal:"));
87+
_delay(1000);
88+
}
89+
90+
void loop() {
91+
92+
motor.loopFOC();
93+
motor.move(target_voltage);
94+
command.run();
95+
motor.monitor();
96+
97+
}

examples/encoders/smoothing/smoothing.ino

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/**
22
*
3-
* Hall sensor velocity motion control example, modified to demonstrate usage of SmoothingSensor
3+
* Hall sensor velocity motion control example, modified to demonstrate usage of SmoothingSensor.
4+
* The only changes are the declaration of the SmoothingSensor, passing it to motor.linkSensor
5+
* instead of the HallSensor instance, and the added Commander code to switch between the two.
6+
*
47
* Steps:
58
* 1) Configure the motor and sensor
69
* 2) Run the code
@@ -63,8 +66,6 @@ void setup() {
6366
sensor.enableInterrupts(doA, doB); //, doC);
6467
// software interrupts
6568
PciManager.registerListener(&listenerIndex);
66-
// set SmoothingSensor phase correction for hall sensors
67-
smooth.phase_correction = -_PI_6;
6869
// link the SmoothingSensor to the motor
6970
motor.linkSensor(&smooth);
7071

0 commit comments

Comments
 (0)