![]() |
Demo program for Decoder 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 | DecoderUsage () |
int | main (int argc, char *argv[]) |
void | Display_channels () |
Variables | |
uint | enable =1 |
enable mode bit for the Decoder 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 Decoder 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 Decoder IP Core Channel. It takes values 0 or 1 and defaults to 1. | |
int | channel =-1 |
channel number for the Decoder 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 | |
uint | num_of_teeths =36 |
num_of_teeths indicating size of A rising edges. It defaults to 36 | |
uint | z_rollover_mode =1 |
Z Rollover Mode of the Decoder IP Core Channel. It takes values 0 or 1 and defaults to 1. | |
fpgawb_ipcore_decoder_info_t | all_info [FPGAWB_MAX_IPCORE_CHANNELS] |
fpgawb_ipcore_decoder_info_t struct to read channel data for the Decoder IP Core Channel. Check fpgawb_lib.h or api call documentation for more information on the struct members | |
fpgawb_ipcore_decoder_configure_t | config |
fpgawb_ipcore_decoder_configure_t struct used to pass config parameters for the Decoder IP Core Channel. Check fpgawb_lib.h or api call documentation for more information on the struct members | |
uint | z_counter =0 |
Z counter reset value for the Decoder IP Core Channel. If the user wants the decode counter to reset at a user specified value for every z rollover then the user can specify it in the z_counter. It takes values >=0 and defaults to 0. | |
double | decoder_start_angle =0 |
Starting angle of the Decoder IP Core Channel. The starting angle of the decoder along with the number of A pulses, and the mode of operation (X1,X2,X4) will define the initial count loaded into the decoder. For example if X4 is used with 36 teeth at an offset of 45 degrees the counter will be loaded with an 18. It takes values 0 to rotation in degrees and defaults to 0. | |
uint | x_select =1 |
Counter mode of operation of the Decoder IP Core Channel. It takes values 1, 2 or 4 indicating X1, X2 or X4 respectively and defaults to 1. | |
uint | z_rollover_iq_state =0 |
Z Rollover IQ State of the Decoder IP Core Channel. This parameter will define on which A/B edge the counter reset will occur. This is also a function of the user defined mode of operation (X1,X2,X4). For example X2 can have the Z-pulse reset occur on either A High/B Low or A Low/B High. It is important to understand that the Z-pulse must span the A/B edge that you expect the reset to occur. If the Z-pulse does not span the desired A/B the decoder will miss the Z-pulse and continue counting. It takes values 0 to 4 in which 0 indicates A High B Low, 1 indicates A High B High, 2 indicates A Low B High and 3 indicates A Low and B Low. It defaults to 0. | |
uint | filter_count = 0 |
Filter count for the Decoder IP Core Channel. Filter count to filter out a noisy digital input signal. The filter count is a 8 bit interger with the count reprensting the clock cycles. After a digital input rising or falling edge, the input must remain high/low for greater than the “Filter Count” clock cycles to be counted. It takes positive integer values >=0 and < 256 and defaults to 0. | |
void DecoderUsage | ( | ) |
Usage:
./fpgawb_ipcore_decoder [-a ActiveHigh] [-A Activate] [-b Board] [-c ChannelNumber] [-e Enable] [-f FilterCount] [i ZRolloverIQState] [-n NumberOfTeeths] [-r ZCounterResetVakue] [-z ZRolloverMode]
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 |
-e Enable (0/1) | 1 |
-f Filter Count ( >=0 & < 256) | 0 |
-i Z Rollover IQ State (0-3) | 0 |
-n Number Of Teeths – size of A rising edges | 36 |
-r Z Counter Reset Value (>=0) | 0 |
-s Start angle of Decoder (0 degrees - <rotation> degrees) | 0 |
-x X select - Counter mode (1-X1, 2-X2 or 4-X4 | 1 |
-z Z Rollover Mode (0/1) | 1 |
Examples:
./fpgawb_ipcore_decoder
void Display_channels | ( | ) |
Step 10: READ DECODER CHANNEL DATA
fpgawb_Decoder_Read_Ch_Data(handle, Chan, &all_info[Chan])
This call returns the Decoder IP Core Channel data such as X1, X2, X4 count and their respective angles in &all_info struct.
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_Decoder_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 DECODER
fpgawb_Decoder_Activate_Ch(handle,Chan,enable,activate)
This call activates the Decoder 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: CONFIGURES DECODER MODES
C_fpgawb_Decoder_Configure_Ch(handle,Chan,&config) This call sets num_of_teeths, z_rollover_mode, z_reset_offset, x_select, decoder_start_angle and z_rollover_iq_state for the Decoder IP Core Channel.
Step 7: SET ACTIVE HIGH
fpgawb_Decoder_Set_Ch_Active_High(handle,Chan,active_high)
This call configures the active high for the Encoder IP Core Channel.
Step 8: ACTIVATE DECODER
fpgawb_Decoder_Activate_Ch(handle,Chan,enable,1)
This call activates the Decoder 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: CLOSE DEVICE
ccurPMFC_Close(handle)
Closes the device with the handle