![]() |
Demo program for Tooth Wheel Generator 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 | ToothWheelGenUsage () |
int | main (int argc, char *argv[]) |
Variables | |
int | rotation =360 |
Rotation of the Tooth Wheel Generator IP Core Channel. It takes values 360/720 degrees and defaults to 360 degree. | |
uint | enable =1 |
enable mode bit for the Tooth Wheel Generator IP Core Channel. Toggling the enable signal will cause the registers to revert to default power-on states. Only once the board is enabled the tooth profile can be programmed into the FPGA. It takes values 0 or 1 and defaults to 1 | |
uint | activate =0 |
output enable for the Tooth Wheel Generator IP Core Channel. Enable this once the tooth profile is being programmed. It takes values 0 or 1 and defaults to 0 | |
uint | active_high =1 |
Active High for the Tooth Wheel Generator IP Core Channel. The output will be active high when the bit is set and inverted when the bit is toggled. It takes values 0 or 1 and defaults to 1. | |
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 | |
int | channel =-1 |
Channel number for the Tooth Wheel Generator IP Core Channel. It takes values 0 to (number of IP Core channels-1) and defaults to -1 (test program executed for all channels) | |
uint | config_mode =0 |
Configuration mode for the test program. Indicates to run the program in configure mode or change rpm on fly mode. It takes values 0-Configuration/1-Change RPM. It defaults to 0. | |
double | rpm =0 |
RPM for the Tooth Wheel Generator IP Core Channel. Positive value for forward rotation and negative value for reverse rotation. The RPM input is converted into an increment angle for the FPGA which is incremented every 10MHz. | |
double | tooth_profile [254] |
Array to specify the Crank angles. The angle at which the transition needs to occur. The first angle to be written is always 0 degrees. The array is initialized to -1. It can take a maximum of 254 values ranging from 0 - 360 in degrees and in increasing order. Eg: 0,10,20,30,40,50,60,70,80. | |
double | crank_angle |
Current crank angle of the Tooth Wheel Generator IP Core Channel is stored in this variable after execution of get Crank Angle api call. | |
uint | fpw =10 |
PFM pulse width in the forward direction for the Tooth Wheel Generator IP Core Channel. It defaults to 10. | |
uint | rpw =20 |
PFM pulse width in the reverse direction for the Tooth Wheel Generator IP Core Channel. It defaults to 20. | |
uint | pfm_mode =0 |
Indicates if the output pulse is in pfm mode or tooth profile mode for the Tooth Wheel Generator IP Core Channel. It takes value 0 and 1 and defaults to 0. | |
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_TW_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 TOOTH WHEEL GEN CHANNEL
fpgawb_TW_Activate_Ch(handle,chan,enable,activate)
This call activates the Tooth Wheel Gen IP Core Channel. Note to set activate to 0 because we will be using the Config api calls which requires activate be 0. The default for activate is 0 in this test program. It is set to 1 at the end. Please be careful to give in the value as 0 when running the test program.
Step 6: CONFIGURE CHANNEL ROTATION AND ACTIVE HIGH
fpgawb_TW_Configure_Ch(handle,chan,rotation,active_high)
This call configures the active high for Tooth Wheel Gen IP Core Channel.
Step 7: CONFIGURE CHANNEL TOOTH PROFILE
C_fpgawb_TW_Set_Ch_Tooth_Profile(handle,chan,tooth_profile)
This call configures the crank angles for the Tooth Wheel Gen IP Core Channel.
Step 8: CONFIGURE PFM
fpgawb_TW_Set_Ch_PFM(handle,chan,fpw,rpw)
This call configures the PFM for forward and reverse direction for the Tooth Wheel Gen IP Core Channel.
Step 9: ACTIVATE TOOTH WHEEL GEN CHANNEL
fpgawb_TW_Activate_Ch(handle,chan,1,1)
This call activates the Tooth Wheel Gen IP Core Channel for Running after the configuration phase. Note that you put the activate to 0 before configuration so make it 1 now.
Step 10: SET CHANNEL PHASE INCREMENT
fpgawb_TW_Set_Ch_RPM(handle,chan,rpm)
This call sets the RPM for the Tooth Wheel Gen IP Core Channel.
Step 11: GET CRANK ANGLE
fpgawb_TW_Get_Ch_Crank_Angle(handle,Chan,&crank_angle)
This call returns the current crank angle of the Tooth Wheel Gen IP Core Channel in crank_angle pointer. This can be written to a file and plotted to view it better.
Step 12: CLOSE DEVICE
ccrtNGFC_Close(handle)
Closes the device with the handle.
void ToothWheelGenUsage | ( | ) |
Usage:
./fpgawb_ipcore_tooth_wheel_generator [-a ActiveHigh] [-A Activate] [-b Board] [-c ChannelNumber] [-C config_mode] [-e Enable] [-f CrankAngleFileName] [-F ForwardPulseWidth] [-i rpm/increment] [-p PFMMode] [-r Rotation] [-R ReversePulseWidth]
Options | Default value |
---|---|
-a Active High(0/1) | 1 |
-A Activate (0/1) | 0 |
-b Board Number | 0 |
-c channel Number (0-(Numchans-1) | -1 (all channels) |
-C Config Mode (0-Configuration/1-No Configuration- Change RPM) | 0 |
-e Enable (0/1) | 1 |
-f Crank Angle File Name - Input even number of edges | None |
-F Forward Pulse Width in microseconds | 10 |
-i RPM | 0 |
-p PFM Mode ( 0 - Tooth profile Output, 1 - PFM Output] | 0 |
-r Rotation (360 or 720 degrees) | 360 |
-R Reverse Pulse Width in microseconds | 20 |
Examples:
./fpgawb_ipcore_tooth_wheel_generator -fangles/engine_angles_0to360_3deg.dat
./fpgawb_ipcore_tooth_wheel_generator -b0 -a1 -A0 -e1 -c0 -fangles/engine_angles_0to360_3deg.dat -F25 -R60
./fpgawb_ipcore_tooth_wheel_generator -C1 -i100