General Information



The purpose of this article is to assist users with the configurations and tuning, in order to drive their motor in Closed Loop Position Count mode, using our G4 products series. In the last chapter, we will describe a method to use console logs to evaluate and improve the system's performance. 


The Closed Loop Count Position mode uses the sensor's reported counts as feedback. Unlike Closed Loop Position Relative mode, the drive is able to receive !PR  or !P commands, to move to relative or absolute counter values respectively. Relative, means additional counts from the current position, while absolute counter value means that the motor will move until the sensor's counter equals that target value. 



NOTE            


Before moving to the Closed Loop Count Position configuration ensure that Open Loop is properly set and validated, as well as Closed Loop Speed operation. 



NOTE 


Ensure that the FOC torque and flux gains have been set by referring to the Motor Controller's User Manual or the Open Loop configurations guide





Cascaded Control Loops 




Our controllers use PID control loops in cascade, as we've seen in the Closed Loop Speed guides. The Position PID controller is the outermost, which commands directly the Speed Controller. 



This indicates the importance of having configured the Torque/FOC gains along with the Speed PID, before configuring the Position. Otherwise power will not flow to the motor. 






Roborun+ Configurations



There are only a few additional configurations to be added, if the Closed Loop Speed has been configured and validated. If these have not been configured, please refer to Closed Loop Speed - G4



1. Motor channel -> Motor Output -> Operating Mode : Closed Loop Counts Position




2.  Motor Channel -> Motor Output -> Closed Loop Parameters -> Position Mode Velocity : This defines how fast the motor will move to reach the desired position.

Note : This speed is reached using the Speed Acceleration & Deceleration ramps, similarly to the Closed Loop Speed Control.  





3. Motor Channel -> Motor Output -> Closed Loop Parameters -> Closed Loop Position :


These are the PID gains for position control. 

Note : More often than not, in this mode, only a KP gain is enough to ensure enough precision of movement, while avoiding position overshoots due to an integral component.




4.  Motor Channel -> Motor Output -> Closed Loop Parameters -> Closed Loop Position -> Velocity FeedForward Gain


This is an added feature of G4 products, allowing to increase the responsiveness of the system, by introducing feedforward terms. What this does essentially, is it propagates a command to the Speed controller before the Position Controller generates a target value based on the error. 









Evaluating performance



When using position control, we want the Feedback to follow the Track as best as possible, and the Speed Feedback to follow the Velocity Demand Value (VDV). By testing these value, we ensure that the Speed and Position control loops work well together to achieve the desired performance. We aim for :  


  • Minimal position overshoots
  • Responsiveness : Reaching the target position fast
  • No instability or large oscillations


For the tests that follow, we have used an 060LDA300 motor + Gearbox 9:1, without load on the motor. Hall + Encoder is used for commutation, and Encoder as Closed Loop Feedback Sensor.



Best practice : Start with only a low P gain for the Position control. Even a small Integral gain usually introduces overshoots. 


Speed KP = 0.05 (Tuned in Closed Loop Speed mode) 

Speed KI = 0.03 (Tuned in Closed Loop Speed mode) 


Position KP = 0.01

Position KI = 0


We use the following stream in console, to stream the VDV, Speed, Track, and Position queries on 1ms repeat rate : 


# c_/?VDV 1_?S 1_?TR 1_?F 1_# 1


Command : !PR 1 500000 


Results :




The position is not reached sufficiently fast, and the target speed (Position Mode Velocity) is not optimally followed by the motor. 




Notice what happens to the curves if we only make the Speed PID gains a bit more aggressive : 


Speed KP = 0.08

Speed KI = 0.07



Result : 


We notice that by tweaking the Speed Controller's PID gains, the target velocity is reached faster and more efficiently. 

If we look at the position and track curves however, we still see a slow response : 





If we make the Position PID a bit more aggressive by increase the P, we will obtain the response we need. 


Position KP = 0.08



The position feedback is still not exactly on top of the track, which is due to the tiny delays of the control algorithm. We can compensate for this using the Velocity Feedforward gain.



Now, let's see how well the track is followed : 



It's following perfectly the ramp. 





Important Note



The above tests were performed without high load the rotor. In systems like AGVs or robots, the tuning parameters will differ. If you face issues like instability, large disturbances, or any undesired results, please contact our support.