Table of Contents
quanser.hardware.task.flush
Flushes any remaining samples from the task's internal buffer to the outputs.
[samples_flushed, err] = task.flush
Flushes any remaining samples from the task's internal buffer to the outputs. This function does not return until all the samples have been written to the 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.
task
Task instance returned by one of the quanser.hardware.hil.task_create functions.
samples_flushed
The number of samples flushed from the internal buffer.
err
A negative error code or zero on success.
% Creates a task to write to analog channel 0, with an internal buffer of 1000 samples. task = board.task_create_analog_writer(1000, 0); % Uniformly distributed random values between -5V and +5V. volts = 5*(rand(1,500)-0.2)*2; % Writes 500 samples to analog channel 0. task.write_analog(500, volts); % Start the task using SYSTEM_CLOCK_1 at 1 kHz. Generate up to 5000 samples. task.start(-1, 1000, 5000); for i=1:10 % Uniformly distributed random values between -5V and +5V. volts = 5*(rand(1,500)-0.2)*2; % Writes 500 samples to analog channel 0. task.write_analog(500, volts); ... end; % Make sure all remaining samples in the internal buffer have been sent to the output. task.flush; % Always good to call task.stop even if the task stops itself. task.stop; task.close;
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.