Table of Contents
quanser.hardware.hil.read_encoder_write_pwm_buffer
Reads from the specified encoder input channels and writes to the PWM output channels at the given sampling rate, for the indicated number of samples.
[counts, samples_read, err] = board.read_encoder_write_pwm_buffer(clock, frequency, samples, ... encoder_channels, pwm_channels, duty_cycles)
Reads from the specified encoder input channels and writes to the PWM 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 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.
encoder_channels
A vector of encoder channel numbers.
Select a board type from the list for board-specific details: .
pwm_channels
A vector of PWM channel numbers.
Select a board type from the list for board-specific details: .
duty_cycles
A matrix of PWM duty cycles. Valid values range from -1.0 to +1.0. There must be one row for each channel and one column for each sample.
counts
A matrix of encoder counts, as int32s. 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 0 and 1. duty = rand(2, 5000); % Writes the 5000 samples of the 'duty' data to PWM channel 5 while reading from encoder channels 0 and 3 at 1 kHz. v = board.read_encoder_write_pwm_buffer(-1, 1000, 5000, [0 3], 5, duty);
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.