quanser.hardware.hil.write_other quanser.hardware.hil.read_analog_write_analog navigation bar

Table of Contents

quanser.hardware.hil.write

Writes to the specified channels.

Syntax

err = board.write(analog_channels, pwm_channels, digital_channels, other_channels,
    analog_voltages, pwm_duty_cycles, digital_values, other_values)
    

Description

Writes to the specified analog, digital, PWM and other channels immediately. Channel numbers are zero-based. Specify an empty matrix, [], to specify no channels.

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 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.

analog_channels

A vector of analog 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_channels

A vector of PWM 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_channels

A vector of digital 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_channels

A vector of other 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_voltages

A vector of analog voltages. There must be one element for each analog channel. If no analog channels were specified then this parameter may be an empty matrix, [].

pwm_duty_cycles

In PWM duty cycle mode, this argument is a vector of PWM duty cycles. Values may range from -1.0 to +1.0. Sign indicates direction for bipolar PWM outputs.

In PWM frequency mode, this argument is a vector of PWM frequencies in Hertz. Sign indicates direction for bipolar PWM outputs.

In PWM period mode, this argument is a vector of PWM periods in seconds. Sign indicates direction for bipolar PWM outputs.

There must be one element for each PWM output channel. If no PWM channels were specified then this parameter may be an empty matrix, [].

digital_values

A vector of logical values. A value of true (1) represents a high digital output and a value of false (0) represents a low digital output. There must be one element for each digital channel. If no digital channels were specified then this parameter may be an empty matrix, [].

other_values

A vector of values. There must be one element for each other channel. If no other channels were specified then this parameter may be an empty matrix, [].

Outputs

err

A negative error code or zero on success.

Examples

% Writes 0.5V to analog channel 0, 70% to PWM channel 4,
% 0 to digital channel 2 and -1.2 to other channel 1
board.write(0, 4, 2, 1, 0.5, 0.7, 0, -1.2);
    

See Also

 

navigation bar