Specifications
Comedi
23 / 148
As you might have guessed, the Comedi library has functions to help you in your quest to accurately measure slowly varying
inputs:
int comedi_sv_init(comedi_sv_t *sv, comedi_t *device, unsigned int subdevice, unsigned int channel);
The above function comedi_sv_init() initializes the comedi_sv_t data structure, used to do the averaging acquisition:
typedef struct comedi_sv_struct {
comedi_t
*
dev;
unsigned int subdevice;
unsigned int chan;
/
*
range policy
*
/
int range;
int aref;
/
*
number of measurements to average (for analog inputs)
*
/
int n;
lsampl_t maxdata;
} comedi_sv_t;
The actual acquisition is done with the function comedi_sv_measure():
int comedi_sv_measure(comedi_sv_t *sv, double *data);
The number of samples over which the function comedi_sv_measure() averages is limited by the implementation (currently
the limit is 100 samples).
One typical use for this function is the measurement of thermocouple voltages. And the Comedi self-calibration utility also uses
these functions. On some hardware, it is possible to tell it to measure an internal stable voltage reference, which is typically going
to be very slowly varying; on the kilosecond time scale or more. So, it is reasonable to measure millions of samples, to get a very
accurate measurement of the A/D converter output value that corresponds to the voltage reference. Sometimes, however, this is
overkill, since there is no need to perform a part-per-million calibration to a standard that is only accurate to a part-per-thousand.
4.7 Experimental functionality
The following subsections document functionality that has not yet matured. Most of this functionality has even not been imple-
mented yet in any single device driver. This information is included here, in order to stimulate discussion about their API, and to
encourage pioneering implementations.
4.7.1 Digital input combining machines
(Status: experimental (i.e., no driver implements this yet))
When one or several digital inputs are used to modify an output value, either an accumulator or a single digital line or bit,
a bitfield structure is typically used in the Comedi interface. The digital inputs have two properties, ‘sensitive’ inputs and
‘modifier’ inputs. Edge transitions on sensitive inputs cause changes in the output signal, whereas modifier inputs change the
effect of edge transitions on sensitive inputs. Note that inputs can be both modifier inputs and sensitive inputs.
For simplification purposes, it is assumed that multiple digital inputs do not change simultaneously.
The combined state of the modifier inputs determine a modifier state. For each combination of modifier state and sensitive input,
there is a set of bits that determine the effect on the output value due to positive or negative transitions of the sensitive input. For
each transition direction, there are two bits defined as follows:
00 transition is ignored.
01 accumulator is incremented, or output is set.
10 accumulator is decremented, or output is cleared.