Skip to content

Commit ebeea8d

Browse files
committed
FIX better explanation of the usage in the serial terminal
1 parent 97aa77d commit ebeea8d

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

arduino_foc_minimal/arduino_foc_minimal.ino

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// - phA, phB, phC - motor A,B,C phase pwm pins
88
// - pp - pole pair number
99
// - enable pin - (optional input)
10-
BLDCMotor motor = BLDCMotor(9, 10, 11, 14);
10+
BLDCMotor motor = BLDCMotor(9, 10, 11, 11);
1111

1212
// // MagneticSensor(int cs, float _cpr, int _angle_register)
1313
// // cs - SPI chip select pin
@@ -16,14 +16,14 @@ BLDCMotor motor = BLDCMotor(9, 10, 11, 14);
1616
// MagneticSensor AS5x4x = MagneticSensor(10, 16384, 0x3FFF);
1717

1818

19-
Encoder encoder = Encoder(A0, A1, 2048);
19+
Encoder encoder = Encoder(2, 3, 8192);
2020
// interrupt ruotine intialisation
2121
void doA(){encoder.handleA();}
2222
void doB(){encoder.handleB();}
2323

24-
// encoder interrupt init
25-
PciListenerImp listenerA(encoder.pinA, doA);
26-
PciListenerImp listenerB(encoder.pinB, doB);
24+
// // encoder interrupt init
25+
// PciListenerImp listenerA(encoder.pinA, doA);
26+
// PciListenerImp listenerB(encoder.pinB, doB);
2727

2828
void setup() {
2929
// debugging port
@@ -32,11 +32,11 @@ void setup() {
3232
// initialise magnetic sensor hardware
3333
// AS5x4x.init();
3434
encoder.init();
35-
// encoder.enableInterrupts(doA,doB);
35+
encoder.enableInterrupts(doA,doB);
3636

37-
// interrupt intitialisation
38-
PciManager.registerListener(&listenerA);
39-
PciManager.registerListener(&listenerB);
37+
// // interrupt intitialisation
38+
// PciManager.registerListener(&listenerA);
39+
// PciManager.registerListener(&listenerB);
4040

4141
// power supply voltage
4242
// default 12V
@@ -89,6 +89,18 @@ void setup() {
8989
Serial.println("- Type F0.03 to you the LPF_velocity.Tf in 0.03\n");
9090
Serial.println("Check the loop executoion time (average):");
9191
Serial.println("- Type T\n");
92+
Serial.println("Change control loop type by typing:");
93+
Serial.println("- C0 - angle contro");
94+
Serial.println("- C1 - velocity control");
95+
Serial.println("- C2 - voltage control\n");
96+
Serial.println("Initial parameters:");
97+
Serial.print("PI velocity P: ");
98+
Serial.print(motor.PI_velocity.P);
99+
Serial.print(",\t I: ");
100+
Serial.print(motor.PI_velocity.I);
101+
Serial.print(",\t Low passs filter Tf: ");
102+
Serial.println(motor.LPF_velocity.Tf,4);
103+
92104
_delay(1000);
93105

94106
}
@@ -158,23 +170,23 @@ void serialEvent() {
158170
Serial.print(",\t I: ");
159171
Serial.print(motor.PI_velocity.I);
160172
Serial.print(",\t Low passs filter Tf: ");
161-
Serial.println(motor.LPF_velocity.Tf);
173+
Serial.println(motor.LPF_velocity.Tf,4);
162174
}else if(inputString.charAt(0) == 'I'){
163175
motor.PI_velocity.I = inputString.substring(1).toFloat();
164176
Serial.print("PI velocity P: ");
165177
Serial.print(motor.PI_velocity.P);
166178
Serial.print(",\t I: ");
167179
Serial.print(motor.PI_velocity.I);
168180
Serial.print(",\t Low passs filter Tf: ");
169-
Serial.println(motor.LPF_velocity.Tf);
181+
Serial.println(motor.LPF_velocity.Tf,4);
170182
}else if(inputString.charAt(0) == 'F'){
171183
motor.LPF_velocity.Tf = inputString.substring(1).toFloat();
172184
Serial.print("PI velocity P: ");
173185
Serial.print(motor.PI_velocity.P);
174186
Serial.print(",\t I: ");
175187
Serial.print(motor.PI_velocity.I);
176188
Serial.print(",\t Low passs filter Tf: ");
177-
Serial.println(motor.LPF_velocity.Tf);
189+
Serial.println(motor.LPF_velocity.Tf,4);
178190
}else if(inputString.charAt(0) == 'T'){
179191
Serial.print("Average loop time is (microseconds): ");
180192
Serial.println((_micros() - timestamp)/t);

0 commit comments

Comments
 (0)