Table of Contents
quanser.hardware.task.read_encoder
Reads the specified number of encoder samples from the task's internal buffer.
[values, samples_read, err] = task.read_encoder(samples)
Reads the specified number of encoder samples from the task's internal buffer. This function will block until the requested number of samples has been read or the task is stopped.
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 quanser.hardware.hil.task_create_encoder_reader or quanser.hardware.hil.task_create_encoder_reader_pwm_writer.
samples
The number of samples to read. This number must be less than or equal to the internal buffer size assigned to the task in the quanser.hardware.hil.task_create_encoder_reader or quanser.hardware.hil.task_create_encoder_reader_pwm_writer call.
values
A matrix of encoder values, as int32s. There is one row for each channel and one column for each sample.
samples_read
The number of samples read. This number will be equal to the number of samples specified unless the total number of samples specified in task.start has expired or the task has been stopped.
err
A negative error code or zero on success.
% Creates a task to read encoder channels 0 and 3, with an internal buffer of 1000 samples. task = board.task_create_encoder_reader(1000, [0 3]); % Start the task using SYSTEM_CLOCK_1 at 1 kHz. Collect up to 5000 samples. task.start(-1, 1000, 5000); % Reads 500 samples of encoder channels 0 and 3. Takes 0.5 seconds to complete read. for i=1:10 [values, n] = task.read_encoder(500); ... end; 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.