Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Therefore this is an attempt to:
> - BG341 low-side current sense sync was lost in v2.3.5 - fixed [#482](https://github.com/simplefoc/Arduino-FOC/pull/482)
> - ESP32
> - Many ESP32 safety optimisations by [@uLipe](https://github.com/uLipe): [#490](https://github.com/simplefoc/Arduino-FOC/pull/490),[#491](https://github.com/simplefoc/Arduino-FOC/pull/491),[#492](https://github.com/simplefoc/Arduino-FOC/pull/492),[#493](https://github.com/simplefoc/Arduino-FOC/pull/493),[#495](https://github.com/simplefoc/Arduino-FOC/pull/495)
> - Better ADC-Timer alignement for more stable current sensing [See this commit](https://github.com/simplefoc/Arduino-FOC/commit/877699b4db4e6e3ecc16b16cc4337af928e746f4)
> - Better ADC-Timer alignment for more stable current sensing [See this commit](https://github.com/simplefoc/Arduino-FOC/commit/877699b4db4e6e3ecc16b16cc4337af928e746f4)
> - Now compiles for all v3.x arduino-esp32 versions (v2.3.5 was compatible with v3.2.x)
> - `adcRead` small refactor - no more magic numbers
> - Others
Expand Down Expand Up @@ -101,7 +101,7 @@ This video is a bit outdated but it demonstrates the *Simple**FOC**library* basi
- Built-in communication and monitoring via Serial, I2C, or custom protocols
- **Cross-platform**:
- Seamless code transfer from one microcontroller family to another
- Supports multiple [MCU architectures](https://docs.simplefoc.commicrocontrollers):
- Supports multiple [MCU architectures](https://docs.simplefoc.com/microcontrollers):
- Arduino: UNO R4, UNO, MEGA, DUE, Leonardo, Nano, Nano33, MKR ....
- STM32 (Nucleo, Bluepill, B-G431B-ESC1, H7 family, etc.)
- ESP32 (ESP32, ESP32-S2, ESP32-S3, ESP32-C3, ESP32-C6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ LowsideCurrentSense currentSense = LowsideCurrentSense(0.003f, -64.0f/7.0f, A_OP
// encoder instance
Encoder encoder = Encoder(A_HALL2, A_HALL3, 2048, A_HALL1);

// Interrupt routine intialisation
// Interrupt routine initialization
// channel A and B callbacks
void doA(){encoder.handleA();}
void doB(){encoder.handleB();}
Expand Down Expand Up @@ -62,7 +62,7 @@ void setup() {
// set motion control loop to be used
motor.controller = MotionControlType::velocity;

// contoller configuration
// controller configuration
// default parameters in defaults.h

// velocity PI controller parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ BLDCDriver3PWM driver = BLDCDriver3PWM(PB6, PB7, PB8, PB5);
// encoder instance
Encoder encoder = Encoder(PA8, PA9, 8192, PA10);

// Interrupt routine intialisation
// Interrupt routine initialization
// channel A and B callbacks
void doA(){encoder.handleA();}
void doB(){encoder.handleB();}
Expand Down Expand Up @@ -60,7 +60,7 @@ void setup() {
// set motion control loop to be used
motor.controller = MotionControlType::velocity;

// contoller configuration
// controller configuration
// default parameters in defaults.h

// velocity PI controller parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void setup() {
// set motion control loop to be used
motor.controller = MotionControlType::angle;

// contoller configuration
// controller configuration
// default parameters in defaults.h

// velocity PI controller parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ BLDCDriver3PWM driver = BLDCDriver3PWM(INH_A, INH_B, INH_C, EN_GATE);
// encoder instance
Encoder encoder = Encoder(2, 3, 8192);

// Interrupt routine intialisation
// Interrupt routine initialization
// channel A and B callbacks
void doA(){encoder.handleA();}
void doB(){encoder.handleB();}
Expand Down Expand Up @@ -82,7 +82,7 @@ void setup() {
// set control loop type to be used
motor.controller = MotionControlType::torque;

// contoller configuration based on the controll type
// controller configuration based on the control type
motor.PID_velocity.P = 0.2f;
motor.PID_velocity.I = 20;
// default voltage_power_supply
Expand All @@ -104,7 +104,7 @@ void setup() {
// align encoder and start FOC
motor.initFOC();

// set the inital target value
// set the initial target value
motor.target = 2;

// define the motor id
Expand All @@ -125,7 +125,7 @@ void loop() {

// iterative function setting the outter loop target
// velocity, position or voltage
// if tatget not set in parameter uses motor.target variable
// if target not set in parameter uses motor.target variable
motor.move();

// user communication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ BLDCDriver6PWM driver = BLDCDriver6PWM(INH_A,INL_A, INH_B,INL_B, INH_C,INL_C, EN
// encoder instance
Encoder encoder = Encoder(2, 3, 8192);

// Interrupt routine intialisation
// Interrupt routine initialization
// channel A and B callbacks
void doA(){encoder.handleA();}
void doB(){encoder.handleB();}
Expand Down Expand Up @@ -83,7 +83,7 @@ void setup() {
// set control loop type to be used
motor.controller = MotionControlType::torque;

// contoller configuration based on the controll type
// controller configuration based on the control type
motor.PID_velocity.P = 0.2f;
motor.PID_velocity.I = 20;
// default voltage_power_supply
Expand All @@ -105,7 +105,7 @@ void setup() {
// align encoder and start FOC
motor.initFOC();

// set the inital target value
// set the initial target value
motor.target = 2;

// define the motor id
Expand All @@ -124,7 +124,7 @@ void loop() {

// iterative function setting the outter loop target
// velocity, position or voltage
// if tatget not set in parameter uses motor.target variable
// if target not set in parameter uses motor.target variable
motor.move();

// user communication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ LowsideCurrentSense cs = LowsideCurrentSense(0.005f, 12.22f, IOUTA, IOUTB, IOUTC
// encoder instance
Encoder encoder = Encoder(22, 23, 500);

// Interrupt routine intialisation
// Interrupt routine initialization
// channel A and B callbacks
void doA(){encoder.handleA();}
void doB(){encoder.handleB();}
Expand Down Expand Up @@ -137,7 +137,7 @@ void setup() {
// align encoder and start FOC
motor.initFOC();

// set the inital target value
// set the initial target value
motor.target = 0;

// define the motor id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ LowsideCurrentSense cs = LowsideCurrentSense(0.005f, 12.22f, IOUTA, IOUTB, IOUTC
// encoder instance
Encoder encoder = Encoder(PB14, PB15, 2048);

// Interrupt routine intialisation
// Interrupt routine initialization
// channel A and B callbacks
void doA(){encoder.handleA();}
void doB(){encoder.handleB();}
Expand Down Expand Up @@ -137,7 +137,7 @@ void setup() {
// align encoder and start FOC
motor.initFOC();

// set the inital target value
// set the initial target value
motor.target = 0;

// define the motor id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ LowsideCurrentSense cs = LowsideCurrentSense(0.005f, 12.22f, IOUTA, IOUTB);
// encoder instance
Encoder encoder = Encoder(10, 11, 2048);

// Interrupt routine intialisation
// Interrupt routine initialization
// channel A and B callbacks
void doA(){encoder.handleA();}
void doB(){encoder.handleB();}
Expand Down Expand Up @@ -138,7 +138,7 @@ void setup() {
// align encoder and start FOC
motor.initFOC();

// set the inital target value
// set the initial target value
motor.target = 0;

// define the motor id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ BLDCDriver3PWM driver = BLDCDriver3PWM(25, 26, 27, 7);
// encoder instance
Encoder encoder = Encoder(4, 2, 1024);

// Interrupt routine intialisation
// Interrupt routine initialization
// channel A and B callbacks
void doA(){encoder.handleA();}
void doB(){encoder.handleB();}
Expand Down Expand Up @@ -52,7 +52,7 @@ void setup() {
// set motion control loop to be used
motor.controller = MotionControlType::velocity;

// contoller configuration
// controller configuration
// default parameters in defaults.h

// velocity PI controller parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void setup() {
// set motion control loop to be used
motor.controller = MotionControlType::angle;

// contoller configuration
// controller configuration
// default parameters in defaults.h

// velocity PI controller parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ BLDCDriver3PWM driver = BLDCDriver3PWM(9, 10, 11);
// encoder instance
Encoder encoder = Encoder(A0, A1, 2048);

// Interrupt routine intialisation
// Interrupt routine initialization
// channel A and B callbacks
void doA(){encoder.handleA();}
void doB(){encoder.handleB();}
Expand Down Expand Up @@ -68,7 +68,7 @@ void setup() {
// set motion control loop to be used
motor.controller = MotionControlType::angle;

// contoller configuration
// controller configuration
// default parameters in defaults.h

// velocity PI controller parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ BLDCDriver3PWM driver = BLDCDriver3PWM(9, 10, 11);
// encoder instance
Encoder encoder = Encoder(A0, A1, 8192);

// Interrupt routine intialisation
// Interrupt routine initialization
// channel A and B callbacks
void doA(){encoder.handleA();}
void doB(){encoder.handleB();}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define M0_INL_A PB13
#define M0_INL_B PB14
#define M0_INL_C PB15
// M0 currnets
// M0 currents
#define M0_IB PC0
#define M0_IC PC1
// Odrive M0 encoder pinout
Expand All @@ -31,7 +31,7 @@
#define M1_INL_A PA7
#define M1_INL_B PB0
#define M1_INL_C PB1
// M0 currnets
// M0 currents
#define M1_IB PC2
#define M1_IC PC3
// Odrive M1 encoder pinout
Expand Down Expand Up @@ -62,7 +62,7 @@ void doMotor(char* cmd) { command.motor(&motor, cmd); }
LowsideCurrentSense current_sense = LowsideCurrentSense(0.0005f, 10.0f, _NC, M0_IB, M0_IC);

Encoder encoder = Encoder(M0_ENC_A, M0_ENC_B, 500,M0_ENC_Z);
// Interrupt routine intialisation
// Interrupt routine initialization
// channel A and B callbacks
void doA(){encoder.handleA();}
void doB(){encoder.handleB();}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define M0_INL_A PB13
#define M0_INL_B PB14
#define M0_INL_C PB15
// M0 currnets
// M0 currents
#define M0_IB PC0
#define M0_IC PC1
// Odrive M0 encoder pinout
Expand All @@ -31,7 +31,7 @@
#define M1_INL_A PA7
#define M1_INL_B PB0
#define M1_INL_C PB1
// M0 currnets
// M0 currents
#define M1_IB PC2
#define M1_IC PC3
// Odrive M1 encoder pinout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Note: in all of the above note that you *cannot* set the timers or WOs used - th
So it is matter of choosing the right pins, nothing else.

Note also: Unfortunately you can't set the PWM frequency. It is currently fixed at 24KHz. This is a tradeoff between limiting PWM resolution vs
increasing frequency, and also due to keeping the pin assignemts flexible, which would not be possible if we ran the timers at different rates.
increasing frequency, and also due to keeping the pin assignments flexible, which would not be possible if we ran the timers at different rates.

## Status

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void setup() {
motor.torque_controller = TorqueControlType::foc_current;
motor.controller = MotionControlType::torque;

// contoller configuration based on the controll type
// controller configuration based on the control type
motor.PID_velocity.P = 0.05f;
motor.PID_velocity.I = 1;
motor.PID_velocity.D = 0;
Expand All @@ -64,7 +64,7 @@ void setup() {

// comment out if not needed
motor.useMonitoring(Serial);
motor.monitor_downsample = 0; // disable intially
motor.monitor_downsample = 0; // disable initially
motor.monitor_variables = _MON_TARGET | _MON_VEL | _MON_ANGLE; // monitor target velocity and angle

// current sense init and linking
Expand All @@ -76,7 +76,7 @@ void setup() {
// align encoder and start FOC
motor.initFOC();

// set the inital target value
// set the initial target value
motor.target = 0;

// subscribe motor to the commander
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ BLDCDriver3PWM driver = BLDCDriver3PWM(11, 10, 9, 8);

// encoder instance
Encoder encoder = Encoder(2, 3, 500);
// Interrupt routine intialisation
// Interrupt routine initialization
// channel A and B callbacks
void doA(){encoder.handleA();}
void doB(){encoder.handleB();}
Expand Down Expand Up @@ -69,7 +69,7 @@ void setup() {
// set motion control loop to be used
motor.controller = MotionControlType::angle;

// contoller configuration
// controller configuration
// default parameters in defaults.h

// velocity PI controller parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ void setup() {
motor1.controller = MotionControlType::torque;
motor2.controller = MotionControlType::torque;

// contoller configuration based on the controll type
// controller configuration based on the control type
motor1.PID_velocity.P = 0.05f;
motor1.PID_velocity.I = 1;
motor1.PID_velocity.D = 0;
// default voltage_power_supply
motor1.voltage_limit = 12;
// contoller configuration based on the controll type
// controller configuration based on the control type
motor2.PID_velocity.P = 0.05f;
motor2.PID_velocity.I = 1;
motor2.PID_velocity.D = 0;
Expand All @@ -92,7 +92,7 @@ void setup() {
// align encoder and start FOC
motor2.initFOC();

// set the inital target value
// set the initial target value
motor1.target = 2;
motor2.target = 2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void setup() {
// set control loop type to be used
motor.controller = MotionControlType::torque;

// contoller configuration based on the controll type
// controller configuration based on the control type
motor.PID_velocity.P = 0.05f;
motor.PID_velocity.I = 1;
motor.PID_velocity.D = 0;
Expand All @@ -56,15 +56,15 @@ void setup() {

// comment out if not needed
motor.useMonitoring(Serial);
motor.monitor_downsample = 0; // disable intially
motor.monitor_downsample = 0; // disable initially
motor.monitor_variables = _MON_TARGET | _MON_VEL | _MON_ANGLE; // monitor target velocity and angle

// initialise motor
motor.init();
// align encoder and start FOC
motor.initFOC();

// set the inital target value
// set the initial target value
motor.target = 2;

// subscribe motor to the commander
Expand Down
Loading