[MAT logo][Prev][Up][Next]

comedi I/O

The comedi module uses the comedi library to interface with various I/O cards (almost 250 as of this writing, from various manufacturers). The library (but not the module) was written by the comedi project.

Example howto

There is a howto in the hardware compatibility section of the webpage, outlining how to use the Advantech PCL-812PG card with this module.

Introduction

Setting up the hardware is described in Chapter 2 of the comedilib manual. Various comedi utilities and sample programs will let you install the device driver, verify that it was correctly detected, obtain information about the input and output ranges of the various devices, and so on.

In comedi, the inputs and outputs on each device (card) are grouped into subdevices. Each input or output is then referred to as a channel. All three of these (devices, subdevices and channels) are numbered, starting from 0. In addition, analogue channels can have multiple ranges and references, if the card supports these, and they can be obtained raw (as an integer) or converted to physical units (volts or milliamps).

Addresses

In the mapping table, comedi addresses are specified as follows:

Examples

I2.3
digital input, device 0, subdevice 2, channel 3.
1:X7.3/2_DIFF
converted analog input, device 1, subdevice 7, channel 3, range 2, reference AREF_DIFF.
U.2
analog output, device 0, subdevice 0, channel 2, default range and reference.

Format

Each address has the form (some parts optional):
device: type subdevice.channel options

This diagram shows which parts are optional, which are mandatory, and the order in which they may be used. To make a valid address, start in the double circle labelled S, and follow the arrows until you get to E. Boxes denote actual letters and punctuation to use, ovals the various settings, as explained below. The small circles are simply junctions.

[raliroad diagram of the
syntax]

Details

device:
either the device filename, or the number of the device ("/dev/comedi" will be prepended in the latter case). The device specification may be omitted, including the colon, in which case 0 will be used.
type
denotes the direction, kind and conversion to physical units; it is mandatory. Lowercase letters may also be used, which is probably a good idea for I and O (so they don't get mistaken for numbers). The floating-point format used by the X and Y types is the same as used by the DSP module.
typemeaningbitsformat
Idigital input 1on/off
O or Qdigital output1on/off
Nanalog input (raw) (mnemonic: iN)1-32integer
Uanalog output (raw) (mnemonic: oUt)1-32integer
Xanalog input converted to physical units32float
Yanalog output converted from physical units32float
subdevice.channel
the subdevice and channel to use on the device; one or the other may be omitted, but not both; omitted parts default to 0.
options
There are two options, either or both of which may be used for analog inputs and outputs; there are no options for digital I/O.
/range
specifies the range to be used, as a number. Default 0.
_ref
specifies the reference to be used, either as a number, or as a keyword (so 0, GROUND and GND are all equivalent). Default GROUND. Mnemonic: the value at the low end; hence underscore.
[Prev][Up][Next]

$Date: 2004/12/28 05:32:10 $