quanser.hardware.hil.write_analog_codes quanser.hardware.hil.write_digital navigation bar

Table of Contents

quanser.hardware.hil.write_pwm

Writes to the specified PWM channels.

Syntax

err = board.write_pwm(channels, duty_cycles)
    

Description

Writes the specified PWM channels immediately. It normally takes a vector of duty cycles since the default PWM mode is the duty cycle mode. However, if the PWM mode is the frequency mode then this function takes a vector of frequencies instead of duty cycles. If it is the period mode, then it takes a vector of periods instead of duty cycles. The frequency and period PWM modes may be used to produce FM outputs, while the PWM duty cycle mode produces the standard PWM output.

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.

channels

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

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

duty_cycles

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

In PWM frequency mode, this argument is a vector of frequencies in Hertz. Sign indicates direction for bipolar PWM outputs. There must be one element for each channel.

In PWM period mode, this argument is a vector of periods in seconds. Sign indicates direction for bipolar PWM outputs. There must be one element for each channel.

Outputs

err

A negative error code or zero on success.

Examples

% Writes 50% to PWM channel 0, 100% to channel 3 and -50% to channel 5
board.write_pwm([0 3 5], [0.5 1.0 -0.5]);
    

See Also

 

navigation bar