
50 Chapter 5 Documentation Number UD128A8D4602 Manual
B&B Electronics Mfg Co – 707 Dayton Rd - PO Box 1040 - Ottawa IL 61350 - Ph 815-433-5100 - Fax 815-433-5104
B&B Electronics Ltd – Westlink Comm. Pk. – Oranmore, Galway, Ireland – Ph 353-91-792444 – Fax 353-91-792445
The GetSamples method requires one parameter, Count, that
specifies the maximum number of samples to return. The Get
Samples method returns data for all I/O points being sampled in a
two dimensional array. The index for the first dimension of the array
is the I/O point. The index for the second dimension of the array is
the sample number.
Dim SampleReadings() as Long
SampleReadings = Device1.GetSamples(5)
Now SampleReadings is an array that contains the next readings
after the previous GetSamples method. It will contain readings from
the I/O Points on Device1 that have their SamplingEnabled Property
set to True.
Note that the array may contain less than 5 samples if the device
has not completed 5 sampling periods since the last GetSamples
method call. The SampleRedings array is of the form
SampleReadings(I/O Point, Sample Number).
For example, if you enable sampling on AD0, AD2, AD3, and AD7
and request 5 samples at a time, then call the GetSamples method,
the returned array will look like this
Fig. 5.1 Timed Sample Array
(ch, sam) Samples Across
Ch Down #1 #2 #3 #4 #5
AD0 #1 V1,1 V1,2 V1,3 V1,4 V1,5
AD2 #2 V2,1 V2,2 V2,3 V2,4 V2,5
AD3 #3 V3,1 V3,2 V3,3 V3,4 V3,5
AD7 #4 V4,1 V4,2 V4,3 V4,4 V4,5
If there is an error during the one or more of the GetSamples values,
the value is flagged with the BDAQ_INVALID_DATA_VALUE instead
a value within the normal range below 4096. The most common
error is that it can't get the data from the driver and hardware fast
enough.
Your program needs to handle indicate where data is missing or
invalid and handle the holes.
For example, to display all the readings from AD7 in a text box called
txtAD7Result:
Dim i as Long
Dim SampleReadings() as Long
SampleReadings = Device1.GetSamples(100)
txtAD7Result = “”
Komentáře k této Příručce