Table of Contents
quanser.hardware.hil.read_write_buffer
Reads from the specified input channels and writes to the specified output channels at the given sampling rate, for the indicated number of samples.
[analog_input_voltages, encoder_counts, digital_input_values, other_input_values, err] = board.read_write_buffer(... clock, frequency, samples, ... 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)
Reads from the specified input channels and writes to the specified output channels at the given sampling rate, for the indicated number of samples. Channel numbers are zero-based. 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). This function is particularly useful for system identification because the reads and writes are synchronized. The first sample read is the initial condition. The next sample read is the response to the previous sample written. Likewise for subsequent samples.
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_buffer 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.
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 sampling frequency in Hertz at which samples will be collected.
samples
The number of samples to collect and generate.
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_output_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 matrix of analog output voltages. There must be one row for each analog output channel and one column for each sample. 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 matrix 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 matrix of PWM frequencies in Hertz. Sign indicates direction for bipolar PWM outputs.
In PWM period mode, this argument is a matrix of PWM periods in seconds. Sign indicates direction for bipolar PWM outputs.
There must be one row for each PWM output channel and one column for each sample. If no PWM output channels were specified then this parameter may be an empty matrix, [].
digital_output_values
A matrix of in digital output values. Values may be 0 or 1. There must be one row for each digital output channel and one column for each sample. If no digital output channels were specified then this parameter may be an empty matrix, [].
other_output_values
A matrix of other values. There must be one row for each other output channel and one column for each sample. If no other output channels were specified then this parameter may be an empty matrix, [].
analog_input_voltages
A matrix of the analog voltages read, as doubles. There will be one row for each analog input channel and one column for each sample. If no analog input channels were specified then this parameter may be an empty matrix, [].
encoder_counts
A matrix of the encoder counts read, as int32s. There will be one row for each encoder input channel and one column for each sample. If no encoder input channels were specified then this parameter may be an empty matrix, [].
digital_input_values
A matrix of the digital values read, as int8s. There will be one row for each digital input channel and one column for each sample. If no digital input channels were specified then this parameter may be an empty matrix, [].
other_input_values
A matrix of the other values read, as doubles. There will be one row for each other input channel and one column for each sample. If no other input channels were specified then this parameter may be an empty matrix, [].
err
A negative error code or zero on success.
% Uniformly distributed random voltages between -5V and +5V. volts = 5*(rand(1, 5000)-0.5)*2; % Uniformly distributed random values between 0 and 1. bits = rand(1, 5000); % Writes the 5000 samples of the 'volts' data to analog channel 0 and and the 'bits' data to digital channel 4 while reading from analog channel 7 and encoder channel 3 at 1 kHz. [volts, counts] = board.read_write_buffer(-1, 1000, 5000, 7, 3, [], [], 0, [], 4, [], volts, [], bits, []);
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.