Logo
NGFC_UVWEncoder_Demo

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

Variables

double starting_angle =0
 Starting angle of the UVW Encoder IP Core Channel rotation. It takes values 0 - rotation in degrees and defaults to 0 degree.
 
int rotation =360
 Rotation of the UVW Encoder IP Core Channel. It takes values 360/720 degrees and defaults to 360 degree.
 
double pulse_width =0
 This is the width of the UVW pulses in degrees. It takes values 0 - 239 in degrees and defaults to 0 degree.
 
uint enable =1
 Enable mode bit for the UVW Encoder IP Core Channel. 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 UVW Encoder IP Core Channel. 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 UVW Encoder IP Core Channel. This represents if the UVW pulses should be set low or high. You can have separate variables too. It takes values 0 or 1 and defaults to 1.
 
double rpm =0
 RPM for the UVW Encoder IP Core Channel. Positive value for forward rotation and negative value for reverse rotation.
 
fpgawb_ipcore_uvw_encoder_configure_t config
 fpgawb_ipcore_uvw_encoder_configure_t struct passed as argument for confiuring the UVW Encoder api call which porgrams the rotation. starting angle and pulse width. Check fpgawb_lib.h or api call documentation for more information
 
double angle
 Current angle of the UVW Encoder IP Core Channel is stored in this variable after execution of get 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 the fly. It takes values 0-Configuration mode/1-set RPM and read current crank angle on the fly. It defaults to 0.
 
int channel =-1
 Channel number for the UVW Encoder IP Core Channel. It takes values 0 to (number of IP Core channels-1) and defaults to -1 (test program executed for all channels)
 
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
 

Function Documentation

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_UVW_Encoder_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 UVW ENCODER
fpgawb_UVW_Encoder_Activate_Ch(handle,Chan,enable,activate)
This call activates the UVW Encoder IP Core Channel. 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 ACTIVE HIGH
fpgawb_UVW_Encoder_Set_Ch_Active_High(handle,Chan,active_high)
This call configures the active high/low of the UVW pulses for Encoder IP Core Channel.

Step 7: CONFIGURE UVW ENCODER
C_fpgawb_UVW_Encoder_Configure_Ch(handle,Chan,&config)
This call sets the starting angle, rotation and pulse width for UVW Encoder IP Core Channel.

Step 8: ACTIVATE UVW ENCODER
fpgawb_UVW_Encoder_Activate_Ch(handle,Chan,enable,1)
This call activates the UVW Encoder 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 9: SET UVW ENCODER RPM
fpgawb_UVW_Encoder_Set_Ch_RPM(handle,Chan,rpm)
This call sets the RPM for the UVW Encoder IP Core Channel for it to run.

Step 10: GET CURRENT ANGLE
fpgawb_UVW_Encoder_Get_Ch_Angle(handle,Chan,&angle)
This call returns the current angle of the UVW Encoder IP Core Channel in the angle pointer. This can be written to a file and plotted to view it better.

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

void UVWEncoderUsage ( )

Usage:
./fpgawb_ipcore_uvw_encoder [-a ActiveHigh] [-A Activate] [-b Board] [-c ChannelNumber] [-C config_mode] [-e Enable] [-i rpm/increment] [-o Rotation] [-p PulseWidth] [-s StartingAngle]

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
-C Config Mode (0-Configuration mode/1-set RPM on fly and read current crank angle) 0
-e Enable (0/1) 1
-i RPM 0
-o Rotation (360 or 720 degrees) 360
-p Width of the UVW pulses(0 degrees - <rotation> degrees) 0
-s Starting Angle (0 degrees - 239 degrees) 0


Examples:
./fpgawb_ipcore_uvw_encoder -a1 -A0 -b0 -c0 -e1 -o360 -p15 -s2
./fpgawb_ipcore_uvw_encoder -C1 -c0 -i100 > readdata