Logo
WSS_Demo

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

Variables

uint enable =1
 enable mode bit for the WSS 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 WSS 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_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 WSS 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_wss_config_t config
 fpgawb_ipcore_wss_config_t struct passed as argument for configure wheel api call. Check fpgawb_lib.h or api call documentation for more information
 
fpgawb_ipcore_wss_fault_params_t fault_params
 fpgawb_ipcore_wss_fault_params_t struct passed as argument for set faults parameters api call. Check fpgawb_lib.h or api call documentation for more information
 
fpgawb_ipcore_wss_df10_config_t df10_config
 fpgawb_ipcore_wss_df10_config_t struct passed as argument for configure DF10 parameters api call. Check fpgawb_lib.h or api call documentation for more information
 
fpgawb_ipcore_wss_df11_config_t df11_config
 fpgawb_ipcore_wss_df11_config_t struct passed as argument for configure DF11 parameters api call. Check fpgawb_lib.h or api call documentation for more information
 
fpgawb_ipcore_wss_ak_config_t ak_config
 fpgawb_ipcore_wss_ak_config_t struct passed as argument for configure AK parameters api call. Check fpgawb_lib.h or api call documentation for more information
 
fpgawb_ipcore_wss_pwm_config_t pwm_config
 fpgawb_ipcore_wss_pwm_config_t struct passed as argument for configure PWM parameters api call. Check fpgawb_lib.h or api call documentation for more information
 
uint config_mode =0
 Configuration mode for the test program. Indicates to run the program in configure mode or dynamic mode. It takes values 0-Wheel setup,Protocol parameters/1-Dynamic parameters(RPM, AK Data, DF11 Strength, Fault Parameters). It defaults to 0.
 
uint fault_control_input = 0
 fault_control_input is the controller of fault and takes values 0 or 1, for all protocols when this bit is set to 1 the wheel and transmitters enact a fault.
 
uint fault_mode = 0
 fault_mode decides the way the wheel behaves during a fault of the protocol. It takes value 0 to 3, 0 indicates wheel angle and magnet index go to zero until fault ends, 1 indicates wheel angle and magnet index return to starting position, 2 indicates wheel angle and magnet index freeze in current position, 3 indicates wheel angle and magnet index continue normal operation.
 
uint calibration_magnet_size = 0
 calibration_magnet_size indicates how many poles plus boundaries need to be seen from the wheel before outputting pulses after startup and/or faults.
 
uint start_magnet_index = 0
 start_magnet_index indicates the index of the magnet that the start angle resides in and is 0's based.
 
uint protocol = 0
 protocol identifies the protocol used and takes value 0 to 3 where 0-AK, 1-PWM, 2-DF10 and 3-DF11.
 
uint protocol_variant = 0
 protocol_variant identifies the variant for the protocol selected. It takes value 0 or 1, DF10: 0-No variant and 1-Rot-Dir variant, DF11-N/A, PWM: 0-No variant and 1-High Res variant, AK: 0-No variant and 1-High Res variant.
 
double start_angle = 0.0f
 start_angle indicates the angle position of wheel on startup in degrees. It takes value 0 to 360 degrees.
 
uint total_magnet = 6
 total_magnet indicates the total number of magnets in the wheel and takes an even number.
 
uint zeroth_polarity = 1
 zeroth_polarity indicates the polarity of the magnet at Index 0. It takes value 0 or 1, 0-North and 1-South.
 
uint pulse_width = 10
 pulse_width defines the pulse width in 10Mhz period steps(0.1us) for the extra 28mA pulse output when the direction is in reverse and the Rot-Dir Protocol variant is being used.
 
uint pole_inversion = 0
 pole_inversion inverts the polarity of the wheel's current magnet. It takes value 0 or 1 and a value of 1 inverts the polarity of the current magnet.
 
uint time_base = 450
 time_base defines the pulse width in 10Mhz period steps(0.1us) for the reference t0 used by other pulse widths. Default is typically 45us.
 
uint very_low_magnet_width = 0
 very_low_magnet_width defines the pulse width in t0 period steps for pulses when the df11_strength is set to very low mode. Defined pulse width is (very_low_magnet_width + 1)*t0. Default is 1t0 so very_low_magnet_width value passed in is 0.
 
uint normal_magnet_forward_width = 1
 normal_magnet_forward_width defines the pulse width in t0 period steps for pulses when the df11_strength is set to normal mode and wheel direction is forward. Defined pulse width is (normal_magnet_forward_width + 1)*t0. Default is 4t0 so normal_magnet_forward_width value passed in is 3.
 
uint normal_magnet_reverse_width = 3
 normal_magnet_reverse_width defines the pulse width in t0 period steps for pulses when the df11_strength is set to normal mode and wheel direction is reverse. Defined pulse width is (normal_magnet_reverse_width + 1)*t0. Default is 2t0 so normal_magnet_reverse_width value passed in is 1.
 
uint high_magnet_forward_width = 7
 high_magnet_forward_width defines the pulse width in t0 period steps for pulses when the df11_strength is set to high mode and wheel direction is forward. Defined pulse width is (high_magnet_forward_width + 1)*t0. Default is 16t0 so high_magnet_forward_width value passed in is 15.
 
uint high_magnet_reverse_width = 15
 high_magnet_reverse_width defines the pulse width in t0 period steps for pulses when the df11_strength is set to high mode and wheel direction is reverse. Defined pulse width is (high_magnet_reverse_width + 1)*t0. Default is 8t0 so high_magnet_reverse_width value passed in is 7.
 
uint standstill_pulse_width = 31
 standstill_pulse_width defines the pulse width in t0 period steps for pulses when a standstill pulse is initiated. Defined pulse width is (standstill_pulse_width + 1)*t0. Default is 32t0 so standstill_pulse_width value passed in is 31.
 
uint tp_half = 450
 tp_half defines the time-base(tp) value for the AK protocol based on steps of 10Mhz periods(0.1us).
 
uint tpssd = 0
 tpssd defines the length of time in steps of 10Mhz periods(0.1us) that represents the amount of forced wait time between a truncated standstill pulse and a high resolution pulse.
 
uint forward_pulse_width = 0
 forward_pulse_width defines the pulse width in 10Mhz period steps(0.1us) for pulse output when the direction is forward.
 
uint reverse_pulse_width = 0
 reverse_pulse_width defines the pulse width in 10Mhz period steps(0.1us) for pulse output when the direction is reverse.
 
uint pwm_standstill_pulse_width = 0
 standstill_pulse_width defines the pulse width in 10Mhz period steps(0.1us) for pulse output when a standstill call occurs.
 
double frequency_high = 1000
 frequency_high high frequency hysteresis is used to identify which speed mode of operation to use for pulse outputs. It takes value in Hertz and defaults to 1000Hz(1ms).
 
double frequency_low = 900
 frequency_low low frequency hysteresis is used to identify which speed mode of operation to use for pulse outputs. It takes value in Hertz and defaults to 900Hz(1.1111ms).
 
uint forced_low_time = 0
 forced_low_time indicates how long the signal pulses must be forced to a LO values between the pulses in units of 10Mhz periods(0.1us).
 
double high_resolution_offset = 15
 high_resolution_offset value represents the amount of degrees above and below each pole where the high resolution pulses will be generated. Eg: Typically the magnet profile is uniform, so if boundaries would exist at 0 degrees and 3 degrees then pole would be at 1.5 degrees. For the high resolution pulses to be perfectly between poles and boundaries at 0.75 degrees and 2.25 degrees, the offset need to be set to 0.75 degrees since 1.5 degrees +/- 0.75 degrees yields the desired values.
 
uint high_speed_pulse_width = 0
 high_speed_pulse_width defines the pulse width in 10Mhz period steps(0.1us) for pulse output for both directions whenever the speed mode defined by frequency hysteresis is high speed.
 
uint df11_strength = 0
 df11_strength which indicates magnetic field strength that affects the pulses output from the protocol. It takes value 0 to 2, 0 indicates very low magnetic field, 1 indicates normal magnetic field and 2 indicates very high magnetic field.
 
uint ak_data = 0
 data is a 9 bit unsigned integer where each bit can be one of the following software[x],direction,direction valid, hres_index[2], hres_index[1], hres_index[0],
 
double rpm = 0.0f
 rpm is the number of revolutions per minute, positive means forward rotation and negative means reverse rotation.
 
uint standstill_sensitivity = 2147483647
 standstill_sensitivity defines the amount of time in 10Mhz periods(0.1us) for no pulse to be seen to enact a standstill pulse.
 
uint bit_control = 0
 bit_control defines which values will populate each data bit in the AK transmit packet. Each data bit in the AK packet data is identified by a 3 bit mask and hence (9x3)27 bit mask to represet a 9 bit packet data. The 3 bit mask takes value 0 to 7, 0-Software[x],1-Direction,2-Direction Valid,3-hres_index[2],4-hres_index[1],5-hres_index[0], 6-standstill,7-Parity.Eg: If bitcontrol is set to 111001110101100011010001000(d'121292424) then the 9 bit AK packet data will represent Parity,Direction,standstill,hres_index[0], hres_index[1].hres_index[2],Direction Valid,Direction,Software[x] MSB to LSB.
 
uint voltage_mode = 0
 voltage_mode takes value 0 for 5V and 1 for 12V and defaults to 0.
 
uint invert_do = 0
 invert_do is a 4 bit one-hot paramerer which inverts the output of the four control bits. When LSB/[0] is set to 1 DO 0 is inverted, when [1] is set to 1 DO 1 is inverted, when [2] is set to 1 DO 2 is inverted and when MSB/[3] is set to 1 DO 3 is inverted. It takes value 0 to 15 and defaults to 0.
 

Function Documentation

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_WSS_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 WSS CHANNEL
fpgawb_WSS_Activate_Ch(handle,chan,enable,activate)
This call activates the Wheel Speed Sensor IP Core Channel. Note to set activate to 0 because we will be using the Configuration 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.

Step 6: CONFIGURE WHEEL PARAMETERS
C_fpgawb_WSS_Configure_Ch(handle,chan,&config)
This call

Step 11: ACTIVATE WSS
fpgawb_WSS_Activate(handle,chan,enable,activate)
This call activates the WSS IP Core channel. Note to set the activate to 1 to start running the WSS IP Core.

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

void WSSUsage ( )

Usage:
./fpgawb_ipcore_wss [-A Activate] [-ak_tp_half] [-ak_tpssd] [-ak_bitcontrol] [-b Board] [-c ChannelNumber] [-C ConfigMode] [-d AKData] [-df10_pw] [-df10_pi] [-df11_time_base] [-df11_very_low_mag_pw] [-df11_normal_mag_fpw] [-df11_normal_mag_rpw] [-df11_high_mag_fpw] [-df11_high_mag_rpw] [-df11_standstill_pw] [-D DF11Strength] [-e Enable] [-f FaultControlInput] [-F FaultMode] [-m CalibrationMagnetSize] [-i StartMagnetIndex] [-invert_do] [-p Protocol] [-pwm_fpw] [-pwm_rpw] [-pwm_standstill_pw] [-[high_freq] [-low_freq] [-forced_lowtime] [-high_res_off] [-pwm_highspeed_pw] [-poles_boundaries] [-v ProtocolVariant] [-voltage_mode] [-r RPM] [-s StartAngle] [-S StandstillSensitivity] [-t TotalMagnet] [-z ZerothPolarity]

Options Default value
-A Activate (0/1) 0
-ak_tp_half AK Timebase half in 10Mhz period steps(0.1us) 450
-ak_tpssd AK Tpssd 0
-ak_bitcontrol AK Bitcontrol is comma separated list of size 9 where each value identifies how each data bit in the AK Packet data is populated MSB to LSB (-0-software[x] -1-direction" -2-direction valid -3-hres_index[2] -4-hres_index[1] -5-hres_index[0] -6-standstill -7-parity) Eg: -ak_bitcontrol 0,1,2,3,4,5,6,7,1 0
-b Board Number 0
-c channel Number (0-(Numchans-1) all channels
-C Config Mode (0-Static/1-Dynamic) 0
-e Enable (0/1) 1
-d AK Packet Data (9-bit data) 0
-df10_pw DF10 Pulsewidthin in 10Mhz period steps(0.1us) 0
-df10_pi DF10 Pole Inversion (0/1) 0
-df11_time_baseDF11 Time Base t0 in 10Mhz period steps(0.1us) 450
-df11_very_low_mag_pw DF11 Very Low Magnet Pulsewidth in t0 period steps 0
-df11_normal_mag_fpw DF11 Normal Magnet Forward Pulsewidth in t0 period steps 3
-df11_normal_mag_rpw DF11 Normal Magnet Reverse Pulsewidth in t0 period steps 1
-df11_high_mag_fpw DF11 High Magnet Forward Pulsewidth in t0 period steps 15
-df11_high_mag_rpw DF11 High Magnet Reverse Pulsewidth in t0 period steps 7
-df11_standstill_pw DF11 Standstill pulsewidth 31
-D DF11 Field Strength (0 to 2) 0
-f fault control input (0/1) 0
-forced_lowtime PWM Forced Lowtime 0
-F fault mode (0 to 3) 0
-high_freq PWM High Frequency Hysteresis (Hz) 1000
-high_res_off PWM High Resolution Offset (degrees) 15
-i start magent index 0
-invert_do 4 bit num that inverts o/p of the 4 control bits, [0] when set to 1 inverts DO0, [1] when set to 1 inverts DO1 etc 0
-low_freq PWM Low Frequency Hysteresis (Hz) 900
-m calibration magnet size 0
-p protocol 0-AK,1-PWM,2-DF10,3-DF11 0
-pwm_fpw PWM Forward Pulsewidth in 10Mhz period steps(0.1us) 0
-pwm_rpw PWM Reverse Pulsewidth in 10Mhz period steps(0.1us) 0
-pwm_standstill_pw PWM Standstill Pulsewidth in 10Mhz period steps(0.1us) 0
-pwm_highspeed_pw PWM High Speed Pulsewidth in 10Mhz period steps(0.1us) 0
-poles_boundaries Poles and Boundaries file input null
-v protocol variant (0/1) DF10: 0-No,1-Rot-Dir DF11:NA PWM: 0-No,1-High Res AK: 0-No,1-High Res 0
-voltage_mode takes value 0 for 5V and 1 for 12V 0
-r rpm 0
-s start angle (0-360 degrees) 0
-S standstill sensitivity in 10Mhz period steps(0.1us) 2147483647
-t total magnet 6
-z zeroth polarity 1


Examples:
./fpgawb_ipcore_wss -C 0 -b 0 -m 4 -i 0 -p 0 -s 0 -S 2147483647 -t 16 -v 0 -z 0 -high_freq 1000 -low_freq 900 -forced_lowtime 10 -high_res_off 15 -ak_tp_half 450 -ak_tpssd 0 -ak_bitcontrol 7,1,6,5,4,3,2,1,0 -poles_boundaries angles/wss_data.txt
./fpgawb_ipcore_wss -C 1 -b 0 -p 0 -d 123 -f 0 -F 0 -r 100
./fpgawb_ipcore_wss -C 0 -b 0 -m 4 -i 0 -p 1 -s 0 -S 2147483647 -t 16 -v 0 -z 0 -pwm_fpw 10 -pwm_rpw 20 -pwm_standstill_pw 10 -high_freq 1000 -low_freq 900 -forced_lowtime 10 -high_res_off 15 -pwm_highspeed_pw 10 -poles_boundaries angles/wss_data.txt
./fpgawb_ipcore_wss -C 1 -b 0 -p 1 -f 0 -F 0 -r 100
./fpgawb_ipcore_wss -C 0 -b 0 -m 4 -i 0 -p 2 -s 0 -t 16 -v 0 -z 0 -df10_pw 10 -df10_pi 0 -poles_boundaries angles/wss_data.txt
./fpgawb_ipcore_wss -C 1 -b 0 -p 2 -f 0 -F 0 -r 100
./fpgawb_ipcore_wss -C 0 -b 0 -m 4 -i 0 -p 3 -s 0 -S 2147483647 -t 16 -v 0 -z 0 -df11_time_base 450 -df11_very_low_mag_pw 0 -df11_normal_mag_rpw 1 -df11_normal_mag_fpw 3 -df11_high_mag_rpw 7 -df11_high_mag_fpw 15 -df11_standstill_pw 31 -poles_boundaries angles/wss_data.txt
./fpgawb_ipcore_wss -C 1 -b 0 -p 3 -D 0 -f 0 -F 0 -r 100