Table of Contents
hil_task_flush
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. |
Flushes any remaining samples from the task's internal buffer to the outputs.
[samples_flushed, err] = hil_task_flush(task)
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 handle returned by one of the 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 = hil_task_create_analog_writer(board, 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. hil_task_write_analog(task, 500, volts); % Start the task using SYSTEM_CLOCK_1 at 1 kHz. Generate up to 5000 samples. hil_task_start(task, -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. hil_task_write_analog(task, 500, volts); ... end; % Make sure all remaining samples in the internal buffer have been sent to the output. hil_task_flush(task); % Always good to call hil_task_stop even if the task stops itself. hil_task_stop(task); hil_task_delete(task);
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.