Table of Contents
quanser.hardware.hil.set_pwm_mode
Sets the mode of the specified PWM channels.
err = board.set_pwm_mode(channels, pwm_modes)
Sets the mode of the specified PWM channels. The mode determines how values written to the PWM outputs are interpreted.
In duty cycle mode values are interpreted as duty cycles, with 0.0 indicating a 0% duty cycle and 1.0 indicating a 100% duty cycle. The PWM output frequency is fixed in this case and may be set using the set_pwm_frequency function.
In frequency mode values are interpreted as frequencies. In this case the duty cycle is fixed and may be set using the set_pwm_duty_cycle function.
In period mode values are interpreted as periods. In this case the duty cycle is fixed and may be set using the set_pwm_duty_cycle function.
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: .
pwm_modes
A vector of PWM modes. There must be one element for each channel in the channels vector. Valid modes are:
Mode |
Name |
Comment |
---|---|---|
0 |
|
Values are interpreted as duty cycles where 0.0 is 0% and 1.0 is 100% - the default |
1 |
|
Values are interpreted as frequencies |
2 |
|
Values are interpreted as periods |
3 |
|
Values are interpreted as duty cycles where 0.0 is 0% and 1.0 is 100%, but only a single pulse generated per write |
4 |
|
Values are interpreted as the active pulse time in seconds, which should range from 0 to the PWM period |
err
A negative error code or zero on success.
% Writes 50% to pwm channel 0, 100% to channel 3 and -50% to channel 5
board.set_pwm_mode([0 3 5], [0.5 1.0 -0.5);
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.