![]() |
Demo program for Field Oriented Control 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 | foc_x1Usage () |
int | main (int argc, char *argv[]) |
Variables | |
uint | enable =1 |
enable mode bit for the Field Oriented Control 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 Field Oriented Control 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_foc_x1_configure_t | config |
fpgawb_ipcore_foc_x1_config_t struct passed as argument for configuring static internal registers api call. Check fpgawb_lib.h or api call documentation for more information | |
uint | angle_shift =10 |
This value shifts the angle increment input to extend the range of acceptable increment angles inside of the 3-phase PWM logic. Thus a smaller shift will support slower RPM's and a larger shift will support very large RPM's. This is only needed if someone decides to spin to Motor extremely slowly. The maximum acceptable value is 12 and it defaults to 10. | |
double | pwm_gain =4000 |
The PWM gain sets the amplitude of the internally generated triangular wave. This triangular wave is used to generate the PWM signal which will control the IGBT switches in the Inverter. Ideally the amplitude of triangular wave will be set relative to the expected current of the motor it is designed to control. It defaults to 4000. | |
double | pi_controller_proportional =9 |
PI Controller proportional is the proportional gain of the PI Controller. The PI Controller's purpose is to filter the angular speed error between the user desired speed and the instantaneous speed of the PMSM ensuring the correct steady state value is achieved as required by the algorithm. It defaults to 10. | |
double | pi_controller_integral =99 |
PI Controller Integral is the integral gain of the PI Controller. he PI Controller's purpose is to filter the angular speed error between the user desired speed and the instantaneous speed of the PMSM ensuring the correct steady state value is achieved as required by the algorithm. It defaults to 99. | |
double | rpm =0 |
The parameter rpm is the speed of the motor in revolutions per minute and converted to radians per second and programmed. It defaults to 0. | |
double | frequency =0 |
Frequency is the Phase Increment used to generate the triangular wave inside of the 3-phase PWM logic and defaults to 0. | |
uint | number_of_pole_pairs =2 |
Number of pole pairs 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-programming frequency and speed 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 | |
void foc_x1Usage | ( | ) |
Usage:
./fpgawb_ipcore_foc_x1 [-A Activate] [-b Board] [-C Config Mode] [-e Enable] [-f Frequency] [-g PWMGain] [-i PIControllerIntegral] [-n NumberOfPolePairs] [-p PIControllerProportional] [-r RPM] [-S AngleShift]
Options | Default value |
---|---|
-A Activate (0/1) | 0 |
-b Board Number | 0 |
-C Config Mode (0-Configuring internal static registers/1-Changing frequency and speed on the fly) | 0 |
-e Enable (0/1) | 1 |
-f Frequency | 0 |
-g PWMGain | 4000 |
-i PI Controller Integral | 99 |
-n Number of pole pairs in the Model | 2 |
-p PI Controller Proportional | 9 |
-r Speed of the motor (converted internally to radians per secaond) | 0 |
-S Angle Shift (1to 12) | 10 |
Examples:
./fpgawb_ipcore_foc_x1 -g4000 -i99 -p9 ./fpgawb_ipcore_foc_x1 -C1 -r300
int main | ( | int | argc, |
char * | argv[] | ||
) |
Step 1: OPEN DEVICE
ccurPMFC_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
ccurPMFC_Get_Driver_Info(handle, &binfo)
This call returns useful driver information and saves in the ccurpmfc_driver_info_t structure for later use.
Step 3: GET LIBRARY INFO
ccurPMFC_Get_Library_Info(handle, &linfo)
This call returns useful library information and saves in the ccurpmfc_library_info_t structure for later use.
Step 4: GET IP INFO
fpgawb_FOC_X1_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 foc_x1
fpgawb_FOC_X1_Activate(handle,enable,activate)
This call activates the Field Oriented Control IP Core. Note to set enable to 1 to start configuring the FOC IP Core.
Step 6: CONFIGURE INTERNAL STATIC REGISTERS
C_fpgawb_FOC_X1_Configure(handle,&config)
This call configures internal static registers such as angle shift, PWM gain, PI ontroller proportional, PI controller integral etc for the Field Oriented Control IP Core.
Step 7: ACTIVATE MOTOR
fpgawb_FOC_X1_Activate(handle,enable,activate)
This call activates the Field Oriented Control IP Core. Note to set the activate to 1 to start running the FOC IP Core.
Step 8: SET SPEED
fpgawb_FOC_X1_Set_Speed(handle,rpm)
This call configures the speed for the motor in radians per second.
Step 9: SET FREQUENCY
fpgawb_FOC_X1_Set_Frequency(handle,frequency)
This call sets the phase increment which is used to henerate the triangular wave inside of the 3-phase PWM logic.
Step 10: CLOSE DEVICE
ccurPMFC_Close(handle)
Closes the device with the handle