quanser.hardware.hil.read_other_buffer quanser.hardware.hil.write_analog_buffer navigation bar

Table of Contents

quanser.hardware.hil.read_buffer

Reads the specified number of samples from a combination of channels at the indicated sampling rate.

Syntax

[analog_voltages, encoder_counts, digital_values, other_values, samples_read, err] = board.read_buffer(...
    clock, frequency, samples, analog_channels, encoder_channels, digital_channels, other_channels)
    

Description

Reads the specified analog, encoder, digital or other input channels at the indicated sampling rate. The clock parameter indicates the clock to use as a timebase. This function outputs voltages, counts, states or values as separate matrices. In each matrix, there is one row for each channel, and one column for each sample. The channels appear in the rows of the output matrix in the same order that they are specified in the channels parameter.

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 must be configured as inputs using this function. Failure to configure the digital I/O may result in the read_buffer function failing to read those inputs.

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.

clock

The clock to use as a timebase for the buffered operation. Hardware clocks are numbered incrementally starting at 0, with 0 meaning HARDWARE_CLOCK_0, 1 meaning HARDWARE_CLOCK_1, etc. The number of clocks available depends on the board selected. Refer to Clocks for more information.

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

frequency

The number of samples per second to collect from the specified channels. At each sampling instant, all indicated channels are read.

samples

The number of samples to collect from the specified channels. One sample consists of all the indicated channels.

analog_channels

A vector of analog 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_channels

A vector of encoder 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_channels

A vector of digital 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_channels

A vector of other 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: .

Outputs

analog_values

A matrix of analog voltages, as doubles. There is one row for each analog channel and one column for each sample. If no analog channels were specified then this parameter may be an empty matrix, [].

encoder_counts

A matrix of encoder counts, as int32s. There is one row for each encoder channel and one column for each sample. If no encoder channels were specified then this parameter may be an empty matrix, [].

digital_values

A matrix of digital values, as int8s. There is one row for each digital channel and one column for each sample. If no digital channels were specified then this parameter may be an empty matrix, [].

other_values

A matrix of other values, as doubles. There is one row for each other channel and one column for each sample. If no other channels were specified then this parameter may be an empty matrix, [].

samples_read

The number of samples read. This value will equal the number of samples specified unless the operation was canceled.

err

A negative error code or zero on success.

Examples

% Reads 5000 samples of analog channel 0, encoder channel 4, digital channel 2 and other channel 1 at 1 kHz using SYSTEM_CLOCK_1
[volt, cnt, bit, xtra] = board.read_buffer(-1, 1000, 5000, 0, 4, 2, 1);

% Reads 5000 samples of analog channel 0 and digital channels 2 and 3 at 1 kHz using HARDWARE_CLOCK_0
[voltage, bits]  = board.read_buffer(0, 1000, 5000, 0, [], [2 3]);

% Reads 5000 samples of analog channel 0 and encoder channel 4 at 10 kHz using HARDWARE_CLOCK_1
[voltage, count] = board.read_buffer(1, 10000, 5000, 0, 4);
    

See Also

 

navigation bar