hil_set_encoder_counts hil_set_encoder_quadrature_mode navigation bar

Table of Contents

hil_set_encoder_filter_frequency

Sets the filter frequency of the encoder inputs on the card.

Description

Some cards support filtering of their encoder inputs. The hil_set_encoder_filter_frequency function sets the filter frequency of the encoder inputs on the card. Note that many cards do not support encoders. Cards which do provide encoders may not support filtering or different filter frequencies, or may not support different filter frequencies for each channel.

The Quanser Q8-series support programmable filter frequencies and each channel may be assigned a different frequency. The fastest frequency is generally used so that the encoder inputs can handle the fastest possible A/B inputs. A slower filter frequency may be required in noisy environments. However, be aware that noisy encoder inputs is often an indication of a grounding problem or inadequate shielding, so be sure to check ground and shield connections carefully before resorting to more filtering of the encoder inputs. Filter frequencies will be rounded to the nearest filter frequency supported by the card.

Prototype

t_error
hil_set_encoder_filter_frequency(t_card card, const t_uint32 encoder_channels[], t_uint32 num_channels, const t_double frequency[]);
    

Parameters

t_card card

A handle to the board, as returned by hil_open.

const t_uint32 [] encoder_channels

An array containing the channel numbers of the encoder inputs whose filter frequencies will be set. Channel numbers are zero-based. Thus, channel 0 is the first channel, channel 1 the second channel, etc.

Select a board type from the list for board-specific details: .

t_uint32 num_channels

The number of channels specified in the encoder_channels array.

const t_double [] frequency

An array of doubles (t_double) containing the new encoder filter frequency for each channel in Hertz. There must be one element for each encoder channel specified in the encoder_channels array.

Return value

The return value is 0 if the encoder filter frequencies are set successfully. Otherwise a negative error code is returned. Error codes are defined in quanser_errors.h. A suitable error message may be retrieved using msg_get_error_message.

Error codes

QERR_HIL_SET_ENCODER_FILTER_FREQUENCY_NOT_SUPPORTED

This function is not supported by the board-specific HIL driver for this board type.

QERR_INVALID_CARD_HANDLE

An invalid card handle was passed as an argument. Once a card has been closed using hil_close the card handle is invalid.

QERR_MISSING_ENCODER_INPUTS

No encoder input channels were specified even though the number of encoder inputs is non-zero.

QERR_TOO_MANY_ENCODER_CHANNELS

Too many encoder channels were specified.

QERR_INVALID_ENCODER_CHANNEL

One of the encoder channels that was specified is not a valid channel number. Channel numbers range from 0 to one less than the number of channels.

QERR_MISSING_ENCODER_FILTER_FREQUENCIES

No filter frequencies were specified even though the number of encoder inputs is non-zero.

QERR_INVALID_ENCODER_FILTER_FREQUENCY

One of the filter frequencies that was specified is not a valid filter frequency.

Requirements

Include Files

Libraries

hil.h

hil.lib;quanser_runtime.lib;quanser_common.lib

Examples


/*
* Set the filter frequencies of channels 0 and 4 to 8.33 MHz and
* set channel 2 to 4.17 MHz.
*/

t_uint32 channels[]  = { 0, 2, 4 };
t_double frequency[] = { 1 /(120e-9 * 1), 1 /(120e-9 * 2), 1 /(120e-9 * 1) };
t_error  result = hil_set_encoder_filter_frequency(card, channels, ARRAY_LENGTH(channels), frequency);
    

 

navigation bar