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, any jumper settings related to input ranges, the I/O base address and IRQ for old non-plug-n-play boards, etc.
The good news is: on most systems PCI and USB based boards are
configured automatically. The kernel will
detect your data acquisition devices, will load the appropriate
kernel drivers and will create the
/dev/comedi
entries.
bp1@bp1-x61:~/sandbox/comedilib$ ls -l /dev/comedi0* crw-rw---- 1 root iocard 98, 0 2012-04-26 23:41 /dev/comedi0 crw-rw---- 1 root iocard 98, 48 2012-04-26 23:41 /dev/comedi0_subd0 crw-rw---- 1 root iocard 98, 49 2012-04-26 23:41 /dev/comedi0_subd1
Usually these devices belong to the group iocard
as shown here. The only
action you need to take is to become member of this group and
then the Comedi device is ready to be used.
There are a few PCI drivers that for one reason or another
do not support auto-configuration, either because there is
more than one variant of a board sharing the same PCI device
ID (e.g. Advantech PCI-1710 and PCI-1710HG), or because
some configuration options are needed (e.g. Amplicon PCI224
and PCI234) or for some other reason. It is also possible
to disable auto-configuration when loading the
comedi
kernel module. In these
cases devices need to be configured manually as for ISA
cards. Conversely, most Comedi drivers supplied with the
kernel sources that support auto-configuration may no longer
support manual configuration.
By default, the comedi
kernel module
does not reserve any devices for manual configuration so
manual configuration will fail. To allow devices to be
configured manually, set the
comedi_num_legacy_minors
module
parameter to the number of devices to reserve for manual
configuration when loading the comedi
kernel module. If using modprobe, this
can be set automatically by editing
/etc/modprobe.conf
or
/etc/modprobe.d/comedi.conf
(depending
on the system) to include the line:
options comedi comedi_num_legacy_minors=4
The number 4
in the above line may be
adjusted to increase or decrease the number of devices to be
reserved for manual configuration.
Old ISA based cards need to be manually configured which is
explained here. You only need to read on here
if you have one of these old cards.
On embedded systems it might also be necessary to load the
driver and then to configure the boards manually.
In general manual configuration is done by running
the comedi_config command
(as root
).
Here is an example of how to use the command (perhaps you should read
its man page now):
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, and their
meaning is driver dependant.
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 preceding comedi_config command to succeed, the
ni_atmio
kernel module must
be loaded first. For plug-n-play boards on
modern kernels, the appropriate comedi kernel modules should get loaded
automatically when your computer is booted.
The modprobe command can
be used to manually load/unload kernel modules, and lsmod
will list all the currently loaded modules.
For the Data Translation board, you need to know
how the board's jumpers are configured in order to specify the correct
comedi_config parameters. These parameters for the board are given in the
kernel drivers section about the dt282x
driver.
The card discussed here is a DT2821-f-8di. The
entry for the dt282x
driver tells you that the
comedi_config parameters give the driver the I/O base,
IRQ, DMA 1, DMA 2, and
in addition the states of the
differential/single-ended and unipolar/bipolar jumpers:
dt282x configuration options:
[0] - I/O port base address
[1] - IRQ
[2] - DMA 1
[3] - DMA 2
[4] - AI jumpered for 0=single ended, 1=differential
[5] - AI jumpered for 0=straight binary, 1=2's complement
[6] - AO 0 jumpered for 0=straight binary, 1=2's complement
[7] - AO 1 jumpered for 0=straight binary, 1=2's complement
[8] - AI jumpered for 0=[-10,10]V, 1=[0,10], 2=[-5,5], 3=[0,5]
[9] - AO 0 jumpered for 0=[-10,10]V, 1=[0,10], 2=[-5,5], 3=[0,5], 4=[-2.5,2.5]
[10]- A0 1 jumpered for 0=[-10,10]V, 1=[0,10], 2=[-5,5], 3=[0,5], 4=[-2.5,2.5]
So, the appropriate options list might be:
0x200,4,0,0,1,1,1,1,0,2,2
and the full configuration command is:
comedi_config /dev/comedi1 dt2821-f-8di 0x200,4,0,0,1,1,1,1,0,2,2
Setting the DMA channels to 0 disables the use of DMA.
So now you have your boards configured correctly.
Since data acquisition boards are not typically well-engineered,
Comedi sometimes can't figure out if an old non-plug-n-play
board is actually in the computer and at the base address you specified.
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.