Controllers
4 minute read
In CSP the drive closes every loop, and the two controllers stay off. When the drive runs CSV or CST, Motorcortex closes the outer loops itself: the position controller turns a position error into a velocity or a torque, and the velocity controller turns a velocity error into a torque. This is the cascade for a position setpoint with a drive in CST:
Which controllers to switch on
| Setpoint | Drive mode | Position controller | Velocity controller | Guide |
|---|---|---|---|---|
| Position | CSP | off | off | Position with CSP |
| Position | CSV | on, output velocity | off | Position with CSV |
| Position | CST | on | on | Position with CST |
| Velocity | CSV | off | off | Velocity with CSV |
| Velocity | CST | off | on | Velocity with CST |
| Torque | CST | off | off | Torque with CST |
Inside a controller
Both controllers are the same PID controller. The control error goes through a proportional, an integral and a derivative part; their sum is limited to the output range.
The settings are under actuatorControlLoopNN/positionController/parameter/ and actuatorControlLoopNN/velocityController/parameter/:
| Parameter | What it does | Default |
|---|---|---|
enable |
Switch the controller on | 0 |
proportionalGain |
Output per unit of error | 0 |
integratorGain |
How fast a remaining error builds up output | 0 |
controlIntegrationMin, controlIntegrationMax |
Range of the integral part. At 0, 0 the integral part does nothing, whatever integratorGain is |
0, 0 |
derivativeGain |
Output per unit of error change | 0 |
derivativeFilter |
Smooths the derivative part. At 0 the derivative part does nothing |
10 |
controlOutputMin, controlOutputMax |
Range of the output: rad/s or Nm | -100, 100 |
controlErrorDeadBand |
The integral part ignores errors smaller than this | 0 |
backCalculationGain |
Pulls the integral part back while the output is at its limit | 0 |
The controllers only run while the axis is engaged. To watch one at work, plot input/controlError and output/controllerOutput in Desk; output/integratorOutput and output/derivativeOutput show the parts.
Warning
A wrong gain or a wrong sign makes the axis oscillate or run away. Tune with the axis free to move, a low velocityLimit on the limiter, and a hand on the emergency stop. Start with small gains and raise them in steps.
To find the gains, follow Tune the controllers.
The position controller works on actuatorPositionError, the position target minus the actual position. Its output goes one of two ways, set by actuatorControlLoopNN/positionController/usePositionControlForTorque:
usePositionControlForTorque |
Output | Use with |
|---|---|---|
0 (default) |
A velocity, added to the velocity target | CSV, or CST together with the velocity controller |
1 |
A torque, added to the torque target. The velocity controller’s output is then not used | CST without a velocity loop |
Tune it
Follow Tune the controllers, after the velocity controller if you use it. For the position controller:
controlOutputMinandcontrolOutputMaxare in rad/s or m/s, or in Nm withusePositionControlForTorqueat1.- Watch
actuatorPositionErrorandpositionController/output/controllerOutput.
Compensate for delay
positionController/delayForControlError/numberOfSamplesTarget and numberOfSamplesActual delay the target or the actual by up to 10 cycles before the controller forms the error. Use them when the actual position lags the target by a fixed number of cycles, so that the controller compares values from the same moment.
The velocity controller works on actuatorVelocityError, the velocity target minus the actual velocity. Its output is a torque in Nm, added to the torque target, so it only makes sense when the drive runs CST. The velocity target is the setpoint’s velocity plus the position controller’s output, if that is on.
Tune it
Tune the velocity controller first when you use both: the position loop can only be as good as the velocity loop inside it. Follow Tune the controllers. For the velocity controller:
controlOutputMinandcontrolOutputMaxare the torque the motor may deliver, in Nm at the load.- Watch
actuatorVelocityErrorandvelocityController/output/controllerOutput.
Info
Older configurations set positionController/Enable and velocityController/Enable. The control loop does not read these: switch a controller on with parameter/enable.
Next: Step 4: set up the mechanism.