PSIM provides the motor identification capability for PMSM motors. It provides a set of code for TI DRV8305 EVM, DRV8312 EVM, and a high‐voltage hardware kit. With small changes, users can adopt
the code to their own motor drive inverter hardware.
With this capability, PSIM provides the easiest way for users to identify motor parameters first and then evaluate the performance of a sensorless motor control algorithm with InstaSPIN (See the
tutorial “Simulation and Code Generation of TI InstaSPIN Using DRV8305 EVM.pdf” for more details).
The core of the InstaSPIN algorithm is a FAST estimator that performs parameter identifications and calculates flux, angle, speed, and torque based on motor phase voltages and currents and dc
bus voltage. The FAST block is illustrated below.
Motor identification is a feature of InstaSPIN that allows identification of parameters for sensorless control. This feature enables users to run their motor to its highest performance even when motor parameters are unknown. A side benefit of the InstaSPIN motor identification is that it also provides controller design of inner current loop and outer speed loop PI controllers, and with these controller parameters, the motor drive system is ready to run.
The code provided in PSIM is largely based on TI’s Motorware InstaSPIN Lab2a. The difference is that, in PSIM’s code, parameters needed for motor identification and InstaSPIN are conveniently
grouped in a parameter file, and the parameter file can be easily recreated and updated using PSIM’s InstaSPIN Parameter Editor (under the Utilities menu). This makes it easier to adopt the
code for different operating conditions or power converter hardware.
When using the code for different hardware, one should compare the control hardware with the control hardware of the sample code in terms of the DSP peripherals (for example, ADC and PWM
channels). If the DSP peripherals are used in the same way, no change is needed to the code, and one needs to update the parameter file only. If DSP peripherals are configured differently, the
code needs to be changed to match the control hardware.
Note that, at the moment, the code is for parameter identification is for surface‐mounted PMSM (SPM) only (where Ld = Lq). It is not for internal PMSM (IPM) (where Ld and Lq are different) or any other types of motors.
The following motor identification examples and code are provided in PSIM:
For further information on TI DRV8305, DRV8312, and High‐Voltage Kit, please refer to relevant TI documents.
This tutorial describes how to use PSIM’s InstaSPIN Parameter Editor and the motor identification code and examples to obtain motor parameters with the DRV8305 EVM hardware. The procedure
for other hardware is similar. In this tutorial, the DRV8305 example files are copied to a new folder “C:\New folder\PSIM Project\InstaSPIN\Drv8305InstaSpinMotorID”.
There are four steps to identify motor parameters with PSIM and motor drive hardware.
Motor parameters:
Voltage/current sensing offsets:
PI Controller parameters:
There are many parameters that need to be defined and calculated for motor identification with InstaSPIN, based on inverter operating conditions and how voltages and currents are sensed. To ease the process of preparing the parameter file, PSIM provides a tool called InstaSPIN Parameter Editor to help users quickly generate the required “InstaSPIN_params_MotorID.h” file.
To generate the InstaSPIN parameter file “InstaSPIN_params_MotorID.h” for motor identification, in PSIM, go to Utilities >> InstaSPIN Parameter Editor. The dialog window is shown below. For more information on how to use the Parameter Editor, click on the Help button.
The entry of the InstaSPIN Parameter Editor can be saved to a text file for later use. Sample files are provided in the “examples\SimCoder\F2806x Target” folder for the following hardware setup:
To create the parameter file from an entry saved previously, click on the Load button and load the file into the InstaSPIN Parameter Editor. Then check the “Motor Identification” box, and click on the Generate button.
The dialog window below shows the entry for the motor identification with TI DRV8305 EVM. The dialog window is divided into several sections, and they are explained below.
For the Motor section:
This section defines the motor type and motor parameters. Two types of motors can be defined: BLDC/PMSM (including IPM and SPM), and induction motor. But for motor identification, only BLDC/PMSM can be selected. For the PMSM motor identification with DRV8305 EVM, the following parameters are defined:
BLDC/PMSM box checked
Back emf Coefficient Ke: disabled (need to identify)
Stator Resistance Rs: disabled (need to identify)
d‐axis Inductance Ls_d: disabled (need to identify)
q‐axis Inductance Ls_q: disabled (need to identify)
Number of Poles: 8
Motor Max. Current 5A
Motor Max. RPM: 11000 rpm
For the Inverter section:
This section defines the maximum dc bus voltage that can occur during the operation and inverter PWM switching frequency. For DRV8305 EVM, the following are defined:
DC Bus Voltage: 24 V
Switching Frequency (kHz): 15 kHz
For the DC Voltage Sensing section:
This section defines how the dc bus voltage is sensed. There are two ways to sense the voltage: either Voltage Divider or User Defined. With Voltage Divider, divider resistances need to be specified. With User Defined, the dc sensing gain is defined directly. For DRV8305 EVM, it uses a voltage divider, and based on the DRV8305 EVM schematic, the resistances are:
Divider box checked
Resistance R1: 62k Ohm
Resistance R2: 4.99k Ohm
For the AC Voltage Sensing section:
This section defines how ac voltages are sensed. There are two ways to sense the voltage: either RC Circuit or User Defined. With RC Circuit, resistances R1 and R2 and capacitance C1 need to be
specified. With User Defined, the ac voltage sensing filter cut‐off frequency is defined directly. For DRV8305 EVM, it uses a RC circuit, and based on the DRV8305 EVM schematic, the values are:
RC Circuit box checked
Resistance R1: 62k Ohm
Resistance R2: 4.99k Ohm
Capacitance C1: 0.1u F
For the AC Current Sensing section:
This section defines how ac currents are sensed. There are three choices: either User Defined, or DRV8305 EVM, or DRV8312 EVM.
For User Defined, the shunt resistance and current gain are defined. Note that when the shunt resistance is not 0, it is assumed that the current is measured through the shunt resistance, and
the overall gain is equal to the shunt resistance multiplied by the current gain entered. If the shunt resistance is 0, it is assumed that the current is measured through a hall effect sensor, and the
overall gain is the same as the current gain entered.
For DRV8305 EVM, the op. amp. the circuit that it uses is fixed, but the reference can be changed through the Reference Divider k, and the gain can be changed through the resistance Rgain. Both can be set through SPI commands.
For DRV8312 EVM, the op. amp. the circuit that it uses is fixed, and the current gain is 19.1.
For this example, we will use the default settings of the DRV8305 EVM. Based on the DRV8305 EVM schematic, the values are:
DRV8305 EVM box checked
Reference Divider k: 2
Resistance Rgain: 50k Ohm
For the DSP Control section:
This section defines the parameters related to DSP and InstaSPIN settings. The following parameters are defined:
DSP Frequency (MHz): 90 MHz
No. of PWM Periods Per Interrupt: 1
Ratio of InstaSPIN vs. ISR Rate: 1
Ratio of InstaSPIN vs. Current Loop Rate: 1
Ratio of InstaSPIN vs. Estimator Rate: 1
For more information on the parameter definition, refer to the Help page.
For the InstaSPIN Parameters section:
This section defines InstaSPIN parameters that can be set directly. They are used for motor identification. For this example, the parameters are defined as:
USER_MAX_VS_MAG_PU: 0.5
USER_R_OVER_L_EST_FREQ_Hz 300
USER_MOTOR_RES_EST_CURRENT 1.0
USER_MOTOR_IND_EST_CURRENT ‐1.0
USER_MOTOR_FLUX_EST_FREQ_Hz 20
USER_MAX_ACCEL_EST_Hzps 2
For more information on the parameter definition, refer to the Help page.
Once the above data are entered into their respective fields, click on the Save button to save the data to a text file for later retrieval using the Load button. To generate the InstaSPIN parameter file for
PSIM, click on the Generate button and save the file “InstaSPIN_params_MotorID.h” to the same location as the rest of the code, as shown below.
The generated InstaSPIN parameter file is shown below. For easy inspection, the parameters are divided into 4 sections: commonly changed parameters, rarely changed parameters, constants, and derived parameters.
TI Code Composer Studio v6.1 is used to show how to load and run the motor identification code.
Launch CCS v6.1. Go to Project >> Import CCS projects. The dialog window is shown below. Click on Browse… to go to “C:\New folder\Psim Project\InstaSPIN\Drv8305InstaSpinMotorID” and check the “DRV8305MotorID” project. Then click on Finish to start importing.
The CCS Project Explorer will appear as shown below.
Before loading the code to the DRV8305 EVM, we need to create a target configuration for the DSP. Select View >> Target Configurations. Right-click on “User Defined” in the Target Configuration dialog. A dialog window will appear as shown below.
Select New Target Configuration in the pop‐up menu. A dialog will appear as shown below.
Change the file name to F28069.ccxml, then click on Finish. A dialog named “F28069.ccxml” will appear as shown in the figure below. In the “Connection” box, choose “Texas Instruments XDS100v2 USB Debug Probe” or a choice that matches your hardware, then check “TMS320F28069” in the list box of “Board or Device”. Click on Save to save the configuration.
Back to the “Target Configurations” dialog, right-click on the “F28069.ccxml” configuration, and select “Set as Default” as shown in the figure below.
To compile the project, right-click on the project name “Drv8305MotorID” in the Project Explorer, and then click on Build Project in the menu. Or click on the project name in the Project Explorer to
select it as the current project (the project name changes to bold). Select Project >> Build to build the project or Project >> Rebuild All to rebuild the whole project. After the compiling is complete,
CCS will display the following messages in the figure below:
When the output file “Drv8305MotorID.out” is generated, it is ready to be loaded onto DSP.
Before running the generated code on the DRV8305 EVM board, one has to set up the DRV8305 EVM and F28069M LaunchPad according to the following procedure:
To load the program into DSP, click on the project “Drv8305MotorID” to set it as the current project (the current project name will appear in bold). Then select Run >> Debug to connect the computer to the DSP. If the connection is successful, the program will be uploaded to the DSP, and the F28069 DSP will automatically reset and run to the start place of the main function as shown below.
To run the DSP program in CCS, click on “Enable Silicon Real‐time Mode” to enable the real‐time mode, then click on “Resume” on the toolbar as shown below.
If the Scripting Console is not displayed in CCS, go to View >> Scripting Console to display the Scripting Console window. In the Scripting Console window, click on the “Open file” icon, and load and run the script file “MotorID.js” as shown below.
After the script runs, a list of motor identification variables will be displayed in the CCS watch window as shown below.
Click on the “Continuous Refresh” icon. Set the values of the flags gMotorVars.Flag_enableSys and gMotorVars.Flag_Run_Identify to 1 as shown below.
Then the motor identification process will start. During the motor identification process, monitor the controller state gMotorVars.CtrlState and the estimator state gMotorVars.EstState . They will change from one state to another in the following way:
The complete process will last around 90 seconds.
Once the motor parameter identification process is completed, one can obtain the motor parameters, hardware offset parameters, and control loop PID parameters from CCS’s watch window as shown below.
Motor Parameters:
Motor parameters obtained from CCS are:
gMotorVars.Rs_Ohm = 0.3814004
gMotorVars.Lsd_H = 0.0006486884
gMotorVars.Lsq_H = 0.0006486884
gMotorVars.Flux_VpHz = 0.03385419
Voltage/Current Offset Parameters:
Voltage/current offset parameters obtained from CCS are:
gMotorVars.I_bias.value[0] = 1.000818074
gMotorVars.I_bias.value[1] = 1.001404524
gMotorVars.I_bias.value[2] = 1.001073182
gMotorVars.V_bias.value[0] = 0.4976398945
gMotorVars.V_bias.value[1] = 0.4967572689
gMotorVars.V_bias.value[2] = 0.4971625209
Control Loop Parameters:
Current loop PID controller parameters obtained from CCS are:
controller_obj‐>pid_id.Kp = 2.42086
controller_obj‐>pid_id.Ki = 0.039197
controller_obj‐>pid_id.Kd = 0.0
controller_obj‐>pid_id.Kp = 2.42086
controller_obj‐>pid_id.Ki = 0.039197
controller_obj‐>pid_id.Kd = 0.0
The parameters obtained from the motor identification process can be entered into a PSIM schematic circuit for simulation. Refer to the tutorial “Simulation and Code Generation of TI InstaSPIN Using DRV8305 EVM.pdf” for more details.