Sie sind auf Seite 1von 10

Procedure to set up the system for GPIB programming: GPIB PCI card: National Instrument PCI-GPIB OS : linux Fedora

Core 6 Kernel: 2.6.19.2 ('uname -r') linux gpib driver version: linux-gpib-3.2.08 ( with minor modifications) --------------------------------------------------------------I) hard ware installation: 1) power off computer 2) install PCI-GPIB card in one of PCI slot 3) turn on computer for plug and play OS one will see the PCI-GPIB card recognised by BIOS aut omatically. [qzpeng@localhost gpib_config]$ /sbin/lspci | grep PCI 04:09.0 Communication controller: National Instruments PCI-GPIB (rev 01) [qzpeng@localhost gpib_config]$ ls /proc/bus/pci/04 05.0 09.0 II) driver installation: 1) unpack linux-gpib-3.2.08 to '/usr/src/linux-gpib-3.2.08/' 2) follwoing instructions from 'INSTALL' i) 'make vmlinux' 'make modules' ? ii) ./configure --> make --> make install (as root) iii) edit '/etc/gpib.conf to match your interface board and devices. iv) load the driver module by /sbin/modprobe tnt4882' v) setup the driver by 'gpib_config --minor 0' ----------------------------------------------------------------Comments on installation check: 0) supposed linux-gpib installed in your kernel successfully. 1) At computer boot up, the pci-gpib card will be automatically recognised by OS and driver/module loaded up automatically. (plug and play?) To check it: a) /sbin/lspci for PCI card recognised b) /sbin/lsmod for pci-gpib driver/module installed, 'tnt4882', 'nec7210' and 'gpib_common' 2) Configure the gpib board and device based on /etc/gpib.conf /usr/src/linux-gpib-3.2.08/lib/gpib_config/gpib_config --minor 0 3) You can alway check the message for each procedure by looking at dmesg | tail -50 or tail -50 /var/log/messages less /proc/interrupts less /proc/ioports 4) When system got fatal error, you can try unload/reload the module by /sbin/rmmod ??? /sbin/modprobe ??? ???/gpib_config --minor 0 5) You may need root priviledge to make your code working... like the /dev/gpib# is R/W accessible. [root@localhost examples]# ls -l /dev/gpib0 crw-rw-rw- 1 root root 160, 0 Feb 7 02:03 /dev/gpib0

----------------------------------------------------------Examples to show: 0) check the PCI-GPIB card recognised [qzpeng@localhost gpib_config]$ /sbin/lspci | grep PCI 04:09.0 Communication controller: National Instruments PCI-GPIB (rev 01) [qzpeng@localhost gpib_config]$ ls /proc/bus/pci/04 05.0 09.0 0') unload module tnt4882 --> driver for the NI pci-gpib card [root@localhost examples]# /sbin/lsmod | grep tnt tnt4882 29572 0 nec7210 23424 1 tnt4882 gpib_common 37828 2 tnt4882,nec7210 [root@localhost examples]# /sbin/rmmod tnt4882 [root@localhost examples]# /sbin/lsmod | grep tnt [qzpeng@localhost gpib]$ dmesg | tail -50 |||||||||||||||||||||||||| gpib: unregistered ni_isa interface gpib: unregistered ni_isa_accel interface gpib: unregistered ni_nat4882_isa interface gpib: unregistered ni_nat4882_isa_accel interface gpib: unregistered ni_nec_isa interface gpib: unregistered ni_nec_isa_accel interface gpib0: exiting autospoll thread ACPI: PCI interrupt for device 0000:04:09.0 disabled gpib: unregistered ni_pci interface gpib: unregistered ni_pci_accel interface 1) load module tnt4882 [root@localhost examples]# /sbin/modprobe tnt4882 [root@localhost examples]# /sbin/lsmod | grep tnt tnt4882 29572 0 nec7210 23424 1 tnt4882 gpib_common 37828 2 tnt4882,nec7210 [qzpeng@localhost gpib]$ dmesg | tail -50 |||||||||||||||||||||||||| gpib: registered ni_isa interface gpib: registered ni_isa_accel interface gpib: registered ni_nat4882_isa interface gpib: registered ni_nat4882_isa_accel interface gpib: registered ni_nec_isa interface gpib: registered ni_nec_isa_accel interface gpib: registered ni_pci interface gpib: registered ni_pci_accel interface Available NI PCI device IDs: 0xc801 2) configure ni_pci gpib board [root@localhost gpib_config]# ./gpib_config --minor 0 [qzpeng@localhost gpib]$ dmesg | tail -50 |||||||||||||||||||||||||| gpib: (debug) request module returned 256 ACPI: PCI Interrupt 0000:04:09.0[A] -> Link [LNKB] -> GSI 17 (level, low) -> IRQ

22 PCI: Enabling bus mastering for device 0000:04:09.0 mite: 0xdfeff000 mapped to f8b80000 mite: daq: 0xdfef8000 mapped to f8e1e000 tnt4882: irq 22 ----------------------------------------------------------Notice: *) board must be opened/loaded before programming. *) the c function calls only can open devices. *) each time ibdev or ibfind called, the devicd opened will be assigned a new 'u d' *) Addr4882_t address == pad if sad=0 tatic __inline__ Addr4882_t MakeAddr(unsigned int pad, unsigned int sad); Example Addr4882_t addressList[ 5 ]; addressList[ addressList[ addressList[ */ addressList[ s 9 */ addressList[ 0 ] = 5 /* primary address 5, no secondary address */ 1 ] = MakeAddr(3, 0); /* primary address 3, no secondary address */ 2 ] = MakeAddr(7, 0x70); /* primary address 3, secondary address 16 3 ] = MakeAddr(20, MSA(9)); /* primary address 20, secondary addres 4 ] = NOADDR;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ My setup log for GPIB coding: devices: NI GPIB-PCI card, HP 8130A, HP 34401A ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2007-01-30 tried to run gpib code on 'beauty': [qzpeng@beauty examples]$ ./ibtest Do you wish to open a (d)evice or an interface (b)oard? (you probably want to open a device): b enter name of interface board (or device) you wish to open: violet trying to open board named 'violet' libgpib: IBOPENDEV ioctl failed libgpib: ibfind failed to get descriptor failed to open board --> I do not have root password, and maybe I need run 'gpib_conf --minor 0' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2007-02-01 Finally I made it working...... linux-gpib-3.2.08 on linux kernel 2.6.19.2 on FC6 Procedure: 1) install linux kernel 2.6.19.2 read "README" 2) install linux-gpib-3.2.08 read "INSTALL" in that directory !!! a) made change to source c file: /usr/src/linux-gpib-3.2.08/drivers/gpib/sys/osinit.c "include <linux/utsrelease.h>

comment out "readv" and "writev" in "struct file_operations ib_fops". /sbin/modprobe <driver_name> --> tnt4882 and nec7210 gpib_config --minor 0 runing test code in examples/ibtest --> OK runing my own test.c not OK --> shared library libgpib.so stored in /usr/local/lib which is not encolsed in link path search file "/etc/ld.so.conf", so as root user add a file "local.co nf" in /etc/ld.so.conf.d/ directory so that "/etc/ld.so.conf" contains that dire cotry. --> run 'ldconfig' after setting. 7) test.c only working ok under root, not for qzpeng, regular user: --> most of gpib package belong to group "games", so add user "qzpeng" to that g roup. --> change /dev/gpib0 to be accessiable by qzpeng, like chmod a+x(r,w) /dev/gpib 0 3) 4) 5) 6) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`` 2007 Feb 4 Comparison: ibwrt, Send, SendList int ibwrt(int ud, const void *data, long num_bytes) void Send(int board_desc, Addr4882_t address, const void *data, long count, int eot_mode); Comparison: *RST, *CLS --> Check 'ibsta' *RST: RESET the device *CLS: Clear the device --------------------------------------------------------2007 Feb 5 It works on Multimeter, what's next? pulse generator. HP 8130A pulse generator, 300MHz. basic def: 8130A pad=4, 34401A pad=3. maybe try some scopes later. -------------------------------------------------2007 Feb 6 changing pad for HP 8130 : press 'LCL' --> 'A 10' --> change address if 'ADS' lights on --> instrument is listen/talk addressed--> address can't be c hanged --> using 'SendIFC(0)' --> but error=14 with Time out and don't know how to recover the problem. -------------------------------------------------2007 Feb 7 Problem:

34401A pad=3, 8130A pad=4 after SendIFC(0) both devices not respond to commands I) To solve the error=14 problem, I did the following: 1) unload modules [root@localhost examples]# /sbin/rmmod tnt4882 [root@localhost examples]# /sbin/lsmod | grep tnt dmesg | tail -20 2) load modules [root@localhost examples]# /sbin/modprobe tnt4882 [root@localhost examples]# /sbin/lsmod | grep tnt dmesg | tail -20 3) configure board [root@localhost gpib_config]# ./gpib_config --minor 0 [root@localhost gpib_config]# pwd /usr/src/linux-gpib-3.2.08/lib/gpib_config dmesg | tail -20 [root@localhost lib]# /sbin/lspci -vv [root@localhost lib]# ls /proc/bus/pci/04 [root@localhost lib]# tail -100 /var/log/messages [root@localhost examples]# more /proc/interrupts [root@localhost examples]# less /proc/ioports Result: The problem still exist, Board OK but devices NOT responding... Next: try only one device 34401A II) unload/reload module tnt4882 gpib_config --minor 0 only 34401A Result: working ok... [qzpeng@localhost gpib]$ ./dvm Monitoring bus lines ==> Result=0xffff96ff " NDAC NRFD REN EOI " are set on... ibsta = 0x164 < CMPL REM CIC LACS > Perform interface clear ibsic(board)... ibsta = 0x160 < CMPL REM CIC > Opened device id=16 (pad=3)... Clear device id=16 (pad=3)... ibsta = 0x100 < CMPL > Reset + Clear... ibsta = 0x2168 < END CMPL REM CIC TACS > ibcnt = 9 Enable Remote... ibsta = 0x2170 < END CMPL REM CIC ATN > Monitoring bus lines ==> Result=0x52ff " NDAC REN ATN " are set on... result: 6781.45 ibsta = 0x2164 < END CMPL REM CIC LACS > ibcnt = 16

[root@localhost examples]# dmesg | tail -50 gpib: (debug) request module returned 256 (note: STOPend == 256) III) plug cable of 8130A on Result: Problem happened again, same as I) [qzpeng@localhost gpib]$ ./dvm Monitoring bus lines ==> Result=0xffff96ff " NDAC NRFD REN EOI " are set on... ibsta = 0x164 < CMPL REM CIC LACS > Perform interface clear ibsic(board)... ibsta = 0x160 < CMPL REM CIC > Opened device id=16 (pad=3)... Clear device id=16 (pad=3)... ibsta = 0xc100 < ERR TIMO CMPL > iberr = 14 EBUS -> Writing to Bus Timed Out EBUS 14: Bus error Reset + Clear... ibsta = 0xc170 < ERR TIMO CMPL REM CIC ATN > iberr = 14 EBUS -> Writing to Bus Timed Out EBUS 14: Bus error Enable Remote... ibsta = 0xc170 < ERR TIMO CMPL REM CIC ATN > iberr = 14 EBUS -> Writing to Bus Timed Out EBUS 14: Bus error Monitoring bus lines ==> Result=0x56ff " NDAC NRFD REN ATN " are set on... InternalReceiveSetup: command failed result: 0 ibsta = 0xc170 < ERR TIMO CMPL REM CIC ATN > iberr = 14 EBUS -> Writing to Bus Timed Out EBUS 14: Bus error [root@localhost examples]# dmesg tnt4882: write timed out gpib: error writing gpib command tnt4882: write timed out gpib: error writing gpib command tnt4882: write timed out gpib: error writing gpib command tnt4882: write timed out gpib: error writing gpib command tnt4882: write timed out gpib: error writing gpib command | tail -50 bytes bytes bytes bytes bytes

IV) unplug cable of 8130A, system works again... [qzpeng@localhost gpib]$ ./dvm Monitoring bus lines ==> Result=0x52ff " NDAC REN ATN " are set on... ibsta = 0x170 < CMPL REM CIC ATN > Perform interface clear ibsic(board)... ibsta = 0x170 < CMPL REM CIC ATN > Opened device id=16 (pad=3)... Clear device id=16 (pad=3)... ibsta = 0x100 < CMPL > Reset + Clear... ibsta = 0x2168 < END CMPL REM CIC TACS >

ibcnt = 9 Enable Remote... ibsta = 0x2170 < END CMPL REM CIC ATN > Monitoring bus lines ==> Result=0x52ff " NDAC REN ATN " are set on... result: 6781.36 ibsta = 0x2164 < END CMPL REM CIC LACS > ibcnt = 16 [root@localhost examples]# dmesg | tail -50 gpib: (debug) request module returned 256 V) plug on cable of 8130A run 'gpib_config --minor 0' Result: NOT working... From dmesg: gpib: (debug) request module returned 256 gpib0: exiting autospoll thread ACPI: PCI interrupt for device 0000:04:09.0 disabled ACPI: PCI Interrupt 0000:04:09.0[A] -> Link [LNKB] -> GSI 17 (level, low) -> IRQ 22 PCI: Enabling bus mastering for device 0000:04:09.0 mite: 0xdfeff000 mapped to f8b80000 mite: daq: 0xdfef8000 mapped to f8e1e000 tnt4882: irq 22 [qzpeng@localhost gpib]$ ./dvm Monitoring bus lines ==> Result=0x56ff " NDAC NRFD REN ATN " are set on... ibsta = 0x130 < CMPL CIC ATN > Perform interface clear ibsic(board)... ibsta = 0x130 < CMPL CIC ATN > Opened device id=16 (pad=3)... Clear device id=16 (pad=3)... ibsta = 0xc100 < ERR TIMO CMPL > iberr = 14 EBUS -> Writing to Bus Timed EBUS 14: Bus error Reset + Clear... ibsta = 0xc130 < ERR TIMO CMPL CIC ATN iberr = 14 EBUS -> Writing to Bus Timed EBUS 14: Bus error Enable Remote... ibsta = 0xc130 < ERR TIMO CMPL CIC ATN iberr = 14 EBUS -> Writing to Bus Timed EBUS 14: Bus error Monitoring bus lines ==> Result=0x56ff " NDAC NRFD REN ATN " are set on... InternalReceiveSetup: command failed result: 0 ibsta = 0xc130 < ERR TIMO CMPL CIC ATN iberr = 14 EBUS -> Writing to Bus Timed EBUS 14: Bus error From dmesg: tnt4882: write timed out gpib: error writing gpib command bytes tnt4882: write timed out gpib: error writing gpib command bytes

Out > Out > Out

> Out

tnt4882: write timed out gpib: error writing gpib command bytes tnt4882: write timed out gpib: error writing gpib command bytes tnt4882: write timed out gpib: error writing gpib command bytes VI) unload module tnt4882 load module tnt4882 configure ni_pci gpib board Result: NOT working... [qzpeng@localhost gpib]$ ./dvm Monitoring bus lines ==> Result=0x56ff " NDAC NRFD REN ATN " are set on... ibsta = 0x130 < CMPL CIC ATN > Perform interface clear ibsic(board)... ibsta = 0x130 < CMPL CIC ATN > Opened device id=16 (pad=3)... Clear device id=16 (pad=3)... ibsta = 0xc100 < ERR TIMO CMPL > iberr = 14 EBUS -> Writing to Bus Timed EBUS 14: Bus error Reset + Clear... ibsta = 0xc130 < ERR TIMO CMPL CIC ATN iberr = 14 EBUS -> Writing to Bus Timed EBUS 14: Bus error Enable Remote... ibsta = 0xc130 < ERR TIMO CMPL CIC ATN iberr = 14 EBUS -> Writing to Bus Timed EBUS 14: Bus error Monitoring bus lines ==> Result=0x56ff " NDAC NRFD REN ATN " are set on... InternalReceiveSetup: command failed result: 0 ibsta = 0xc130 < ERR TIMO CMPL CIC ATN iberr = 14 EBUS -> Writing to Bus Timed EBUS 14: Bus error

Out > Out > Out

> Out

VII) turn off power of 8130A, leave the cable pluged on 34401A works... [qzpeng@localhost gpib]$ ./dvm Monitoring bus lines ==> Result=0x52ff " NDAC REN ATN " are set on... ibsta = 0x170 < CMPL REM CIC ATN > Perform interface clear ibsic(board)... ibsta = 0x170 < CMPL REM CIC ATN > Opened device id=16 (pad=3)... Clear device id=16 (pad=3)... ibsta = 0x100 < CMPL > Reset + Clear... ibsta = 0x2168 < END CMPL REM CIC TACS > ibcnt = 9 Enable Remote... ibsta = 0x2170 < END CMPL REM CIC ATN > Monitoring bus lines ==> Result=0x52ff " NDAC REN ATN " are set on...

result: 6781.82 ibsta = 0x2164 < END CMPL REM CIC LACS > ibcnt = 16 VIII) turn on power of 8130A 34401A still working !!! [qzpeng@localhost gpib]$ ./dvm Monitoring bus lines ==> Result=0xffff96ff " NDAC NRFD REN EOI " are set on... ibsta = 0x164 < CMPL REM CIC LACS > Perform interface clear ibsic(board)... ibsta = 0x160 < CMPL REM CIC > Opened device id=16 (pad=3)... Clear device id=16 (pad=3)... ibsta = 0x100 < CMPL > Reset + Clear... ibsta = 0x2168 < END CMPL REM CIC TACS > ibcnt = 9 Enable Remote... ibsta = 0x2170 < END CMPL REM CIC ATN > Monitoring bus lines ==> Result=0x52ff " NDAC REN ATN " are set on... result: 6781.81 ibsta = 0x2164 < END CMPL REM CIC LACS > ibcnt = 16 Conclusion: 8130A hardware problem inside the machine, need power off/on to reboot system. ---------------------------------------------------------question: what's the diff of 'ibsta' and 'ThreadIbsta'? ---------------------------------------------------------2007 Feb 8 on HP 8130A It's found that after changing the 'ibclr' to 'SendOut("*CLR")' the HP 8130A wor ks more stable. Difference of "*CLR" and "*RST" "*CLR" keep the instrument settings while "*RST" reset to Default settings. Every time Receive() used it way empty the buffer. -------------------------------------------------------2007-03-07 Problem: libgpib: ibBoardOpen failed to open device file /dev/gpib0 libgpib: Permission denied [qzpeng@localhost gpib]$ ls -l /dev/gpib0 crw------- 1 root root 160, 0 Mar 1 06:07 /dev/gpib0

Fix: Get root previledge to 'chmod a+rw /dev/gpib' [qzpeng@localhost gpib]$ su Password: [root@localhost gpib]# chmod a+rw /dev/gpib0 [root@localhost gpib]# exit exit [qzpeng@localhost gpib]$ ls -l /dev/gpib0 crw-rw-rw- 1 root root 160, 0 Mar 1 06:07 /dev/gpib0 problem: libgpib: error locking board mutex! tried: [qzpeng@localhost gpib]$ ./gpib_config --minor 0 failed to bring board offline failed to configure board main: Operation not permitted [qzpeng@localhost gpib]$ ls -l /usr/src/linux-gpib-3.2.08/lib/gpib_config/gpib_c onfig -rwxr-xr-x 1 root root 4453 Feb 1 07:11 /usr/src/linux-gpib-3.2.08/lib/gpib_con fig/gpib_config [root@localhost gpib]# chmod a+rw /usr/src/linux-gpib-3.2.08/lib/gpib_config/gpi b_config [root@localhost gpib]# exit exit [qzpeng@localhost gpib]$ ls -l /usr/src/linux-gpib-3.2.08/lib/gpib_config/gpib_c onfig -rwxrwxrwx 1 root root 4453 Feb 1 07:11 /usr/src/linux-gpib-3.2.08/lib/gpib_con fig/gpib_config [qzpeng@localhost gpib]$ ./gpib_config --minor 0 failed to bring board offline failed to configure board main: Operation not permitted [qzpeng@localhost gpib]$ su Password: [root@localhost gpib]# ./gpib_config --minor 0 [root@localhost gpib]#

Das könnte Ihnen auch gefallen