Table of Contents
hil_read_analog_write_analog_buffer
The HIL API MATLAB functions have been deprecated in favour of the new quanser.hardware.hil class, which has support for code generation for Quanser targets. Hence, with the new hil class it is possible to run MATLAB scripts in real-time on Quanser targets, while making use of the Quanser hardware. |
Reads from the specified analog input channels and writes to the analog output channels at the given sampling rate, for the indicated number of samples.
[input_voltages, samples_read, err] = hil_read_analog_write_analog_buffer(board, clock, frequency, samples, ... input_channels, output_channels, output_voltages)
Reads from the specified analog input channels and writes to the analog 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.
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 handle returned by hil_open.
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_voltages
A matrix of analog voltages. There must be one row for each channel and one column for each sample.
input_voltages
A matrix of analog voltages, as doubles. 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.
% Uniformly distributed random voltages between -5V and +5V. volts = 5*(rand(2, 5000)-0.5)*2; % Writes the 5000 samples of the 'volts' data to analog channel 5 while reading from analog channels 0 and 3 at 1 kHz. v = hil_read_analog_write_analog_buffer(board, -1, 1000, 5000, [0 3], 5, volts);
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.