Logo
NGFC_CrankCam_Demo

Demo program for Engine 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 EngineUsage ()
 
int main (int argc, char *argv[])
 

Variables

double phase_b_offset =1.5
 PhaseB Offet of the Engine IP Core. It should be less that the minimum difference between all the crank angles provided in the profile_array[i]. If this condition is not met api returns error. It defaults to 1.5.
 
double starting_angle =0
 Starting angle of the Engine IP Core rotation. It takes values 0 - rotation in degrees and defaults to 0 degree.
 
double advance_delay =0
 Advance delay to be augmented with the CAM. It takes values -180 degrees to +180 degrees for 360 rotation and -360 to +360 for 720 rotation and defaults to 0, meaning none of the CAMs is advanced or delayed.
 
int rotation =360
 Rotation of the Engine IP Core. It takes values 360/720 degrees and defaults to 360 degree.
 
double reverse_pw =90
 Reverse pulse width for the PFM (Rising edge). It takes values 0 to 655 microseconds and defaults to 90.
 
double forward_pw =30
 Forward pulse width for the PFM (Rising edge). It takes values 0 to 655 microseconds and defaults to 30.
 
double mvo_reverse_pw =2
 Reverse pulse width for the MVO (Rising edge). It takes values 0 to 5 volts and defaults to 2.
 
double mvo_forward_pw =3
 Forward pulse width for the MVO (Rising edge). It takes values 0 to 5 volts and defaults to 2.
 
int cam_number =0
 CAM number to be advanced or delayed. It takes values 0 to 4 and defaults to 0.
 
int num_of_cams =4
 Number of CAMs of the Engine IP Core. It takes value 0 to 4 and defaults to 4.
 
uint rollover_mode =15
 Rollover mode for the Engine IP Core. It takes values 15,30,45,60,90,180,270,360 in degrees and defaults to 15.
 
uint enable =1
 enable mode bit for the Engine 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 Engine 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
 
uint active_high =1
 Active High for the Engine IP Core. This represents active high for all four ab, pfm, cam and zpulse. You can have separate variables too. It takes values 0 or 1 and defaults to 1.
 
double rpm =0
 RPMs for the Engine IP Core. Positive value for forward rotation and Negative value for reverse rotation.
 
double cam_angle_array [4][24]
 Array to specify the CAM angles for the different CAMs. Since there can be a maximum of four CAMs each of 24 edges, the size is 4*24. The array is initialized to -1 and take values from 0-rotation in degrees. Note that the angles in each row should be in increasing order.
Eg: 20,40,60,80,100 for CAM 0; 30,50,70,90,110 for CAM1; 40,60,80,100,120 for CAM2; 50,70,90,110,130 for CAM3.
 
double profile_array [256]
 Array to specify the Crank angles. The array is initialized to -1. It can take a maximum of 256 values ranging from 0 - 360 in degrees in increasing order. Eg: 10,20,30,40,50,60,70,80.
 
fpgawb_ipcore_engine_tooth_profile_configure_t config
 fpgawb_ipcore_engine_tooth_profile_configure_t struct passed as argument for setting the tooth profile. Check fpgawb_lib.h or api call documentation for more information
 
fpgawb_ipcore_engine_pfm_configure_t pfm_config
 fpgawb_ipcore_engine_pfm_configure_t struct passed as argument for configure PFM. Check fpgawb_lib.h or api call documentation for more information
 
fpgawb_ipcore_engine_mvo_configure_t mvo_config
 fpgawb_ipcore_engine_mvo_configure_t struct passed as argument for configure MVO. Check fpgawb_lib.h or api call documentation for more information
 
fpgawb_ipcore_engine_active_high_configure_t active_high_config
 fpgawb_ipcore_engine_active_high_configure_t struct passed as argument for setting active high for the ab, pfm, cam and zpulse. Check fpgawb_lib.h or api call documentation for more information
 
fpgawb_ipcore_engine_modes_configure_t modes_config
 fpgawb_ipcore_engine_modes_configure_t struct passed as argument configuring modes doe the Engine IP Core. Check fpgawb_lib.h or api call documentation for more information
 
double crank_angle
 Current crank angle of the Engine IP Core is stored in this variable after execution of get Crank Angle api call.
 
uint config_mode =0
 Configuration mode for the test program. Indicates to run the program in configure mode or set RPM on fly and read current crank angle on fly. It takes values 0-Configuration mode/1-Set RPM and read current crank angle on fly. It defaults to 0.
 
fpgawb_ipcore_t ip_core
 fpgawb_ipcore_t struct which stores useful information about the IP Core after get IP Info api call. Check fpgawb_lib.h or api call documentation for more information
 
int channel =-1
 Channel number for the Crank Cam IP Core Channel. It takes values 0 to (number of IP Core channels-1) and defaults to -1 (test program executed for all channels)
 

Function Documentation

void EngineUsage ( )

Usage:
./fpgawb_ipcore_engine [-a ActiveHigh] [-A Activate] [-b Board] [-c Channel] [-C config_mode] [-d AdvanceDelay] [-e Enable] [-f PFM ForwardPulseWidth] [-F MVO ForwardPulseWidth] [-i rpm/increment] [-l RolloverMode] [-m CAMNumber] [-n NumberOfCAMs] [-N CrankAngleFileName] [-o Rotation] [-p PhaseBOffset] [-r PFM ReversePulseWidth] [-R MVO ReversePulseWidth] [-s StartingAngle] [-Z CAMAngleFileName]

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 mode/1-set RPM on fly and read current crank angle) 0

-d Advance delay (-180 degrees to +180 degrees for 360 rotation || -360 degrees to +360 degrees for 720 rotation) | 0 -e Board Enable (0/1) | 1 -f PFM Forward pulse width (0 - 655 micro seconds) | 30 -F MVO Forward pulse width (0 - 5 volts) | 3 -i RPM | 0 -l Rollover mode (15,30,45,60,90,180,270,360 in degrees | 15 -m CAM number for advance or delay (0-(num_of_cams-1)) | 0 -n Number of CAMs | 4 -N Crank Angle File Name | None -o Rotation (360 or 720 degrees) | 360 -p PhaseBOffset - degrees (Should be less than the minimum difference between the Crank angles) | 1.5 -r PFM Reverse pulse width (0 - 655 micro seconds) | 90 -R MVO Reverse pulse width (0 - 5 volts) | 2 -s Starting Angle (0 degrees - <rotation> degrees) | 0 -Z CAM Angle File Name | None
Examples:
./fpgawb_ipcore_engine -b0 -a1 -A0 -e1 -o720 -n4 -m0 -r250 -f50 -R3 -F4 -s2 -p1.5 -Nangles/engine_angles_0to360_3deg.dat -Zangles/cam_v1.dat
./fpgawb_ipcore_engine -m0 -C1 -d10 -i100 > readdata

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_Engine_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 ENGINE
fpgawb_Engine_Activate_Ch(handle,enable,activate)
This call activates the Engine IP Core. Note to set activate to 0 because we will be using the Config api calls which requires that 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: SET ENGINE TOOTH PROFILE
C_fpgawb_Engine_Set_Tooth_Profile(handle,&config)
This call sets the Engine Tooth Profile and initial conditions.

Step 7: Configure PFM
C_fpgawb_Engine_Configure_Ch_PFM(handle,&pfm_config)
This call configures the PFM for Engine IP Core. The pfm_config takes in the rising edge's forward and reverse pulse width and falling edge's forward and reverse pulse width (which is +50 from the rising edge's respective pulse width's values in this test program). You can have options to input them separately according to your requirement.

Step 8: SET ENGINE CAM EDGES
C_fpgawb_Engine_Set_Ch_CAM_Edges(handle,num_of_cams,cam_angle_array)
This call sets the Engine's CAM Edges for it's CAMs.

Step 9: CONFIGURES MODES
C_fpgawb_Engine_Configure_Ch_Modes(handle,&modes_config) This call sets the rollover mode using the modes_config for the Engine IP Core.

Step 10: CONFIGURE MVO
C_fpgawb_Engine_Configure_Ch_MVO(handle,&mvo_config)
This call configures the MVO for Engine IP Core. The mvo_config takes in the rising edge's forward and reverse pulse width and falling edge's forward and reverse pulse width ( which is +1 from the rising edge's respective pulse width's values in this test program). You can have options to input them separately according to your requirement.

Step 11: SET ACTIVE HIGH
fpgawb_Engine_Set_Ch_Active_High(handle,&active_high_config)
This call configures the active high for the AB, CAM, PFM and ZPulse for Engine IP Core.

Step 12: ACTIVATE ENGINE
fpgawb_Engine_Activate_Ch(handle,1,1)
This call activates the Engine for Running after the configuration phase. Note that you put the activate to 0 before configuration so make it 1 now.

Step 13: SET ENGINE RPM
fpgawb_Engine_Set_Ch_RPM(handle,rpm)
This call sets the RPM for the Engine for it to run.

Step 14: SET ENGINE ADVANCE DELAY FOR THE CAM
C_fpgawb_Engine_Set_Ch_CAM_Advance_Delay(handle,cam_number,advance_delay)
This call advances or delays the specified CAM with advance_delay degrees.

Step 15: GET CRANK ANGLE
fpgawb_Engine_Get_Ch_Crank_Angle(handle,&crank_angle)
This call returns the current crank angle in crank_angle pointer. This can be written to a file and plotted to view it better.

Step 16: CLOSE DEVICE
ccrtNGFC_Close(handle)
Closes the device with the handle