Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
cdfcfc7
prepare for 1.1.0 release
runger1101001 Jul 28, 2025
e7273af
add a driver for kth78xx magnetic sensors
runger1101001 Oct 21, 2025
6cd7180
add a driver for MT6826S magnetic sensors
runger1101001 Oct 21, 2025
01e1801
add a driver for the DRV8376
runger1101001 Oct 21, 2025
b2e891e
update main README
runger1101001 Oct 21, 2025
94c4661
add initial README for DRV8376
runger1101001 Oct 21, 2025
d2b2b44
work on MT6826S
runger1101001 Oct 21, 2025
066b7ef
fix documentation error
runger1101001 Oct 21, 2025
3c0f19e
fix angle reading
runger1101001 Oct 21, 2025
ae40a7a
fix compile problem
runger1101001 Oct 21, 2025
7f2f5f5
add automatic hall sector detection sensor
Moddingear Nov 4, 2025
80626af
Merge pull request #67 from Moddingear/hall_auto_sector
runger1101001 Nov 4, 2025
ef73a14
inita can implementation
askuric Nov 21, 2025
9966a77
can example
askuric Nov 21, 2025
550339f
NC in example
askuric Nov 21, 2025
011c612
Merge remote-tracking branch 'origin/dev' into feat_can_commander
askuric Nov 24, 2025
572f2ec
allow for custom regs
askuric Nov 24, 2025
f0b9b78
filter mask for extended can stm32
askuric Nov 24, 2025
28242ce
stspin32g4: Add bootstrap capacitor charge mode on enable to avoid hi…
Moddingear Nov 29, 2025
a8a3d20
esp32: fix compilation on models without a pcnt peripheral
Moddingear Nov 29, 2025
7fa6670
update info
askuric Dec 1, 2025
d1928ab
more info about registers
askuric Dec 1, 2025
78e168f
Merge pull request #71 from Moddingear/esp32_no_pcnt
runger1101001 Dec 3, 2025
12c0a10
fix kth7812 logic bug
runger1101001 Dec 4, 2025
fce9c0c
add the new nano r4
runger1101001 Dec 4, 2025
42a439c
correct errors in README for SimpleFOCNanoDriver
runger1101001 Dec 4, 2025
da2c875
Merge remote-tracking branch 'origin/dev' into dev
runger1101001 Dec 4, 2025
7323f6c
readme for calibrated sensor updated
askuric Dec 4, 2025
f05d618
skip calibartion if lut provided
askuric Dec 4, 2025
bae5423
u16 lut
askuric Dec 5, 2025
49f027c
update the readme and comments
askuric Dec 5, 2025
b449248
update the examples
askuric Dec 5, 2025
890aa53
Merge remote-tracking branch 'origin/dev' into dev
runger1101001 Dec 28, 2025
2a89d63
Add drv8323 and drv8320 drivers (untested)
Moddingear Dec 29, 2025
854e5dc
drv832x: improve dev messages
Moddingear Jan 29, 2026
0affd7c
Merge pull request #77 from Moddingear/drv832x
runger1101001 Jan 29, 2026
e9237cf
updates to SimpleFOCNano driver
runger1101001 Feb 2, 2026
7355804
Merge remote-tracking branch 'origin/dev' into dev
runger1101001 Feb 2, 2026
2bf3ce0
add link and changenote for new driver
runger1101001 Feb 2, 2026
890740a
Implement encoder count setting functions and getter for handler
Santynolo Feb 8, 2026
f78262e
merge with dev
askuric Feb 25, 2026
982f51d
an error in the resolution
askuric Feb 25, 2026
e62f3e4
Merge pull request #75 from simplefoc/bug_calibrated_sensor
runger1101001 Feb 25, 2026
16935bd
Merge pull request #82 from simplefoc/feat_can_commander
runger1101001 Feb 26, 2026
9cf7fcb
CalibratedSensor: Allow calibration with provided lut
schnili Mar 11, 2026
630cd84
drv832x: add clock setting, remove current limit
Moddingear Mar 22, 2026
d06264b
drv832x: add current sense calibration routine
Moddingear Mar 22, 2026
551dab4
Improve SPI reading of mt6816.
samguns Mar 31, 2026
17d5738
Merge pull request #85 from Moddingear/drv832x
runger1101001 Apr 14, 2026
57f39f3
Merge pull request #81 from Santynolo/dev
runger1101001 Apr 14, 2026
a47a7f5
Merge pull request #83 from schnili/dev
runger1101001 Apr 14, 2026
c3b7306
Merge pull request #86 from samguns/dev
runger1101001 Apr 14, 2026
ef7fc75
Merge pull request #72 from Moddingear/stspin32_startup
runger1101001 Apr 14, 2026
4542024
dont detach the interrupt
askuric Apr 22, 2026
29781d7
Make CANCommander compile only when SimpleCANio.h exists
Moddingear Apr 22, 2026
9f8c767
Check for C++17 before __has_include for SimpleCANio
Moddingear Apr 22, 2026
455cd1e
Merge pull request #88 from Moddingear/optional_SimpleCANio
runger1101001 Apr 22, 2026
1d7c972
Add Phoque and Phoque2a current sense
Moddingear May 21, 2026
54ba124
Merge pull request #90 from Moddingear/Phoque2_CurrentSense
runger1101001 May 22, 2026
6a4290f
Improvements to LinearHall
dekutree64 Jun 17, 2026
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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Richard Unger
Copyright (c) 2025 Richard Unger

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
34 changes: 20 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,15 @@ The intent is to keep the core of SimpleFOC clean, and thus easy to maintain, un

## New Release

v1.0.9 - Released July 2025, for Simple FOC 2.3.5 or later
v1.1.0 - Released xxx 2026, for Simple FOC 2.3.x or later


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's changed since 1.0.9?
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=milestone%3A1.1.0)
- new SPI driver for MT6826S magnetic sensors
- new SPI driver for KTH78xx magnetic sensors
- new SPI driver for the DRV8376 integrated BLDC driver from TI
- new SPI driver for the DRV8320 / DRV8323 thanks to [@Moddingear](https://github.com/Moddingear)

## What is included

Expand All @@ -35,7 +30,10 @@ Software to control gate driver ICs or integrated driver ICs which have advanced

- [TMC6200 driver](src/drivers/tmc6200/) - SPI driver for Trinamics TMC6200 motor driver IC.
- [DRV8316 driver](src/drivers/drv8316/) - SPI driver for TI's DRV8316 motor driver IC.
- [DRV8376 driver](src/drivers/drv8376/) - SPI driver for TI's DRV8376 motor driver IC.
- [DRV8320/DRV8323 driver](src/drivers/drv832x/) - SPI driver for TI's DRV832x motor driver ICs.
- [STSPIN32G4 driver](src/drivers/stspin32g4/) - I2C and BLDCDriver for the STSPIN32G4 integrated gate driver MCU.
- [SimpleFOCNano driver](src/drivers/simplefocnano/) - BLDCDriver subclass preconfigured for SimpleFOCNano

### Encoders

Expand All @@ -55,12 +53,20 @@ Drivers for various position sensor ICs. In many cases these hardware-specific d
- [ESP32 Hardware Encoder](src/encoders/esp32hwencoder/) - ESP32 Hardware timer based encoder driver for ABI type quadrature encoders.
- [SC60228 SPI driver](src/encoders/sc60228/) - SPI driver for SemiMent SC60288 magnetic encoder IC.
- [MA330 SPI driver](src/encoders/ma330/) - SPI driver for the MPS MagAlpha MA330 absolute position magnetic rotary encoder IC.
- [MT6816 SPI driver](src/encoders/mt6816/) - SPI driver for the MagnTek MT6816 absolute position magnetic rotary encoder IC.
- [MT6701 SSI driver](src/encoders/mt6701/) - SSI driver for the MagnTek MT6701 absolute position magnetic rotary encoder IC.
- [MT6816 SPI driver](src/encoders/mt6816/) - SPI driver for the MagnTek MT6816 absolute position magnetic rotary encoder IC.
- [MT6826S SPI driver](src/encoders/mt6826s/) - SPI driver for the MagnTek MT6826S absolute position magnetic rotary encoder IC.
- [MT6835 SPI driver](src/encoders/mt6835/) - SPI driver for the MagnTek MT6835 21 bit magnetic rotary encoder IC.
- [STM32 PWM sensor driver](src/encoders/stm32pwmsensor/) - STM32 native timer-based driver for PWM angle sensors.
- [KTH78xx SPI driver](src/encoders/kth78xx/) - SPI driver for the Conntek KTH78xx series absolute position magnetic rotary encoder ICs.

### Special Encoders

- [CalibratedSensor](src/encoders/calibrated/) - A sensor which can calibrate for eccentricity on the magnet placement.
- [SmoothingSensor](src/encoders/smoothing/) - A SimpleFOC Sensor wrapper implementation which adds angle extrapolation.
- [LinearHall](src/encoders/linearhall/) - A HallSensor with linear interpolation between ticks
- [FluxObserver](src/encoders/MXLEMMING_observer/) - A "sensorless sensor" implementing flux observer (requires current sensing)
-

### Communications

Expand All @@ -85,7 +91,7 @@ Load and store SimpleFOC motor settings, based on register abstraction. Storing

Drive different kinds of motors, or use alternate algorithms to SimpleFOC's default BLDCMotor and StepperMotor classes.

- [HybridStepperMotor](motors/HybridStepperMotor/) - Drive stepper motors with 3 phases.
- [HybridStepperMotor](https://github.com/simplefoc/Arduino-FOC/blob/master/src/HybridStepperMotor.h) - HybridStepper has moved to the main repostory.


### Utilities
Expand Down
73 changes: 73 additions & 0 deletions examples/comms/can/can_custom_regs/can_custom_regs.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include "Arduino.h"
#include "SimpleFOC.h"
#include "SimpleFOCDrivers.h"
#include "SimpleCANio.h"
#include "comms/can/CANCommander.h"

// can pins
#define CAN_RX NC // define the RX pin
#define CAN_TX NC // define the TX pin
#define CAN_SHDN NC // define the Shhutdown pin (inverse of enable) if needed
#define CAN_ENABLE NC // define the ENABLE pin if needed
#define CAN_ID 1

// 3pwm pins
#define PHA PA6
#define PHB PA7
#define PHC PA8

BLDCMotor motor = BLDCMotor(7); // 7 pole pairs
BLDCDriver3PWM driver = BLDCDriver3PWM(PHA, PHB, PHC);

//CANio can(PIN_CAN0_RX, PIN_CAN0_TX); // Create CAN object
CANio can(CAN_RX, CAN_TX, NC, CAN_ENABLE); // Create CAN object

CANCommander commander(can, CAN_ID);
void setup()
{
Serial.begin(115200);
SimpleFOCDebug::enable(&Serial);

commander.init();
commander.addMotor(&motor);

// add custom register to control built-in LED
pinMode(LED_BUILTIN, OUTPUT);
commander.addCustomRegister(
0xF0, // register id (should be > 0xE0)
1, // size in bytes
[](RegisterIO& comms, FOCMotor* motor) -> bool {
// Read handler for custom register 0xF0
uint8_t customValue = digitalRead(LED_BUILTIN);
comms << customValue;
return true;
},
[](RegisterIO& comms, FOCMotor* motor) -> bool {
// Write handler for custom register 0xF0
uint8_t receivedValue;
comms >> receivedValue;
digitalWrite(LED_BUILTIN, receivedValue ? HIGH : LOW);
return true;
}
);

delay(5000);

motor.linkDriver(&driver);
driver.voltage_power_supply = 12;
driver.init();

motor.init();
motor.initFOC();

Serial.println("Setup complete!");
delay(10);
}

void loop()
{
motor.loopFOC();
motor.move();

commander.run();
}
52 changes: 52 additions & 0 deletions examples/comms/can/can_example/can_example.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "Arduino.h"
#include "SimpleFOC.h"
#include "SimpleFOCDrivers.h"
#include "SimpleCANio.h"
#include "comms/can/CANCommander.h"

// can pins
#define CAN_RX NC // define the RX pin
#define CAN_TX NC // define the TX pin
#define CAN_SHDN NC // define the Shhutdown pin (inverse of enable) if needed
#define CAN_ENABLE NC // define the ENABLE pin if needed
#define CAN_ID 1

// 3pwm pins
#define PHA PA6
#define PHB PA7
#define PHC PA8

BLDCMotor motor = BLDCMotor(7); // 7 pole pairs
BLDCDriver3PWM driver = BLDCDriver3PWM(PHA, PHB, PHC);

//CANio can(PIN_CAN0_RX, PIN_CAN0_TX); // Create CAN object
CANio can(CAN_RX, CAN_TX, NC, CAN_ENABLE); // Create CAN object

CANCommander commander(can, CAN_ID);
void setup()
{
Serial.begin(115200);
SimpleFOCDebug::enable(&Serial);

commander.init();
commander.addMotor(&motor);
delay(5000);

motor.linkDriver(&driver);
driver.voltage_power_supply = 12;
driver.init();

motor.init();
motor.initFOC();

Serial.println("Setup complete!");
delay(10);
}

void loop()
{
motor.loopFOC();
motor.move();

commander.run();
}
3 changes: 3 additions & 0 deletions examples/encoders/calibrated_sensor/calibrated/calibrated.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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)
// argument 3 - pointer to LUT array (if null, LUT will be filled only during calibration)
CalibratedSensor sensor_calibrated = CalibratedSensor(sensor);

// voltage set point variable
Expand Down Expand Up @@ -57,6 +58,8 @@ void setup() {
// Running calibration
// it will ouptut the LUT and the zero electrical angle to the serial monitor !!!!
sensor_calibrated.calibrate(motor);
// print the LUT to serial monitor
sensor_calibrated.printLUT(motor, Serial);

//Serial.println("Calibrating Sensor Done.");
// Linking sensor to motor object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@
*
* 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.
* 3. Run the same example again and the code will use the provided calibration data and skip the calibration procedure.
*/

#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};
// Replace these with the calibration data obtained from the first run
uint16_t 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);
Expand All @@ -29,7 +28,10 @@ StepperDriver4PWM driver = StepperDriver4PWM(10, 9, 5, 6,8);
// 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]));
sensor,
sizeof(calibrationLut)/sizeof(calibrationLut[0]), // number of samples
sensor_direction==Direction::UNKNOWN ? nullptr : calibrationLut // pointer to LUT array
);

// voltage set point variable
float target_voltage = 2;
Expand Down Expand Up @@ -64,12 +66,17 @@ void setup() {
// initialize motor
motor.init();

if(values_provided) {
if(sensor_direction != Direction::UNKNOWN){
Serial.println(F("Using saved calibration data."));
// provide the saved zero angle and direction
motor.zero_electric_angle = zero_electric_angle;
motor.sensor_direction = sensor_direction;
} else {
// Running calibration
Serial.println(F("Running calibration..."));
sensor_calibrated.calibrate(motor);
// print the LUT to serial monitor
sensor_calibrated.printLUT(motor, Serial);
}

// Linking sensor to motor object
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SimpleFOCDrivers
version=1.0.9
version=1.1.0
author=Simplefoc <info@simplefoc.com>
maintainer=Simplefoc <info@simplefoc.com>
sentence=A library of supporting drivers for SimpleFOC. Motor drivers chips, encoder chips, current sensing and supporting code.
Expand Down
5 changes: 4 additions & 1 deletion src/comms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Implementations are available for either ASCII based protocol (TextIO) or binary

[SimpleFOCRegisters.h](./SimpleFOCRegisters.h) contains a list of registers known to SimpleFOC. These registers can be read and/or written and code is provided to serialize/deserialize them.

**📋 Complete register reference**: See [REGISTERS.md](./REGISTERS.md) for the full table with access types, data types, and sizes.

The SimpleFOC packet based IO (PacketCommander, Telemetry), I2CCommander and SettingsStorage as well as our Python API [PySimpleFOC](https://github.com/simplefoc/pysimplefoc) are all based on this register abstraction, and therefore share the same register names/ids.

If implementing your own communications protocol, we encourage you to base it on the Register abstraction if appropriate. This will provide you with ready to use code to access/write the register values, and will make your solution easier to use due to the shared common conventions.
If implementing your own communications protocol, we encourage you to base it on the Register abstraction if appropriate. This will provide you with ready to use code to access/write the register values, and will make your solution easier to use due to the shared common conventions.

Loading
Loading