You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/simplefoc_library/code/from_scratch.md
+26-6Lines changed: 26 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -825,7 +825,10 @@ void setup() {
825
825
return;
826
826
}
827
827
// align sensor and start FOC
828
-
motor.initFOC();
828
+
if(!motor.initFOC()){
829
+
Serial.println("FOC init failed!");
830
+
return;
831
+
}
829
832
830
833
// set the initial motor target
831
834
motor.target = 2; // Volts
@@ -913,7 +916,10 @@ void setup() {
913
916
return;
914
917
}
915
918
// align sensor and start FOC
916
-
motor.initFOC();
919
+
if(!motor.initFOC()){
920
+
Serial.println("FOC init failed!");
921
+
return;
922
+
}
917
923
918
924
// set the initial motor target
919
925
motor.target = 2; // Volts
@@ -998,7 +1004,10 @@ void setup() {
998
1004
// initialize motor
999
1005
motor.init();
1000
1006
// align sensor and start FOC
1001
-
motor.initFOC();
1007
+
if(!motor.initFOC()){
1008
+
Serial.println("FOC init failed!");
1009
+
return;
1010
+
}
1002
1011
1003
1012
// set the initial motor target
1004
1013
motor.target = 2; // Volts
@@ -1144,7 +1153,10 @@ void setup() {
1144
1153
return;
1145
1154
}
1146
1155
// align sensor and start FOC
1147
-
motor.initFOC();
1156
+
if(!motor.initFOC()){
1157
+
Serial.println("FOC init failed!");
1158
+
return;
1159
+
}
1148
1160
1149
1161
// set the initial motor target
1150
1162
motor.target = 2; // Volts
@@ -1250,7 +1262,10 @@ void setup() {
1250
1262
return;
1251
1263
}
1252
1264
// align sensor and start FOC
1253
-
motor.initFOC();
1265
+
if(!motor.initFOC()){
1266
+
Serial.println("FOC init failed!");
1267
+
return;
1268
+
}
1254
1269
1255
1270
// set the initial motor target
1256
1271
motor.target = 2; // Volts
@@ -1355,7 +1370,10 @@ void setup() {
1355
1370
return;
1356
1371
}
1357
1372
// align sensor and start FOC
1358
-
motor.initFOC();
1373
+
if(!motor.initFOC()){
1374
+
Serial.println("FOC init failed!");
1375
+
return;
1376
+
}
1359
1377
1360
1378
// set the initial motor target
1361
1379
motor.target = 2; // Volts
@@ -1428,3 +1446,5 @@ Once the current control works well you can proceed to the velocity and angle mo
1428
1446
- To go from the current control to the velocity control you just need to change the `motor.controller` variable to `MotionControlType::velocity` and set the `motor.target` to the desired velocity (in radians per second `RAD/s`).
1429
1447
- To go from the current control to the angle control you just need to change the `motor.controller` variable to `MotionControlType::angle` and set the `motor.target` to the desired angle (in radians `RAD`).
1430
1448
- You can also use the `Commander` interface to transition to the velocity and angle control modes using the `MC1` and `MC2` commands.
1449
+
1450
+
The velocity and angle motion control modes have additional configuration parameters that might be needed to obtain a smooth and stable operation of your motor. You can find more info about these parameters in the [motion control docs](closed_loop_motion_control).
0 commit comments