Introduction


The purpose of this tutorial is to assist users in configuring a G4 controller for Closed Loop Speed operation. 

The initial steps, which refer to the Open Loop configuration and operation, are identical and necessary for other Closed Loop modes as well. After finishing with the closed loop speed configuration, the user will also learn how to use the Run Tab and Console tab for debugging and for improving the speed response of the system.


For reasons of simplicity, we have used a BLDC motor with Hall sensors, because they are very common for brushless motors' phase commutation. When an encoder is used, a higher resolution of feedback is achieved. There are many different ways to give commands to the motors (USB, RS232, CANOpen, Analog Inputs, Scripting etc) but this article is useful for the initial testing of the motor, using USB and Roborun+ utility. The motor is wired for channel 1.


Tested system :  FBLG2360T + Nidec 089LDA150Q motor of 5 pole pairs w/ Hall sensors and encoder.



First step : Configurations for Open Loop operation


Before jumping to any closed loop operation, it is very important to configure some fundamental parameters that will ensure the successful operation of our system in open loop. This is necessary to later perform motor/sensor setup. The resulting angle table for the Hall sensors, will then be used for the commutation of the motor phases.


The parameters that need to be set for Open Loop operation are the following : 


  1. General -> STO enable : Disabled (If you are using the STO feature and power the STO inputs, choose Enabled)
  2. General -> Molex Input : Hall Sensors 
  3. Motor 1 -> Motor Configuration -> Number of pole pairs : (check motor's datasheet)
  4. Motor 1 -> Motor Configuration -> Sensor Error detection : Strict 
  5. Motor 1 -> Motor Configuration -> Switching Mode : Sinusoidal
  6. Motor 1 -> Motor Configuration -> Reference Seek Power : 10 A (Use the nominal current of the motor) 
  7. Motor 1 -> Motor Configuration -> Sinusoidal Settings -> Sinusoidal Angle Sensor : Hall 
  8. Motor 1 -> Motor Output -> Amps limits -> Amps limit : 30 A (Use the peak motor current) 
  9. Motor 1 -> Motor Output -> Operating Mode : Open Loop
  10. Motor 2 -> Motor Configuration -> Sensor Error Detection : Disabled (If the controller expects signals from the channel 2 sensor inputs, and we use only channel 1, we will get a Motor/Sensor Error)




Second Step : Perform Motor/Sensor setup 


Go to the Diagnostics tab, and in the plot panel select Log Configuration -> Load configuration -> HALL


Now when we start the MSS(Motor sensor setup) process, we will be able to see whether the hall signals are clear and as expected. Usually hall sensors are placed at 120 degrees apart, and generate 6 Hall states (1-6). These states repeat for every pole pair.


Press the Motor/Sensor Setup button. The Hall Status(red) pattern should look like the one below :







Third Step : Motor Characterization (Configuring FOC gains)


Our G4 controllers use Field Oriented Control with cascaded control loops of Position, Speed and Torque to achieve optimal response and performance.  The torque(current control) loop is the first one we should configure, because it is used to regulate the Flux and Quadrature amps Id,Iq. For that we need the motor's inductance values Ld,Lq and Resistance Rs. The simplest way to get them is to allow the controller to automatically calculate them using the Motor Characterization tool. The user will then select a current loop bandwidth which be used to determine the Torque PID gains. 


Note 

The calculated values with the Motor Characterization tool are an estimation of the real ones. If a user has access to the actual R,L parameters of the motor and wants optimal current control, they can skip the estimation phase of Motor Characterization (Phase 1).

Simply configure the motor L, R under Motor configuration -> Sinusoidal settings -> Motor Parameters, and then go directly to Diagnostics -> Motor characterization arrow -> Calculate Gains. The bandwidth selection is described below.




1. Go to Diagnostics tab and press Motor Characterization. Go to phase 1, ensure that the Reference Seek power is the nominal Amps of the motor as configured before, and press Start




2. Wait for the process to finish. It is normal to hear sounds while the process is running. 


3. Once it's done, click next. In phase 2, you are asked to choose a bandwidth of the control. A recommended initial value is  200Hz which is not very aggressive but can yield smooth movement. You can always go back to Motor Characterization -> Calculate gains to change this BW. 

Note that motors with relatively High L(inductance) generally need Lower BW, while motors with Low L need Higher BW.  Application-specific requirements also need to be considered.

Click next after choosing value.


4. The utility will show you the results and the calculated Torque Gains. Press save, which will save these values to the controller. The changes will not appear to Roborun+ configurations unless you press "Load from controller".




Fourth Step :  Run in Open Loop 


Now that the sensor is calibrated, our motor should be able to run in Open Loop. It is generally recommended to do a brief test in Open Loop before switching to the Closed Loop operation modes.


1. Go to Run Tab and configure the chart feed to show : 

  • Motor Command 1
  • Motor Power 1
  • Motor Amps 1
  • Internal Sensor RPM 1
  • Battery Volts
  • Battery Amps 


These values may prove useful to spotting unusual behaviors of the system.


In Open Loop, the controller will only adjust the PWM duty cycle from 0 to 100% according to the motor command. In essence, it just controls the power that is given to the motor, and performs commutation according to the internal sensor(Hall) signals.


For example : 

Motor command 1000 <=> Power 1000 => Duty cycle 100% -> The motor should run close to its nominal speed.


2. Press the PLAY button on the chart. Then slide the bar of channel 1 to fully positive and the fully negative command, and make sure that the reported speed is correct( Internal speed RPM > 0 for Command > 0 and the reverse for negative direction). After finishing the movement, pause the chart and check that everything is looking smooth, without spikes/noise :





Fifth Step : Configurations for Closed Loop Speed


  1. Motor 1 -> Motor Configuration -> Torque Constant kt(Nm/A) : 0.20 (Check motor's datasheet.
  2. Motor 1 -> Motor Configuration -> Closed Loop Feedback Sensor : Internal (Use "Other" when encoder or an SSI sensor is used) 
  3. Motor 1 -> Motor Configuration -> Sinusoidal Settings -> Motor Parameters -> Voltage Constant(Vk - V/kRPM) : 15.17 (Motor datasheet)
  4. Motor 1 -> Motor Configuration -> Sinusoidal Settings -> Mechanical system characteristics -> Intertia J (kg * cm^2) : 6.5 (Motor datasheet)
  5. Motor 1 -> Motor Configuration -> Sinusoidal Settings -> Mechanical system characteristics -> Rotating Friction coefficient B : Unknown (Motor datasheet) 
  6. Motor 1 -> Motor Output -> Speed & Acceleration -> Max Speed (RPM) : 2575
  7. Motor 1 -> Motor Output -> Speed & Acceleration -> Min Speed (RPM) : 0
  8. Motor 1 -> Motor Output -> Speed & Acceleration -> Acceleration(RPM/s) : 1000 (More steep ramp is of course possible, but always keep in mind that the regeneration voltage will increase for high Accel/Decel values.
  9. Motor 1 -> Motor Output -> Speed & Acceleration -> Deceleration (RPM/s) : 1000
  10. Motor 1 -> Motor Output -> Operating Mode -> Closed Loop Speed



Sixth Step : Setting up the PID gains and Run the motor



At this step, we are going to tune the PID gains and then run the motor. This step usually requires some trail and error before achieving a satisfactory result. A good tuning of the PID in general, has the following characteristics :

  • Responsiveness : Reacting to changes on the command fast
  • Minimal overshoot : The overshoot usually happens when the PI gains are too high, so the variable surpasses the desired setpoint. It is acceptable to have overshoot, as long as it is insignificant and cannot cause damage to the system.
  • Stability: The system should not oscillate uncontrollably.
  • Small Steady-State Error : When the speed command has been stable for some time, the measured speed should be very close to the desired one. The integral (Ki) gain is generally responsible for correcting steady state errors.

We don't generally use differential (D) gain unless we expect strong disturbances on the system. 


Knowing these, we start the PI tuning with a small P gain only, and we increase it up to the point where the responsiveness is high and there is a slight overshoot. Remember to save the changed configurations to the controller. For this example we have chosen a P=0.01. This can vary depending on the motor.


Prepare the run tab chart :  We are interested in the following variables, logged every 1 ms in the chart : 



Run the motor :  There are two ways to quickly check our PID tuning :


1. We can use the slide bar as before, which now that we use Closed Loop Speed, will be translated to a speed command.

Example : We slide the bar to +500 , and we have set Max Speed = 3000 RPM.  This command we gave, will be translated as speed command of 1500 RPM (50%)


2. We can send speed command explicitly using the console tabs below the run chart. The syntax is :  "!S [channel] [speed]"

Important : Remember the following things before sending commands explicitly via console : 

 -Mute slider command

 -Disable serial command watchdog : 




Example : !S 1 1500 -> Motor 1 goes to speed 1500

!S 1 0 -> Motor 1 stops



3. Get the resulting response from the chart :

 

We notice 2 things here : 

-There is a slight bump at the low speed command. This is attributed to the hall sensors' low resolution which results in bad driving at low speeds. This is expected.

-There is a steady state error between the desired RPM and the actual RPM. 


Let's see if increasing the P gain only, can give a faster response : 


With P = 0.02 the response was indeed faster and the steady state error smaller, but the results on low speeds are a bit undesirable :




Decrease P gain a bit, and add an integral gain. We shall use P = 0.01 and I= 0.01 : 



This time we got both a fast response and a correction of the steady state error. This is a good initial result. 

Keep in mind that this tuning was performed on the bench, where the motor had no load. Under real circumstances, the behaviour might differ and different gains might be required for optimal performance.