Next Previous Contents

5. Application-specific functions

5.1 Digital Input/Output

Many boards supported by comedi have digital input and output channels. Some boards allow the direction of a channel to be specified in software.

Comedi groups digital channels into subdevice, which is a group of digital channels that have the same characteristics. For example, digital output lines will be grouped into a digital output subdevice, bidirectional digital lines will be grouped into a digital I/O subdevice. Thus, there can be multiple digital subdevices on a particular board.

5.2 Timed Input/Output

5.3 Slowly-varying inputs

Sometimes, your input channels change slowly enough that you are able to average many sucessive input values to get a more accurate measurement of the actual value. In general, the more samples you average, the better your estimate gets, roughly by a factor of sqrt(number_of_samples). Obviously, there are limitations to this:

As you might have guessed, the comedi library has functions to help you in your quest to accurately measure slowly varying inputs. I use these functions to measure thermocouple voltages -- actually, the library functions came from a section of code that was previously part of the thermocouple reading program.

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 part-per-thousand.


Next Previous Contents