You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Averaging behaves much like oversampling, except the accumulated values are divided by the number of samples so that the scaling of the returned values does not change. This is often more-convenient, but occasionally the additional roundoff error introduced by the rounding is undesirable.
61
53
62
54
.. tab-set-code::
63
55
64
-
```java
65
-
// Sets the AnalogInput to 4-bit averaging. 16 samples will be averaged together.
66
-
// The update rate will decrease by a factor of 16.
.. note:: When oversampling and averaging are used at the same time, the oversampling is applied *first,* and then the oversampled values are averaged. Thus, 2-bit oversampling and 2-bit averaging used at the same time will increase the scale of the returned values by approximately a factor of 2, and decrease the update rate by approximately a factor of 4.
77
65
@@ -85,55 +73,55 @@ The :code:`getValue` method returns the raw instantaneous measured value from th
The :code:`getVoltage` method returns the instantaneous measured voltage from the analog input. Oversampling and averaging settings are ignored, but the value is rescaled to represent a voltage. The returned value is a double.
The :code:`getAverageValue` method returns the averaged value from the analog input. The value is not rescaled, but oversampling and averaging are both applied. The returned value is an integer.
The :code:`getAverageVoltage` method returns the averaged voltage from the analog input. Rescaling, oversampling, and averaging are all applied. The returned value is a double.
Sometimes, it is necessarily to obtain matched measurements of the count and the value. This can be done using the :code:`getAccumulatorOutput` method:
179
145
180
146
.. tab-set-code::
181
147
182
-
```java
183
-
// Instantiate an AccumulatorResult object to hold the matched measurements
184
-
AccumulatorResult result = new AccumulatorResult();
185
-
// Fill the AccumulatorResult with the matched measurements
186
-
analog.getAccumulatorOutput(result);
187
-
// Read the values from the AccumulatorResult
188
-
long count = result.count;
189
-
long value = result.value;
190
-
```
191
-
192
-
```c++
193
-
// The count and value variables to fill
194
-
int_64t count;
195
-
int_64t value;
196
-
// Fill the count and value variables with the matched measurements
0 commit comments