<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Configuration</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE=" Comedi " HREF="index.html"><LINK REL="PREVIOUS" TITLE=" Comedi " HREF="index.html"><LINK REL="NEXT" TITLE="Writing Comedi programs" HREF="x403.html"></HEAD ><BODY CLASS="SECTION" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Comedi: The <SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >Control and Measurement Device Interface</I ></SPAN > handbook </TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="index.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="x403.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECTION" ><H1 CLASS="SECTION" ><A NAME="INSTALL" >2. Configuration</A ></H1 ><P >This section assumes that you have successfully compiled and installed the <ACRONYM CLASS="ACRONYM" >Comedi</ACRONYM > 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.</P ><DIV CLASS="SECTION" ><H2 CLASS="SECTION" ><A NAME="CARDCONFIGURATION" >2.1. Configuration</A ></H2 ><P >Before being able to get information from a DAQ card, you first have to tell the <ACRONYM CLASS="ACRONYM" >Comedi</ACRONYM > 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 <B CLASS="COMMAND" >comedi_config</B > command. (As root of course.) Here is an example of how to use the command (perhaps you should read its <B CLASS="COMMAND" >man</B > page now): <PRE CLASS="SCREEN" >PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH comedi_config /dev/comedi0 labpc-1200 0x260,3</PRE > This command says that the <SPAN CLASS="QUOTE" >"file"</SPAN > <TT CLASS="FILENAME" >/dev/comedi0</TT > can be used to access the <ACRONYM CLASS="ACRONYM" >Comedi</ACRONYM > device that uses the <CODE CLASS="PARAMETER" >labpc-1200</CODE > board, and that you give it two run-time parameters (<TT CLASS="LITERAL" >0x260</TT > and <TT CLASS="LITERAL" >3</TT >). More parameters are possible, for example to discriminate between two or more identical cards in your system.</P ><P >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 <TT CLASS="FILENAME" >/etc/rc.d/rc.local</TT > 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.</P ><P >This tutorial goes through the process of configuring <ACRONYM CLASS="ACRONYM" >Comedi</ACRONYM > for two devices, a <TT CLASS="LITERAL" >National Instruments AT-MIO-16E-10</TT >, and a <TT CLASS="LITERAL" >Data Translation DT2821-F-8DI</TT >.</P ><P >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 <PRE CLASS="SCREEN" >comedi_config /dev/comedi0 ni_atmio</PRE ></P ><P > For the <TT CLASS="LITERAL" >Data Translation</TT > board, you need to have a list of the jumper settings; these are given in the <ACRONYM CLASS="ACRONYM" >Comedi</ACRONYM > manual section about this card. (Check first to see whether they are still correct!) The card discussed her is a <TT CLASS="LITERAL" >DT2821-f-8di</TT >. The <B CLASS="COMMAND" >man</B > page of <B CLASS="COMMAND" >comedi_config</B > tells you that you need to know the I/O base, IRQ, DMA 1, DMA 2. However, the <ACRONYM CLASS="ACRONYM" >Comedi</ACRONYM > driver also recognizes the differential/single-ended and unipolar/bipolar jumpers. As always, the source is the final authority, and looking in <TT CLASS="FILENAME" >module/dt282x.c</TT > tells us that the options list is interpreted as:</P ><P >(... TO BE FILLED IN ...)</P ><P >So, the appropriate options list is: <PRE CLASS="SCREEN" >0x200,4,,1,1,1</PRE > and the full configuration command is: <PRE CLASS="SCREEN" >comedi_config /dev/comedi1 dt2821-f-8di 0x200,4,,1,1,1</PRE > 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.</P ><P >So now you have your boards configured correctly. Since data acquisition boards are not typically well-engineered, <ACRONYM CLASS="ACRONYM" >Comedi</ACRONYM > 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 <ACRONYM CLASS="ACRONYM" >Comedi</ACRONYM > will give an error message if it can't find them. The <ACRONYM CLASS="ACRONYM" >Comedi</ACRONYM > kernel module, since it is a part of the kernel, prints messages to the kernel logs, which you can access through the command <B CLASS="COMMAND" >dmesg</B > or the file <TT CLASS="FILENAME" >/var/log/messages</TT >. Here is a configuration failure (from <B CLASS="COMMAND" >dmesg</B >):</P ><PRE CLASS="SCREEN" >comedi0: ni_atmio: 0x0200 can't find board</PRE ><P >When it does work, you get:</P ><PRE CLASS="SCREEN" >comedi0: ni_atmio: 0x0260 at-mio-16e-10 ( irq = 3 )</PRE ><P >Note that it also correctly identified the board.</P ></DIV ><DIV CLASS="SECTION" ><H2 CLASS="SECTION" ><A NAME="GETTINGINFORMATION" >2.2. Getting information about a card</A ></H2 ><P >So now that you have <ACRONYM CLASS="ACRONYM" >Comedi</ACRONYM > talking to the hardware, try to talk to <ACRONYM CLASS="ACRONYM" >Comedi</ACRONYM >. Here's some pretty low-level information, which can sometimes be useful for debugging:</P ><PRE CLASS="SCREEN" >cat /proc/comedi</PRE ><P >On the particular system this demonstration was carried out, this command gives:</P ><PRE CLASS="SCREEN" >comedi version 0.6.4 format string 0: ni_atmio at-mio-16e-10 7 1: dt282x dt2821-f-8di 4</PRE ><P >This documentation feature is not well-developed yet. Basically, it currently returns the driver name, the device name, and the number of subdevices.</P ><P >In the <TT CLASS="FILENAME" >demo/</TT > directory, there is a command called <B CLASS="COMMAND" >info</B >, 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 <TT CLASS="LITERAL" >National Instruments</TT > board (which is on <TT CLASS="FILENAME" >/dev/comedi0</TT >), as a result of the command <B CLASS="COMMAND" >demo/info /dev/comedi0</B >:</P ><PRE CLASS="SCREEN" >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 ...</PRE ><P >The overall info gives information about the device; basically the same information as <TT CLASS="FILENAME" >/proc/comedi</TT >.</P ><P >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.</P ><P ><ACRONYM CLASS="ACRONYM" >Comedi</ACRONYM > has more information about the device than what is displayed above, but <B CLASS="COMMAND" >demo/info</B > doesn't currently display this.</P ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="index.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="x403.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Comedi</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" > </TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Writing <ACRONYM CLASS="ACRONYM" >Comedi</ACRONYM > programs</TD ></TR ></TABLE ></DIV ></BODY ></HTML >