Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #1

Merged
merged 69 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
b6c0c7d
Merge pull request #30 from simplefoc/dev
runger1101001 Sep 23, 2023
8a4d287
don't use dev platform for esp32 tests
Oct 30, 2023
c66b9db
fix bug with SPI mode 3
Nov 2, 2023
b1ae311
add a stm32 LPTIM encoder
Nov 7, 2023
0255fcc
add a check to ensure encoder mode is supported
Nov 7, 2023
2316b78
Add CRC check to MT6835
Nov 7, 2023
eb2fc66
unfinished STM32FlashSettingsStorage
Nov 7, 2023
afea0c7
self cal verification
VIPQualityPost Nov 8, 2023
5daf24e
oops typo
VIPQualityPost Nov 8, 2023
4b15bfc
fix bugs in STM32G4 settings storage
Nov 8, 2023
ad05d2f
Update main README
Nov 8, 2023
9c93bd4
Merge pull request #33 from VIPQualityPost/mt6835-selfcal
runger1101001 Nov 8, 2023
28110b8
update readme for 1.0.6 release
Dec 1, 2023
e3036a6
add correct release month in readme
Dec 1, 2023
14b67b0
prepare for next 1.0.7 release
Dec 1, 2023
76be538
Merge pull request #34 from simplefoc/dev
runger1101001 Dec 1, 2023
3c4ff83
fix double precision constant
Dec 17, 2023
c467cb0
major refactoring of registers and IO code
Dec 20, 2023
c7e8f89
added teleplot telemetry
Dec 21, 2023
852dea4
fixing bugs in stream based IO
Dec 23, 2023
8decf46
Binary io is working in first tests
Dec 23, 2023
bb863cf
updated main README
Dec 23, 2023
0f8454d
Documentation updates
Dec 23, 2023
4c0031a
add missing class
Dec 23, 2023
00cfedf
More docs on communications code
Dec 23, 2023
9b7a755
fixing bugs in new IO code
Dec 27, 2023
7d25dfc
fix TextIO compile problems on ESP32
Dec 28, 2023
5069e26
Add SimpleFOCNano driver
Dec 28, 2023
6c0db29
fix compile errors due to non-public access
Dec 28, 2023
c0f3e2f
Buffer TextIO input to make non-blocking
Jan 10, 2024
d5748ec
update build flags to detect nano boards
Jan 10, 2024
76f6514
making TextIO more robust to bad input
Jan 16, 2024
4d08d14
fix RP2040 compile problems
Jan 16, 2024
e6913d8
Change order of SPI transaction
Jan 16, 2024
38413a5
change order of SPI operations on MA330, MA730
Jan 21, 2024
948a8f5
add example and update test cases for SimpleFOCNano
Jan 26, 2024
5c73b2e
refactoring the SimpleFOCRegisters
Feb 10, 2024
4178759
bugfix in AS5600 driver
Feb 10, 2024
6468e52
change SPI operations order on MT6701SSI driver
runger1101001 Feb 12, 2024
d4c0ce5
Improvements to LinearHall
dekutree64 Feb 14, 2024
a765332
Example for LinearHall
dekutree64 Feb 14, 2024
3da319d
Fix compile error
dekutree64 Feb 14, 2024
9cc5ab8
add atmega example for simplefocnano shield
runger1101001 Feb 14, 2024
5e9981c
Merge pull request #39 from dekutree64/dev
runger1101001 Feb 14, 2024
59e3502
exclude linearhall example from ESP32
runger1101001 Feb 14, 2024
3a4d671
add HysteresisSensor
Feb 20, 2024
e50a40b
refactoring registers
Feb 20, 2024
b12a8a9
Merge remote-tracking branch 'origin/dev' into dev
Feb 20, 2024
0d149e5
change order of initializer
Feb 20, 2024
3a11d58
add some missing registers
Feb 20, 2024
72ddddc
Fix compiler warning in MT6835.cpp
ystradmann Mar 20, 2024
232386b
Merge pull request #40 from ystradmann/fix-mt6835
runger1101001 Mar 21, 2024
a542a71
very simple trapezoidal velocity planner
Mar 28, 2024
8caf05d
Merge remote-tracking branch 'origin/dev' into dev
Mar 28, 2024
790852f
update README file for release
Mar 29, 2024
447be3f
change link to include PRs
Mar 29, 2024
bfd07bd
Merge pull request #42 from simplefoc/dev
runger1101001 Mar 29, 2024
17be3a5
update README for next release
Mar 29, 2024
69287af
fix SPI operation order #43
runger1101001 May 10, 2024
52b754d
fix warnings
runger1101001 May 10, 2024
855e110
Add ESP32 Hardware Encoder Class - squashed
mcells May 19, 2024
ea0b769
Merge pull request #44 from mcells/Esp32HwEncoder-feature
runger1101001 May 22, 2024
9952f3b
add missing velocity register
runger1101001 Jun 1, 2024
ff2fb84
update simplefocnanodriver docs
runger1101001 Jun 3, 2024
27189ec
Merge remote-tracking branch 'origin/dev' into dev
runger1101001 Jun 3, 2024
79af273
move setting target to beginning of move()
runger1101001 Jun 5, 2024
07fbcc9
Added support for MA735
techy-robot Jul 17, 2024
9b895ce
Updates README file examples of of use
techy-robot Jul 17, 2024
5de9220
Merge pull request #45 from techy-robot/develop
runger1101001 Jul 19, 2024
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
24 changes: 12 additions & 12 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
arduino-boards-fqbn:
- arduino:avr:uno # arudino uno
- arduino:avr:nano # arudino nano
- arduino:sam:arduino_due_x # arduino due
- arduino:samd:nano_33_iot # samd21
- adafruit:samd:adafruit_metro_m4 # samd51
Expand All @@ -25,42 +25,42 @@ jobs:
- STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_F411RE # stm32 nucleo
- arduino:mbed_rp2040:pico # rpi pico
include:
- arduino-boards-fqbn: arduino:avr:uno
sketches-exclude: calibrated mt6816_spi smoothing
- 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
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
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
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://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
required-libraries: Simple FOC
sketches-exclude: calibrated smoothing
sketches-exclude: calibrated smoothing simplefocnano_torque_voltage simplefocnano_atmega linearhall
- arduino-boards-fqbn: esp32:esp32:esp32s2 # esp32s2
platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
required-libraries: Simple FOC
sketches-exclude: calibrated smoothing
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
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
sketches-exclude: smoothing simplefocnano_torque_voltage simplefocnano_atmega
# Do not cancel all jobs / architectures if one job fails
fail-fast: false
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.project
.DS_Store
src/encoders/esp32hwencoder.bak/
64 changes: 52 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,29 @@ The intent is to keep the core of SimpleFOC clean, and thus easy to maintain, un

## New Release

v1.0.6 - Released July 2023, for Simple FOC 2.3.1 or later
v1.0.8 - Released ??? 2024, for Simple FOC 2.3.3 or later


What's changed since 1.0.7?
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=milestone%3A1.0.8+)

What's changed since 1.0.5?
- Added AS5600 Sensor Driver
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=is%3Aissue+milestone%3A1.0.6+)

## What is included

What is here? See the sections below. Each driver or function should come with its own more detailed README.

### Motor/Gate driver ICs

Software to control gate driver ICs or integrated driver ICs which have advanced configuration and status interfaces, e.g. via I2C or SPI.

- [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.
- [STSPIN32G4 driver](src/drivers/stspin32g4/) - I2C and BLDCDriver for the STSPIN32G4 integrated gate driver MCU.

### Encoders

Drivers for various position sensor ICs. In many cases these hardware-specific drivers often support more functionality than the generic SimpleFOC sensor drivers, including reading status registers, setting configurations and more.

- [AS5048A SPI driver](src/encoders/as5048a/) - SPI driver for the AMS AS5048A absolute position magnetic rotary encoder IC.
- [AS5047 SPI driver](src/encoders/as5047/) - SPI driver for the AMS AS5047P and AS5047D absolute position magnetic rotary encoder ICs.
- [AS5047U SPI driver](src/encoders/as5047u/) - SPI driver for the AMS AS5047U absolute position magnetic rotary encoder ICs.
Expand All @@ -42,27 +48,42 @@ What is here? See the sections below. Each driver or function should come with i
- [MT6701 SSI driver](src/encoders/mt6701/) - SSI driver for the MagnTek MT6701 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.
- [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.

### Communications

- [I2CCommander I2C driver](src/comms/i2c/) - I2C communications protocol and drivers for both controller and target devices, based on register abstraction
- [STM32 SpeedDir Input](src/comms/stm32speeddir/) - Control target velocity with PWM speed and direction inputs
- [SerialBinaryCommander](src/comms/serial/) - Serial communications with binary protocol, based on register abstraction
- [Telemetry](src/comms/telemetry/) - Telemetry abstraction, based on registers
- [SerialASCIITelemetry](src/comms/serial/) - Serial communications with ascii protocol, based on register abstraction
Extended communications classes for SimpleFOC. In particular the Telemetry and PacketCommander classes, which implement ASCII or Binary communications and allow monitoring and control of multiple motors, via an easy to use "Registers" abstraction. The Binary and ASCII packet based protocols are directly supported in [PySimpleFOC](https://github.com/simplefoc/pysimplefoc).

- [PacketCommander](src/comms/streams/) - Serial communications with binary protocol, based on register abstraction - get or set any value in SimpleFOC
- [Telemetry](src/comms/telemetry/) - Telemetry based on registers - monitor any value in SimpleFOC, and log in either ASCII or Binary, compatible with PacketCommander
- [SimpleTelemetry](src/comms/telemetry/) - Register telemetry for use with Arduino Serial Plotter tool
- [TeleplotTelemetry](src/comms/telemetry/) - Register telemetry for use with VSCode Teleplot extension
- [I2CCommander I2C driver](src/comms/i2c/) - I2C communications based on register abstraction
- [STM32 SpeedDir Input](src/comms/stm32speeddir/) - Control target velocity with PWM speed and direction inputs

### Settings

Load and store SimpleFOC motor settings, based on register abstraction.
Load and store SimpleFOC motor settings, based on register abstraction. Storing the motor calibration allows you to skip the calibration phase during setup.

- [SAMD NVM storage driver](src/settings/samd/) - Store settings to the NVM flash memory in your SAMD MCU
- [SAMD NVM storage driver](src/settings/samd/) - Store settings to either the main flash memory or the RWWEE memory (if available) in your SAMD MCU
- [CAT24 I2C EEPROM storage driver](src/settings/i2c/) - Store settings to CAT24 I2C EEPROMs
- [STM32 flash storage driver](src/settings/stm32/) - Store settings directly to STM32 on-board flash, currently supporting STM32G4 MCUs.

### Motor classes

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.


### Utilities

- [STM32 PWM Input driver](src/utilities/stm32pwm/) - PWM Input driver for STM32 MCUs. Accurately measure PWM inputs with zero MCU overhead.
Other support code not fitting in the above categories.

- [STM32 PWM Input driver](src/utilities/stm32pwm/) - PWM Input driver for STM32 MCUs. Accurately measure PWM inputs with zero MCU overhead.
- [STM32 CORDIC trig driver](src/utilities/stm32math/) - CORDIC driver to accellerate sine and cosine calculations in SimpleFOC, on STM32 MCUs which have a CORDIC unit.
- [TrapezoidalPlanner](src/utilities/trapezoids/) - Simple trapezoidal motion planner.

## How to use

Expand Down Expand Up @@ -90,6 +111,25 @@ Find out more information about the Arduino SimpleFOC project on the [docs websi

## Release History

What's changed since 1.0.6?
- Improvements to LinearHall driver, thanks to dekutree
- Fix for ESP32 compiler warning, thanks to Yannik Stradmann
- Added STM32 LPTIM encoder driver
- Refactored communications code
- Working telemetry abstraction
- Working streams communications, ASCII based
- 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+)

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+)

What's changed since 1.0.4?
- Added smoothing sensor by [@dekutree64](https://github.com/dekutree64)
- Added TMD6200 SPI driver by [@YaseenTwati](https://github.com/YaseenTwati)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include <Arduino.h>
#include <SPI.h>
#include "SimpleFOC.h"
#include "SimpleFOCDrivers.h"
#include "drivers/simplefocnano/SimpleFOCNanoDriver.h"
#include "encoders/as5048a/MagneticSensorAS5048A.h"


MagneticSensorAS5048A sensor = MagneticSensorAS5048A(PIN_nCS);
SimpleFOCNanoDriver driver = SimpleFOCNanoDriver();
BLDCMotor motor = BLDCMotor(11); // 11 pole pairs

long loopts = 0;
int iterations = 0;
float volts = 0.0f;

void setup() {
Serial.begin(115200); // enable serial port
delay(5000);
SimpleFOCDebug::enable(); // enable debug messages to Serial

sensor.init(); // init sensor on default SPI pins

// read voltage
SimpleFOCDebug::print("Bus voltage: ");
volts = driver.getBusVoltage(5.0f, 1024); // 5V reference, 10-bit ADC
SimpleFOCDebug::println(volts);
driver.voltage_power_supply = volts; // set driver voltage to measured value
driver.voltage_limit = 10.0f; // limit voltage to 10V
driver.pwm_frequency = 30000; // set pwm frequency to 30kHz
driver.init(); // init driver

motor.linkSensor(&sensor); // link the motor to the sensor
motor.linkDriver(&driver); // link the motor to the driver

motor.controller = MotionControlType::torque; // torque control
motor.torque_controller = TorqueControlType::voltage; // use voltage torque control
motor.voltage_limit = driver.voltage_limit / 2.0f; // limit voltage to 1/2 of driver limit
motor.voltage_sensor_align = 4.0f; // align voltage sensor to 4V

motor.init(); // init motor
delay(100); // wait for driver to power up
motor.initFOC(); // init FOC and calibrate motor

Serial.println("Motor ready.");
loopts = millis();

// Set the motor target to 2 volts
motor.target = 2.0f;
}


void loop() {
motor.move();
motor.loopFOC();
long now = millis();
iterations++;
if (now - loopts > 1000) {
Serial.print("Iterations/s: ");
Serial.println(iterations);
Serial.print("Angle: ");
Serial.println(sensor.getAngle());
loopts = now;
iterations = 0;
}
if (now - loopts < 0)
loopts = 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include <Arduino.h>
#include <SPI.h>
#include "SimpleFOC.h"
#include "SimpleFOCDrivers.h"
#include "drivers/simplefocnano/SimpleFOCNanoDriver.h"
#include "encoders/as5048a/MagneticSensorAS5048A.h"


MagneticSensorAS5048A sensor = MagneticSensorAS5048A(PIN_nCS);
SimpleFOCNanoDriver driver = SimpleFOCNanoDriver();
BLDCMotor motor = BLDCMotor(11); // 11 pole pairs

Commander commander = Commander(Serial);
void doMotor(char* cmd) { commander.motor(&motor, cmd); }

long loopts = 0;
int iterations = 0;
float volts = 0.0f;

void setup() {
Serial.begin(115200); // enable serial port
delay(5000);
SimpleFOCDebug::enable(); // enable debug messages to Serial

sensor.init(); // init sensor on default SPI pins

// read voltage
SimpleFOCDebug::print("Bus voltage: ");
volts = driver.getBusVoltage(3.3, 4096);
SimpleFOCDebug::println(volts);
driver.voltage_power_supply = volts; // set driver voltage to measured value
driver.voltage_limit = 10.0f; // limit voltage to 10V
driver.pwm_frequency = 30000; // set pwm frequency to 30kHz
driver.init(); // init driver

motor.linkSensor(&sensor); // link the motor to the sensor
motor.linkDriver(&driver); // link the motor to the driver

motor.controller = MotionControlType::torque; // torque control
motor.torque_controller = TorqueControlType::voltage; // use voltage torque control
motor.voltage_limit = driver.voltage_limit / 2.0f; // limit voltage to 1/2 of driver limit
motor.voltage_sensor_align = 4.0f; // align voltage sensor to 4V

motor.init(); // init motor
delay(100); // wait for driver to power up
motor.initFOC(); // init FOC and calibrate motor

commander.add('M', doMotor); // add motor command

Serial.println("Motor ready.");
loopts = millis();
}


void loop() {
motor.move();
motor.loopFOC();
commander.run();
long now = millis();
iterations++;
if (now - loopts > 1000) {
Serial.print("Iterations/s: ");
Serial.println(iterations);
Serial.print("Angle: ");
Serial.println(sensor.getAngle());
loopts = now;
iterations = 0;
}
if (now - loopts < 0)
loopts = 0;
}
Loading
Loading