quanser.hardware.hil.task_create_other_reader_other_writer quanser.hardware.task.read_analog navigation bar

Table of Contents

quanser.hardware.hil.task_create_reader_writer

Creates a task to read the specified channels and write to the specified channels.

Syntax

[task, err] = board.task_create_reader_writer(samples_in_buffer, ...
    analog_input_channels, encoder_input_channels, digital_input_channels, other_input_channels, ...
    analog_output_channels, pwm_output_channels, digital_output_channels, other_output_channels)
    

Description

Creates a task to read from and write to the specified channels. The task must be deleted using the task.close or task_delete_all function. Tasks are used for operation such as data streaming and control. Tasks maintain an internal buffer into which samples are read or from which samples are written in the background once the task is started. Data may be written asynchronously to and read from this buffer using the task_read_write function.

Warning 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 inputs or outputs must be configured accordingly using this function. Failure to configure the digital I/O may result in the task.read_write function failing to read or write the digital I/O as expected.

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.

Parameters

board

The board instance returned by the quanser.hardware.hil.open function.

samples_in_buffer

The number of samples in the task's internal buffer. For double-buffering, make this parameter twice the size of the number of samples read using task_read.

analog_input_channels

A vector of analog input channel numbers. Channel numbers are zero-based. This parameter may be an empty matrix, [].

Select a board type from the list for board-specific details: .

encoder_input_channels

A vector of encoder input channel numbers. Channel numbers are zero-based. This parameter may be an empty matrix, [].

Select a board type from the list for board-specific details: .

digital_input_channels

A vector of digital input channel numbers. Channel numbers are zero-based. This parameter may be an empty matrix, [].

Select a board type from the list for board-specific details: .

other_input_channels

A vector of other input channel numbers. Channel numbers are zero-based. This parameter may be an empty matrix, [].

Select a board type from the list for board-specific details: .

analog_output_channels

A vector of analog output channel numbers. Channel numbers are zero-based. This parameter may be an empty matrix, [].

Select a board type from the list for board-specific details: .

pwm_output_channels

A vector of pwm output channel numbers. Channel numbers are zero-based. This parameter may be an empty matrix, [].

Select a board type from the list for board-specific details: .

digital_output_channels

A vector of digital output channel numbers. Channel numbers are zero-based. This parameter may be an empty matrix, [].

Select a board type from the list for board-specific details: .

other_output_channels

A vector of other output channel numbers. Channel numbers are zero-based. This parameter may be an empty matrix, [].

Select a board type from the list for board-specific details: .

Outputs

task

A task instance.

err

A negative error code or zero on success.

Examples

% Creates a task to read analog channels 0 and 3 and encoder channel 2, and write to analog channel 7 and digital channel 5, with an internal buffer of 1000 samples.
task = board.task_create_reader_writer(1000, [0 3], 2, [], [], 7, [], 5, []);
    

See Also

 

navigation bar