![]() |
Demo program for PMSM Electric Motor IP Core.
The Usage() function shows how to execute the test program, options available and default values set for different configuration variables. The Variables section specifies variables used in the test program, what they specify, the values it holds and can take. The main() function specifies sequence of api calls executed and tested.
Functions | |
void | PMSMElectricMotorUsage () |
int | main (int argc, char *argv[]) |
void | Display_channels () |
Variables | |
uint | enable =1 |
enable mode bit for the PMSM Electric Motor IP Core. Toggling the enable signal will cause the registers to revert to default power-on states. It takes values 0 or 1 and defaults to 1 | |
uint | activate =0 |
output enable for the PMSM Electric PMSM Electric Motor IP Core. Enable this after configuring the registers associated with api calls starting with C. It takes values 0 or 1 and defaults to 0 | |
fpgawb_ipcore_pmsm_electric_motor_config_t | config |
fpgawb_ipcore_pmsm_electric_motor_config_t struct passed as argument for configuring static internal registers api call. Check fpgawb_lib.h or api call documentation for more information | |
double | tload =2 |
tload is the load attached to the PMSM Rotor in Newton Meter. | |
double | resistance =1 |
This is the resistance of the stator windings in the PMSM Model. | |
double | ld =16.5 |
ld is the Direct Inductance in the stator of the PMSM Model. | |
double | lq =18.7 |
lq is the Quadrature Inductance in the stator of the PMSM Model. | |
double | lambda_af =0.2041 |
Magnetic flux in Webers linking the stator windings of the PMSM Model. | |
double | inertia =0.0170 |
Inertia of the PMSM Model. | |
double | number_of_pole_pairs =2 |
Number of pole pairs in the PMSM Model. | |
double | bfriction =0 |
bfriction in the PMSM Model. | |
uint | config_mode =0 |
Configuration mode for the test program. Indicates to run the program in static configure mode or dynamic mode. It takes values 0-Configuring internal registers/1-Changing tload on the fly. It defaults to 0. | |
fpgawb_ipcore_t | ip_core |
fpgawb_ipcore_t struct which stores useful information about the IP Core after executing get IP Info api call. Check fpgawb_lib.h or api call documentation for more information | |
uint | interpolation_point =0 |
Interpolatation point takes an integer value which indicates number of points to be interpolated in the LD/LQ matrix. It defaults to 0. | |
uint | mode_bit = 0 |
It indicates the PMSM Type. 0-Fixed LD/LQ and 1-Var LD/LQ. It defaults to 0. | |
void Display_channels | ( | ) |
Step 9: SEIZE MSGDMA
ccrtNGFC_MsgDma_Seize(handle)
Seizes the MsgDma for data transfer
Step 10: MSGDMA INITIALIZE
fpgawb_ip_core_MsgDma_Initialize(handle,CCRTNGFC_IPCODE_MASK_MOTOR)
This call initializes Modular Scatter-Gather DMA for the selected IP Cores specified using the _ccrtngfc_ipcode_mask_t mask. The api call calculates and allocates physical memory for the DMA transfer and configures the DMA Descriptors
Step 11: MSGDMA FIRE
fpgawb_ip_core_MsgDma_Fire(handle)
This call commences the MsgDma transfer
Step 12: READ DATA USING MSGDMA
fpgawb_PMSM_Get_Info(handle, &info)
Returns currents iab ibc and ica, torque, omega_e, theta, ld, lq, id, iq, magnitude, phase of the Motor
Step 13: RELEASE MSGDMA
ccrtNGFC_MsgDma_Release(handle)
This call releases the seized MsgDma. Release the MsgDma once done with the transfer
int main | ( | int | argc, |
char * | argv[] | ||
) |
Step 1: OPEN DEVICE
ccrtNGFC_Open(&handle,board_no,oflags)
Before using any API calls, the user needs to open the device and get a handle. This handle is then used as the first argument in most of the following APIs.
Step 2: GET DRIVER INFO
ccrtNGFC_Get_Driver_Info(handle, &binfo)
This call returns useful driver information and saves in the ccrtngfc_driver_info_t structure for later use.
Step 3: GET LIBRARY INFO
ccrtNGFC_Get_Library_Info(handle, &linfo)
This call returns useful library information and saves in the ccrtngfc_library_info_t structure for later use.
Step 4: GET IP INFO
fpgawb_PMSM_Get_Ip_Info(handle, &ip_core)
This call returns useful IP Core information and saves in the fpgawb_ipcore_t structure for later use
Step 5: ACTIVATE MOTOR
fpgawb_PMSM_Activate(handle,enable,activate)
This call activates the PMSM Electric Motor IP Core. Note to set enable to 1 to start configuring the PMSM Electric Motor IP Core.
Step 6: CONFIGURE INTERNAL STATIC REGISTERS
C_fpgawb_PMSM_Configure(handle,&config)
This call configures internal static registers including resistance, ld, lq, lambda_af, inertia, number_of_pole_pairs, bfriction, ld/lq, lq/ld 1/ld, 1/lq and sampling frequency inverted for the PMSM Electric Motor IP Core.
Step 7: ACTIVATE MOTOR
fpgawb_PMSM_Activate(handle,enable,activate)
This call activates the PMSM Electric Motor IP Core. Note to set the activate to 1 to start running the PMSM Electric Motor IP Core.
Step 8: SET TLOAD
fpgawb_PMSM_Set_Load(handle,tload)
This call configures the load that is attached to the PMSM Rotor.
Step 14: CLOSE DEVICE
ccrtNGFC_Close(handle)
Closes the device with the handle
void PMSMElectricMotorUsage | ( | ) |
Usage:
./fpgawb_ipcore_pmsm [-A Activate] [-b Board] [-C Config Mode] [-d DirectInductance] [-e Enable] [-f BFriction] [-F RTTFileName] [-l LambdaAf/MagneticFlux] [-i InertiaJa] [-I InductanceFileName] [-m ModeBit] [-n NumberOfPolePairs] [-p InterpolationPoint] [-q QuadratureInductance] [-r Resistance] [-t tLoad] [-V MaximumRatedVoltage]"
VarLD/LQ: -I is a Comma separated file with first row having magnitude values, second row having phase values, then the LD matrix and then the LQ matrix. Eg: Contents of angles/ldlq.txt 1, 2, 3, 4 –> magnitude 0, 45, 90 –> phase LD: 16, 15, 14, 13 16, 15, 14, 13 16, 15, 14, 13 LQ: 18, 17, 16, 15 18, 17, 16, 15 18, 17, 16, 15
Options | Default value |
---|---|
-A Activate (0/1) | 0 |
-b Board Number | 0 |
-C Config Mode (0-Configuring internal static registers/1-Changing tload on the fly) | 0 |
-d Direct Inductance ld in mH | 16.5 |
-e Enable (0/1) | 1 |
-f BFriction in the PMSM Model | 0 |
-F RTT File | null |
-l Lambda Af/Magnetic flux in Webers of the PMSM Model | 0.2041 |
-i Inertia Ja in the PMSM Model | 0.0170 |
-I Inductance file for Var ld/lq | null |
-m Mode Bit (0 - Fixed ld/lq | 1 - Var ld/lq) | 0 -n Number of pole pairs in the PMSM Model | 2 -q Quadrature Inductance lq in mH | 18.7 -p Interpolation point - Intger > 0 | 0 -r Resistance in the PMSM Model in ohms | 1 -t tload attached to the PMSM Rotor in Newton Meter | 2 -V Maximum rated voltage in volts | 1000 volts
Examples:
./fpgawb_ipcore_pmsm -C0 -b0 -d16.5 -e1 -f0 -l0.2041 -i0.0170 -n2 -m0 -q18.7 -r1 -V1000
./fpgawb_ipcore_pmsm -m0
./fpgawb_ipcore_pmsm -m1 -Iangles/ldlq.txt -p2 -V1000
./fpgawb_ipcore_pmsm -m0 -Fangles/RT_PMSM_LdLq_SH.rtt
./fpgawb_ipcore_pmsm -m1 -Fangles/RT_PMSM_LdLq_SH.rtt -p2
./fpgawb_ipcore_pmsm -C1 -t2