Including Comedi devices in Simulink RTW model

Roberto Bucher roberto.bucher at supsi.ch
Tue Jan 10 11:11:52 CET 2006


I think that the problem is simple: you have a counter board. At present, 
RTAI-Lab contains only 4 kinds of blocks:

COMEDI_DATA_READ: Analog Input Board
COMEDI_DATA_WRITE: Analog Output Board
COMEDI_DIO_READ: Digitl Input Board
COMEDI_DIO_WRITE: Digital Output Board

The C-MEX S-Function connected with these blocks are able only to initialize 
the COMEDI_SUBD of the specific type(COMEDI_SUBD_AI, COMEDI_SUBD_AO, 
COMEDI_SUBD_DIO, COMEDI_SUBD_DI and COMEDI_SUBD_DO). Your card (NI-660x) is a 
"counter" card, which requires (I think) to initialize a COMEDI_SUBD_COUNTER.

It is necessary to get one of these C-MEX S-Function (for example 
sfun_comedi_data_read) and to modify it in order to work with 
COMEDI_SUBD_COUNTER devices. The basic idea is to implement the code that you 
have in the working application (encoder.c ?) and to put it into the C-MEX 
S-Function.

Regards

Roberto

P.S. If somebody already did this job, we are interested in putting these 
blocks in the RTAI-Lab library!!!


On Tuesday 10 January 2006 09:27, Stienen, A.H.A. (CTW) wrote:
> (Second try to send this message, after the first one hasn't shown up
> after a day's waiting. Sorry for the possible double posting.)
>
> Hello,
>
> I'm having a problem very similar the one from Todd M. Drullinger a year
> ago (https://mail.rtai.org/pipermail/rtai/2005-March/010503.html).
> Perhaps somebody has found a solution?
>
> I've installed Comedi 0.7.70, Comedilib 0.7.22 and RTAI 3.2 according to
> Roberto Bucher RTAI-Lab Tutorial version 0.50 (November 2005). I'm using
> Matlab 6.5 on Windows to generate the source code, after which I compile
> and run this code on a Linux box with Kernel version 2.4.27, patched
> with the RTAI HAL/ADEOS patch included in the RTAI download.
>
> The test model included with RTAI-Lab is working fine. I can generate
> the code, compile and run it, and then access the running program with
> xrtailab. However, when I include a RTAI-Lab Comedi device (for instance
> the data_read block), the compiled program will give this error when I
> try to run it:
>
> 	´óÿ¿Pôÿ¿) opened.
> 	Comedi find_subdevice failed (No analog input)
> 	Cannot init mailbox
>
> As far as I understand it, I've loaded all the required modules. I've
> adapted a (non-RTAI-Lab) test program named 'encoder.c' which came with
> the NI_660x drivers and when I try to run comedi_find_subdevice_by_type
> in this test program (the function which is giving the error above), it
> workes just fine and I can access the in- and output ports of my three
> NI cards in this way.
>
> Can anybody tell me what is going on?
>
> As many newbie questions on this list are followed by a request for the
> lsmod, dmesg and other similar informatie, I've included my dmesg output
> (both directly after running the RTAI-Lab generated program with Comedi
> devices, as directly after boot), lsmod output and rc.local script. I'm
> sorry for the very long email...
>
> Kind regards,
> Arno Stienen.
>
>
> *** DMESG DIRECTLY AFTER RUNNING RTAI-LAB GENERATED PROGRAM ***
>
> smb_trans2_request: result=-104, setting invalid
> smb_retry: successful, new pid=166, generation=2
> smb_trans2_request: result=-104, setting invalid
> smb_retry: successful, new pid=170, generation=2
> BAD: null rt_fun_ext[9]
> BAD: null rt_fun_ext[9]
> BAD: null rt_fun_ext[9]
> BAD: null rt_fun_ext[9]
> LXRT releases PID 353 (ID: encoder).
>
>
> *** LOADED MODULES ***
>
> Module                  Size  Used by    Not tainted
> ni_660x                14144   0
> ni_pcimio              38752   0
> 8255                    2240   0 [ni_pcimio]
> comedi_fc                864   0 [ni_pcimio]
> ni_670x                 1904   0
> mite                    3028   0 [ni_660x ni_pcimio ni_670x]
> rtai_lxrt              56504   0 [ni_pcimio]
> rtai_fifos             26796   0 (unused)
> rtai_msg               12880   0 (unused)
> rtai_netrpc            14548   0 (unused)
> rtai_mbx                6928   0 [rtai_netrpc]
> rtai_comedi             1868   0 (unused)
> kcomedilib              5616   0 [rtai_comedi]
> comedi                 22496   0 [ni_660x ni_pcimio 8255 comedi_fc
> ni_670x kcomedilib]
> rtai_sem               11040   0 [rtai_netrpc rtai_mbx rtai_comedi]
> rtai_shm                5968   0 [rtai_comedi]
> rtai_ksched            57656   0 [rtai_fifos rtai_msg rtai_netrpc
> rtai_mbx rtai_comedi kcomedilib rtai_sem rtai_shm]
> rtai_hal                9684   0 [ni_660x ni_pcimio 8255 comedi_fc
> ni_670x mite rtai_lxrt rtai_fifos rtai_msg rtai_netrpc rtai_mbx
> rtai_comedi kcomedilib comedi rtai_sem rtai_shm rtai_ksched]
> smbfs                  39824   2 (autoclean)
> ntfs                   51232   1 (autoclean)
> agpgart                43684   0 (unused)
> e1000                  65196   1
> eepro100               18996   1
> mii                     2272   0 [eepro100]
>
>
> *** RC.LOCAL SCRIPT INITIALIZING COMEDI ***
>
> # I've softlinked the RTAI modules to the module tree; the modprobing
> # of the modules below results in the loading of all the modules as
> # seen above.
>
> /sbin/modprobe rtai_comedi
> /sbin/modprobe rtai_netrpc
> /sbin/modprobe rtai_msg
> /sbin/modprobe rtai_fifos
> /sbin/modprobe rtai_lxrt
>
> /sbin/modprobe ni_670x
> /sbin/modprobe ni_pcimio
> /sbin/modprobe ni_660x
>
> /usr/local/sbin/comedi_config /dev/comedi0 ni_670x
> /usr/local/sbin/comedi_config /dev/comedi1 ni_pcimio
> /usr/local/sbin/comedi_config /dev/comedi2 ni_660x
>
>
> *** COMPLETE DMESG AFTER BOOT ***
>
> Linux version 2.4.27-adeos (arno at AR2) (gcc version 3.3.6) #2 Thu Dec 29
> 11:26:07 CET 2005
> [...]
> Adeos 2.4r15/x86: Root domain Linux registered.
> [...]
> Adeos: Pipelining started.
> [...]
> RTAI[hal]: mounted (PIPED).
> Adeos: Domain RTAI registered.
> RTAI[hal]: 3.2 mounted over Adeos 2.4r15/x86.
> RTAI[hal]: compiled with gcc version 3.3.6.
> RTAI[malloc]: kmalloced extent cdc20000, size 131072.
> RTAI[malloc]: loaded (global heap size=131072 bytes).
> RTAI[sched_lxrt]: loaded (PIPED, UP, KERNEL SPACE).
> RTAI[sched_lxrt]: timer=periodic (8254-PIT),.
> RTAI[sched_lxrt]: standard tick=100 hz, CPU freq=1193180 hz.
> RTAI[sched_lxrt]: timer setup=1676 ns, resched latency=2514 ns.
> ***** WARNING: GLOBAL HEAP NEITHER SHARABLE NOR USABLE FROM USER SPACE
> (use the vmalloc option for RTAI malloc) *****
> comedi: version 0.7.70 - David Schleef <ds at schleef.org>
> rt_pend_tq: RT bottom half scheduler initialized OK
> RTAI[malloc]: kmalloced extent cda00000, size 131072.
> RTAI[malloc]: loaded (global heap size=131072 bytes).
> RTAI[sched_lxrt]: loaded (PIPED, UP, KERNEL/USER SPACE).
> RTAI[sched_lxrt]: timer=periodic (8254-PIT),.
> RTAI[sched_lxrt]: standard tick=100 hz, CPU freq=1193180 hz.
> RTAI[sched_lxrt]: timer setup=1676 ns, resched latency=2514 ns.
> Available NI device IDs: 0x1310 0x2ca0 0x2c90
> comedi0: ni_670x: <6>PCI: Found IRQ 7 for device 03:00.0
> MITE:0xfeafe000 mapped to d0cdb000 DAQ:0xfeafd000 mapped to d0cdd000
>   PCI-6703attached
> comedi1: ni_pcimio: pci-6034e<6>PCI: Found IRQ 10 for device 03:01.0
> MITE:0xfeafc000 mapped to d0cdf000 DAQ:0xfeafb000 mapped to d0ce1000
>   ( irq = 10 )
> comedi2: ni_660x: <6>PCI: Found IRQ 3 for device 03:02.0
> PCI: Sharing IRQ 3 with 00:1f.3
> MITE:0xfeafa000 mapped to d0cf4000 mite: detected NI660X board, using
> PCI DAQ SIZE of 8k
> DAQ:0xfeaf8000 mapped to d0cf6000
> mite: detected NI6602, using other I/O Window Base Size register
>   PCI-6602 NI6602: Setting Counterswap on second TIO
> attached
>
>
>
> _______________________________________________
> RTAI mailing list
> RTAI at rtai.org
> https://mail.rtai.org/cgi-bin/mailman/listinfo/rtai

-- 
University of Applied Sciences of Southern Switzerland
Dept. Innovative Technologies
CH-6928 Lugano-Manno
http://www.dti.supsi.ch/~bucher




More information about the Rtai mailing list