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
To debug control loop exection in the examples we added a funciton `motor_monitor()` which log the motor variables to the serial port. The funciton logs different variables based for differenc control loops.
334
+
```cpp
335
+
// utility function intended to be used with serial plotter to monitor motor variables
336
+
// significantly slowing the execution down!!!!
337
+
voidmotor_monitor() {
338
+
switch (motor.controller) {
339
+
case ControlType::velocity_ultra_slow:
340
+
case ControlType::velocity:
341
+
Serial.print(motor.voltage_q);
342
+
Serial.print("\t");
343
+
Serial.print(motor.shaft_velocity_sp);
344
+
Serial.print("\t");
345
+
Serial.println(motor.shaft_velocity);
346
+
break;
347
+
case ControlType::angle:
348
+
Serial.print(motor.voltage_q);
349
+
Serial.print("\t");
350
+
Serial.print(motor.shaft_angle_sp);
351
+
Serial.print("\t");
352
+
Serial.println(motor.shaft_angle);
353
+
break;
354
+
case ControlType::voltage:
355
+
Serial.print(motor.voltage_q);
356
+
Serial.print("\t");
357
+
Serial.println(motor.shaft_velocity);
358
+
break;
359
+
}
360
+
}
361
+
```
362
+
This is just a template funciton to help you debug and create your own functions in future.
363
+
The funciton accesses the motor variables:
364
+
```cpp
365
+
366
+
classBLDCMotor
367
+
{
368
+
public:
369
+
...
370
+
// current elelctrical angle
371
+
float elctric_angle;
372
+
// current motor angle
373
+
float shaft_angle;
374
+
// current motor velocity
375
+
float shaft_velocity;
376
+
// current target velocity
377
+
float shaft_velocity_sp;
378
+
// current target angle
379
+
float shaft_angle_sp;
380
+
// current voltage u_q set
381
+
float voltage_q;
382
+
...
383
+
}
384
+
```
385
+
Additionally it is possible to use encoder api directly to get the encoder angle and velocity.
386
+
```cpp
387
+
388
+
class Encoder{
389
+
public:
390
+
// shaft velocity getter
391
+
float getVelocity();
392
+
// shaft angle getter
393
+
float getAngle();
394
+
}
395
+
```
396
+
397
+
398
+
326
399
# Future Work Roadmap
327
400
-[ ] Encoder index proper implementation
328
401
-[ ] Timer interrupt execution rather than in the `loop()`
329
-
-[ ] Proper introduction of the **Arudino FOC Shield V1.1**
402
+
-[ ] Proper introduction of the **Arudino FOC Shield V1.2**
330
403
-[ ] Make the library accesible in the Arduino Library Manager
331
404
-[ ] Publish a video utilising the library and the samples
0 commit comments