quanser.hardware.hil.read_other_write_other End of trail navigation bar

Table of Contents

quanser.hardware.hil.read_write

Reads from the specified input channels and writes to the specified output channels.

Syntax

[analog_input_voltages, encoder_counts, digital_input_values, other_input_values, err] = board.read_write(...
    analog_input_channels, encoder_input_channels, digital_input_channels, other_input_channels, ...
    analog_output_channels, pwm_output_channels, digital_output_channels, other_output_channels, ...
    analog_output_voltages, pwm_duty_cycles, digital_output_values, other_output_values)
    

Description

Reads from the specified input channels and writes to the specified output channels. Channel numbers are zero-based. Specify an empty matrix, [], to specify no channels. The write operation is performed immediately after the read operation (generally performed at the hardware or device driver level so the operations are virtually concurrent).

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 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 read_write function failing to read or write the digital I/O as expected.

If no err output is provided then it throws an exception if an error occurs. In generated code it prints the error message. Use hil_get_error_message to get the message associated with an error code.

Parameters

board

The board instance returned by the quanser.hardware.hil.open function.

analog_input_channels

A vector of analog input channel numbers. Channel numbers are zero-based. This parameter may be an empty matrix, [].

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

encoder_input_channels

A vector of encoder input channel numbers. Channel numbers are zero-based. This parameter may be an empty matrix, [].

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

digital_input_channels

A vector of digital input channel numbers. Channel numbers are zero-based. This parameter may be an empty matrix, [].

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

other_input_channels

A vector of other input channel numbers. Channel numbers are zero-based. This parameter may be an empty matrix, [].

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

analog_output_channels

A vector of analog output channel numbers. Channel numbers are zero-based. This parameter may be an empty matrix, [].

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

pwm_output_channels

A vector of PWM output channel numbers. Channel numbers are zero-based. This parameter may be an empty matrix, [].

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

digital_ouput_channels

A vector of digital output channel numbers. Channel numbers are zero-based. This parameter may be an empty matrix, [].

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

other_output_channels

A vector of other output channel numbers. Channel numbers are zero-based. This parameter may be an empty matrix, [].

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

analog_output_voltages

A vector of analog output voltages. There must be one element for each other output channel. If no analog output channels were specified then this parameter may be an empty matrix, [].

pwm_duty_cycles

In PWM duty cycle mode, this argument is a vector of PWM duty cycles. Values may range from -1.0 to +1.0. Sign indicates direction for bipolar PWM outputs.

In PWM frequency mode, this argument is a vector of PWM frequencies in Hertz. Sign indicates direction for bipolar PWM outputs.

In PWM period mode, this argument is a vector of PWM periods in seconds. Sign indicates direction for bipolar PWM outputs.

There must be one element for each PWM output channel. If no PWM output channels were specified then this parameter may be an empty matrix, [].

digital_output_values

A vector of digital output values. The vector must consist of logical values where true (1) represents a high digital input, and false (0) represents a low digital input. There must be one element for each other output channel. If no digital output channels were specified then this parameter may be an empty matrix, [].

other_output_values

A vector of other values. The meaning of the values depends on the channel definitions of the other output channels for the particular data acquisition card. There must be one element for each other output channel. If no other output channels were specified then this parameter may be an empty matrix, [].

Outputs

analog_input_voltages

A vector of the analog voltages read, as doubles. There will be one element for each analog input channel. If no analog input channels were specified then this parameter may be an empty matrix, [].

encoder_counts

A vector of the encoder counts read, as int32s. There will be one element for each encoder input channel. If no encoder input channels were specified then this parameter may be an empty matrix, [].

digital_input_values

A vector of the digital values read, as int8s. There will be one element for each digital input channel. If no digital input channels were specified then this parameter may be an empty matrix, [].

other_input_values

A vector of the other values read, as doubles. The meaning of the values depends on the channel definitions of the other input channels for the particular data acquisition card. There will be one element for each other input channel. If no other input channels were specified then this parameter may be an empty matrix, [].

err

A negative error code or zero on success.

Examples

% Writes 0.5V to analog channel 0 and 1 to digital channel 4 while reading from analog channel 7 and encoder channel 3
[volts, counts] = board.read_write(7, 3, [], [], 0, [], 4, [], 0.5, [], 1, []);
    

See Also

 

navigation bar