Skip to content

Commit 16cfe08

Browse files
committed
FEAT magnetic sensor infinite range, velocity filter, changed PI structure
1 parent 857a540 commit 16cfe08

File tree

19 files changed

+182
-509
lines changed

19 files changed

+182
-509
lines changed

examples/encoder_examples/HMBGC_example/HMBGC_example.ino

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,19 @@ void setup() {
5454

5555
// contoller configuration based on the controll type
5656
// velocity PI controller parameters
57-
// default K=1.0 Ti = 0.003
58-
motor.PI_velocity.K = 0.3;
59-
motor.PI_velocity.Ti = 0.003;
57+
// default P=0.5 I = 10
58+
motor.PI_velocity.P = 0.2;
59+
motor.PI_velocity.I = 20;
6060
//defualt voltage_power_supply/2
6161
motor.PI_velocity.voltage_limit = 6;
6262
// jerk control using voltage voltage ramp
6363
// default value is 300 volts per sec ~ 0.3V per millisecond
64-
motor.PI_velocity.voltage_ramp = 300;
64+
motor.PI_velocity.voltage_ramp = 1000;
65+
66+
// velocity low pass filtering
67+
// default 5ms - try different values to see what is the best.
68+
// the lower the less filtered
69+
motor.LPF_velocity.Tf = 0.01;
6570

6671
// use debugging with serial for motor init
6772
// comment out if not needed

examples/encoder_examples/angle_control/angle_control.ino

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ void setup() {
5555
// index search velocity - default 1rad/s
5656
motor.index_search_velocity = 1;
5757
// index search PI contoller parameters
58-
// default K=0.5 Ti = 0.01
59-
motor.PI_velocity_index_search.K = 0.1;
60-
motor.PI_velocity_index_search.Ti = 0.01;
58+
// default P=1, I=10
59+
motor.PI_velocity_index_search.P = 1;
60+
motor.PI_velocity_index_search.I = 20;
6161
//motor.PI_velocity_index_search.voltage_limit = 3;
6262
// jerk control using voltage voltage ramp
6363
// default value is 100
@@ -72,22 +72,28 @@ void setup() {
7272

7373
// contoller configuration based on the controll type
7474
// velocity PI controller parameters
75-
// default K=1.0 Ti = 0.003
76-
motor.PI_velocity.K = 0.3;
77-
motor.PI_velocity.Ti = 0.003;
75+
// default P=0.5 I = 10
76+
motor.PI_velocity.P = 0.2;
77+
motor.PI_velocity.I = 20;
7878
//defualt voltage_power_supply/2
7979
motor.PI_velocity.voltage_limit = 6;
8080
// jerk control using voltage voltage ramp
8181
// default value is 300 volts per sec ~ 0.3V per millisecond
82-
motor.PI_velocity.voltage_ramp = 300;
82+
motor.PI_velocity.voltage_ramp = 1000;
8383

84+
// velocity low pass filtering
85+
// default 5ms - try different values to see what is the best.
86+
// the lower the less filtered
87+
motor.LPF_velocity.Tf = 0.01;
88+
8489
// angle P controller
85-
// default K=70
86-
motor.P_angle.K = 20;
90+
// default P=20
91+
motor.P_angle.P = 20;
8792
// maximal velocity of the poisiiton control
8893
// default 20
8994
motor.P_angle.velocity_limit = 4;
9095

96+
9197
// use debugging with serial for motor init
9298
// comment out if not needed
9399
motor.useDebugging(Serial);

examples/encoder_examples/change_direction/change_direction.ino

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ void setup() {
4646
// index search velocity - default 1rad/s
4747
motor.index_search_velocity = 1;
4848
// index search PI contoller parameters
49-
// default K=0.5 Ti = 0.01
50-
motor.PI_velocity_index_search.K = 0.1;
51-
motor.PI_velocity_index_search.Ti = 0.01;
49+
// default P=1, I=10
50+
motor.PI_velocity_index_search.P = 1;
51+
motor.PI_velocity_index_search.I = 20;
5252
//motor.PI_velocity_index_search.voltage_limit = 3;
5353
// jerk control using voltage voltage ramp
5454
// default value is 100
5555
motor.PI_velocity_index_search.voltage_ramp = 100;
56-
56+
5757
// set FOC loop to be used
5858
// ControlType::voltage
5959
// ControlType::velocity
@@ -63,15 +63,19 @@ void setup() {
6363

6464
// contoller configuration based on the controll type
6565
// velocity PI controller parameters
66-
// default K=1.0 Ti = 0.003
67-
motor.PI_velocity.K = 0.3;
68-
motor.PI_velocity.Ti = 0.003;
66+
// default P=0.5 I = 10
67+
motor.PI_velocity.P = 0.2;
68+
motor.PI_velocity.I = 20;
6969
//defualt voltage_power_supply/2
7070
motor.PI_velocity.voltage_limit = 6;
7171
// jerk control using voltage voltage ramp
7272
// default value is 300 volts per sec ~ 0.3V per millisecond
73-
motor.PI_velocity.voltage_ramp = 300;
73+
motor.PI_velocity.voltage_ramp = 1000;
7474

75+
// velocity low pass filtering
76+
// default 5ms - try different values to see what is the best.
77+
// the lower the less filtered
78+
motor.LPF_velocity.Tf = 0.01;
7579

7680
// use debugging with serial for motor init
7781
// comment out if not needed

examples/encoder_examples/velocity_control/velocity_control.ino

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ void setup() {
5555
// index search velocity - default 1rad/s
5656
motor.index_search_velocity = 1;
5757
// index search PI contoller parameters
58-
// default K=0.5 Ti = 0.01
59-
motor.PI_velocity_index_search.K = 0.1;
60-
motor.PI_velocity_index_search.Ti = 0.01;
58+
// default P=1, I=10
59+
motor.PI_velocity_index_search.P = 1;
60+
motor.PI_velocity_index_search.I = 20;
6161
//motor.PI_velocity_index_search.voltage_limit = 3;
6262
// jerk control using voltage voltage ramp
6363
// default value is 100
6464
motor.PI_velocity_index_search.voltage_ramp = 100;
65-
65+
6666
// set control loop type to be used
6767
// ControlType::voltage
6868
// ControlType::velocity
@@ -72,15 +72,20 @@ void setup() {
7272

7373
// contoller configuration based on the controll type
7474
// velocity PI controller parameters
75-
// default K=1.0 Ti = 0.003
76-
motor.PI_velocity.K = 0.3;
77-
motor.PI_velocity.Ti = 0.003;
75+
// default P=0.5 I = 10
76+
motor.PI_velocity.P = 0.2;
77+
motor.PI_velocity.I = 20;
7878
//defualt voltage_power_supply/2
7979
motor.PI_velocity.voltage_limit = 6;
8080
// jerk control using voltage voltage ramp
8181
// default value is 300 volts per sec ~ 0.3V per millisecond
82-
motor.PI_velocity.voltage_ramp = 300;
83-
82+
motor.PI_velocity.voltage_ramp = 1000;
83+
84+
// velocity low pass filtering
85+
// default 5ms - try different values to see what is the best.
86+
// the lower the less filtered
87+
motor.LPF_velocity.Tf = 0.01;
88+
8489
// use debugging with serial for motor init
8590
// comment out if not needed
8691
motor.useDebugging(Serial);

examples/encoder_examples/velocity_ultraslow_control/velocity_ultraslow_control.ino

Lines changed: 0 additions & 167 deletions
This file was deleted.

examples/encoder_examples/voltage_control/voltage_control.ino

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#include <SimpleFOC.h>
2-
// software interrupt library
3-
#include <PciManager.h>
4-
#include <PciListenerImp.h>
52

63
// Only pins 2 and 3 are supported
74
#define arduinoInt1 2 // Arduino UNO interrupt 0
@@ -16,16 +13,12 @@ BLDCMotor motor = BLDCMotor(9, 10, 11, 11, 8);
1613
// - encA, encB - encoder A and B pins
1714
// - ppr - impulses per rotation (cpr=ppr*4)
1815
// - index pin - (optional input)
19-
Encoder encoder = Encoder(arduinoInt1, arduinoInt2, 8192, A0);
16+
Encoder encoder = Encoder(arduinoInt1, arduinoInt2, 8192);
2017

2118
// Interrupt rutine intialisation
2219
// channel A and B callbacks
2320
void doA(){encoder.handleA();}
2421
void doB(){encoder.handleB();}
25-
void doIndex(){encoder.handleIndex();}
26-
27-
// If no available hadware interrupt pins use the software interrupt
28-
PciListenerImp listenerIndex(encoder.index_pin, doIndex);
2922

3023
void setup() {
3124
// debugging port
@@ -45,24 +38,11 @@ void setup() {
4538
encoder.init();
4639
// hardware interrupt enable
4740
encoder.enableInterrupts(doA, doB);
48-
// software interrupts
49-
PciManager.registerListener(&listenerIndex);
5041

5142
// power supply voltage
5243
// default 12V
5344
motor.voltage_power_supply = 12;
5445

55-
// index search velocity - default 1rad/s
56-
motor.index_search_velocity = 1;
57-
// index search PI contoller parameters
58-
// default K=0.5 Ti = 0.01
59-
motor.PI_velocity_index_search.K = 0.1;
60-
motor.PI_velocity_index_search.Ti = 0.01;
61-
//motor.PI_velocity_index_search.voltage_limit = 3;
62-
// jerk control using voltage voltage ramp
63-
// default value is 100
64-
motor.PI_velocity_index_search.voltage_ramp = 100;
65-
6646
// set FOC loop to be used
6747
// ControlType::voltage
6848
// ControlType::velocity

0 commit comments

Comments
 (0)