Skip to content

Commit e3f394f

Browse files
committed
Merge branch 'KaSroka-use_float_consts' into dev
2 parents 2bda51f + dc51797 commit e3f394f

File tree

68 files changed

+873
-842
lines changed

Some content is hidden

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

68 files changed

+873
-842
lines changed

examples/hardware_specific_examples/Bluepill_examples/encoder/bluepill_position_control/bluepill_position_control.ino

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
2-
*
2+
*
33
* STM32 Bluepill position motion control example with encoder
4-
*
4+
*
55
* The same example can be ran with any STM32 board - just make sure that put right pin numbers.
6-
*
6+
*
77
*/
88
#include <SimpleFOC.h>
99

@@ -32,10 +32,10 @@ void doTarget(char* cmd) { command.scalar(&target_angle, cmd); }
3232

3333

3434
void setup() {
35-
35+
3636
// initialize encoder sensor hardware
3737
encoder.init();
38-
encoder.enableInterrupts(doA, doB, doI);
38+
encoder.enableInterrupts(doA, doB, doI);
3939
// link the motor to the sensor
4040
motor.linkSensor(&encoder);
4141

@@ -54,32 +54,32 @@ void setup() {
5454
// set motion control loop to be used
5555
motor.controller = MotionControlType::velocity;
5656

57-
// contoller configuration
57+
// contoller configuration
5858
// default parameters in defaults.h
5959

6060
// velocity PI controller parameters
61-
motor.PID_velocity.P = 0.2;
61+
motor.PID_velocity.P = 0.2f;
6262
motor.PID_velocity.I = 20;
6363
// default voltage_power_supply
6464
motor.voltage_limit = 6;
6565
// jerk control using voltage voltage ramp
6666
// default value is 300 volts per sec ~ 0.3V per millisecond
6767
motor.PID_velocity.output_ramp = 1000;
68-
68+
6969
// velocity low pass filtering time constant
70-
motor.LPF_velocity.Tf = 0.01;
70+
motor.LPF_velocity.Tf = 0.01f;
7171

7272
// angle P controller
7373
motor.P_angle.P = 20;
7474
// maximal velocity of the position control
7575
motor.velocity_limit = 4;
7676

7777

78-
// use monitoring with serial
78+
// use monitoring with serial
7979
Serial.begin(115200);
8080
// comment out if not needed
8181
motor.useMonitoring(Serial);
82-
82+
8383
// initialize motor
8484
motor.init();
8585
// align encoder and start FOC
@@ -97,7 +97,7 @@ void loop() {
9797
// main FOC algorithm function
9898
// the faster you run this function the better
9999
// Arduino UNO loop ~1kHz
100-
// Bluepill loop ~10kHz
100+
// Bluepill loop ~10kHz
101101
motor.loopFOC();
102102

103103
// Motion control function
@@ -109,7 +109,7 @@ void loop() {
109109
// function intended to be used with serial plotter to monitor motor variables
110110
// significantly slowing the execution down!!!!
111111
// motor.monitor();
112-
112+
113113
// user communication
114114
command.run();
115115
}

examples/hardware_specific_examples/Bluepill_examples/magnetic_sensor/bluepill_position_control/bluepill_position_control.ino

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
2-
*
2+
*
33
* STM32 Bluepill position motion control example with magnetic sensor
4-
*
4+
*
55
* The same example can be ran with any STM32 board - just make sure that put right pin numbers.
6-
*
6+
*
77
*/
88
#include <SimpleFOC.h>
99

@@ -47,37 +47,37 @@ void setup() {
4747
driver.init();
4848
// link the motor and the driver
4949
motor.linkDriver(&driver);
50-
50+
5151
// choose FOC modulation (optional)
5252
motor.foc_modulation = FOCModulationType::SpaceVectorPWM;
5353

5454
// set motion control loop to be used
5555
motor.controller = MotionControlType::angle;
5656

57-
// contoller configuration
57+
// contoller configuration
5858
// default parameters in defaults.h
5959

6060
// velocity PI controller parameters
61-
motor.PID_velocity.P = 0.2;
61+
motor.PID_velocity.P = 0.2f;
6262
motor.PID_velocity.I = 20;
6363
// maximal voltage to be set to the motor
6464
motor.voltage_limit = 6;
65-
65+
6666
// velocity low pass filtering time constant
6767
// the lower the less filtered
68-
motor.LPF_velocity.Tf = 0.01;
68+
motor.LPF_velocity.Tf = 0.01f;
6969

70-
// angle P controller
70+
// angle P controller
7171
motor.P_angle.P = 20;
7272
// maximal velocity of the position control
7373
motor.velocity_limit = 40;
7474

75-
// use monitoring with serial
75+
// use monitoring with serial
7676
Serial.begin(115200);
7777
// comment out if not needed
7878
motor.useMonitoring(Serial);
7979

80-
80+
8181
// initialize motor
8282
motor.init();
8383
// align sensor and start FOC
@@ -99,7 +99,7 @@ void loop() {
9999
// main FOC algorithm function
100100
// the faster you run this function the better
101101
// Arduino UNO loop ~1kHz
102-
// Bluepill loop ~10kHz
102+
// Bluepill loop ~10kHz
103103
motor.loopFOC();
104104

105105
// Motion control function
@@ -112,7 +112,7 @@ void loop() {
112112
// function intended to be used with serial plotter to monitor motor variables
113113
// significantly slowing the execution down!!!!
114114
// motor.monitor();
115-
115+
116116
// user communication
117117
command.run();
118118
}

examples/hardware_specific_examples/DRV8302_driver/3pwm_example/encoder/full_control_serial/full_control_serial.ino

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/**
22
* Comprehensive BLDC motor control example using encoder and the DRV8302 board
3-
*
3+
*
44
* Using serial terminal user can send motor commands and configure the motor and FOC in real-time:
55
* - configure PID controller constants
66
* - change motion control loops
77
* - monitor motor variabels
88
* - set target values
9-
* - check all the configuration values
10-
*
9+
* - check all the configuration values
10+
*
1111
* check the https://docs.simplefoc.com for full list of motor commands
12-
*
12+
*
1313
*/
1414
#include <SimpleFOC.h>
1515

@@ -20,7 +20,7 @@
2020
#define INH_C 11
2121

2222
#define EN_GATE 7
23-
#define M_PWM A1
23+
#define M_PWM A1
2424
#define M_OC A2
2525
#define OC_ADJ A3
2626

@@ -45,7 +45,7 @@ void setup() {
4545

4646
// initialize encoder sensor hardware
4747
encoder.init();
48-
encoder.enableInterrupts(doA, doB);
48+
encoder.enableInterrupts(doA, doB);
4949
// link the motor to the sensor
5050
motor.linkSensor(&encoder);
5151

@@ -76,14 +76,14 @@ void setup() {
7676
// set control loop type to be used
7777
motor.controller = MotionControlType::torque;
7878

79-
// contoller configuration based on the controll type
80-
motor.PID_velocity.P = 0.2;
79+
// contoller configuration based on the controll type
80+
motor.PID_velocity.P = 0.2f;
8181
motor.PID_velocity.I = 20;
8282
// default voltage_power_supply
8383
motor.voltage_limit = 12;
8484

8585
// velocity low pass filtering time constant
86-
motor.LPF_velocity.Tf = 0.01;
86+
motor.LPF_velocity.Tf = 0.01f;
8787

8888
// angle loop controller
8989
motor.P_angle.P = 20;
@@ -111,7 +111,7 @@ void setup() {
111111
Serial.println(F("Run user commands to configure and the motor (find the full command list in docs.simplefoc.com) \n "));
112112
Serial.println(F("Initial motion control loop is voltage loop."));
113113
Serial.println(F("Initial target voltage 2V."));
114-
114+
115115
_delay(1000);
116116
}
117117

examples/hardware_specific_examples/DRV8302_driver/6pwm_example/encoder/full_control_serial/full_control_serial.ino

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/**
22
* Comprehensive BLDC motor control example using encoder and the DRV8302 board
3-
*
3+
*
44
* Using serial terminal user can send motor commands and configure the motor and FOC in real-time:
55
* - configure PID controller constants
66
* - change motion control loops
77
* - monitor motor variabels
88
* - set target values
9-
* - check all the configuration values
10-
*
9+
* - check all the configuration values
10+
*
1111
* check the https://docs.simplefoc.com for full list of motor commands
12-
*
12+
*
1313
*/
1414
#include <SimpleFOC.h>
1515

@@ -23,7 +23,7 @@
2323
#define INL_C 10
2424

2525
#define EN_GATE 7
26-
#define M_PWM A1
26+
#define M_PWM A1
2727
#define M_OC A2
2828
#define OC_ADJ A3
2929

@@ -48,7 +48,7 @@ void setup() {
4848

4949
// initialize encoder sensor hardware
5050
encoder.init();
51-
encoder.enableInterrupts(doA, doB);
51+
encoder.enableInterrupts(doA, doB);
5252
// link the motor to the sensor
5353
motor.linkSensor(&encoder);
5454

@@ -77,14 +77,14 @@ void setup() {
7777
// set control loop type to be used
7878
motor.controller = MotionControlType::torque;
7979

80-
// contoller configuration based on the controll type
81-
motor.PID_velocity.P = 0.2;
80+
// contoller configuration based on the controll type
81+
motor.PID_velocity.P = 0.2f;
8282
motor.PID_velocity.I = 20;
8383
// default voltage_power_supply
8484
motor.voltage_limit = 12;
8585

8686
// velocity low pass filtering time constant
87-
motor.LPF_velocity.Tf = 0.01;
87+
motor.LPF_velocity.Tf = 0.01f;
8888

8989
// angle loop controller
9090
motor.P_angle.P = 20;
@@ -112,7 +112,7 @@ void setup() {
112112
Serial.println(F("Run user commands to configure and the motor (find the full command list in docs.simplefoc.com) \n "));
113113
Serial.println(F("Initial motion control loop is voltage loop."));
114114
Serial.println(F("Initial target voltage 2V."));
115-
115+
116116
_delay(1000);
117117
}
118118

examples/hardware_specific_examples/ESP32/encoder/esp32_position_control/esp32_position_control.ino

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/**
22
* ESP32 position motion control example with encoder
33
*
44
*/
@@ -23,14 +23,14 @@ Commander command = Commander(Serial);
2323
void doTarget(char* cmd) { command.scalar(&target_angle, cmd); }
2424

2525
void setup() {
26-
26+
2727
// initialize encoder sensor hardware
2828
encoder.init();
29-
encoder.enableInterrupts(doA, doB);
29+
encoder.enableInterrupts(doA, doB);
3030

3131
// link the motor to the sensor
3232
motor.linkSensor(&encoder);
33-
33+
3434
// driver config
3535
// power supply voltage [V]
3636
driver.voltage_power_supply = 12;
@@ -46,32 +46,32 @@ void setup() {
4646
// set motion control loop to be used
4747
motor.controller = MotionControlType::velocity;
4848

49-
// contoller configuration
49+
// contoller configuration
5050
// default parameters in defaults.h
5151

5252
// velocity PI controller parameters
53-
motor.PID_velocity.P = 0.2;
53+
motor.PID_velocity.P = 0.2f;
5454
motor.PID_velocity.I = 20;
5555
// default voltage_power_supply
5656
motor.voltage_limit = 6;
5757
// jerk control using voltage voltage ramp
5858
// default value is 300 volts per sec ~ 0.3V per millisecond
5959
motor.PID_velocity.output_ramp = 1000;
60-
60+
6161
// velocity low pass filtering time constant
62-
motor.LPF_velocity.Tf = 0.01;
62+
motor.LPF_velocity.Tf = 0.01f;
6363

6464
// angle P controller
6565
motor.P_angle.P = 20;
6666
// maximal velocity of the position control
6767
motor.velocity_limit = 4;
6868

6969

70-
// use monitoring with serial
70+
// use monitoring with serial
7171
Serial.begin(115200);
7272
// comment out if not needed
7373
motor.useMonitoring(Serial);
74-
74+
7575
// initialize motor
7676
motor.init();
7777
// align encoder and start FOC
@@ -92,7 +92,7 @@ void loop() {
9292
// main FOC algorithm function
9393
// the faster you run this function the better
9494
// Arduino UNO loop ~1kHz
95-
// Bluepill loop ~10kHz
95+
// Bluepill loop ~10kHz
9696
motor.loopFOC();
9797

9898
// Motion control function
@@ -104,7 +104,7 @@ void loop() {
104104
// function intended to be used with serial plotter to monitor motor variables
105105
// significantly slowing the execution down!!!!
106106
// motor.monitor();
107-
107+
108108
// user communication
109109
command.run();
110110
}

0 commit comments

Comments
 (0)