General Information
The purpose of this article is to give step by step instructions for the configuration of the Closed Loop Speed mode and to explain how this mode works, along with some new features that exist only for G4 products (current decoupling, Acceleration feedforward terms)
The Closed Loop Speed mode uses the sensor’s reported speed as feedback. When the actual speed of the motor (feedback) differs from the desired setpoint, the PID controller is responsible for correcting that error by commanding the Torque(current) PID controller. This is due to the cascaded control modes architecture.
Cascaded control modes
RoboteQ controllers (firmware 2.1 and newer) use three control loops that work in cascade to drive the motor. This operation has the advantage that more than one variables are being controlled at the same time (speed, voltage, current), ensuring the controller operates within safe limits under all conditions. In this structure, the Position Loop drives the Speed Loop and the Speed Loop in turn drives the Torque Loop, that is finally providing the PWM voltage to the motor.
How to use this guide
This guide requires that the Open Loop is already set and validated by the user. Then the Closed Loop Speed configuration can be achieved by following the next steps.
NOTE
Before moving to the closed Loop configuration ensure that Open Loop is properly set and validated
NOTE
Ensure that the FOC torque and flux gains have been set by refering to the Motor Controller's User Manual or any relative guide
WARNING
Ensure that the motor speed is reported positive when a positive command is given, otherwise the motor can run uncontrolled when testing Closed Loop,
Configurations in Roborun+
Before configuring the necessary parameters for Closed Loop operation, the user must have configured first the Open Loop parameters. If you haven't done that step, please refer to the Quickstart guides for Open Loop before continuing.
The parameters that need to be set are following :
1. If SSI or Encoder Sensor is used, set the action as feedback and select the channel. The correct sensor resolution should have already been set during the Open Loop configuration.
2. Motor ch -> Motor Configuration -> Closed Loop Feedback Sensor :
Select between "Other" and "Internal Sensor" from the options listed below:
Other: Encoder, SSI
Internal: Hall, Sin/Cos, Resolver, Analog
3. Motor ch -> Motor Output -> Speed & Acceleration -> Max Speed (RPM) :
The maximum speed that the controller is allowed to command. This corresponds to a motor command of +-1000
4. Motor ch -> Motor Output -> Speed & Acceleration -> Min Speed (RPM) :
The minimum speed that the controller is allowed to command. The default value is 0.
5. Motor ch -> Motor Output -> Speed & Acceleration -> Acceleration(RPM/s) and Deceleration(RPM/s):
These parameters se the ramps that are used for applying the speed setpoint.
6. Motor ch -> Motor Output -> Operating Mode :
The operaing mode must be set to Closed Loop Speed.
7. Motor ch -> Motor Output -> Closed Loop Parameters :
The PID parameters need to be set, for the controller to supply power to the motor. The PID gains will work together with the configured FOC torque gains. Some initial values that can be used to drive a motor without load are the following:
P = 0.03
I = 0.03
D = 0
These gains will make the motor follow the desired speed in most of the cases. Further tuning should be done to improve the motor response, and have the same result under all load conditions.
NOTE
Follow the relative Speed PID tuning guide for more information :
PID Tuning - Closed Loop Speed
Besides the mentioned parameters that are essential for the Closed Loop Speed operation, the following optional parameters can be set to enhance the performance of th e motor:
8. (Optional) Motor ch -> Motor Configuration -> Torque constant (Kt) :
This parameter is useful when the user wants to send torque commands in Nm or when the field weakening is intended to be used. Configure this parameter by refering to the motor datasheet.
Note that the current in the denominator is considered as Peak Value, therefore the correct value to configure is Kt = Kt(datasheet) * 0.707
9. (Optional) Motor ch -> Motor Configuration -> Sinusoidal Settings -> Motor Parameters -> Voltage Constant:
This parameter is used for the Decoupling Current control, and it can improve the responsiveness of the system Especially during deceleration.
10. (Optional) Motor ch -> Motor Configuration -> Sinusoidal Settings -> Mechanical system characteristics -> Intertia J (kg * cm^2) and Rotating Friction Coefficient B :
When both parameters are set, the Acceleration Feedforward control will be enabled.
These parameters will be automatically calculated from the automatic PI tuning runs. Alternatively, then they can be set experimentally by considering that inertia coefficient improves the response during acceleration/deceleration and the friction coefficient improves the constant speed error. Both parameters must be set for the feedforword control to be enabled.
Additional Functions
Field Weakening
If a user is interested in operating the motor at higher RPM at the cost of output Torque, the field weakening method is used. The Q-axis current (Iq) will be reduced in order to allow higher current in the D-axis (Id) and thus higher back-EMF. The following diagram shows how Field Weakening works, in Constant Power region:
The parameters that need to be configured are the following :
By setting the field weakening voltage ratio with values < 100%, the field weakening
control is automatically enabled for all closed loop modes including FOC torque, flux,
and speed gains (no additional Enable/Disable input command required). Disabling can be done
by setting field weakening voltage ratio at 100 %. Default values for field weakening
voltage ratio is 100%, meaning that field weakening control is by default OFF. Value range
for field weakening voltage ratio is 75% - 100%. Typical field weakening voltage ratio values
should be around 90-97 %, depending on the application.
Acceleration Feedforward Control
The diagram below shows how the B (Rotating Friction) and J (inertia) parameters affect the input of the current controller in order to assist during transient states of Acceleration or Deceleration :
These parameters could be automatically calculated from the Motor Sensor and Tuning
setup wizard(under development), supported in Roborun+ v3.0 utility (see Roborun+ Utility User Manual for
more details).
By setting both the above parameters with values higher than 0, the acceleration
feedforward control is automatically enabled for speed control and position control
modes when speed gains are used. Disabling can be done by zeroing the mechanical
system inertia or friction coefficient. Default values for mechanical system inertia/friction
are zero, meaning the acceleration feedforward algorithm is by default OFF.
If the automatic PI tuning is not used, then they can be set experimentally by considering that inertia coefficient improves the response during acceleration/deceleration and the friction coefficient improves the constant speed error. Both parameters must be set for the feedforword control to be enabled.
Decoupling current control(optional)
Decoupling Current Control is a powerful feedforward control technique, running in parallel with the traditional FOC Id and Iq PI regulators, as shown in the following figure. Decoupling control exploits the synchronous motor d-q equivalent circuit steady state equations in order to estimate the required d-q axis voltage, based on the commanded currents, measured speed and motor parameters Ld, Lq and voltage constant. Therefore, this particular technique realizes the high response of speed control system by giving the ability to control the d-axis and q-axis independently.
The parameters that need to be configured for the decoupling current control are the following:
Useful Commands and Queries
In Closed Loop Speed mode, the following commands can prove useful for scripting, testing, or debugging :
Motor Command
Serial : !G [cc] [nn]
Microbasic Script : setCommand(_G, cc , nn),
where cc = Motor Channel and nn = Motor Command value(-1000...+1000).
In Closed Loop Speed, the motor command is translated into speed command according to the Max Speed and Min Speed parameters. For example :
G 1 500 : With Max Speed = 3000 RPM, the motor is commanded to reach 0.5*3000 = 1500 RPM
Speed Command
Serial : !S [cc] [nn]
Microbasic Script : setCommand(_S , cc , nn),
where cc = Motor Channel and nn = Speed Command(Min…Max)
Ramped Command query
Serial : ?RMP [cc]
Microbasic Script : getValue(_RMP , cc)
Ramped command is essentially the motor command which is applied based on the configured Acceleration and Deceleration ramps (RPM/s).
Feedback query
Serial : ?F [cc]
Microbasic Script : getValue(_F , cc)
Feedback in Closed Loop Speed is the sensor's reported speed.
Specific sensor feedback
Use :
?BS [cc] to ask the internal sensor speed
?S [cc] to ask the encoder speed
?SS [cc] to ask the SSI speed
Motor Current query
Serial : ?A [cc]
Microbasic Script : getValue(_A , cc)
Motor current is the refers to the rms current of the motor
Motor Power query query
Serial : ?P [cc]
Microbasic Script : getValue(_P , cc)
Motor power concerns the percentage of the PWM voltage duty cycle (100% is 1000)