@@ -43,8 +43,8 @@ void setup() {
43
43
Serial.begin (115200 );
44
44
45
45
// 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 " );
48
48
49
49
float pp_search_voltage = 4 ; // maximum power_supply_voltage/2
50
50
float pp_search_angle = 6 *M_PI; // search electrical angle to turn
@@ -60,6 +60,7 @@ void setup() {
60
60
float motor_angle = 0 ;
61
61
while (motor_angle <= pp_search_angle){
62
62
motor_angle += 0.01 ;
63
+ sensor.getAngle (); // keep track of the overflow
63
64
motor.setPhaseVoltage (pp_search_voltage, motor_angle);
64
65
}
65
66
_delay (1000 );
@@ -73,9 +74,9 @@ void setup() {
73
74
// calculate the pole pair number
74
75
int pp = round ((pp_search_angle)/(angle_end-angle_begin));
75
76
76
- Serial.print (" Estimated pole pairs number is : " );
77
+ Serial.print (" Estimated PP : " );
77
78
Serial.println (pp);
78
- Serial.println (" Electrical angle / Encoder angle = Pole pairs " );
79
+ Serial.println (" PP = Electrical angle / Encoder angle " );
79
80
Serial.print (pp_search_angle*180 /M_PI);
80
81
Serial.print (" /" );
81
82
Serial.print ((angle_end-angle_begin)*180 /M_PI);
@@ -86,13 +87,13 @@ void setup() {
86
87
87
88
// a bit of monitoring the result
88
89
if (pp <= 0 ){
89
- Serial.println (" Pole pair number cannot be negative" );
90
+ Serial.println (" PP number cannot be negative" );
90
91
Serial.println (" - Try changing the search_voltage value or motor/sensor configuration." );
91
92
return ;
92
93
}else if (pp > 30 ){
93
- Serial.println (" Pole pair number very high, possible error." );
94
+ Serial.println (" PP number very high, possible error." );
94
95
}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!" );
96
97
Serial.println (" - If it is not moving try to relaunch the program!" );
97
98
Serial.println (" - You can also try to adjust the target voltage using serial terminal!" );
98
99
}
0 commit comments