hil_write_analog hil_write_pwm navigation bar

hil_write_analog_codes

Writes to analog outputs immediately using raw D/A converter values.

Description

The hil_write_analog_codes function writes to the specified analog output channels immediately using raw D/A converter values. The function does not return until the data has been written.

Prototype

t_error
hil_write_analog_codes(t_card card, const t_uint32 analog_channels[], t_uint32 num_channels, const t_int32 buffer[]);
    

Parameters

t_card card

A handle to the board, as returned by hil_open .

const t_uint32 [] analog_channels

An array containing the channel numbers of the analog outputs to be written.

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

t_uint32 num_channels

The number of channels specified in the analog_channels array.

const t_int32 [] buffer

An array containing the raw D/A converter values to write to the analog outputs. The array must contain num_channels elements. Each element in the buffer array corresponds to the same element in the analog_channels array.

Return value

The return value is 0 if the analog outputs are written 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_WRITE_ANALOG_CODES_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_ANALOG_OUTPUTS

The analog_channels argument is NULL. If the number of channels is greater than zero then a channel vector must be provided.

QERR_MISSING_ANALOG_OUTPUT_BUFFER

The buffer argument is NULL. If the number of channels is greater than zero then a buffer must be provided.

QERR_TOO_MANY_ANALOG_OUTPUT_CHANNELS

Too many analog output channels were specified.

QERR_INVALID_ANALOG_OUTPUT_CHANNEL

One of the analog 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_DRIVER_INCOMPATIBLE_WITH_BOARD_DLL

The board-specific HIL driver passed an invalid parameter to the operating system specific kernel-level driver for the board. The board-specific HIL driver is likely not compatible with the operating system specific kernel-level driver for the board. Make sure both are up-to-date and compatible versions.

QERR_INTERNAL_BUFFER_TOO_SMALL

The board-specific HIL driver used an internal buffer that was too small for the operating system specific kernel-level driver for the board. The board-specific HIL driver is likely not compatible with the operating system specific kernel-level driver for the board. Make sure both are up-to-date and compatible versions.

QERR_OUT_OF_REQUIRED_SYSTEM_RESOURCES

There are not enough system resources to perform the requested operation. Try rebooting, requesting fewer samples, or adding more memory to your machine.

Requirements

Include Files

Libraries

hil.h

hil.lib;quanser_runtime.lib;quanser_common.lib

Examples


/*
* Write to the first four analog output channels using raw D/A converter values.
*/

t_uint32 channels[] = { 0, 1, 2, 3 };
t_int32  buffer[]   = { 0x000, 0x3ff, 0x5ff, 0x7ff };
t_error result = hil_write_analog_codes(board, channels, ARRAY_LENGTH(channels), buffer);
    

 

navigation bar