Table of Contents
quanser.hardware.hil.write_digital_buffer
Writes the specified samples to the digital channels at the indicated sampling rate.
[samples_written, err] = board.write_digital_buffer(clock, frequency, channels, values)
Writes the specified samples to the digital channels at the indicated sampling rate. The number of samples is determined by the number of columns in the values matrix.
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 outputs must be configured as outputs using this function. Failure to configure the digital I/O may result in the write_digital_buffer function failing to write those outputs.
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.
channels
A vector of channel numbers. Channel numbers are zero-based.
Select a board type from the list for board-specific details: .
values
A matrix of logical values. Valid values are 0 or 1. There must be one row for each channel and one column for each sample.
samples_written
The number of samples written. This value will equal the number of samples specified unless the operation was canceled.
err
A negative error code or zero on success.
% Random logical values values = (rand(2, 5000) >= 0.5); % Writes 5000 samples to digital channels 0 and 3 at 1 kHz using SYSTEM_CLOCK_1 board.write_digital_buffer(-1, 1000, [0 3], 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.