2. Configuration

This section assumes that you have successfully compiled and installed the Comedi software, that your hardware device is in your computer, and that you know the relevant details about it, i.e., what kind of card it is, the I/O base, the IRQ, jumper settings related to input ranges, etc.

2.1. Configuration

Before being able to get information from a DAQ card, you first have to tell the Comedi core kernel module which device you have, which driver you want to attach to the card, and which run-time options you want to give to the driver. This configuration is done by running the comedi_config command. (As root of course.) Here is an example of how to use the command (perhaps you should read its man page now):

PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH
comedi_config /dev/comedi0 labpc-1200 0x260,3
This command says that the "file" /dev/comedi0 can be used to access the Comedi device that uses the labpc-1200 board, and that you give it two run-time parameters (0x260 and 3). More parameters are possible, for example to discriminate between two or more identical cards in your system.

If you want to have the board configured in this way every time you boot, put the lines above into a start-up script file of your Linux system (for example, the /etc/rc.d/rc.local file), or for PCMCIA boards the appropriate place is the /etc/pcmcia/comedi script. For non-PCMCIA boards, you can also arrange to have your driver loaded and comedi_config run with by adding a few lines to /etc/modules.conf (see the INSTALL file for the comedi kernel modules). You can, of course, also run comedi_config at a command prompt.

This tutorial goes through the process of configuring Comedi for two devices, a National Instruments AT-MIO-16E-10, and a Data Translation DT2821-F-8DI.

The NI board is plug-and-play. The current ni_atmio driver has kernel-level ISAPNP support, which is used by default if you do not specify a base address. So you could simply run comedi_config as

comedi_config /dev/comedi0 ni_atmio

For the Data Translation board, you need to have a list of the jumper settings; these are given in the Comedi manual section about this card. (Check first to see whether they are still correct!) The card discussed her is a DT2821-f-8di. The man page of comedi_config tells you that you need to know the I/O base, IRQ, DMA 1, DMA 2. However, the Comedi driver also recognizes the differential/single-ended and unipolar/bipolar jumpers. As always, the source is the final authority, and looking in module/dt282x.c tells us that the options list is interpreted as:

(... TO BE FILLED IN ...)

So, the appropriate options list is:

0x200,4,,1,1,1
and the full configuration command is:
comedi_config /dev/comedi1 dt2821-f-8di 0x200,4,,1,1,1
The differential/single-ended number is left blank, since the driver already knowns (from the board name), that it is differential. Also the DMA numbers are left blank, since we don't want the driver to use DMA. (Which could interfere with the sound card...) Keep in mind that things commented in the source, but not in the documentation are about as likely to change as the weather, so put good comments next to the following line when you put it in a start-up file.

So now you have your boards configured correctly. Since data acquisition boards are not typically well-engineered, Comedi sometimes can't figure out if the board is actually there. If it can't, it assumes you are right. Both of these boards are well-made, so Comedi will give an error message if it can't find them. The Comedi kernel module, since it is a part of the kernel, prints messages to the kernel logs, which you can access through the command dmesg or the file /var/log/messages. Here is a configuration failure (from dmesg):

comedi0: ni_atmio: 0x0200 can't find board

When it does work, you get:

comedi0: ni_atmio: 0x0260 at-mio-16e-10 ( irq = 3 )

Note that it also correctly identified the board.

2.2. Getting information about a card

So now that you have Comedi talking to the hardware, try to talk to Comedi. Here's some pretty low-level information, which can sometimes be useful for debugging:

cat /proc/comedi

On the particular system this demonstration was carried out, this command gives:

comedi version 0.6.4
format string
 0: ni_atmio             at-mio-16e-10           7
 1: dt282x               dt2821-f-8di            4

This documentation feature is not well-developed yet. Basically, it currently returns the driver name, the device name, and the number of subdevices.

In the demo/ directory, there is a command called info, which provides information about each subdevice on the board. Its output can be rather long, if the board has several subdevices. Here's part of the output of the National Instruments board (which is on /dev/comedi0), as a result of the command demo/info /dev/comedi0:

overall info:
  version code: 0x000604
  driver name: ni_atmio
  board name: at-mio-16e-10
  number of subdevices: 7
subdevice 0:
  type: 1 (analog input)
  number of channels: 16
  max data value: 4095
...

The overall info gives information about the device; basically the same information as /proc/comedi.

This board has seven subdevices. Devices are separated into subdevices that each have a distinct purpose; e.g., analog input, analog output, digital input/output. This board also has an EEPROM and calibration DACs that are also subdevices.

Comedi has more information about the device than what is displayed above, but demo/info doesn't currently display this.