Skip to content

Commit 13d67f9

Browse files
committed
current sense hardware restructuring + added bg431-esc to compile check + bugfixes
1 parent 5dfb4aa commit 13d67f9

File tree

15 files changed

+32
-34
lines changed

15 files changed

+32
-34
lines changed

.github/workflows/ccpp.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ jobs:
1717
- STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8 # stm32 bluepill
1818
- STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_F411RE # stm32 nucleo
1919
- STMicroelectronics:stm32:GenF4:pnum=GENERIC_F405RGTX # stm32f405 - odrive
20+
- STMicroelectronics:stm32:Disco:pnum=B_G431B_ESC1 # B-G431-ESC1
2021
- arduino:mbed_rp2040:pico # rpi pico
2122

2223
include:
2324
- arduino-boards-fqbn: arduino:avr:uno # arudino uno - compiling almost all examples
2425
sketch-names: '**.ino'
2526
required-libraries: PciManager
26-
sketches-exclude: bluepill_position_control, esp32_position_control, esp32_i2c_dual_bus_example, stm32_i2c_dual_bus_example, magnetic_sensor_spi_alt_example, osc_esp32_3pwm, osc_esp32_fullcontrol, nano33IoT_velocity_control, smartstepper_control,esp32_current_control_low_side, stm32_spi_alt_example, esp32_spi_alt_example, B_G431B_ESC1_position_control, odrive_example
27+
sketches-exclude: bluepill_position_control, esp32_position_control, esp32_i2c_dual_bus_example, stm32_i2c_dual_bus_example, magnetic_sensor_spi_alt_example, osc_esp32_3pwm, osc_esp32_fullcontrol, nano33IoT_velocity_control, smartstepper_control,esp32_current_control_low_side, stm32_spi_alt_example, esp32_spi_alt_example, B_G431B_ESC1_position_control, Odrive_example
2728

2829
- arduino-boards-fqbn: arduino:sam:arduino_due_x # arduino due - one full example
2930
sketch-names: single_full_control_example.ino
@@ -50,9 +51,13 @@ jobs:
5051
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
5152
sketch-names: bluepill_position_control.ino, stm32_i2c_dual_bus_example.ino, stm32_spi_alt_example.ino
5253

54+
- arduino-boards-fqbn: STMicroelectronics:stm32:Disco:pnum=B_G431B_ESC1 # B-G431-ESC1
55+
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
56+
sketch-names: B_G431B_ESC1_position_control.ino
57+
5358
- arduino-boards-fqbn: STMicroelectronics:stm32:GenF4:pnum=GENERIC_F405RGTX # stm32f405 - odrive
5459
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
55-
sketch-names: odrive_example.ino
60+
sketch-names: Odrive_example.ino
5661

5762
- arduino-boards-fqbn: STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_F411RE # nucleo one full example
5863
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Therefore this is an attempt to:
1818
- See also [@byDagor](https://github.com/byDagor)'s *fully-integrated* ESP32 based board: [Dagor Brushless Controller](https://github.com/byDagor/Dagor-Brushless-Controller)
1919

2020

21-
>
2221
> NEXT RELEASE 📢: <span class="simple">Simple<span class="foc">FOC</span>library</span> v2.2.2
2322
> - GenericCurrentSense bugfix and testing
2423
> - Odrive example code see `examples/hardware_specific/odrive_example`

examples/hardware_specific_examples/B_G431B_ESC1/B_G431B_ESC1.ino

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,22 @@
66

77
// Motor instance
88
BLDCMotor motor = BLDCMotor(11);
9-
BLDCDriver6PWM driver = BLDCDriver6PWM(PHASE_UH, PHASE_UL, PHASE_VH, PHASE_VL, PHASE_WH, PHASE_WL);
10-
LowsideCurrentSense currentSense = LowsideCurrentSense(0.003, -64.0/7.0, OP1_OUT, OP2_OUT, OP3_OUT);
9+
BLDCDriver6PWM driver = BLDCDriver6PWM(A_PHASE_UH, A_PHASE_UL, A_PHASE_VH, A_PHASE_VL, A_PHASE_WH, A_PHASE_WL);
10+
LowsideCurrentSense currentSense = LowsideCurrentSense(0.003, -64.0/7.0, A_OP1_OUT, A_OP2_OUT, A_OP3_OUT);
1111

1212

1313
// encoder instance
14-
Encoder encoder = Encoder(HALL2, HALL3, 2048, HALL1);
14+
Encoder encoder = Encoder(A_HALL2, A_HALL3, 2048, A_HALL1);
1515

1616
// Interrupt routine intialisation
1717
// channel A and B callbacks
1818
void doA(){encoder.handleA();}
1919
void doB(){encoder.handleB();}
2020
void doIndex(){encoder.handleIndex();}
2121

22-
// angle set point variable
23-
float target_angle = 0;
2422
// instantiate the commander
2523
Commander command = Commander(Serial);
26-
void doTarget(char* cmd) { command.scalar(&target_angle, cmd); }
24+
void doTarget(char* cmd) { command.motion(&motor, cmd); }
2725

2826
void setup() {
2927

@@ -96,14 +94,11 @@ void setup() {
9694
_delay(1000);
9795
}
9896

99-
// angle set point variable
100-
float target_angle = 0;
101-
10297
void loop() {
10398
// main FOC algorithm function
10499

105100
// Motion control function
106-
motor.move(target_angle);
101+
motor.move();
107102

108103
// function intended to be used with serial plotter to monitor motor variables
109104
// significantly slowing the execution down!!!!

examples/hardware_specific_examples/odrive_example/odrive_example.ino

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
#define M1_INL_B PB0
3232
#define M1_INL_C PB1
3333
// M0 currnets
34-
#define M0_IB PC2
35-
#define M0_IC PC3
34+
#define M1_IB PC2
35+
#define M1_IC PC3
3636
// Odrive M1 encoder pinout
3737
#define M1_ENC_A PB6
3838
#define M1_ENC_B PB7
@@ -78,7 +78,6 @@ void setup(){
7878
// control loop type and torque mode
7979
motor.torque_controller = TorqueControlType::voltage;
8080
motor.controller = MotionControlType::torque;
81-
motor.voltage_sensor_align = 0.5;
8281

8382
// max voltage allowed for motion control
8483
motor.voltage_limit = 8.0;

src/current_sense/hardware_specific/esp32_ledc_mcu.cpp renamed to src/current_sense/hardware_specific/esp32/esp32_ledc_mcu.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include "../hardware_api.h"
2-
#include "../../drivers/hardware_api.h"
1+
#include "../../hardware_api.h"
2+
#include "../../../drivers/hardware_api.h"
33

44
#if defined(ESP_H) && defined(ARDUINO_ARCH_ESP32) && !defined(SOC_MCPWM_SUPPORTED)
55

src/current_sense/hardware_specific/esp32_mcu.cpp renamed to src/current_sense/hardware_specific/esp32/esp32_mcu.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include "../hardware_api.h"
2-
#include "../../drivers/hardware_api.h"
3-
#include "../../drivers/hardware_specific/esp32_driver_mcpwm.h"
1+
#include "../../hardware_api.h"
2+
#include "../../../drivers/hardware_api.h"
3+
#include "../../../drivers/hardware_specific/esp32_driver_mcpwm.h"
44

55
#if defined(ESP_H) && defined(ARDUINO_ARCH_ESP32) && defined(SOC_MCPWM_SUPPORTED)
66

src/current_sense/hardware_specific/samd21_mcu.cpp renamed to src/current_sense/hardware_specific/samd/samd21_mcu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifdef _SAMD21_
22

33
#include "samd21_mcu.h"
4-
#include "../hardware_api.h"
4+
#include "../../hardware_api.h"
55

66

77
static bool freeRunning = false;

0 commit comments

Comments
 (0)