hil_watchdog_set_pwm_expiration_state hil_watchdog_set_other_expiration_state navigation bar

hil_watchdog_set_digital_expiration_state

Sets the state that the digital outputs will be set to if the watchdog expires.

Description

The hil_watchdog_set_digital_expiration_state function sets the state that the digital outputs will be set to if the watchdog expires. Most cards do not allow this state to be configured. The expiration states must be set prior to starting the watchdog timer using hil_watchdog_start. Valid output states are:

State

Description

DIGITAL_STATE_LOW

Set the digital output low (ground).

DIGITAL_STATE_HIGH

Set the digital output high (Vcc).

DIGITAL_STATE_TRISTATE

Set the digital output tristate.

DIGITAL_STATE_NO_CHANGE

Do not change the expiration state of this digital output.

The Q8-series cards may be configured to reset the digital outputs to tri-state. In this case, the analog outputs must also be configured to go to 0V. If no expiration states are configured for the Q8-series, then the analog and digital outputs will not be reconfigured when the watchdog expires.

Warning Many cards allow the digital I/O lines to be programmed as inputs or outputs. The digital I/O lines are configured as inputs or outputs using the hil_set_digital_directions function. All the channels which will be used as digital outputs must be configured as outputs using this function. Failure to configure the digital I/O may result in the hil_watchdog_set_digital_expiration_state function failing to write those outputs when the watchdog expires.

Prototype

t_error
hil_watchdog_set_digital_expiration_state(t_card card, const t_uint channels[], t_uint num_channels, const t_digital_state states[]);
    

Parameters

t_card card

A handle to the board, as returned by hil_open .

const t_uint32 [] channels

An array containing the numbers of the digital output channels for which the expiration state should 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 channels array.

const t_digital_state [] states

An array of t_digital_state constants in which each element contains the digital state to which to set the corresponding channel in the digital_channels array upon watchdog expiration. This array must be the same size as the digital_channels array.

Return value

The return value is 0 if the digital expiration states are configured 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_WATCHDOG_SET_DIGITAL_EXPIRATION_STATE_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_DIGITAL_OUTPUT_CHANNELS

Too many digital output channels were specified.

QERR_INVALID_DIGITAL_OUTPUT_CHANNEL

One of the digital output 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_DIGITAL_OUTPUTS

The array of digital output channels is NULL even though the number of digital outputs specified is non-zero.

QERR_MISSING_DIGITAL_OUTPUT_BUFFER

The array of states is NULL even though the number of channels specified is non-zero.

Requirements

Include Files

Libraries

hil.h

hil.lib;quanser_runtime.lib;quanser_common.lib

Examples


/*
* Configure the first three digital outputs to go tristate upon watchdog expiration.
*/

t_uint32 channels[] = {  0, 1, 2 };
t_double states[]   = {  DIGITAL_STATE_TRISTATE, DIGITAL_STATE_TRISTATE, DIGITAL_STATE_TRISTATE };
t_error  result = hil_watchdog_set_digital_expiration_state(card, channels, ARRAY_LENGTH(channels), states);
    

 

navigation bar