%comedilib_entities; ]>
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, any jumper settings related to input ranges, the I/O base address and IRQ for old non-plug-n-play boards, etc.
Configuration 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.
Getting information about a card So now that you have &comedi; talking to the hardware, try to talk to &comedi;. Call the command comedi_board_info, which provides information about each subdevice on the board. Here's part of the output for the USB-DUX sigma board (which is on /dev/comedi0), as a result of the command comedi_board_info -v. overall info: version code: 0x00074c driver name: usbduxsigma board name: usbduxsigma number of subdevices: 4 subdevice 0: type: 1 (analog input) flags: 0x10119000 SDF_CMD_READ:can do asynchronous input commands SDF_READABLE:subdevice can be read SDF_GROUND:can do aref=ground SDF_LSAMPL:subdevice uses 32-bit samples for commands number of channels: 16 max data value: 16777215 ranges: all chans: [-1.325 V,1.325 V] command: start: now|int scan_begin: timer convert: now scan_end: count stop: none|count command structure filled with probe_cmd_generic_timed for 16 channels: start: now 0 scan_begin: timer 1000000 scan_begin_src = TRIG_TIMER: The sampling rate is defined per scan meaning all channels are sampled at the same time. The maximum sampling rate is f=1000 Hz convert: now 0 scan_end: count 16 stop: count 2 subdevice 1: type: 2 (analog output) flags: 0x00125000 SDF_CMD_WRITE:can do asynchronous output commands SDF_WRITABLE:subdevice can be written SDF_GROUND:can do aref=ground number of channels: 4 max data value: 255 ranges: all chans: [0 V,2.5 V] command: start: now|int scan_begin: timer convert: now scan_end: count stop: none|count command structure filled with probe_cmd_generic_timed for 4 channels: start: now 0 scan_begin: timer 1000000 scan_begin_src = TRIG_TIMER: The sampling rate is defined per scan meaning all channels are sampled at the same time. The maximum sampling rate is f=1000 Hz convert: now 0 scan_end: count 4 stop: count 2 subdevice 2: type: 5 (digital I/O) flags: 0x00030000 SDF_READABLE:subdevice can be read SDF_WRITABLE:subdevice can be written number of channels: 24 max data value: 1 ranges: all chans: [0 V,5 V] command: not supported subdevice 3: type: 12 (pwm) flags: 0x00020100 SDF_MODE1:can do mode 1 SDF_WRITABLE:subdevice can be written number of channels: 8 max data value: 512 ranges: all chans: [0,1] command: not supported This board has four subdevices. Devices are separated into subdevices that each have a distinct purpose; e.g., analog input, analog output, digital input/output. Here's the information from &comedi;'s /proc/comedi file, which indicates what drivers are loaded and which boards are configured: cat /proc/comedi comedi version 0.7.76 format string: "%2d: %-20s %-20s %4d",i,driver_name,board_name,n_subdevices 0: usbduxsigma usbduxsigma 4 usbduxfast: usbduxfast usbduxsigma: usbduxsigma This documentation feature currently returns the driver name, the device name, and the number of subdevices. Following those lines are a list of the &comedi; kernel driver modules currently loaded, each followed by a list of the board names it recognizes (names that can be used with comedi_config).