Assembly: Quanser.Hardware.Hil (in Quanser.Hardware.Hil.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Sub ReadEncoderWritePwm ( _ inputChannels As Integer(), _ outputChannels As Integer(), _ inputCounts As Integer(), _ outputDutyCycles As Double() _ ) |
C# |
---|
public void ReadEncoderWritePwm( int[] inputChannels, int[] outputChannels, int[] inputCounts, double[] outputDutyCycles ) |
Visual C++ |
---|
public: void ReadEncoderWritePwm( array<int>^ inputChannels, array<int>^ outputChannels, array<int>^ inputCounts, array<double>^ outputDutyCycles ) |
JavaScript |
---|
function readEncoderWritePwm(inputChannels, outputChannels, inputCounts, outputDutyCycles); |
Parameters
- inputChannels
- Type: array<
System..::.Int32
>[]()[]
An array containing the numbers of the encoder input channels to be read. Channel numbers are zero-based. Thus, channel 0 is the first channel, channel 1 the second channel, etc.
Select a board type to the list for board-specific details: .
- outputChannels
- Type: array<
System..::.Int32
>[]()[]
An array containing the numbers of the PWM output channels to be written. Channel numbers are zero-based. Thus, channel 0 is the first channel, channel 1 the second channel, etc.
Select a board type to the list for board-specific details: .
- inputCounts
- Type: array<
System..::.Int32
>[]()[]
An array for receiving the count values read from the encoder inputs. Each element in the inputCounts array corresponds to the same element in the inputChannels array. Hence, there must be as many elements in the inputCounts array as there are channels.
- outputDutyCycles
- Type: array<
System..::.Double
>[]()[]
An array containing the values to write to the PWM outputs. How these values are interpreted depends on the PWM mode. The PWM mode is configured using the SetPwmMode(array<Int32>[]()[], array<Hil..::.PwmMode>[]()[]) method. Each element in the outputDutyCycles array corresponds to the same element in the outputChannels array. Hence, there must be as many elements in the outputDutyCycles array as there are channels.
Remarks
The ReadEncoderWritePwm method reads from the specified encoder input channels and writes to the specified PWM output channels immediately, in a single method call. The write operation occurs immediately following the read operation. Since the read-write operation occurs at the lowest level the read and write occur virtually concurrently. The method does not return until the data has been read and written.
The interpretation of the PWM samples to be written depends upon the PWM mode. Typically the data is interpreted as a duty cycle, in which a magnitude of 0.0 denotes a 0% duty cycle and magnitude of 1.0 indicates a 100% duty cycle. The sign determines the polarity of the output for those boards supporting bidirectional PWM outputs. However, other PWM modes are possible with some boards. Refer to the SetPwmMode(array<Int32>[]()[], array<Hil..::.PwmMode>[]()[]) method for details.
Examples
C# | Copy Code |
---|---|
int [] inputChannels = { 0, 1, 2, 3 }; int [] outputChannels = { 0, 1 }; int [] inputBuffer = new int [inputChannels.Length]; double [] outputBuffer = { 0.3, 0.7 }; card.ReadEncoderWritePwm(inputChannels, outputChannels, inputBuffer, outputBuffer); |
Visual Basic | Copy Code |
---|---|
Dim inputChannels() As Integer = {0, 1, 2, 3} Dim outputChannels() As Integer = {0, 1} Dim inputBuffer(inputChannels.Length - 1) As Integer Dim outputBuffer() As Double = {0.3, 0.7} card.ReadEncoderWritePwm(inputChannels, outputChannels, inputBuffer, outputBuffer) |
Visual C++ | Copy Code |
---|---|
array<int>^ inputChannels = { 0, 1, 2, 3 }; array<int>^ outputChannels = { 0, 1 }; array<int>^ inputBuffer = gcnew array<int>(inputChannels->Length); array<double>^ outputBuffer = { 0.3, 0.7 }; card->ReadEncoderWritePwm(inputChannels, outputChannels, inputBuffer, outputBuffer); |
Exceptions
Exception | Condition |
---|---|
Quanser.Hardware..::.HilException | If the read or write cannot be performed then an exception is thrown. This situtation typically arises if the board does not support this method. |