quanser.hardware.hil.set_integer_property quanser.hardware.hil.set_pwm_deadband navigation bar

Table of Contents

quanser.hardware.hil.set_pwm_configuration

Sets the configuration, alignment and polarity of the specified PWM channels.

Syntax

err = board.set_pwm_configuration(channels, configurations, alignments, polarities)
    

Description

Sets the configuration, alignment and polarity of the specified PWM channels. This function configures the PWM channels to be unipolar, bipolar, complementary or paired. It also determines whether the pulses are aligned on the leading-edge or trailing-edge of the PWM period or center-aligned. Finally, the polarity of the output can also be configured.

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

configurations

A vector of configuration values, in which each element may be:

Configuration

Name

Comment

0

PWM_UNIPOLAR_CONFIGURATION

unipolar output (default)

1

PWM_BIPOLAR_CONFIGURATION

bipolar output

2

PWM_PAIRED_CONFIGURATION

paired output

3

PWM_COMPLEMENTARY_CONFIGURATION

complementary output

Each element corresponds to the channel at the same index in the channels vector.

alignments

A vector of alignments. Each element may be assigned:

Alignment

Name

Comment

0

PWM_LEADING_EDGE_ALIGNED

leading-edge alignment (pulse occurs at beginning of period)

1

PWM_TRAILING_EDGE_ALIGNED

trailing-edge alignment (pulse occurs at end of period)

2

PWM_CENTER_ALIGNED

center-aligned (pulse occurs in middle of period)

Each element corresponds to the channel at the same index in the channels vector.

polarities

A vector of polarities. Each element is either:

Polarity

Name

Comment

0

PWM_ACTIVE_LOW_POLARITY

active-low polarity (duty cycle determines low pulse width)

1

PWM_ACTIVE_HIGH_POLARITY

active-high polarity (duty cycle determines high pulse width)

Each element corresponds to the channel at the same index in the channels vector.

Outputs

err

A negative error code or zero on success.

Examples

board.set_pwm_configuration(0, [3], [2], [1]); % Sets PWM channel 0 to complementary, center-aligned, active-high
    

See Also

 

navigation bar