hil_set_encoder_filter_frequency hil_set_pwm_mode navigation bar

hil_set_encoder_quadrature_mode

Sets the quadrature mode of the encoder inputs on the card.

Description

The hil_set_encoder_quadrature_mode function sets the quadrature mode of the encoder inputs on the card. Many cards do not support encoders. Cards which do provide encoders may not support different quadrature modes, or may not support different quadrature modes for each channel. Valid quadrature modes are:

ENCODER_QUADRATURE_NONE

-

No quadrature. Inputs are count and direction.

ENCODER_QUADRATURE_1X

-

1X. Inputs are A and B channels.

ENCODER_QUADRATURE_2X

-

2X. Inputs are A and B channels.

ENCODER_QUADRATURE_4X

-

4X. Inputs are A and B channels.

The Quanser Q8-series support all the quadrature modes and each channel may be assigned a different mode. The 4X quadrature mode is typically the mode used for encoders because it provides the highest encoder resolution. The non-quadrature mode is used for frequency counting and other applications where count and direction inputs are required rather than standard A/B encoder inputs.

Prototype

t_error
hil_set_encoder_quadrature_mode(t_card card, const t_uint32 encoder_channels[], t_uint32 num_channels, const t_encoder_quadrature_mode mode[]);
    

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 quadrature modes 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_encoder_quadrature_mode [] mode

An array of t_encoder_quadrature constants containing the new encoder quadrature mode for each channel. 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 quadrature modes 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_QUADRATURE_MODE_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_QUADRATURE_MODES

No quadrature modes were specified even though the number of encoder inputs is non-zero.

QERR_INVALID_ENCODER_QUADRATURE_MODE

One of the quadrature modes that was specified is not a valid mode.

Requirements

Include Files

Libraries

hil.h

hil.lib;quanser_runtime.lib;quanser_common.lib

Examples


/*
* Set the quadrature mode of channels 0 and 2 to 4X quadrature and
* set channel 1 to non-quadrature mode.
*/

t_uint32 channels[] = { 0, 1, 2 };
t_int32  modes[]    = { ENCODER_QUADRATURE_4X, ENCODER_QUADRATURE_NONE, ENCODER_QUADRATURE_4X };
t_error  result = hil_set_encoder_quadrature_mode(card, channels, ARRAY_LENGTH(channels), modes);
    

 

navigation bar