Assembly: Quanser.Hardware.Hil (in Quanser.Hardware.Hil.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Sub Write ( _ analogChannels As Integer(), _ pwmChannels As Integer(), _ digitalChannels As Integer(), _ otherChannels As Integer(), _ analogVoltages As Double(), _ pwmDutyCycles As Double(), _ digitalBits As SByte(), _ otherValues As Double() _ ) |
C# |
---|
public void Write( int[] analogChannels, int[] pwmChannels, int[] digitalChannels, int[] otherChannels, double[] analogVoltages, double[] pwmDutyCycles, sbyte[] digitalBits, double[] otherValues ) |
Visual C++ |
---|
public: void Write( array<int>^ analogChannels, array<int>^ pwmChannels, array<int>^ digitalChannels, array<int>^ otherChannels, array<double>^ analogVoltages, array<double>^ pwmDutyCycles, array<signed char>^ digitalBits, array<double>^ otherValues ) |
JavaScript |
---|
function write(analogChannels, pwmChannels, digitalChannels, otherChannels, analogVoltages, pwmDutyCycles, digitalBits, otherValues); |
Parameters
- analogChannels
- Type: array<
System..::.Int32
>[]()[]
An array containing the numbers of the analog output channels to be written. Channel numbers are zero-based. Thus, channel 0 is the first channel, channel 1 the second channel, etc. If no analog output channels are to be written then set this parameter to NoChannels or nullptr.
Select a board type to the list for board-specific details: .
- pwmChannels
- 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. If no PWM output channels are to be written then set this parameter to NoChannels or nullptr.
Select a board type to the list for board-specific details: .
- digitalChannels
- Type: array<
System..::.Int32
>[]()[]
An array containing the numbers of the digital output channels to be written. Channel numbers are zero-based. Thus, channel 0 is the first channel, channel 1 the second channel, etc. If no digital output channels are to be written then set this parameter to NoChannels or nullptr.
Select a board type to the list for board-specific details: .
- otherChannels
- Type: array<
System..::.Int32
>[]()[]
An array containing the numbers of the other output channels to be written. Channel numbers are zero-based. Thus, channel 0 is the first channel, channel 1 the second channel, etc. If no other output channels are to be written then set this parameter to NoChannels or nullptr.
Select a board type to the list for board-specific details: .
- analogVoltages
- Type: array<
System..::.Double
>[]()[]
An array containing the voltage values to be written to the analog outputs. Each element in the analogVoltages array corresponds to the same element in the analogChannels array. Hence, there must be as many elements in the analogVoltages array as there are analog channels.
If no analog output channels are being written then this parameter may be set to NoDoubleBuffer or nullptr.
- pwmDutyCycles
- Type: array<
System..::.Double
>[]()[]
An array containing the values to be written 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 pwmDutyCycles array corresponds to the same element in the pwmChannels array. Hence, there must be as many elements in the pwmDutyCycles array as there are PWM channels.
If no PWM output channels are being written then this parameter may be set to NoDoubleBuffer or nullptr.
- digitalBits
- Type: array<
System..::.SByte
>[]()[]
An array containing the binary values to be written to the digital outputs. Each element in the digitalBits array corresponds to the same element in the digitalChannels array. Hence, there must be as many elements in the digitalBits array as there are digital channels.
If no digital output channels are being written then this parameter may be set to NoBooleanBuffer or nullptr.
- otherValues
- Type: array<
System..::.Double
>[]()[]
An array containing the values to be written to the other outputs. Each element in the otherValues array corresponds to the same element in the otherChannels array. Hence, there must be as many elements in the otherValues array as there are other channels.
If no other output channels are being written then this parameter may be set to NoDoubleBuffer or nullptr.
Remarks
The Write method writes to the specified output channels immediately. The method does not return until the data has been written.
Many cards allow the digital I/O lines to be programmed as inputs or outputs. The digital I/O lines are configured as inputs or outputs using the SetDigitalDirections(array<Int32>[]()[], array<Int32>[]()[]) method. All the channels which will be used as digital inputs or outputs must be configured accordingly using this function. Failure to configure the digital I/O may result in the Write(array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Int32>[]()[], array<Double>[]()[], array<Double>[]()[], array<SByte>[]()[], array<Double>[]()[]) method failing to write the digital I/O as expected. |
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 [] analogChannels = { 0, 1 }; int [] pwmChannels = { 0, 1 }; int [] digitalChannels = { 0, 1, 2, 3 }; double [] analogBuffer = { 2.5, -2.5 }; double [] pwmBuffer = { 0.3, 0.7 }; sbyte [] digitalBuffer = { 1, 0, 1, 0 }; card.Write(analogChannels, pwmChannels, digitalChannels, nullptr, analogBuffer, pwmBuffer, digitalBuffer, nullptr); |
Visual Basic | Copy Code |
---|---|
Dim analogChannels() As Integer = {0, 1} Dim pwmChannels() As Integer = {0, 1} Dim digitalChannels() As Integer = {0, 1, 2, 3} Dim analogBuffer() As Double = {2.5, -2.5} Dim pwmBuffer() As Double = {0.3, 0.7} Dim digitalBuffer() As SByte = {1, 0, 1, 0} card.Write(analogChannels, pwmChannels, digitalChannels, Hil.NoChannels, _ analogBuffer, pwmBuffer, digitalBuffer, Hil.NoDoubleBuffer) |
Visual C++ | Copy Code |
---|---|
array<int>^ analogChannels = { 0, 1 }; array<int>^ pwmChannels = { 0, 1 }; array<int>^ digitalChannels = { 0, 1, 2, 3 }; array<double>^ analogBuffer = { 2.5, -2.5 }; array<double>^ pwmBuffer = { 0.3, 0.7 }; array<char>^ digitalBuffer = { 1, 0, 1, 0 }; card->Write(analogChannels, pwmChannels, digitalChannels, nullptr, analogBuffer, pwmBuffer, digitalBuffer, nullptr); |
Exceptions
Exception | Condition |
---|---|
Quanser.Hardware..::.HilException | If the write cannot be performed then an exception is thrown. This situtation typically arises if the board does not support one of the outputs or the hardware resources required are in use by a task. |