Sets the frequencies of the PWM outputs on the card.

Namespace:  Quanser.Hardware
Assembly:  Quanser.Hardware.Hil (in Quanser.Hardware.Hil.dll)

Syntax

Visual Basic (Declaration)
Public Sub SetPwmFrequency ( _
	channels As Integer(), _
	frequencies As Double() _
)
C#
public void SetPwmFrequency(
	int[] channels,
	double[] frequencies
)
Visual C++
public:
void SetPwmFrequency(
	array<int>^ channels, 
	array<double>^ frequencies
)
JavaScript
function setPwmFrequency(channels, frequencies);

Parameters

channels
Type: array< System..::.Int32 >[]()[]

An array containing the numbers of the PWM channels whose frequencies 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: .

frequencies
Type: array< System..::.Double >[]()[]
An array of modes containing the new frequencies for each channel. Each element in the frequencies array corresponds to the same element in the channels array. Hence, there must be as many elements in the frequencies array as there are channels.

Remarks

The SetPwmFrequency method sets the frequencies that will be used for PWM outputs. This method is typically used only in Hil.PwmMode.DutyCycle mode (the default). Refer to the Hil..::.PwmMode enumeration for a list of the valid PWM modes.

The actual PWM output frequencies are not changed until the PWM outputs are used in one of the following functions:

Examples

This sample illustrates how to use the SetPwmFrequency(array<Int32>[]()[], array<Double>[]()[]) method. It sets the PWM frequency to 10 kHz for PWM output channel 0 and 20 kHz for PWM output channel 1.
C# Copy Code
int []    channels    = {   0,     1   };
double [] frequencies = { 10000, 20000 };

board.SetPwmFrequency(channels, frequencies);
Visual Basic Copy Code
Dim channels() As Integer = {0, 1}
Dim frequencies() As Double = {10000, 20000}

board.SetPwmFrequency(channels, frequencies)
Visual C++ Copy Code
array<int>^    channels    = {   0,     1   };
array<double>^ frequencies = { 10000, 20000 };

board->SetPwmFrequency(channels, frequencies);

Exceptions

ExceptionCondition
Quanser.Hardware..::.HilException If the PWM frequencies cannot be set then an exception is thrown. This situtation typically arises when a PWM frequency is out of range or the card does not support programmable PWM frequencies.

See Also