Sets the mode of the PWM outputs on the card.
Namespace:
Quanser.HardwareAssembly: Quanser.Hardware.Hil (in Quanser.Hardware.Hil.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Sub SetPwmMode ( _ channels As Integer(), _ modes As Hil..::.PwmMode() _ ) |
C# |
---|
public void SetPwmMode( int[] channels, Hil..::.PwmMode[] modes ) |
Visual C++ |
---|
public: void SetPwmMode( array<int>^ channels, array<Hil..::.PwmMode>^ modes ) |
JavaScript |
---|
function setPwmMode(channels, modes); |
Parameters
- channels
- Type: array<
System..::.Int32
>[]()[]
An array containing the numbers of the PWM channels whose modes will be set. Channel numbers are zero-based. Thus, channel 0 is the first channel, channel 1 the second channel, etc.
Select a board type from the list for board-specific details: .
- modes
- Type: array<
Quanser.Hardware..::.Hil..::.PwmMode
>[]()[]
An array of modes containing the new PWM mode for each channel. Each element in the modes array corresponds to the same element in the channels array. Hence, there must be as many elements in the modes array as there are channels.
Remarks
The SetPwmMode method sets the modes that will be used for PWM outputs. The mode determines how the values written to a PWM output are interpreted. Refer to the Hil..::.PwmMode enumeration for a list of the valid PWM modes.
The actual PWM output modes are not changed until the PWM outputs are used in one of the following functions:
- WritePwm(array<Int32>[]()[], array<Double>[]()[])
- Write(array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Double>[]()[], array<Double>[]()[], array<SByte>[]()[], array<Double>[]()[])
- ReadEncoderWritePwm(array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Double>[]()[])
- ReadWrite(array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Double>[]()[], array<Int32>[]()[], array<SByte>[]()[], array<Double>[]()[], array<Double>[]()[], array<Double>[]()[], array<SByte>[]()[], array<Double>[]()[])
- WritePwmBuffer(Hil..::.Clock, Double, Int32, array<Int32>[]()[], array<Double>[]()[])
- WriteBuffer(Hil..::.Clock, Double, Int32, array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Double>[]()[], array<Double>[]()[], array<SByte>[]()[], array<Double>[]()[])
- ReadEncoderWritePwmBuffer(Hil..::.Clock, Double, Int32, array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Double>[]()[])
- ReadWriteBuffer(Hil..::.Clock, Double, Int32, array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Double>[]()[], array<Int32>[]()[], array<SByte>[]()[], array<Double>[]()[], array<Double>[]()[], array<Double>[]()[], array<SByte>[]()[], array<Double>[]()[])
Examples
This sample illustrates how to use the SetPwmMode(array<Int32>[]()[], array<Hil..::.PwmMode>[]()[]) method.
It sets the PWM mode of channel 0 to Hil.PwmMode.DutyCycle and the
mode of channel 1 to Hil.PwmMode.Frequency.
C# | Copy Code |
---|---|
int [] channels = { 0, 1, }; Hil.PwmMode [] modes = { Hil.PwmMode.DutyCycle, Hil.PwmMode.Frequency }; board.SetPwmMode(channels, modes); |
Visual Basic | Copy Code |
---|---|
Dim channels() As Integer = {0, 1} Dim modes() As Hil.PwmMode = {Hil.PwmMode.DutyCycle, Hil.PwmMode.Frequency} board.SetPwmMode(channels, modes) |
Visual C++ | Copy Code |
---|---|
array<int>^ channels = { 0, 1, }; array<Hil::PwmMode>^ modes = { Hil::PwmMode::DutyCycle, Hil::PwmMode::Frequency }; board->SetPwmMode(channels, modes); |
Exceptions
Exception | Condition |
---|---|
Quanser.Hardware..::.HilException | If the PWM modes cannot be set then an exception is thrown. This situtation typically arises when the card does not support one of the PWM modes specified. |