hil_set_encoder_filter_frequency hil_set_pwm_deadband navigation bar

Table of Contents

hil_set_pwm_configuration

Deprecated

The HIL API MATLAB functions have been deprecated in favour of the new quanser.hardware.hil class, which has support for code generation for Quanser targets. Hence, with the new hil class it is possible to run MATLAB scripts in real-time on Quanser targets, while making use of the Quanser hardware.

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

Syntax

err = hil_set_pwm_configuration(board, 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

A board handle returned by hil_open.

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

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

See Also

 

navigation bar