NI PCI-6229 interfacing

173 views
Skip to first unread message

∂єєραк >>;)

unread,
Jun 23, 2009, 7:16:44 AM6/23/09
to comed...@googlegroups.com

Hello friends,

I am actually new to comedi/RTAI/Linux and I have my RTAI/Linux set up running successfully. I have an NI-PCI-6229 DAQ card interfaced with my machine and comedi driver is installed in RTAI/Linux. After reading some documentation, I think I have configured my comedi driver for this card but i m not sure. Is there any body who have tried this card with RTAI/linux/comedi and have some simple procedure for it? I need more information about its interfacing and configuration. Early reply will be highly appreciated.


I build a simple model in matlab/simulink using rtai blocksets containing comedi blocks(sfun_comedi_data_write or sfun_comedi_data_read) for analog input/output and transferred this model files into my Linux machine. Now I am wandering whether it is configured or not ? Do I need to download some driver assuming RTAI/linux won't detect it automatically.

thanks,
Kind Regards
Deepak

dsharma

unread,
Jun 23, 2009, 7:57:10 AM6/23/09
to Comedi: Linux Control and Measurement Device Interface
I have actually used this command and got this output :

root@deepak-desktop:/# cat /proc/comedi
comedi version 0.7.76
format string: "%2d: %-20s %-20s
%4d",i,driver_name,board_name,n_subdevices
0: ni_pcimio pci-6229 14
ni_pcimio:
ni_pcimio
8255:
8255

So, i think it is configured

root@deepak-desktop:/# sudo comedi_config /dev/comedi0 ni_pcimio -v
configuring driver=ni_pcimio
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Configure failed!: Device or resource busy
Check kernel log for more information
Possible reasons for failure:
Already configured

Any help plz?

Guillaume Millet

unread,
Jun 23, 2009, 10:17:55 AM6/23/09
to comed...@googlegroups.com
for several months, /dev/comedi0 has been directly configured when you
load the ni_pcimio module.

If the driver is correctly loaded, you can launch the board_info demo of
comedilib.


dsharma a écrit :

∂єєραк >>;)

unread,
Jun 23, 2009, 10:25:08 AM6/23/09
to comed...@googlegroups.com
thanks Guillaume for your reply,

what is the command for launching board info...? And can I interface analog input/output.

Regards
DP

Guillaume Millet

unread,
Jun 23, 2009, 10:44:34 AM6/23/09
to comed...@googlegroups.com
go to the folder where you have compiled comedilib, there is a demo
folder with several (not RT) demo programs: inp for reading a AI or DI
channel , outp for writing, board_info for getting info, ... look at the
README file in this folder for instructions.

For testing your rtai-lib blocks, you have to generate the RT code of
your model (RTAICodeGen function, see the RTAI-Lab tutorial).

∂єєραк >>;) a écrit :


> thanks Guillaume for your reply,
>
> what is the command for launching board info...? And can I interface
> analog input/output.
>
> Regards
> DP
>
> On Tue, Jun 23, 2009 at 2:17 PM, Guillaume Millet <mil...@isir.fr
> <mailto:mil...@isir.fr>> wrote:
>
>
> for several months, /dev/comedi0 has been directly configured when you
> load the ni_pcimio module.
>
> If the driver is correctly loaded, you can launch the board_info
> demo of
> comedilib.
>

--
Guillaume Millet

Institut des Systèmes Intelligents et de Robotique
Université Pierre et Marie Curie - Paris 6
Tel : +33 1 44 27 63 79

∂єєραк >>;)

unread,
Jun 24, 2009, 7:09:02 AM6/24/09
to comed...@googlegroups.com
thanks for your advise,
I am currently understanding these examples then I found that outp.c is outputtting 0 value on my subdevice1(for analog output) using command :
root@deepak-desktop:/usr/local/src/comedilib/demo# ./outp -v -s 1
writing 0 to device=/dev/comedi0 subdevice=1 channel=0 range=0 analog reference=0
0

but when I change this output value(data =1200) and complied it is giving me some error I don't find any solution for this.

root@deepak-desktop:/usr/local/src/comedilib/demo# gcc outp.c -lcomedi -o outp
In file included from outp.c:16:
/usr/local/include/comedilib.h:32:2: error: #error linux/comedilib.h should not be included by non-kernel-space code


Can any body please guide me through..? Where is this structure defined data =options.value;

kind regards
DP

Ian Abbott

unread,
Jun 24, 2009, 8:17:29 AM6/24/09
to comed...@googlegroups.com
∂єєραк >>;) wrote:
> thanks for your advise,
> I am currently understanding these examples then I found that outp.c is
> outputtting 0 value on my subdevice1(for analog output) using command :
> root@deepak-desktop:/usr/local/src/comedilib/demo# ./outp -v -s 1
> writing 0 to device=/dev/comedi0 subdevice=1 channel=0 range=0 analog
> reference=0
> 0
>
> but when I change this output value(data =1200) and complied it is
> giving me some error I don't find any solution for this.

Actually, you can just set the value on the command line:

./outp -v -s 1 1200

> root@deepak-desktop:/usr/local/src/comedilib/demo# gcc outp.c -lcomedi
> -o outp
> In file included from outp.c:16:
> /usr/local/include/comedilib.h:32:2: error: #error linux/comedilib.h
> should not be included by non-kernel-space code

It looks like gcc has found Comedi's comedilib.h file instead of
Comedilib's comedilib.h. There are some instructions floating around
which say to replace the comedilib.h file installed by Comedilib with
the one from Comedi, but that breaks compilation of user-space programs
using comedilib.

If you run "make" in Comedilib's demo directory, I think it will use
local copies of the comedi.h and comedilib.h files instead of the ones
in /usr/local/include.

It is possible to build RTAI without having to overwrite the comedilib.h
file by using the following RTAI ./configure option:
--with-comedi=/path/to/comedi-source (replacing with the real path to
the Comedi source). I don't think there is a way to do this in the RTAI
configuration menu yet.

> Can any body please guide me through..? Where is this structure defined
> data =options.value;

It's in the common.c file in Comedilib's demo directory. This needs to
be compiled and linked with outp.c:

gcc -O2 outp.c common.c -o outp -lcomedi -lm

(The above command assumes you haven't replaced the comedilib.h
installed by Comedilib with the one from Comedi.)

--
-=( Ian Abbott @ MEV Ltd. E-mail: <abb...@mev.co.uk> )=-
-=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-

Guillaume Millet

unread,
Jun 24, 2009, 9:05:35 AM6/24/09
to comed...@googlegroups.com
Ian Abbott a écrit :

>> root@deepak-desktop:/usr/local/src/comedilib/demo# gcc outp.c -lcomedi
>> -o outp
>> In file included from outp.c:16:
>> /usr/local/include/comedilib.h:32:2: error: #error linux/comedilib.h
>> should not be included by non-kernel-space code
>>
>
> It looks like gcc has found Comedi's comedilib.h file instead of
> Comedilib's comedilib.h. There are some instructions floating around
> which say to replace the comedilib.h file installed by Comedilib with
> the one from Comedi, but that breaks compilation of user-space programs
> using comedilib.
>
> If you run "make" in Comedilib's demo directory, I think it will use
> local copies of the comedi.h and comedilib.h files instead of the ones
> in /usr/local/include.
>
> It is possible to build RTAI without having to overwrite the comedilib.h
> file by using the following RTAI ./configure option:
> --with-comedi=/path/to/comedi-source (replacing with the real path to
> the Comedi source). I don't think there is a way to do this in the RTAI
> configuration menu yet.
>

Now, it's not a problem from RTAI as RTAI uses
/usr/local/include/linux/comedilib.h (if comedi is installed in /usr/local).
Maybe it was not the case in the past (used
/usr/local/include/comedilib.h), so most tutorials said what Ian explained.

When you install comedi, you should just execute the following lines:
make install
mkdir -p /usr/local/include/linux
cp include/linux/comedi.h include/linux/comedilib.h /usr/local/include/linux

By the way, with last RTAI (>= 3.7.1), by default, you need to keep the
non-RT comedilib.h in /usr/local/include to compile Scicos RTAI-Lib
blocks using soft-calibration data (needed if your board is
soft-calibrated, with comedi_soft_calibrate). If you can use
comedi_calibrate, then you don't need this feature and can disable it at
the compilation in removing -DSOFTCALIB in the appropriate Makefile.

--
Guillaume Millet

∂єєραк >>;)

unread,
Jun 24, 2009, 10:18:39 AM6/24/09
to comed...@googlegroups.com
thanks guys for your advise....
but i have already done these steps like by refering from guides

make install
mkdir -p /usr/local/include/linux
cp include/linux/comedi.h include/linux/comedilib.h /usr/local/include/linux

actually I am understanding how the comedi works but my actually aim is to run an matlab/simulink model running on RTAI/linux/Comedi which is having comedi block in it(COMEDI_DATA READ & COMEDI_DATA_WRITE) and output some information(analog or digital) and input some information. I dont know whether I can use these blocks for continous data aquisition. Can I able to use these blocks ....how I can select the subdevice (like subdevice 1for analog output) in these block.( no option in it)....any simple application...
thanks
DP

Guillaume Millet

unread,
Jun 24, 2009, 10:33:47 AM6/24/09
to comed...@googlegroups.com
∂єєραк >>;) a écrit :

> thanks guys for your advise....
> but i have already done these steps like by refering from guides
> make install
> mkdir -p /usr/local/include/linux
> cp include/linux/comedi.h include/linux/comedilib.h
> /usr/local/include/linux

I wrote these lines because they are different from that in main guides
(RTAI-Lab-tutorial and RTAI-UbuntuGutsy-Matlab.txt).

> actually I am understanding how the comedi works but my actually aim
> is to run an matlab/simulink model running on RTAI/linux/Comedi which
> is having comedi block in it(COMEDI_DATA READ & COMEDI_DATA_WRITE) and
> output some information(analog or digital) and input some information.
> I dont know whether I can use these blocks for continous data
> aquisition. Can I able to use these blocks ....how I can select the
> subdevice (like subdevice 1for analog output) in these block.( no
> option in it)....any simple application...
> thanks
> DP
>

Yes you can. I don't use simulink, but I think that there should be a
dialog box when open the block in simulink, no ?
For problems about RTAI-lib blocks, you should post on the RTAI mailing
list.

--
Guillaume Millet

∂єєραк >>;)

unread,
Jun 24, 2009, 11:17:21 AM6/24/09
to comed...@googlegroups.com
thanks Guillaume,

Actually I have build an simple model in Simulink and running executable file in RTAI/linux but I have an doubt that I am able to run my comedi driver or not using these blocks. but using demo program I am sure that my driver is working properly..here is that output...

root@deepak-desktop:/usr/local/src/tests# ./testcomedi -v -f 5

Target settings
===============
  Real-time : HARD
  Timing    : internal / periodic
  Priority  : 0
  Finaltime : 5.000000 [s]
  CPU map   : f

COMEDI /dev/comedi0 (pci-6229) opened.

AI Channel 0 - Range : -10.00 [V] - 10.00 [V]
Cannot init rt_HostInterfaceTask

COMEDI /dev/comedi0 closed.

Target is terminated.
root@deepak-desktop:/usr/local/src/tests# ./testcomedi &
[2] 12153
root@deepak-desktop:/usr/local/src/tests# COMEDI /dev/comedi0 (pci-6229) opened.

AI Channel 0 - Range : -10.00 [V] - 10.00 [V]
Cannot init rt_HostInterfaceTask

COMEDI /dev/comedi0 closed.

Target is terminated.

I dont know what went wrong in it. Any help will be appreciated.

Thanks
DP
Reply all
Reply to author
Forward
0 new messages