Skip to content

Commit 5187d53

Browse files
committed
FIX pole pairs memeory problems and overflow fix
1 parent 424aaec commit 5187d53

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

examples/utils/find_pole_pair_number/encoder/find_pole_pairs_number/find_pole_pairs_number.ino

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ void setup() {
4747
Serial.begin(115200);
4848

4949
// pole pairs calculation routine
50-
Serial.println("Motor pole pair number estimation example");
51-
Serial.println("---------------------------------------------\n");
50+
Serial.println("Pole pairs (PP) estimator");
51+
Serial.println("-\n");
5252

5353
float pp_search_voltage = 4; // maximum power_supply_voltage/2
5454
float pp_search_angle = 6*M_PI; // search electrical angle to turn
@@ -77,9 +77,9 @@ void setup() {
7777
// calculate the pole pair number
7878
int pp = round((pp_search_angle)/(angle_end-angle_begin));
7979

80-
Serial.print("Estimated pole pairs number is: ");
80+
Serial.print("Estimated PP : ");
8181
Serial.println(pp);
82-
Serial.println("Electrical angle / Encoder angle = Pole pairs ");
82+
Serial.println("PP = Electrical angle / Encoder angle ");
8383
Serial.print(pp_search_angle*180/M_PI);
8484
Serial.print("/");
8585
Serial.print((angle_end-angle_begin)*180/M_PI);
@@ -90,13 +90,13 @@ void setup() {
9090

9191
// a bit of monitoring the result
9292
if(pp <= 0 ){
93-
Serial.println("Pole pair number cannot be negative");
93+
Serial.println("PP number cannot be negative");
9494
Serial.println(" - Try changing the search_voltage value or motor/encoder configuration.");
9595
return;
9696
}else if(pp > 30){
97-
Serial.println("Pole pair number very high, possible error.");
97+
Serial.println("PP number very high, possible error.");
9898
}else{
99-
Serial.println("If pp is estimated well your motor should turn now!");
99+
Serial.println("If PP is estimated well your motor should turn now!");
100100
Serial.println(" - If it is not moving try to relaunch the program!");
101101
Serial.println(" - You can also try to adjust the target voltage using serial terminal!");
102102
}

examples/utils/find_pole_pair_number/magnetic_sensor/find_pole_pairs_number/find_pole_pairs_number.ino

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ void setup() {
4343
Serial.begin(115200);
4444

4545
// pole pairs calculation routine
46-
Serial.println("Motor pole pair number estimation example");
47-
Serial.println("---------------------------------------------\n");
46+
Serial.println("Pole pairs (PP) estimator");
47+
Serial.println("-\n");
4848

4949
float pp_search_voltage = 4; // maximum power_supply_voltage/2
5050
float pp_search_angle = 6*M_PI; // search electrical angle to turn
@@ -60,6 +60,7 @@ void setup() {
6060
float motor_angle = 0;
6161
while(motor_angle <= pp_search_angle){
6262
motor_angle += 0.01;
63+
sensor.getAngle(); // keep track of the overflow
6364
motor.setPhaseVoltage(pp_search_voltage, motor_angle);
6465
}
6566
_delay(1000);
@@ -73,9 +74,9 @@ void setup() {
7374
// calculate the pole pair number
7475
int pp = round((pp_search_angle)/(angle_end-angle_begin));
7576

76-
Serial.print("Estimated pole pairs number is: ");
77+
Serial.print("Estimated PP : ");
7778
Serial.println(pp);
78-
Serial.println("Electrical angle / Encoder angle = Pole pairs ");
79+
Serial.println("PP = Electrical angle / Encoder angle ");
7980
Serial.print(pp_search_angle*180/M_PI);
8081
Serial.print("/");
8182
Serial.print((angle_end-angle_begin)*180/M_PI);
@@ -86,13 +87,13 @@ void setup() {
8687

8788
// a bit of monitoring the result
8889
if(pp <= 0 ){
89-
Serial.println("Pole pair number cannot be negative");
90+
Serial.println("PP number cannot be negative");
9091
Serial.println(" - Try changing the search_voltage value or motor/sensor configuration.");
9192
return;
9293
}else if(pp > 30){
93-
Serial.println("Pole pair number very high, possible error.");
94+
Serial.println("PP number very high, possible error.");
9495
}else{
95-
Serial.println("If pp is estimated well your motor should turn now!");
96+
Serial.println("If PP is estimated well your motor should turn now!");
9697
Serial.println(" - If it is not moving try to relaunch the program!");
9798
Serial.println(" - You can also try to adjust the target voltage using serial terminal!");
9899
}

0 commit comments

Comments
 (0)