Table of Contents
quanser.hardware.hil.set_pwm_configuration
Sets the configuration, alignment and polarity of the specified PWM channels.
err = board.set_pwm_configuration(channels, configurations, alignments, polarities)
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.
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 |
|
unipolar output (default) |
1 |
|
bipolar output |
2 |
|
paired output |
3 |
|
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 |
|
leading-edge alignment (pulse occurs at beginning of period) |
1 |
|
trailing-edge alignment (pulse occurs at end of period) |
2 |
|
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 |
|
active-low polarity (duty cycle determines low pulse width) |
1 |
|
active-high polarity (duty cycle determines high pulse width) |
Each element corresponds to the channel at the same index in the channels vector.
err
A negative error code or zero on success.
board.set_pwm_configuration(0, [3], [2], [1]); % Sets PWM channel 0 to complementary, center-aligned, active-high
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.