Assembly: Quanser.Hardware.Hil (in Quanser.Hardware.Hil.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Sub ReadEncoderBuffer ( _ clock As Hil..::.Clock, _ frequency As Double, _ numSamples As Integer, _ channels As Integer(), _ buffer As Integer() _ ) |
C# |
---|
public void ReadEncoderBuffer( Hil..::.Clock clock, double frequency, int numSamples, int[] channels, int[] buffer ) |
Visual C++ |
---|
public: void ReadEncoderBuffer( Hil..::.Clock clock, double frequency, int numSamples, array<int>^ channels, array<int>^ buffer ) |
JavaScript |
---|
function readEncoderBuffer(clock, frequency, numSamples, channels, buffer); |
Parameters
- clock
- Type: Quanser.Hardware..::.Hil..::.Clock
The clock used to time the operation. Note that some clocks allow faster sampling rates than others. See the Hil..::.Clock enumeration for more information on clocks.
Select a board type from the list for board-specific details: .
- frequency
- Type: System..::.Double
The frequency in Hertz at which to sample the encoder input channels. For example, if frequency is set to 1000, then the ReadEncoderBuffer method will read all the selected channels every millisecond.
- numSamples
- Type: System..::.Int32
The number of samples to collect. Each "sample" consists of all the encoder input channels specified. For example, if frequency is set to 1000 and numSamples is set to 5000, then the ReadEncoderBuffer method will return after 5 seconds with 5000 samples. If 3 channels have been selected, then the output buffer will contain 15,000 elements.
- channels
- 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 from the list for board-specific details: .
- buffer
- Type: array<
System..::.Int32
>[]()[]
An array for receiving the count values read from the encoder inputs. The array must contain channels.Length * numSamples elements. The array is organized as a linear array of samples, with each sample consisting of a group of channels. For example, if encoder input channels 0, 1 and 3 are being read, than the data appears in the array as follows, where the numbers correspond to channel numbers:
0 1 3 0 1 3 ...
Remarks
The ReadEncoderBuffer method reads the specified number of samples from the encoder channels at the given sampling frequency. This method does not return until all the data has been read.
Examples
C# | Copy Code |
---|---|
int [] channels = { 0, 1, 2, 3 }; double frequency = 1000; int samples = 5000; int [] buffer = new int [samples * channels.Length]; card.ReadEncoderBuffer(Hil.Clock.Hardware0, frequency, samples, channels, buffer); |
Visual Basic | Copy Code |
---|---|
Dim channels() As Integer = {0, 1, 2, 3} Dim frequency As Double = 1000 Dim samples As Integer = 5000 Dim buffer(samples * channels.Length - 1) As Integer card.ReadEncoderBuffer(Hil.Clock.Hardware0, frequency, samples, channels, buffer) |
Visual C++ | Copy Code |
---|---|
array<int>^ channels = { 0, 1, 2, 3 }; double frequency = 1000; int samples = 5000; array<int>^ buffer = gcnew array<int>(samples * channels->Length); card->ReadEncoderBuffer(Hil::Clock::Hardware0, frequency, samples, channels, buffer); |
Exceptions
Exception | Condition |
---|---|
Quanser.Hardware..::.HilException | If the read cannot be performed then an exception is thrown. This situtation typically arises if the board does not support encoder inputs or the hardware resources required are in use by a task. |