hil_watchdog_set_analog_expiration_state hil_watchdog_set_digital_expiration_state navigation bar

Table of Contents

hil_watchdog_set_pwm_expiration_state

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

Description

The hil_watchdog_set_pwm_expiration_state function sets the state that the PWM outputs will be set to if the watchdog expires. The expiration states must be set prior to starting the watchdog timer using hil_watchdog_start. Currently there are no cards which allow this state to be configured.

Prototype

t_error
hil_watchdog_set_pwm_expiration_state(t_card card, const t_uint channels[], t_uint num_channels, const t_double duty_cycles[]);
    

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 PWM 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_double [] duty_cycles

An array of doubles (t_double) in which each element contains the PWM duty cycle, frequency or period to which to set the corresponding channel in the pwm_channels array upon watchdog expiration. The interpretation of this parameter depends upon the PWM mode set using the hil_set_pwm_mode function. This array must be the same size as the pwm_channels array.

Return value

The return value is 0 if the PWM 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_PWM_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_PWM_OUTPUT_CHANNELS

Too many PWM output channels were specified.

QERR_INVALID_PWM_OUTPUT_CHANNEL

One of the PWM 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_PWM_OUTPUTS

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

QERR_MISSING_PWM_OUTPUT_BUFFER

The array of duty_cycles 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 two PWM outputs to go to 0V upon watchdog expiration.
*/

t_uint32 channels[]    = { 0, 1 };
t_double duty_cycles[] = { 0, 0 };
t_error  result = hil_watchdog_set_pwm_expiration_state(card, channels, ARRAY_LENGTH(channels), duty_cycles);
    

 

navigation bar