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
This g-code like interface provides callback to configure and tune any:
19
-
- BLDC or Stepper motor
20
+
-[BLDC or Stepper motor](commander_motor)
20
21
- PID controllers
21
22
- Low pass filters
22
23
- Motion control
@@ -26,9 +27,11 @@ This g-code like interface provides callback to configure and tune any:
26
27
- sensor offsets
27
28
- phase resistance
28
29
- ...
29
-
- PID controllers
30
-
- Low pass filters
31
-
- Or float variables
30
+
-[PID controllers](commander_pid)
31
+
-[Low pass filters](commander_lpf)
32
+
-[Scalar variables](commander_scalar)
33
+
-[Motion control target](commander_target) <b><i>NEW</i>📢</b>
34
+
- Setting target values and limits at once (ex. angle velocity torque)
32
35
33
36
Furthermore commander enables you to easily create your own commands and extend this interface in any way you might need for your particular application.
34
37
@@ -228,339 +231,6 @@ P: some pid
228
231
R: some other motor
229
232
```
230
233
231
-
### PID commands
232
-
When using a standard callback for `PIDController` class:`commander.pid(&pid,cmd)` the user will have available set of possible commands:
233
-
-**P**: PID controller P gain
234
-
-**I**: PID controller I gain
235
-
-**D**: PID controller D gain
236
-
-**R**: PID controller output ramp
237
-
-**L**: PID controller output limit
238
-
239
-
For example if you have a PID controller added to the `commander`:
240
-
```cpp
241
-
PIDController pid = ....
242
-
Commander commander = ...
243
-
244
-
voidonPid(char* cmd){ commander.pid(&pid,cmd); }
245
-
void setup(){
246
-
...
247
-
commander.add('C',onPid,"my pid");
248
-
...
249
-
}
250
-
void loop(){
251
-
...
252
-
commander.run();
253
-
}
254
-
```
255
-
You will be able to configure (set and get) its parameters from serial monitor:
256
-
```sh
257
-
$ CP # get P gain
258
-
P: 1.0
259
-
$ CD0.05 # set D gain
260
-
D: 0.05
261
-
$ CO # unknown command
262
-
err
263
-
$ CL3.25 # set output limit
264
-
limit: 3.25
265
-
```
266
-
267
-
### Low pass filter commands
268
-
When using a standard callback for `LowPassFilter` class:`commander.lpf(&lpf,cmd)` the user will have available a command:
269
-
-**F**: Low pass filter time constant
270
-
271
-
For example if you have a low pass filter added to the `commander`:
You will be able to configure (set and get) its parameters from serial monitor:
288
-
```sh
289
-
$ AF # get time constant
290
-
Tf: 1.0
291
-
$ AF0.05 # set time constant
292
-
Tf: 0.05
293
-
$ AW # unknown command
294
-
err
295
-
```
296
-
### Motor commands
297
-
When using a standard callback for `BLDCMotor` and `StepperMotor` classes:`commander.motor(&motor,cmd)` the user will have available set of possible commands:
298
-
299
-
-**Q** - Q current PID controller & LPF (see [pid](#pid-commands) and [lpf](#low-pass-filter-commands) for commands)
300
-
-**D** - D current PID controller & LPF (see [pid](#pid-commands) and [lpf](#low-pass-filter-commands) for commands)
301
-
-**V** - Velocity PID controller & LPF (see [pid](#pid-commands) and [lpf](#low-pass-filter-commands) for commands)
302
-
-**A** - Angle PID controller & LPF- (see [pid](#pid-commands) and [lpf](#low-pass-filter-commands) for commands)
You will be able to configure (set and get) its parameters from serial monitor:
355
-
```sh
356
-
$ MVP # get PID velocity P gain
357
-
PID vel| P: 0.20
358
-
$ MVP1.2 # set PID velocity P gain
359
-
PID vel| P: 1.20
360
-
$ MAI # get PID angle I gain
361
-
PID angle| I: 0.00
362
-
$ MAF # get LPF angle time constant
363
-
LPF angle| Tf: 0.00
364
-
$ MLV50.4 # set velocity limit
365
-
Limits| vel: 50.4
366
-
$ MLC # get current limit
367
-
Limits| curr: 0.5
368
-
$ MT # get torque control mode
369
-
Torque: volt
370
-
$ MT1 # set torque control mode
371
-
Torque: dc curr
372
-
$ MT2 # set torque control mode
373
-
Torque: foc curr
374
-
$ ME # get motor status enabled/disabled
375
-
Status: 1
376
-
$ MSM # get sensor offset
377
-
Sensor| offset: 0.0
378
-
$ MSM1.2 # set sensor offset
379
-
Sensor| offset: 1.2
380
-
$ MC # get motion control mode
381
-
Motion: torque
382
-
$ MC3 # set motion control mode
383
-
Motion: vel open
384
-
$ MC2 # set motion control mode
385
-
Motion: angle
386
-
$ MCD100 # get motion control downsampling
387
-
Motion: downsample: 100
388
-
$ MMG0 # get variable - target
389
-
Monitor | target: 0.0
390
-
$ MMG1 # get variable - voltage q
391
-
Monitor | Vq: 1.4
392
-
$ MMG6 # get variable - angle
393
-
Monitor | angle: 23.5
394
-
$ MMG6 # get variable - angle
395
-
Monitor | angle: 24.6
396
-
$ MMG6 # get variable - angle
397
-
Monitor | angle: 25.5
398
-
$ M0 # set target
399
-
Target: 0.0
400
-
$ M0.4 # set target
401
-
Target: 0.4
402
-
$ @1 # set verbose mode: on_request
403
-
Verb | on!
404
-
$ MMG6 # get variable - angle
405
-
26.5
406
-
$ MMG5 # get variable - velocity
407
-
2.57
408
-
$ #6 # set 6 decimal places
409
-
Decimal: 6
410
-
$ MMG6 # get variable - angle
411
-
27.732821
412
-
$ @0 # set verbose mode: nothing
413
-
Verb: off!
414
-
$ MMG6 # get variable - angle
415
-
$ MMG6 # get variable - angle
416
-
$ @2 # set verbose mode: user_friendly
417
-
Verb: on!
418
-
$ MMG6 # get variable - angle
419
-
Monitor | angle: 25.532131
420
-
```
421
-
422
-
#### Motor monitoring control commands
423
-
Commander interface enables the user to control the output of the [monitoring](monitoring) functionality. The combination of the two enables user a full control of the motor configuration and tuning as well as full control of variables that are outputted to the user. In order to use his functionality the user needs to enable monitoring for the motor which is really straight-forward:
Finally once the motor is added to the commander interface the use will be able to configure the monitoring with commands:
442
-
- **M** - Monitoring control
443
-
- **D** - downsample monitoring
444
-
- **C** - clear monitor
445
-
- **S** - set monitoring variables
446
-
447
-
Using these commands you can change the downsampling rate (`motor.monitor_downsampling`) of the `monitor()` function that will determine your output sampling frequency. For example if your `loop` time is around 1ms, then with downsampling of monitor function with the rate of 100, it will output the motor variables each 100ms.
448
-
If monitor dowsampling is set to 0 the `monitor()` function is disabled. The same is true if the `motor.monitor_variables` bitmap is empty (equal to `0`). Therefore the command **C** effectively does:
449
-
```cpp
450
-
// when command MC is called
451
-
motor.monitor_variables = 0;
452
-
```
453
-
Finally the command **MS** is used to get/set the `motor.monitor_variables` bitmap.
454
-
455
-
Therefore te communication could look something like this:
456
-
```sh
457
-
$ MMD # get monitor downsampling rate
458
-
Monitor | downsample: 10
459
-
$ MMD1000 # set monitor downsampling rate
460
-
Monitor | downsample: 1000
461
-
$ MMS # get monitor variables
462
-
Monitor | 0000000
463
-
$ MMS1000001 # set monitor variables (target and angle)
464
-
Monitor | 1000001
465
-
1.000 0.999
466
-
1.000 0.985
467
-
1.000 1.064
468
-
.....
469
-
1.000 1.040
470
-
$ MMS0100000 # set monitor variables (voltage q)
471
-
Monitor | 0100000
472
-
1.234
473
-
-0.345
474
-
...
475
-
0.772
476
-
$ MMC # clear monitoring variables
477
-
Monitor | clear
478
-
$ MMS # get monitoring variables
479
-
Monitor | 0000000
480
-
```
481
-
482
-
<blockquoteclass="info"><pclass="heading">📈 Good practice for visualization</p>
483
-
When using monitoring to tune the motion control parameters or just to visualize the different variables it makes sense to disable the commander outputs so that in the serial monitor you only have monitor output. To do that use the mode <codeclass="highlighter-rouge">VerboseMode::nothing</code> of the commander by sending the command <codeclass="highlighter-rouge">@0</code>. See all <ahref="#commander-commands">commander commands</a>.
484
-
</blockquote>
485
-
486
-
487
-
## Example code using the motor commands
488
-
This is one simple example of using motor commands with monitoring in the code. For more examples browse through the library examples, especially through the `examples/utils/communication_tes/commander` folder.
// iterative function setting the outter loop target
555
-
motor.move();
556
-
557
-
// monitoring
558
-
motor.monitor();
559
-
// user communication
560
-
command.run();
561
-
}
562
-
```
563
-
564
234
## *Simple**FOC**Studio* by [@JorgeMaker](https://github.com/JorgeMaker)
565
235
566
236
SimpleFOCStudio is an awesome application built by [@JorgeMaker](https://github.com/JorgeMaker) which we will try to keep up to date with out library. It is a python application that uses commander interface for tunning and configuring the motor.
0 commit comments