LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Information for Controlling Devices using GPIB in Linux/Cygwin/Python (https://www.linuxquestions.org/questions/linux-general-1/information-for-controlling-devices-using-gpib-in-linux-cygwin-python-4175444964/)

B Akshay 01-10-2013 05:26 AM

Information for Controlling Devices using GPIB in Linux/Cygwin/Python
 
Hello,
I wish to control a Agilent Techs DC power source. I have NI's PCI-GPIB card.
I am new to the GPIB programming and need some guidance.
  • The controlling has to be done by using cygwin.(will the purpose be fulfilled??)
  • After searching on net thinking to have scripts in python, but pyvisa is not present on cygwin.(Is python a good choice?? Suggest for any other programming language)
  • is Linux-GPIB scripts required??(How to add to cygwin?)

I am just a beginner in this field, any suggestions for the above mentioned will be helpful.

Thanks in advance

theNbomr 01-10-2013 07:06 PM

Cygwin is not Linux. The Linux-GPIB driver package is mostly a collection of Linux device drivers (building requires Linux kernel headers) and API library as well as a bit of example source code that exercises the drivers and demonstrates how to communicate with your GPIB instrument.
I'm not a Windows person at all, but from what I know, I don't think you could have chosen a more difficult environment in which to use GPIB. NI does (did, at least) have a layer they called 'Visa', and I had some success using that on Solaris with an ethernet attached GPIB interface. That would be the first thing I'd look for in your situation.

--- rod.

B Akshay 01-10-2013 10:33 PM

Rod, Thanks for your response

so according to you, controlling the device from the cygwin will be a tedious job.

Will it be good to use python for scripts??
So that, i can directly use ActivePython for windows which support for the VISA module. (Again a newbie to python)
I am searching more for, programming and support for the VISA and GPIB in python.


Regards,
Akshay

theNbomr 01-11-2013 08:50 AM

Yes, that is potentially correct. The existence of a Visa library may be the savior in that architecture.

The usual method (at least in Linux; don't know about Windows) is that an OS-specific kernel driver provides access to the bus. Above that, a shareable object library (probably a DLL, in Windows) exposes a common API (Visa, or the Linux-GPIB API, which is modeled after the NI API) for accessing the bus/device from userspace. Multiple language bindings to the API can then exist, and I would guess that Python is probably included in those language bindings.

If you have the option of using a real Linux host, your job may be easier (definitely easier than using Cygwin), and you will certainly find more help here and at other online sites. For Windows, your best resource is probably the NI site, which I think has a forum similar to this one.

--- rod.

B Akshay 01-12-2013 07:45 AM

Thanks for the information rod !!!
I am tracking the same.

Will try to do the setup using Linux machine.

B Akshay 01-16-2013 02:57 AM

Hello Rod,
I was just trying with the linux part of it. But confused, how to initiate with script.
Can you please provide me a small sample code using Gpib-utils or Linux-Gpib ?

Thanks & Regards,
B Akshay

theNbomr 01-16-2013 08:39 AM

If you built and installed the Linux-GPIB drivers, then there will be some sample code there. The ibtest utility that is part of the package is very useful for making sure that you've got the driver correctly loaded and installed. It allows you to interactively send commands to devices attached to the bus, as well as configure the bus itself. I have used the source code for that as a model for some basic test and development code in some projects. There is other source code samples in the 'language/' tree of the driver package.
There is a tool, ibconfig, that must be run before you can use the loaded driver. After that, everything should work.I usually put the ibconfig step into /etc/rc.local so it runs at boot time. You may have to also modify the permission levels on the device node(s) /dev/gpip* in order to access the bus. The only problem I've ever had with the package is that some of the drivers don't always build for all kernel versions, but the NI board drivers have always built and worked fine. If you run into that, then comment out the recalcitrant ones in the appropriate Makefile, so the build completes successfully.
One aspect that may warrant further clarification is the use of the gpib.conf file that is used by ibconfig. In there, you can created named devices that are associated with particular GPIB bus addresses and with some GPIB configuration parameters like time-outs, etc. These are only necessary if your code uses the API functions that need these named devices. There is a whole class of name-agnostic functions which rely only on device names (/dev/gpibX) and GPIB addresses. I tend to prefer these over the fucntions that use the named devices set up in the config file (not saying there is anything wrong with the others; just haven't used them much). I think the sample code tends to use the API functions that do use the named devices.
If you have a NI GPIB interface, it probably came with some DOS-ish software and libraries. The documentation for those libraries is also a useful guide, as the Linux-GPIB package models the API after NI's version, and seems to be a pretty faithful rendition of the NI software.
The software does work well. I've got a dozen or so installations that run 24/7 controlling a variety of T&M gear, all problem free, and some that has been doing so for over ten years. I have been using Scientific Linux (4,5, & 6), and more recently a Debian-6 based package for both building the software and running applications. I only today became aware of the gpib-utils package, so I cannot offer any comment on that product.

--- rod.

B Akshay 02-05-2013 05:54 AM

Thanks alot!!!
I have gone through the site.. It helped me a lot.
Simultaneously i searched for the pyVisa in python, i have installed it successfully on my system.
I have programmed my device as well and is working fine.
Will carry on with the GPIB programming on Linux also.

Regards,
B Akshay


All times are GMT -5. The time now is 08:41 PM.