Admesy Brontes Linux Howto
Admesy Brontes Linux Howto
Admesy Brontes Linux Howto
Version : 1.0.2
Page 1
Version : 1.0.2
Page 2
All rights reserved. No part of this document may be reproduced, stored in a database or retrieval system, or published in any form or way, electronically, mechanically, by print, photo print, microfilm or any other means without prior written permission from the publisher. All correspondence regarding copyrights : Admesy B.V. Beneluxstraat 7 6014CC Ittervoort The Netherlands Tel : +31 (0) 475 600232 Fax : +31 (0) 475 600316 URL : http://www.admesy.nl
Version : 1.0.2
Page 3
Contents
1 2 3 4 5 6 7 Admesy products and drivers Installation of NI-VISA on Linux 2.1 Fedora 10 (both 32 and 64bit) 2.2 Fedora 7 & 8 Adding the Colorimeter to the NI-VISA configuration. Installing the Linux application. 4.1 Installing the Labview runtime engine. 4.2 Installing the Colorimeter application. Linux USBTMC kernel driver Libusb Using the Agilent open source USBTMC driver. 7.1 Installing and testing the Agilent USBTMC driver 7.2 Writing a small C program to control the Brontes 7.3 Graphical scripting for the Brontes 5 6 6 6 7 10 10 10 12 12 12 12 13 16
Version : 1.0.2
Page 4
Operating system Windows Windows Linux Linux Linux Linux OSX OSX
Driver name NI-VISA Libusb NI-VISA Kernel USBTMC driver Agilent driver Libusb NI-VISA Libusb
Source National Instruments Open source National Instruments Open source Open source Open source National Instruments Open source
Comment
Note that for embedded systems the driver support is processor dependant. NI-VISA should work on Win-CE but currently the best choice for embedded systems would be Linux with 4 choices of available drivers.
Version : 1.0.2
Page 5
Version : 1.0.2
Page 6
After this, copy the config file of your current kernel to the kernel source directory. For example : cd /usr/src/redhat/BUILD/kernel-2.6.23/linux-2.6.23.i686/configs/kernel-2.6.23.15-i586.config .config After this, installation can be continued. When upgrading a kernel, the updateNIdrivers script can be used to update the NI driver for the new kernel. After installation of the drivers either reboot the pc or restart the nipal service : /sbin/service nipal restart
Version : 1.0.2
Page 7
distributions, only the root user can access all of the USB devices. Running this script is not necessary if NI-VISA will be run only by the 'root' user or if usbfs (formerly known as usbdevfs) is mounted with the "devmode=0666" option. "udev" detected. The Vendor ID (VID) of a USB device is a numeric identifier that may be up to 4 hexadecimal digits. It is found in the "device descriptor" of the USB Device. An example is "0xA1B2". What is the Vendor ID (VID) of the USB Device? 0x1781 The Product ID (PID) of a USB device is a numeric identifier that may be up to 4 hexadecimal digits. It is found in the "device descriptor" of the USB Device. An example is "0xA1B2". What is the Product ID (PID) of the USB Device? 0x0E93 The following USB Device information has been entered: Vendor ID (VID) : Product ID (PID) : Continue? [Yn] y If the USB Device is currently plugged in, please unplug and plug it back in for these changes to take effect. USB Device successfully added. Restart the PC. "0x1781" "0x0E93"
After this, the device should show up in the VISA interactive control dialog :
Version : 1.0.2
Page 8
Double click the device to open a connection. Enter :*IDN? to test if the Brontes works.
Go to the viRead tab to read back the information from the Brontes :
Version : 1.0.2
Page 9
If this works than the Brontes is ready for use on your Linux machine.
Version : 1.0.2
Page 10
Version : 1.0.2
Page 11
6 Libusb
People who can't work with NI-VISA, The 2.6.28 or later kernels or the open source Agilent driver can use libusb, which is open source as well. It can be used on both Windows and Linux (and probably also OSX) and tests have shown no performance difference compared to the earlier mentioned drivers. Explanation about libusb is out of scope for this document. Developers interested in this option should contact Admesy for more information.
Version : 1.0.2
Page 12
Version : 1.0.2
Page 13
int main() { int myfile; char buffer[4000]; int actual; int retval; int en; struct usbtmc_instrument inst; struct usbtmc_attribute attr; myfile=open("/dev/usbtmc1",O_RDWR); // Open instrument #1 for reading and writing if(myfile==-1) exit(1); // Tell the driver we are using read(2), not fread(2) attr.attribute=USBTMC_ATTRIB_READ_MODE; attr.value=USBTMC_ATTRIB_VAL_READ; ioctl(myfile,USBTMC_IOCTL_SET_ATTRIBUTE,&attr); attr.attribute=USBTMC_ATTRIB_NUM_INSTRUMENTS; ioctl(myfile,USBTMC_IOCTL_GET_ATTRIBUTE,&attr); printf("Number of instruments active: %d\n",attr.value); retval=write(myfile,":*IDN?\n",7); // Send *IDN? command if(retval==-1) { en=errno; printf("Error during write: %s\n",strerror(en)); } actual=read(myfile,buffer,4000); // Read response if(actual==-1) { en=errno; printf("Error during read: %s\n",strerror(en)); printf("ID: %s\n",buffer); } else { buffer[actual]=0; printf("ID: %s\n",buffer); } // Get info about instrument #1 inst.minor_number=1; if(ioctl(myfile,USBTMC_IOCTL_INSTRUMENT_DATA,&inst)!=-1) { printf("MANUFACTURER: %s\n",inst.manufacturer); printf("PRODUCT: %s\n",inst.product); printf("S/N: %s\n",inst.serial_number); }
Version : 1.0.2
Page 14
retval=write(myfile,":sense:aver 1000\n",17); // Set averaging if(retval==-1) { en=errno; printf("Error during write: %s\n",strerror(en)); } else printf("Averaging set to 1000\n"); retval=write(myfile,":sense:gain 1\n",14); // Set gain 1 if(retval==-1) { en=errno; printf("Error during write: %s\n",strerror(en)); } else printf("Gain set to 1\n"); retval=write(myfile,":meas:xyz\n",10); // Send *IDN? command if(retval==-1) { en=errno; printf("Error during write: %s\n",strerror(en)); } actual=read(myfile,buffer,4000); // Read response if(actual==-1) { en=errno; printf("Error during read: %s\n",strerror(en)); printf("ID: %s\n",buffer); } else { buffer[actual]=0; printf("Measure XYZ : %s\n",buffer); } // Demonstrate timeout handling actual=read(myfile,buffer,4000); // Provoke timeout if(actual==-1) { en=errno; printf("Error during read: %s\n",strerror(en)); printf("Recover from timeout using ABORT_BULK_IN\n"); ioctl(myfile,USBTMC_IOCTL_ABORT_BULK_IN,0); } close(myfile); // Done using the instrument return 1; }
Version : 1.0.2
Page 15
Version : 1.0.2
Page 16