Angel Posted February 2, 2005 Share Posted February 2, 2005 (edited) Hi, I have made a VISA/GPIB library for AutoIt3. If you are interested in this you probably already know what is VISA and GPIB, but here there is a short description for those that don't know about it: Basically GPIB allows you to control instruments like Power Supplies, Signal Generators, Oscilloscopes, Signal Generators, etc. You need to install or connect a GPIB interface card (PCI, PCMCIA or USB) to your PC and install the corresponding GPIB driver. VISA is a standard API that sits on top of the GPIB driver and it allows you to use the same programs to control your instruments regardless of the type of GPIB card that you have installed in your PC (most cards are made either by National Instruments or by Agilent/Hewlett-Packard). The cool thing about this library is that it opens AutoIt to a whole new kind of automation (instrument automation). Normally you would need to use some expensive "instrumentation" environment like Labwindows/CVI, LabView or Matlab to automate instruments but now you can do so with AutoIt. The only requirement is that you need a VISA compatible GPIB card (all cards that I know are) and the corresponding VISA driver must be installed (look for visa32.dll in the windows\system32 folder). I've tried to make the function descriptions in the attached "visa.au3" library as clear as possible, and I've put a small (commented) example at the bottom of the file. I've even put the C code prototypes of the visa32.dll function there (also commented) for those that might be interested. Basically you have 4 main functions: _viExecCommand - Executes commands and queries through GPIB _viOpen, _viClose - Open/Close a connection to a GPIB instrument. _viFindGPIB - Find all the instruments in the GPIB bus There are other less important functions, like: _viGTL - Go to local mode (exeit the "remote control mode") _viGpibBusReset - Reset the GPIB bus if it is in a bad state _viSetTimeout - Sets the GPIB Query timeout _viSetAttribute - Set any VISA attribute There is only one limitation that I know of, which is that the GPIB queries only return the 1st line of the device answer. This is not a problem in most cases, as most devices will always answer with a single line anyway. Please let me know if what you think, if you are able to make it work (I only have a National Instruments card so I'd like to see other people try it with an Agilent card) or if you have any trouble or suggestion. I recommend that you try first to execute the _viFindGPIB function (as shown in the example at the bottom of the file) and see if you can find any instruments. You can also have a look at the examples in the _viExecCommand function description. Ah! Another neat thing about this is that you can use it to open a TCP SOCKET, as VISA gives you access to the TCP stack by means of the "TCPIP[board]::host address::port::SOCKET" descriptor. However the limitation on the queries could be a problem in this case. Cheers, Angelvisa.au3 Edited February 2, 2005 by Angel mLipok 1 Link to comment Share on other sites More sharing options...
Sentinel Posted February 2, 2005 Share Posted February 2, 2005 This is very cool! I just tried it right now and works great. I was able to find all the instruments that were connected to my PC in no time! I am currently using Test-Stand for my automation, but now I have a cheaper alternative for our small projects (Test-Stand costs more than 500$ per machine!) Thanks a lot! I hope that this functions become part of the standard library of AutoIt. Manuel P.D.- Some time ago you made a suggestion for adding "Matlab-like" arrays to AutoIt. Have you done something about this? Link to comment Share on other sites More sharing options...
Developers Jos Posted February 3, 2005 Developers Share Posted February 3, 2005 Angel submitted this collection of UDFs to me and asked if they can be included in the standard UDF library. This is not my field of experties and am wondering if this UDF collection is something that has enouigh supporters to justify inclusion ...... Opinions are welcome..... SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Sentinel Posted February 3, 2005 Share Posted February 3, 2005 Angel submitted this collection of UDFs to me and asked if they can be included in the standard UDF library.This is not my field of experties and am wondering if this UDF collection is something that has enouigh supporters to justify inclusion ...... Opinions are welcome.....<{POST_SNAPBACK}>You can imagine by my post from before that I support this inclusion very, very, very much! This would be awesome!I don't know if many here know but GPIB is very important in the test industry. I use TestStand at work, but they charge you 5000$ for the development license and 500$ for the user license (that is true, you also pay to use the programs that you write!). I don't write often in these forums because as I said I use much more TestStand than AutoIt. But this could change that For simple programs I would defenitelly want to use AutoIt instead.Manuel Link to comment Share on other sites More sharing options...
Guest omma_rok Posted February 3, 2005 Share Posted February 3, 2005 Wow! This is what I call luck. I just found about AutoIt from a colleage at work 5 days ago and I told him: "This thing would rock if it had ActiveX and GPIB support". And bam! less than a week later someone "hears" my wishes and creates this GPIB library and I think that someone is working in ActiveX too! I work in a lab at a major chip maker company and we use GPIB all the time (we use LabView for most of our programs). I haven't had a chance to try this library yet, but I will as soon as I can. In the mean time, if it does what it says it does I would like this to be added to the default installation of AutoIt. - Omma Link to comment Share on other sites More sharing options...
Angel Posted February 3, 2005 Author Share Posted February 3, 2005 Omma, JdeB gave me some feedback on my code and I will do some small changes to it soon. Right know it shows some message boxes in case of error but I will remove them and change the returned error codes instead. Please, let me know if you have any problems with it. Do you have a National Instruments or Agilent card? Cheers, Angel Link to comment Share on other sites More sharing options...
Guest the1ake Posted February 4, 2005 Share Posted February 4, 2005 Greetings from Tokyo, friends of AutoIt. GPIB excellent addition to this good looking language will be. Hope it accepted is. Big sorry for English. Not accustomed to write it. I read it. Altavista and Google help me. Please, excuse me. I try it with Agilent card. No problem. Why _viFindGPIB? _viGpibFind not better? Like VISA-GPIB-FIND. More logic. I vote yes. I like this. Thank you Angel. Please accept this. Teiya Link to comment Share on other sites More sharing options...
Guest santy Posted February 4, 2005 Share Posted February 4, 2005 Wow!! This is really cool! I just tried it out and it is really good. I wanted something like this for my work, and I think I can use this. Thanks Angel! I vote YES! Santy Link to comment Share on other sites More sharing options...
Guest agarde1 Posted February 4, 2005 Share Posted February 4, 2005 Another GPIB user here. I would really like this feature by default in AutoIt. One suggestion, could there be a "test function" added that would show you a GUI were you could search instruments and send them commands, queries and reset the BUS is there is aproblem (like the VISA interactive tool from National Instruments). What do you think? Gardel Link to comment Share on other sites More sharing options...
Angel Posted February 4, 2005 Author Share Posted February 4, 2005 Another GPIB user here. I would really like this feature by default in AutoIt.One suggestion, could there be a "test function" added that would show you a GUI were you could search instruments and send them commands, queries and reset the BUS is there is aproblem (like the VISA interactive tool from National Instruments).What do you think?Gardel<{POST_SNAPBACK}>Gardel,I think that it could be done very easily. However, although it could be very useful I don't know if such a function should be integrated into the "default library".Cheers,Angel Link to comment Share on other sites More sharing options...
Angel Posted February 4, 2005 Author Share Posted February 4, 2005 Greetings from Tokyo, friends of AutoIt.GPIB excellent addition to this good looking language will be. Hope it accepted is.Big sorry for English. Not accustomed to write it. I read it. Altavista and Google help me. Please, excuse me.I try it with Agilent card. No problem. Why _viFindGPIB? _viGpibFind not better? Like VISA-GPIB-FIND. More logic.I vote yes. I like this. Thank you Angel. Please accept this.Teiya<{POST_SNAPBACK}>Thanks Teiya,the reason why I named that function _viFindGPIB instead of _viGpibFind is that it is basically a wrapper around the _viFindRsrc function, and I wanted to keep my function names as close as possible to the VISA library functions. I did not call it _viFindRsrc because I think that in the context of autoit it is much clear to use GPIB instead of Rsrc (which stands for resource) as its only purpose is in fact finding GPIB resources (I do a search for GPIB instruments only).Perhaps it should be called _viFindGpib (instead of _viFindGPIB) though...Cheers,Angel Link to comment Share on other sites More sharing options...
Guest omma_rok Posted February 4, 2005 Share Posted February 4, 2005 I have an Agilent card. I tried the library and it works very well for the most part. I found a little problem, though. The reset function does not work properly (it shows an error message box). All the other functions work very well. Thanks! - Omma Link to comment Share on other sites More sharing options...
Angel Posted February 4, 2005 Author Share Posted February 4, 2005 I have an Agilent card.I tried the library and it works very well for the most part. I found a little problem, though. The reset function does not work properly (it shows an error message box). All the other functions work very well.Thanks!- Omma<{POST_SNAPBACK}>Omma,actually I already found that problem and I have fixed in a new version of the file. It was silly mistake. I had not been able to make my GPIB bus hung, so I could not try to reset the bus. I tested all the other functions very thoroughfully and I found no problems with it. I am glad to see that you have no problems either.Angel Link to comment Share on other sites More sharing options...
Guest omma_rok Posted February 4, 2005 Share Posted February 4, 2005 Omma,actually I already found that problem and I have fixed in a new version of the file. It was silly mistake. I had not been able to make my GPIB bus hung, so I could not try to reset the bus. I tested all the other functions very thoroughfully and I found no problems with it. I am glad to see that you have no problems either.Angel<{POST_SNAPBACK}>OK, will you post your fixed version here?It is not really very important, as I only reset my bus on purpose to test your function. Take your time if you need to - Omma Link to comment Share on other sites More sharing options...
Guest agarde1 Posted February 4, 2005 Share Posted February 4, 2005 Gardel,I think that it could be done very easily. However, although it could be very useful I don't know if such a function should be integrated into the "default library".Cheers,Angel<{POST_SNAPBACK}>OK, I understand, but I think that this would be great to have anyway.Gardel Link to comment Share on other sites More sharing options...
Angel Posted February 4, 2005 Author Share Posted February 4, 2005 OK, will you post your fixed version here?It is not really very important, as I only reset my bus on purpose to test your function. Take your time if you need to - Omma<{POST_SNAPBACK}>Omma, I am working on the modifications that JdeB suggested. I will post the new version when I am done (perhaps today?) if you don't mind.Cheers,Angel Link to comment Share on other sites More sharing options...
Sentinel Posted February 4, 2005 Share Posted February 4, 2005 Omma, I am working on the modifications that JdeB suggested. I will post the new version when I am done (perhaps today?) if you don't mind.Cheers,Angel<{POST_SNAPBACK}>Do you plan to fix the limitation on the queries too? it is not common but I've seen some old instruments return more than 1 line.Sentinel Link to comment Share on other sites More sharing options...
garetoi Posted February 4, 2005 Share Posted February 4, 2005 Angel, is it possible to access secondary addresses on GPIB instruments? I read the comments on the _viExecCommand function and it seems that you can by using: "GPIB::1::2" descriptor to access the secondary address for instrument one. Is this correct? I have a Rohde & Schwarz CMU200 that I need to automate and it requires that you use secondary addresses for almost everything. I would like to try it next week so I would be nice if you could confirm that it works. A+ Pierre Link to comment Share on other sites More sharing options...
Angel Posted February 5, 2005 Author Share Posted February 5, 2005 Angel,is it possible to access secondary addresses on GPIB instruments? I read the comments on the _viExecCommand function and it seems that you can by using:"GPIB::1::2" descriptor to access the secondary address for instrument one.Is this correct? I have a Rohde & Schwarz CMU200 that I need to automate and it requires that you use secondary addresses for almost everything. I would like to try it next week so I would be nice if you could confirm that it works.A+Pierre<{POST_SNAPBACK}>Pierre,you can use secondary addresses in the manner that you described. Please tell me if you have any trouble with that.Cheers,AngelP.S.- What does A+ mean? Link to comment Share on other sites More sharing options...
garetoi Posted February 5, 2005 Share Posted February 5, 2005 P.S.- What does A+ mean?<{POST_SNAPBACK}>A+ means "A plus" which in French means something like "see you" or "Later". I'm so used to writing that in my emails that I also put it when I write in English :"> Sorry!A+ Pierre Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now