Back to the Gcode Dictionary
M569.5: Closed loop data collection
Collect performance data from a drive whilst in closed loop mode. Can be used alongside the Duet Closed Loop plugin for visualisation. Records back to a CSV file located in the /sys/closed-loop directory, which will be created if it does not exist.
Supported for drivers attached to:
Note: The driver must be configured in closed loop mode (See M569 D parameter).
- Pnn Motor driver number
- F"filename.csv" Filename to write to, optional, defaults to driveraddr_datetime.csv. All files are stored in the sys/closed-loop directory.
- An Mode: 0=record immediately, 1=record when the target position of the motor is next changed (i.e. on next move)
- Rnn Sample rate. Measured in samples per second. If R0 is sent, the board will record as fast as possible.
- Dnn Variable filter. Determines which variables are recorded. See below for a list of available variables and how they are represented.
- Vnn Perform a tuning manoeuvre. Available manoeuvres are identical to those listed in M569.6.
- Snn Number of samples to record. When recording with rate R0, this sample rate is limited depending on the number of variables being recorded. The command will report back the maximum allowable samples if the maximum is exceeded. The maximum allowable samples may differ between board types since it is dependant on the available RAM.
The following variables are available to record:
|Variable Name||Description||Variable ID|
|Raw Encoder Reading||The raw reading that the expansion board has read from the encoder. For a quadrature encoder, this represents the number of pulses received, so may be 4 times the expected CPR.||1|
|Current motor Steps||The current position of the motor measured in the standard unit of 'steps'. Similar to raw encoder reading, but will be standardised across different types of encoders with different CPRs.||2|
|Target Motor Steps||The number of steps that the motor has been commanded to take. This becomes the target signal fed into the PID controller.||4|
|Current Error||The difference between the current motor steps and the target motor steps. Directly used as an input to the PID controller.||8|
|PID Control Signal||The control signal (normalised between -255 and 255 coming from the PID controller.||16|
|PID P Term||The value of the PID controller's P term.||32|
|PID I Term||The value of the PID controller's I term||64|
|PID D Term||The value of the PID controller's D term.||128|
|Step Phase||The current position of the motor's stator, expressed as the proportion of the way through the motor's 4 step cycle. Normalised between 0-4095||256|
|Desired Step Phase||The angle for which current will be applied. For maximal torque, this value will be 25% ahead of step phase, for minimal torque, this value will equal step phase.||512|
|Phase Shift||The difference between the desired step phase and the step phase. Roughly proportional to torque applied.||1024|
|Coil A Current||The current running through coil A, expressed as a proportion of the motor's maximum current normalised between -255 to 255.||2048|
|Coil B Current||The current running through coil B, expressed as a proportion of the motor's maximum current normalised between -255 to 255.||4096|
To record multiple variables, sum the variable IDs and pass the resulting value as the D parameter. For example, to record coil A current (2048) and coil B current (4096), use D6144.
M569.5 P50.0 S500 A0 R0 D6 V64
Record 500 samples (S500) of the current motor steps and target motor steps (D6) of driver 0 attached to board 50 (P50.0) immediately (A0) and as fast as possible (R0) whilst performing a step manoeuvre (V64)
The Duet Closed Loop plugin can be used to generate and run M569.5 commands.