This guide will describe all the necessary steps to perform the configuration of the Closed Loop by using any of the supported motor sensors. Before that, a brief expanation of the different motor sensors and of the cascaded control modes will be given, as it is essential for the understanding of the Closed Loop mode operation. For a more detailed analysis please refer to the Roboteq Controllers User manual.

Different motor sensors

Brushless controllers use the motor sensors for two different reasons: For the commutation of the rotor (to get the rotor's angle and supply the appropriate current, so the the rotor can rotate) and as feedback sensors (to measure the rotor position or speed and implement the closed loop algorith). The commutation (angle) sensor has been configured during the Open Loop configuration of the motor. Usually the feedback sensor will be the same, but there is the capability to use a different feedback sensor, if the motor is equipped with more than one. In that case, the sensor with the higher resolution should be chossen for the feedback and commutation of the motor.

Cascaded control modes

Roboteq controllers (firmware 2.1 and newer) use three control loops that work cascaded to drive the motor. This has the advantage that more than one parameters are being controlled at the same time and and controller can stay under all conditions at the safe limits. 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. 

So, if the controller operates in Speed mode, the PID algorith will not give directly PWM voltage, but the Current Loop (Torque Mode) will be in between and and the current of the motor will be also regulated and stay at safe levels. The control modes that do not rely to other control modes don't need to be tuned if they are not used. So position mode doesn't need to be tuned if only speed mode is used and Speed mode doesn't need to be tuned when torque mode is used, alhtough in the last case speed loop can be used for optimization. Torque mode should have already be tuned during the Open Loop configuration by setting the FOC gains, so only Speed Loop must be tuned for Speed operation and Speed and Position Loops for Position operation.


Speed mode configuration

To proceed with the closed Loop configuration, the Open Loop configuration first must have beem done. So, please refer to the related quick startup guide or to the Roboteq Controllers User manual and proceed with the Open Loop configuration, if not have done already. One of the Open Loop requirements is to ensure that the motor speed is positive by giving a positive motor command, otherwise the motor will go into runaway when configuring Closed Loop. Check the respective documentation for making such a correction .

 Important notice! Before proceeding with the Closed Loop configuration, ensure that the Open Loop has been properly conifgured. Ensure that the motor speed is positive by giving a positive motor command.

To configure the Closed Loop Speed, follow the next steps:

1. Configure the Closed Loop feedback sensor

This is the sensor that will be used to get the feedback of the Closed Loop mode.



  Other must be selected when Encoder, SSI/SPI or analog/pulse sensors are used for feedback

  Internal Sensor must be selected when Sin/Cos, Resolver or Hall sensors are used for feedback

The Sin/Cos and resolver sensors can be used for feedback only if they are already used as sinusoidal angle sensors and the motor/sensor setup has been performed. 


2. Configure the sensor's resolution (Only for SSI or Encoder sensors)

If encoder or SSI/SPI sensors are used for feedback, then their resolution and the channel that will be used must be set in the I/Os section. 

For Encoder, set the sensor's PPR (pulses per resolution), the channel that the sensor will be used for (motor 1 or motor 2) and set the the sensor's usage as feedback

For SSI sensors, set their resolution, the channel that the sensor will be used for (motor 1 or motor 2) and their usage as feedback. The sensor resolution is equal to (2^number of bits)+1. So 12 bit sensors should be configured as 4096, 14 bit sensors as 16384 etc.

The Sensor's channel and resolution should have been already set in the Open Loop configuration.

3. Configure the analog or pulse input (Only for analog or Pulse sensors)




Because the configuration of these sensors requires some additional parametrization, please consult the official documentation (Roboteq Controllers User Manual) if these sensors are used.

4. Set the Operating Mode to Closed Loop Speed

5. Configure the Max speed, Acceleration and deceleration of the motor



In Closed Loop Speed mode, the controller will drive the motor to the desired speed by following the defined acceleration/deceleration parameters. The trajectory of the motor can be monitored with the "Ramped Command". The motor will not be able to follow any given acceleration under all load conditions, so it is importan to configure these parameters according to what the motor is capable to achieve. 

6. FOC torque and Flux gains must be already enabled

This ation should have been done during the Open Loop configuration, so if these gains have not been set, please refer to the relevant guide or on the Roboteq Controllers User manual.

7. Configure Closed Loop Speed PID gains

In this mode, the controller will regulate the motor power to reach the desired speed, by implenenting a PID algorith. An importan thing to notice is that this PID loop will work cascaded with the Torue Loop, enabled by adding the FOC gains in the Open Loop configuraiton. This will have as a result, the required PID gains to be completely different depending on if the Torque Loop is enabled or not. Previous estimated gains will not give the same results, if the Torque Loop has been enabled or removed afterwards. 

 Important notice! The previous estimated PID gains will not work if the torque loop was not already enabled 

Start by configuring the following PI gains:

Speed Proportional Gain = 0.03

Speed Integral Gain 0.03 = 0.03

At most of the cases, the motor will be able to follow the given command when it is unloaded, by using these gains. The PID tuning of the motor with load will not be analyzed here as it is a separate subject.

8. Configure the CLosed Loop Error detection

Loop error detection will be triggered if the motor will maintain an amount of error for more than the defined time. It can be disabled during the PID tuning, where the response will not be already the optimal. After the tuning process, the motor should be able to reach the given speed quick enough, so the Loop Error will not be triggered. Please note that the error units are not a percentage but actual RPM in the current fw implementation (10, 25 or 50 RPM).

9. Evaluate the speed response at run tab chart

Now the motor speed should be able to follow the given command. The controller will drive the motor to the desired speed by following the configured acceleration and deceleration. The trajectory of the motor can be monitored by the Ramped Command parameterHow close the Feedback is following the Ramped Command depends on the configured PID gains. By increasing the PID gains, the motor speed will change quicker, but there is also the chance of the motor getting unstable. It is a matter of choosing the correct PID gains to have a stable and quick speed response at the same time.

At the run tab ensure that the motor Feedback is following closely the Ramped command and that the Feedback is stable.

Position mode configuration

The position mode must be tuned only after the Torque and Speed Loop have been tuned. This is because as has already mentioned, the Position Loop will work based on Speed and Torque Loops.

1. Change the Operating mode to Closed Loop Count Position

This is the most common position mode, where the feedback will be given in counts of the configured feedback sensor

2. Configured the Closed Loop Position gains

The Speed and Torque (FOC) gains must be left untouched. You can start by using a position gain of 0.1. In most of the cases, the motor will be able to follow the given command with these gains when is unloaded. Here the PID gains will be different depending on the resolution of the sensor, since the provided power will be relevant to the position error. Sensors with higher resolution (more PPR) will require smalled PID gains and sensors with smaller reslution higher.

3. Evaluate the Position response

In position mode, the slide bar is not working. So the desired position must be given with console commands. Use the below command to send an absolute position in feedback sensor counts:

!P cc nn, where cc is the channel and nn is the desired position

By giving a command, you shoud see the rotor moving. The rotor will go from its current position to the commanded. The trajectory of the motor can be monitored by the Track command and the actual position by the Feedback. Because track command and feedback can get high values, it is likely that they cannot be monitored on the chart, so the user must copy the logs and plot them to assess the position response.