Table of Contents
hil_read_digital_write_digital
Reads from digital inputs and writes to digital outputs immediately.
Description
The hil_read_digital_write_digital function reads from the specified digital input channels and writes to the specified digital output channels in a single function call. The write operation occurs immediately following the read operation. Since the read-write operation occurs at the lowest level the read and write occur virtually concurrently. The function does not return until the data has been read and written.
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 inputs or outputs must be configured accordingly using this function. Failure to configure the digital I/O may result in the hil_read_digital_write_digital function failing to read or write the digital I/O as expected.
Prototype
t_error hil_read_digital_write_digital(t_card card, const t_uint32 digital_input_channels[], t_uint32 num_digital_input_channels, const t_uint32 digital_output_channels[], t_uint32 num_digital_output_channels, t_boolean digital_input_buffer[], const t_boolean digital_output_buffer[]);
Parameters
t_card card
A handle to the board, as returned by hil_open
const t_uint32 [] digital_input_channels
An array containing the channel numbers of the digital inputs to be read.
Select a board type from the list for board-specific details: .
t_uint32 num_digital_input_channels
The number of channels specified in the digital_input_channels array.
const t_uint32 [] digital_output_channels
An array containing the channel numbers of the digital outputs to be written.
Select a board type from the list for board-specific details: .
t_uint32 num_digital_output_channels
The number of channels specified in the digital_output_channels array.
t_boolean [] digital_input_buffer
An array for receiving the voltage values read from the digital inputs. The array must contain num_digital_input_channels elements. Each element in the returned digital_input_buffer array will correspond to the same element in the digital_input_channels array.
const t_boolean [] digital_output_buffer
An array of voltage values to write to the digital outputs. The array must contain num_digital_output_channels elements. Each element in the digital_output_buffer array corresponds to the same element in the digital_output_channels array.
Return value
The return value is 0 if the I/O operation is performed 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_READ_DIGITAL_WRITE_DIGITAL_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_INPUT_CHANNELS
Too many digital input channels were specified.
QERR_INVALID_DIGITAL_INPUT_CHANNEL
One of the digital input channels that was specified is not a valid channel number. Channel numbers range from 0 to one less than the number of channels.
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_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
/*
* Read the first four digital input channels and writes
* to digital output channels 5 and 7.
*/
t_uint32 input_channels[] = { 0, 1, 2, 3 };
t_boolean input_buffer[4];
t_uint32 output_channels[] = { 5, 7 };
t_boolean output_buffer[] = { 1, 0 };
t_error result = hil_read_digital_write_digital(board
, input_channels, ARRAY_LENGTH(input_channels)
, output_channels, ARRAY_LENGTH(output_channels)
, input_buffer
, output_buffer
);
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.