Table of Contents
quanser.hardware.hil.read_digital_write_digital_buffer
Reads from the specified digital input channels and writes to the digital output channels at the given sampling rate, for the indicated number of samples.
[input_values, samples_read, err] = board.read_digital_write_digital_buffer(clock, frequency, samples, ... input_channels, output_channels, output_values)
Reads from the specified digital input channels and writes to the digital 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_digital_write_digital_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.
input_channels
A vector of input channel numbers.
Select a board type from the list for board-specific details: .
output_channels
A vector of output channel numbers.
Select a board type from the list for board-specific details: .
output_values
A matrix of logical values. There must be one row for each channel and one column for each sample.
input_values
A matrix of digital values, as int8s. There is one row for each channel. All output matrices must have the same number of columns.
samples_read
The number of samples collected. This number will always equal the number of specified samples unless the operation was canceled.
err
A negative error code or zero on success.
% Random logical values. values = (rand(2, 5000) >= 0.5); % Writes the 5000 samples of the 'values' data to digital channel 5 while reading from digital channels 0 and 3 at 1 kHz. v = board.read_digital_write_digital_buffer(-1, 1000, 5000, [0 3], 5, values);
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.