2
2
* Simple example intended to help users find the zero offset and natural direction of the sensor.
3
3
*
4
4
* These values can further be used to avoid motor and sensor alignment procedure.
5
- *
6
- * motor.initFOC(zero_offset, sensor_direction);
5
+ * To use these values add them to the code:");
6
+ * motor.sensor_direction=Direction::CW; // or Direction::CCW
7
+ * motor.zero_electric_angle=1.2345; // use the real value!
7
8
*
8
9
* This will only work for abosolute value sensors - magnetic sensors.
9
10
* Bypassing the alignment procedure is not possible for the encoders and for the current implementation of the Hall sensors.
@@ -44,6 +45,9 @@ void setup() {
44
45
// set motion control loop to be used
45
46
motor.controller = MotionControlType::torque;
46
47
48
+ // force direction search - because default is CW
49
+ motor.sensor_direction = Direction::UNKNOWN;
50
+
47
51
// initialize motor
48
52
motor.init ();
49
53
// align sensor and start FOC
@@ -54,9 +58,16 @@ void setup() {
54
58
Serial.println (" Sensor zero offset is:" );
55
59
Serial.println (motor.zero_electric_angle , 4 );
56
60
Serial.println (" Sensor natural direction is: " );
57
- Serial.println (motor.sensor_direction == 1 ? " Direction::CW" : " Direction::CCW" );
61
+ Serial.println (motor.sensor_direction == Direction::CW ? " Direction::CW" : " Direction::CCW" );
62
+
63
+ Serial.println (" To use these values add them to the code:" );
64
+ Serial.print (" motor.sensor_direction=" );
65
+ Serial.print (motor.sensor_direction == Direction::CW ? " Direction::CW" : " Direction::CCW" );
66
+ Serial.println (" ;" );
67
+ Serial.print (" motor.zero_electric_angle=" );
68
+ Serial.print (motor.zero_electric_angle , 4 );
69
+ Serial.println (" ;" );
58
70
59
- Serial.println (" To use these values provide them to the: motor.initFOC(offset, direction)" );
60
71
_delay (1000 );
61
72
Serial.println (" If motor is not moving the alignment procedure was not successfull!!" );
62
73
}
0 commit comments