Skip to content

Commit 9dbd91a

Browse files
committed
Merge branch 'dev' of github.com:runger1101001/Arduino-FOC into dev
2 parents 49cfd38 + 1c25100 commit 9dbd91a

File tree

37 files changed

+1841
-1043
lines changed

37 files changed

+1841
-1043
lines changed

.github/workflows/arduino.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- arduino-boards-fqbn: arduino:avr:uno # arudino uno - compiling almost all examples
2626
sketch-names: '**.ino'
2727
required-libraries: PciManager
28-
sketches-exclude: teensy4_current_control_low_side, full_control_serial, angle_control, 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, odrive_example_spi, odrive_example_encoder, single_full_control_example, double_full_control_example, stm32_current_control_low_side, open_loop_velocity_6pwm
28+
sketches-exclude: measure_inductance_and_resistance, teensy4_current_control_low_side, full_control_serial, angle_control, 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, odrive_example_spi, odrive_example_encoder, single_full_control_example, double_full_control_example, stm32_current_control_low_side, open_loop_velocity_6pwm
2929

3030
- arduino-boards-fqbn: arduino:sam:arduino_due_x # arduino due - one full example
3131
sketch-names: single_full_control_example.ino

.github/workflows/esp32.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333

3434
- arduino-boards-fqbn: esp32:esp32:esp32c3 # esp32c3
3535
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
36-
sketch-names: esp32_position_control.ino, esp32_i2c_dual_bus_example.ino, stepper_driver_2pwm_standalone.ino, stepper_driver_4pwm_standalone.ino
36+
sketch-names: esp32_position_control.ino, stepper_driver_2pwm_standalone.ino, stepper_driver_4pwm_standalone.ino
3737

3838
- arduino-boards-fqbn: esp32:esp32:esp32doit-devkit-v1 # esp32
3939
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json

examples/hardware_specific_examples/Teensy/Teensy3/open_loop_velocity_6pwm/open_loop_velocity_6pwm.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void setup() {
3838
// limiting motor movements
3939
// limit the voltage to be set to the motor
4040
// start very low for high resistance motors
41-
// currnet = resistance*voltage, so try to be well under 1Amp
41+
// currnet = voltage/resistance, so try to be well under 1Amp
4242
motor.voltage_limit = 3; // [V]
4343

4444
// open loop control config

examples/hardware_specific_examples/Teensy/Teensy4/open_loop_velocity_6pwm/open_loop_velocity_6pwm.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void setup() {
5353
// limiting motor movements
5454
// limit the voltage to be set to the motor
5555
// start very low for high resistance motors
56-
// currnet = resistance*voltage, so try to be well under 1Amp
56+
// currnet = voltage/resistance, so try to be well under 1Amp
5757
motor.voltage_limit = 3; // [V]
5858

5959
// open loop control config

examples/motion_control/open_loop_motor_control/open_loop_position_example/open_loop_position_example.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void setup() {
4646
// limiting motor movements
4747
// limit the voltage to be set to the motor
4848
// start very low for high resistance motors
49-
// currnet = resistance*voltage, so try to be well under 1Amp
49+
// currnet = voltage/resistance, so try to be well under 1Amp
5050
motor.voltage_limit = 3; // [V]
5151
// limit/set the velocity of the transition in between
5252
// target angles
@@ -78,4 +78,4 @@ void loop() {
7878

7979
// user communication
8080
command.run();
81-
}
81+
}

examples/utils/sensor_test/magnetic_sensors/magnetic_sensor_i2c/magnetic_sensor_i2c_dual_bus_examples/esp32_i2c_dual_bus_example/esp32_i2c_dual_bus_example.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <SimpleFOC.h>
2+
#include <Wire.h>
23

34
/** Annoyingly some i2c sensors (e.g. AS5600) have a fixed chip address. This means only one of these devices can be addressed on a single bus
45
* This example shows how a second i2c bus can be used to communicate with a second sensor.
@@ -7,6 +8,8 @@
78
MagneticSensorI2C sensor0 = MagneticSensorI2C(AS5600_I2C);
89
MagneticSensorI2C sensor1 = MagneticSensorI2C(AS5600_I2C);
910

11+
// example of esp32 defining 2nd bus, if not already defined
12+
//TwoWire Wire1(1);
1013

1114
void setup() {
1215

src/common/base_classes/CurrentSense.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class CurrentSense{
3434
FOCDriver* driver = nullptr; //!< driver link
3535
bool initialized = false; // true if current sense was successfully initialized
3636
void* params = 0; //!< pointer to hardware specific parameters of current sensing
37-
DriverType driver_type = DriverType::Unknown; //!< driver type (BLDC or Stepper)
37+
DriverType driver_type = DriverType::UnknownDriver; //!< driver type (BLDC or Stepper)
3838

3939

4040
// ADC measurement gain for each phase

src/common/base_classes/FOCDriver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ enum PhaseState : uint8_t {
1313

1414

1515
enum DriverType{
16-
Unknown=0,
16+
UnknownDriver=0,
1717
BLDC=1,
1818
Stepper=2
1919
};

src/current_sense/hardware_specific/stm32/b_g431/b_g431_mcu.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void* _configureADCLowSide(const void* driver_params, const int pinA,const int p
132132
Stm32CurrentSenseParams* params = new Stm32CurrentSenseParams {
133133
.pins = { pinA, pinB, pinC },
134134
.adc_voltage_conv = (_ADC_VOLTAGE) / (_ADC_RESOLUTION),
135-
.timer_handle = (HardwareTimer *)(HardwareTimer_Handle[get_timer_index(TIM1)]->__this)
135+
.timer_handle = ((STM32DriverParams*)driver_params)->timers_handle[0],
136136
};
137137

138138
return params;
@@ -153,21 +153,21 @@ void* _driverSyncLowSide(void* _driver_params, void* _cs_params){
153153
Stm32CurrentSenseParams* cs_params = (Stm32CurrentSenseParams*)_cs_params;
154154

155155
// stop all the timers for the driver
156-
_stopTimers(driver_params->timers, 6);
156+
stm32_pause(driver_params);
157157

158158
// if timer has repetition counter - it will downsample using it
159159
// and it does not need the software downsample
160-
if( IS_TIM_REPETITION_COUNTER_INSTANCE(cs_params->timer_handle->getHandle()->Instance) ){
160+
if( IS_TIM_REPETITION_COUNTER_INSTANCE(cs_params->timer_handle->Instance) ){
161161
// adjust the initial timer state such that the trigger for DMA transfer aligns with the pwm peaks instead of throughs.
162162
// only necessary for the timers that have repetition counters
163-
cs_params->timer_handle->getHandle()->Instance->CR1 |= TIM_CR1_DIR;
164-
cs_params->timer_handle->getHandle()->Instance->CNT = cs_params->timer_handle->getHandle()->Instance->ARR;
163+
cs_params->timer_handle->Instance->CR1 |= TIM_CR1_DIR;
164+
cs_params->timer_handle->Instance->CNT = cs_params->timer_handle->Instance->ARR;
165165
}
166166
// set the trigger output event
167-
LL_TIM_SetTriggerOutput(cs_params->timer_handle->getHandle()->Instance, LL_TIM_TRGO_UPDATE);
167+
LL_TIM_SetTriggerOutput(cs_params->timer_handle->Instance, LL_TIM_TRGO_UPDATE);
168168

169169
// restart all the timers of the driver
170-
_startTimers(driver_params->timers, 6);
170+
stm32_resume(driver_params);
171171

172172
// return the cs parameters
173173
// successfully initialized

src/current_sense/hardware_specific/stm32/stm32_mcu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ typedef struct Stm32CurrentSenseParams {
1414
int pins[3] = {(int)NOT_SET};
1515
float adc_voltage_conv;
1616
ADC_HandleTypeDef* adc_handle = NP;
17-
HardwareTimer* timer_handle = NP;
17+
TIM_HandleTypeDef* timer_handle = NP;
1818
} Stm32CurrentSenseParams;
1919

2020
#endif

0 commit comments

Comments
 (0)