Skip to content

Commit b6c0c7d

Browse files
Merge pull request #30 from simplefoc/dev
PR for v1.0.5 Release
2 parents 72c1a9e + ecb3866 commit b6c0c7d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3886
-62
lines changed

.github/workflows/ccpp.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,40 +26,41 @@ jobs:
2626
- arduino:mbed_rp2040:pico # rpi pico
2727
include:
2828
- arduino-boards-fqbn: arduino:avr:uno
29-
sketches-exclude: calibrated mt6816_spi
29+
sketches-exclude: calibrated mt6816_spi smoothing
3030
required-libraries: Simple FOC
3131
- arduino-boards-fqbn: arduino:sam:arduino_due_x
3232
required-libraries: Simple FOC
33-
sketches-exclude: calibrated
33+
sketches-exclude: calibrated smoothing
3434
- arduino-boards-fqbn: arduino:samd:nano_33_iot
3535
required-libraries: Simple FOC
36-
sketches-exclude: calibrated
36+
sketches-exclude: calibrated smoothing
3737
- arduino-boards-fqbn: arduino:mbed_rp2040:pico
3838
required-libraries: Simple FOC
39-
sketches-exclude: calibrated
39+
sketches-exclude: calibrated smoothing
4040
- arduino-boards-fqbn: adafruit:samd:adafruit_metro_m4
4141
platform-url: https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
4242
required-libraries: Simple FOC
43-
sketches-exclude: calibrated
43+
sketches-exclude: calibrated smoothing
4444
# - arduino-boards-fqbn: esp32:esp32:esp32doit-devkit-v1
4545
# platform-url: https://dl.espressif.com/dl/package_esp32_index.json
4646
# required-libraries: Simple FOC
4747
# sketch-names: '**.ino'
4848
- arduino-boards-fqbn: esp32:esp32:esp32 # esp32
4949
platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
5050
required-libraries: Simple FOC
51-
sketches-exclude: calibrated
51+
sketches-exclude: calibrated smoothing
5252
- arduino-boards-fqbn: esp32:esp32:esp32s2 # esp32s2
5353
platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
5454
required-libraries: Simple FOC
55-
sketches-exclude: calibrated
55+
sketches-exclude: calibrated smoothing
5656
- arduino-boards-fqbn: STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8
5757
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
5858
required-libraries: Simple FOC
59-
sketches-exclude: calibrated mt6816_spi
59+
sketches-exclude: calibrated mt6816_spi smoothing
6060
- arduino-boards-fqbn: STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_F411RE
61-
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
61+
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
6262
required-libraries: Simple FOC
63+
sketches-exclude: smoothing
6364
# Do not cancel all jobs / architectures if one job fails
6465
fail-fast: false
6566
steps:

README.md

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

1111
## New Release
1212

13-
v1.0.4 - Released June 2023, for Simple FOC 2.3.0
14-
15-
What's changed since 1.0.3?
16-
- New Comms/Input: STM32SpeedDirCommander
17-
- New Utility: STM32PWMInput
18-
- Fixed MT6835 driver bugs
19-
- Improved AS5047 driver, fixed bugs
20-
- Improved AS5047U driver, fixed bugs
13+
v1.0.5 - Released July 2023, for Simple FOC 2.3.1
14+
15+
What's changed since 1.0.4?
16+
- Added smoothing sensor by [@dekutree64](https://github.com/dekutree64)
17+
- Added TMD6200 SPI driver by [@YaseenTwati](https://github.com/YaseenTwati)
18+
- Added HybridStepperMotor by [@VIPQualityPost](https://github.com/VIPQualityPost)
19+
- New Settings abstraction to load and save SimpleFOC settings and calibration
20+
- New Settings driver: SAMDNVMSettingsStorage
21+
- SimpleFOCRegisters abstraction, mapping SimpleFOC parameters to virtual "Registers"
22+
- Updated I2CCommander to use the new registers abstraction
23+
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=is%3Aissue+milestone%3A1.0.5+)
2124

2225
## What is included
2326

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

2629
### Motor/Gate driver ICs
2730

31+
- [TMC6200 driver](src/drivers/tmc6200/) - SPI driver for Trinamics TMC6200 motor driver IC.
2832
- [DRV8316 driver](src/drivers/drv8316/) - SPI driver for TI's DRV8316 motor driver IC.
2933

3034
### Encoders
@@ -43,11 +47,22 @@ What is here? See the sections below. Each driver or function should come with i
4347
- [MT6701 SSI driver](src/encoders/mt6701/) - SSI driver for the MagnTek MT6701 absolute position magnetic rotary encoder IC.
4448
- [MT6835 SPI driver](src/encoders/mt6835/) - SPI driver for the MagnTek MT6835 21 bit magnetic rotary encoder IC.
4549
- [STM32 PWM sensor driver](src/encoders/stm32pwmsensor/) - STM32 native timer-based driver for PWM angle sensors.
50+
- [SmoothingSensor](src/encoders/smoothing/) - A SimpleFOC Sensor wrapper implementation which adds angle extrapolation.
4651

4752
### Communications
4853

49-
- [I2CCommander I2C driver](src/comms/i2c/) - I2C communications protocol and drivers for both controller and target devices.
54+
- [I2CCommander I2C driver](src/comms/i2c/) - I2C communications protocol and drivers for both controller and target devices, based on register abstraction
5055
- [STM32 SpeedDir Input](src/comms/stm32speeddir/) - Control target velocity with PWM speed and direction inputs
56+
- [SerialBinaryCommander](src/comms/serial/) - Serial communications with binary protocol, based on register abstraction
57+
- [Telemetry](src/comms/telemetry/) - Telemetry abstraction, based on registers
58+
- [SerialASCIITelemetry](src/comms/serial/) - Serial communications with ascii protocol, based on register abstraction
59+
60+
### Settings
61+
62+
Load and store SimpleFOC motor settings, based on register abstraction.
63+
64+
- [SAMD NVM storage driver](src/settings/samd/) - Store settings to the NVM flash memory in your SAMD MCU
65+
- [CAT24 I2C EEPROM storage driver](src/settings/i2c/) - Store settings to CAT24 I2C EEPROMs
5166

5267
### Utilities
5368

@@ -80,6 +95,13 @@ Find out more information about the Arduino SimpleFOC project on the [docs websi
8095

8196
## Release History
8297

98+
What's changed since 1.0.3?
99+
- New Comms/Input: STM32SpeedDirCommander
100+
- New Utility: STM32PWMInput
101+
- Fixed MT6835 driver bugs
102+
- Improved AS5047 driver, fixed bugs
103+
- Improved AS5047U driver, fixed bugs
104+
83105
What's changed since 1.0.2?
84106
- New Sensor: MT6835
85107
- Fixed bugs
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
/**
2+
*
3+
* Hall sensor velocity motion control example, modified to demonstrate usage of SmoothingSensor
4+
* Steps:
5+
* 1) Configure the motor and sensor
6+
* 2) Run the code
7+
* 3) Set the target velocity (in radians per second) from serial terminal
8+
* 4) Try with and without smoothing to see the difference (send E1 and E0 commands from serial terminal)
9+
*
10+
*
11+
*
12+
* NOTE :
13+
* > Specifically for Arduino UNO example code for running velocity motion control using a hall sensor
14+
* > Since Arduino UNO doesn't have enough interrupt pins we have to use software interrupt library PciManager.
15+
*
16+
* > If running this code with Nucleo or Bluepill or any other board which has more than 2 interrupt pins
17+
* > you can supply doC directly to the sensor.enableInterrupts(doA,doB,doC) and avoid using PciManger
18+
*
19+
*/
20+
#include <SimpleFOC.h>
21+
// software interrupt library
22+
#include <PciManager.h>
23+
#include <PciListenerImp.h>
24+
#include <SimpleFOCDrivers.h>
25+
#include <encoders/smoothing/SmoothingSensor.h>
26+
27+
// BLDC motor & driver instance
28+
BLDCMotor motor = BLDCMotor(11);
29+
BLDCDriver3PWM driver = BLDCDriver3PWM(9, 5, 6, 8);
30+
// Stepper motor & driver instance
31+
//StepperMotor motor = StepperMotor(50);
32+
//StepperDriver4PWM driver = StepperDriver4PWM(9, 5, 10, 6, 8);
33+
34+
// hall sensor instance
35+
HallSensor sensor = HallSensor(2, 3, 4, 11);
36+
// wrapper instance
37+
SmoothingSensor smooth(sensor, motor);
38+
39+
// Interrupt routine intialisation
40+
// channel A and B callbacks
41+
void doA(){sensor.handleA();}
42+
void doB(){sensor.handleB();}
43+
void doC(){sensor.handleC();}
44+
// If no available hadware interrupt pins use the software interrupt
45+
PciListenerImp listenerIndex(sensor.pinC, doC);
46+
47+
// velocity set point variable
48+
float target_velocity = 0;
49+
// instantiate the commander
50+
Commander command = Commander(Serial);
51+
void doTarget(char* cmd) { command.scalar(&target_velocity, cmd); }
52+
53+
void enableSmoothing(char* cmd) {
54+
float enable;
55+
command.scalar(&enable, cmd);
56+
motor.linkSensor(enable == 0 ? (Sensor*)&sensor : (Sensor*)&smooth);
57+
}
58+
59+
void setup() {
60+
61+
// initialize sensor sensor hardware
62+
sensor.init();
63+
sensor.enableInterrupts(doA, doB); //, doC);
64+
// software interrupts
65+
PciManager.registerListener(&listenerIndex);
66+
// set SmoothingSensor phase correction for hall sensors
67+
smooth.phase_correction = -_PI_6;
68+
// link the SmoothingSensor to the motor
69+
motor.linkSensor(&smooth);
70+
71+
// driver config
72+
// power supply voltage [V]
73+
driver.voltage_power_supply = 12;
74+
driver.init();
75+
// link the motor and the driver
76+
motor.linkDriver(&driver);
77+
78+
// aligning voltage [V]
79+
motor.voltage_sensor_align = 3;
80+
81+
// set motion control loop to be used
82+
motor.controller = MotionControlType::velocity;
83+
84+
// contoller configuration
85+
// default parameters in defaults.h
86+
87+
// velocity PI controller parameters
88+
motor.PID_velocity.P = 0.2f;
89+
motor.PID_velocity.I = 2;
90+
motor.PID_velocity.D = 0;
91+
// default voltage_power_supply
92+
motor.voltage_limit = 6;
93+
// jerk control using voltage voltage ramp
94+
// default value is 300 volts per sec ~ 0.3V per millisecond
95+
motor.PID_velocity.output_ramp = 1000;
96+
97+
// velocity low pass filtering time constant
98+
motor.LPF_velocity.Tf = 0.01f;
99+
100+
// use monitoring with serial
101+
Serial.begin(115200);
102+
// comment out if not needed
103+
motor.useMonitoring(Serial);
104+
105+
// initialize motor
106+
motor.init();
107+
// align sensor and start FOC
108+
motor.initFOC();
109+
110+
// add target command T
111+
command.add('T', doTarget, "target voltage");
112+
113+
// add smoothing enable/disable command E (send E0 to use hall sensor alone, or E1 to use smoothing)
114+
command.add('E', enableSmoothing, "enable smoothing");
115+
116+
Serial.println(F("Motor ready."));
117+
Serial.println(F("Set the target velocity using serial terminal:"));
118+
_delay(1000);
119+
}
120+
121+
122+
void loop() {
123+
// main FOC algorithm function
124+
// the faster you run this function the better
125+
// Arduino UNO loop ~1kHz
126+
// Bluepill loop ~10kHz
127+
motor.loopFOC();
128+
129+
// Motion control function
130+
// velocity, position or voltage (defined in motor.controller)
131+
// this function can be run at much lower frequency than loopFOC() function
132+
// You can also use motor.move() and set the motor.target in the code
133+
motor.move(target_velocity);
134+
135+
// function intended to be used with serial plotter to monitor motor variables
136+
// significantly slowing the execution down!!!!
137+
// motor.monitor();
138+
139+
// user communication
140+
command.run();
141+
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SimpleFOCDrivers
2-
version=1.0.4
2+
version=1.0.5
33
author=Simplefoc <[email protected]>
44
maintainer=Simplefoc <[email protected]>
55
sentence=A library of supporting drivers for SimpleFOC. Motor drivers chips, encoder chips, current sensing and supporting code.

src/comms/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
# SimpleFOC communications support code
3+
4+
This folder contains classes to support you communicating between MCUs running SimpleFOC, and other systems.
5+

0 commit comments

Comments
 (0)