hil_set_digital_directions hil_set_encoder_filter_frequency navigation bar

Table of Contents

hil_set_encoder_counts

Sets the count values for the encoder counters.

Description

The hil_set_encoder_counts function sets the count values for the encoder counters. This function is typically used to initialize the encoder counters to zero when the board is first opened.

Prototype

t_error
hil_set_encoder_counts(t_card card, const t_uint32 encoder_channels[], t_uint32 num_channels, const t_int32 counts[]);
    

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 counters will be set.

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_int32 [] counts

An array of count values to which to set the encoder counters. Each element in the counts array corresponds to the same element in the encoder_channels array. Hence, there must be as many elements in the counts array as there are channels.

Return value

The return value is 0 if the encoder counts 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_COUNTS_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_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.

Requirements

Include Files

Libraries

hil.h

hil.lib;quanser_runtime.lib;quanser_common.lib

Examples


/*
* Set the count values for three encoder channels. Channel 0 is set to 1000, channel 1 is set to -1000
* and channel 3 is set to 0.
*/

t_uint32 channels[] = { 0, 1, 3 };
t_int32 counts[] = { 1000, -1000, 0 };
t_error result = hil_set_encoder_counts(board, channels, ARRAY_LENGTH(channels), counts);
    

 

navigation bar