Table of Contents
hil_set_pwm_configuration
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.
err = hil_set_pwm_configuration(board, 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
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 |
|
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.
hil_set_pwm_configuration(board, 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.