quanser.hardware.hil.task_create_pwm_writer quanser.hardware.hil.task_create_other_writer navigation bar

Table of Contents

quanser.hardware.hil.task_create_digital_writer

Creates a task to write to the specified digital channels.

Syntax

[task, err] = board.task_create_digital_writer(samples_in_buffer, channels)
    

Description

Creates a task to write to the specified digital 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 this buffer using the task_write functions or read from this buffer using the task_read functions.

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 outputs must be configured as outputs using this function. Failure to configure the digital I/O may result in the hil_task_write_digital function failing to write those 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.

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 written using task_write_digital.

channels

A vector of channel numbers. Channel numbers are zero-based.

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 write to digital channels 0 and 3, with an internal buffer of 1000 samples.
task = board.task_create_digital_writer(1000, [0 3]);
    

See Also

 

navigation bar