@@ -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