Jump to content
Sign in to follow this  
Angel

VISA / GPIB library for AutoIt3

Recommended Posts

Thanks Angel...

I've been waiting for the time to look into this very thing ever since I saw a post this past summer about GPIB and AutoIt.

I still have a lot of reading/learning to do before I can make use of AutoIt and your UDF --- but I would like to know if I'm the task that I have in mind is reasonable for this UDF? I would like to move a bitmap file from a TEK scope to the hard drive of the computer controlling it.

Thanks again...


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Thanks Angel...

I've been waiting for the time to look into this very thing ever since I saw a post this past summer about GPIB and AutoIt.

I still have a lot of reading/learning to do before I can make use of AutoIt and your UDF --- but I would like to know if I'm the task that I have in mind is reasonable for this UDF? I would like to move a bitmap file from a TEK scope to the hard drive of the computer controlling it.

Thanks again...

<{POST_SNAPBACK}>

Thanks herewasplato,

I think that it could be possible, although perhaps some modifications to the current _viExecCommand function would be needed.

If you know which is the SCPI command that will tell the TEK oscilloscope to send the image through GPIB. The issue would be with receiving the data. Right know I'm using the VISA function viQuery, which I think is mainly supposed for text transfer. Also I have the limitation of a single line per query.

So, depending on the way that the scope sends the data this might or might not work as it its. I've seen instruments send binary files as a buch of 0s and 1s in text form. If this is the case for your scope then it will work. Otherwise we might need to add a _viRead function to the library, which would add binary transfer capabilities.

Also, if your scope does not use a GPIB bus, but instead it uses serial interface, you can use this library. Simply use the VISA descriptor ASRL, as described in the help of _viExecCommand.

Do not hesitate to contact me if you have trouble with this. Is should be pretty easy to add the binary transfer function.

Cheers,

Angel

Share this post


Link to post
Share on other sites

JdeB,

According to this thread, I think that there is a pretty good amount of interest on this new capability for AutoIt, and I haven't seen anyone raise their voice against adding this to the standard set of libraries. What do you think? I certainly think that this would open AutoIt to a whole new type of automation! This would make the life of those that control measurement instruments dayly so much easier! :lmao:

Cheers,

Angel

Share this post


Link to post
Share on other sites

JdeB,

According to this thread, I think that there is a pretty good amount of interest on this new capability for AutoIt, and I haven't seen anyone raise their voice against adding this to the standard set of libraries. What do you think? I certainly think that this would open AutoIt to a whole new type of automation! This would make the life of those that control measurement instruments dayly so much easier! :lmao:

Cheers,

Angel

<{POST_SNAPBACK}>

No problem here..... lets put the whole thing in a separate file called Visa.Au3 and sent me the required files for the helpfile .... o:)

EDIT: As mentioned in the PM: lets not have UDFs show msgboxes but just return an error code to allow the scripter to decide if a msgbox is needed or something needs to be done.

Edited by JdeB

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.
  :)

Share this post


Link to post
Share on other sites

Angel,

I just tried your library and it works great. Thanks!

JdeB,

I have downloaded the latest AutoIt version and I've seen that you have included this Visa library as one of the default UDF! It even has some help for the functions. This is great, thanks a lot! I am sure that this will be very very useful :-)

A+

Pierre

Share this post


Link to post
Share on other sites

Angel,

I just tried your library and it works great. Thanks!

JdeB,

I have downloaded the latest AutoIt version and I've seen that you have included this Visa library as one of the default UDF! It even has some help for the functions. This is great, thanks a lot! I am sure that this will be very very useful :-)

A+

Pierre

<{POST_SNAPBACK}>

I just noticed that too, Garetoi. Thanks a lot to JdeB and Jon for adding this in such a short notice.

Thanks a lot!

Cheers,

Angel

Share this post


Link to post
Share on other sites

Angel,

I am sorry to report that there is a bug in the query code of your function. It seems to only return the right answer when you perform an *IDN? query!

Other than that everything else works fine.

Also, I'd be cool to have some helper function to test that the commands are working fine.

Garetoi

Share this post


Link to post
Share on other sites

Angel,

I am sorry to report that there is a bug in the query code of your function. It seems to only return the right answer when you perform an *IDN? query!

Other than that everything else works fine.

Also, I'd be cool to have some helper function to test that the commands are working fine.

Garetoi

<{POST_SNAPBACK}>

Garetoi,

I just found the origin of the bug. I verified that this new version works fine.

Also, to compensate you guys for my mistake I have finally removed the limitation of reading a single line of the Instrument answers! :">

I will send the updated version to JdeB and to Jon so that they can update the library. In the meantime please use the attached Visa.au3 file (simply overwrite the one in the AutoIt3\include folder).

Cheers,

Angel

Visa.au3

Share this post


Link to post
Share on other sites

Garetoi,

I just found the origin of the bug. I verified that this new version works fine.

Also, to compensate you guys for my mistake I have finally removed the limitation of reading a single line of the Instrument answers!  :">

I will send the updated version to JdeB and to Jon so that they can update the library. In the meantime please use the attached Visa.au3 file (simply overwrite the one in the AutoIt3\include folder).

Cheers,

Angel

<{POST_SNAPBACK}>

Thanks Angel,

I am testing it right now. If I can finish testing before I leave I'll let you know if it works today. Otherwise I'll tell you tomorrow, ok?

Share this post


Link to post
Share on other sites

Dear Angel,

I'm trying to read info from my Keithley2010 using a serial interface.

According to the info supplied by the UDF this should be possible, but until now I didn't succeed in doing so.

I used the example of the _viExecCommand function and modified it a little.

As I'm not sure what serial settings are used by default I've included the serial settings for my device.

#include <Visa.au3>

Dim $h_session = 0
Dim $h_instr = _viOpen("ASRL9::INSTR")

_viSetAttribute($h_instr, $VI_ATTR_TMO_VALUE, 2000)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_BAUD, 19200)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_DATA_BITS, 8)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_PARITY, $VI_ASRL_PAR_NONE)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_STOP_BITS, $VI_ASRL_STOP_ONE)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_FLOW_CNTRL, $VI_ASRL_FLOW_XON_XOFF)

; Query the ID of the instrument
MsgBox(0,"Step 1","Simple query using a VISA Descriptor")
Dim $s_answer = _viExecCommand("ASRL9::INSTR", "*IDN?", 2000)
MsgBox(0,"QUERY result",$s_answer); Show the answer

MsgBox(0,"Step 2","Go to LOCAL using VISA Descriptor")
_viGTL("ASRL9::INSTR"); Go to local (exit remote control mode)

MsgBox(0,"Step 3","Close the Instrument connection using _viClose")
_viClose($h_instr); Close the instrument connection

Do you know what I'm doing wrong here? The Keithley2010 does go to remote, but a beep occurs and no data is read back, only a number.

Any help is welcome.

Also the _viFindGpib and _viGpibBusReset do not seem to work for Serial devices.

Greetings,

Marcel.

Share this post


Link to post
Share on other sites

Anybody have ever tried to use visa library to interface a non gpib rs232 device.

Some people use visa library in other languages and can contol raw rs232 device.

If it is possible using autoit too, it may be a interesting inrefacing alternative.

I know the question is strange but if somebody can help me i'll be very happy!

Share this post


Link to post
Share on other sites

Dear Angel,

I'm trying to read info from my Keithley2010 using a serial interface.

According to the info supplied by the UDF this should be possible, but until now I didn't succeed in doing so.

I used the example of the _viExecCommand function and modified it a little.

As I'm not sure what serial settings are used by default I've included the serial settings for my device.

#include <Visa.au3>

Dim $h_session = 0
Dim $h_instr = _viOpen("ASRL9::INSTR")

_viSetAttribute($h_instr, $VI_ATTR_TMO_VALUE, 2000)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_BAUD, 19200)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_DATA_BITS, 8)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_PARITY, $VI_ASRL_PAR_NONE)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_STOP_BITS, $VI_ASRL_STOP_ONE)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_FLOW_CNTRL, $VI_ASRL_FLOW_XON_XOFF)

; Query the ID of the instrument
MsgBox(0,"Step 1","Simple query using a VISA Descriptor")
Dim $s_answer = _viExecCommand("ASRL9::INSTR", "*IDN?", 2000)
MsgBox(0,"QUERY result",$s_answer); Show the answer

MsgBox(0,"Step 2","Go to LOCAL using VISA Descriptor")
_viGTL("ASRL9::INSTR"); Go to local (exit remote control mode)

MsgBox(0,"Step 3","Close the Instrument connection using _viClose")
_viClose($h_instr); Close the instrument connection

Do you know what I'm doing wrong here? The Keithley2010 does go to remote, but a beep occurs and no data is read back, only a number.

Any help is welcome.

Also the _viFindGpib and _viGpibBusReset do not seem to work for Serial devices.

Greetings,

Marcel.

Marcel, sorry for the late delay, as I've been on vacation for a while.

By looking at your code I already see a problem in that you open and close the connection twice. If you pass a VISA descriptor (i.e. a string) to the _viExecCommand function then it will "take care of itself" and open a VISA handle for you (and close it after executing the command. In this case you do not want this behaviour because you want to use _viSetAttribute. So instead pasee the handler variable ($h_instr) to the _viExecCommand function calls. This might explain why it goes to remote mode but then on the first _viExecCommand call it will fail. The returned number is probably the error code returned when you try to open the handler twice.

Please let me know if this fixes your problem.

Cheers,

Angel

Share this post


Link to post
Share on other sites

Marcel, sorry for the late delay, as I've been on vacation for a while.

By looking at your code I already see a problem in that you open and close the connection twice. If you pass a VISA descriptor (i.e. a string) to the _viExecCommand function then it will "take care of itself" and open a VISA handle for you (and close it after executing the command. In this case you do not want this behaviour because you want to use _viSetAttribute. So instead pasee the handler variable ($h_instr) to the _viExecCommand function calls. This might explain why it goes to remote mode but then on the first _viExecCommand call it will fail. The returned number is probably the error code returned when you try to open the handler twice.

Please let me know if this fixes your problem.

Cheers,

Angel

Angel,

I tried the following:

#include <Visa.au3>

Dim $h_session = 0
Dim $h_instr = "ASRL9::INSTR"

_viSetAttribute($h_instr, $VI_ATTR_TMO_VALUE, 2000)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_BAUD, 19200)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_DATA_BITS, 8)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_PARITY, $VI_ASRL_PAR_NONE)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_STOP_BITS, $VI_ASRL_STOP_ONE)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_FLOW_CNTRL, $VI_ASRL_FLOW_XON_XOFF)

; Query the ID of the instrument
MsgBox(0,"Step 1","Simple query using a VISA Descriptor")
Dim $s_answer = _viExecCommand($h_instr, "*IDN?", 2000)
MsgBox(0,"QUERY result",$s_answer); Show the answer

MsgBox(0,"Step 2","Go to LOCAL using VISA Descriptor")
_viGTL($h_instr); Go to local (exit remote control mode)

I still have the same problem. Errorcode -1073807339 is returned instead of the Query result.

The Meter remains in Remote mode, even though the command _viGTL($h_instr) is given (This is probably the same thing that causes the errormessage.

Share this post


Link to post
Share on other sites

Marcel, try the following. I am not 100% sure that it works, as I have no access to AutoIt in this machine.

#include <Visa.au3>

Dim $h_session = 0
Dim $h_instr = _viOpen("ASRL9::INSTR")
MsgBox(0,"Step 1","$h_instr = " & $h_instr)

_viSetAttribute($h_instr, $VI_ATTR_TMO_VALUE, 2000)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_BAUD, 19200)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_DATA_BITS, 8)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_PARITY, $VI_ASRL_PAR_NONE)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_STOP_BITS, $VI_ASRL_STOP_ONE)
_viSetAttribute($h_instr, $VI_ATTR_ASRL_FLOW_CNTRL, $VI_ASRL_FLOW_XON_XOFF)

; Query the ID of the instrument
MsgBox(0,"Step 1","Simple query using a VISA Descriptor")
Dim $s_answer = _viExecCommand($h_instr, "*IDN?", 2000)
MsgBox(0,"QUERY result",$s_answer); Show the answer

MsgBox(0,"Step 2","Go to LOCAL using VISA Descriptor")
_viGTL($h_instr); Go to local (exit remote control mode)

MsgBox(0,"Step 3","Close the Instrument connection using _viClose")
_viClose($h_instr); Close the instrument connection

Please, add any MsgBox as you see fee to check the output of every function that is called, and make sure that the output conforms to what the help file states and also that there are no error messages.

Also, you must make sure that your instruments supports the "*IDN?" SCPI command.

Do you have the proper VISA drivers installed in your machine?

Please, let me know if it works.

Cheers,

Angel

Share this post


Link to post
Share on other sites

Angel,

this is what happens when I run the script:

Step 1: $h_instr = 1

Step 1: Simple query using a VISA Descriptor

Query result: -1073807339 > DMM goes to Remote, no errors on DMM

Step 2: Go to LOCAL using VISA Descriptor

Step 3: Close the Instrument connection using _viClose > DMM remains in Remote

Query result -1073807339 means "VI_ERROR_TMO" " Device Timeout occurred !"

So it's still the same problem.

The DMM does support the "*IDN?" SCPI command, because I can run it from the utility within Agilent IO libraries suite, which is correctly installed and working. I then can see the manufacturers name and DMM model.

Hopefully you have an answer to this.

Greetings,

Harrie

Share this post


Link to post
Share on other sites

If you get 1 from $h_instr it means that it was possible to open the connection to your instrument. That explains why it goes to remote mode. The timeout you get is because the library sends the query and is waiting for an answer that the instrument does not send back. I don't know why.

Can you try to open and then close and se if you get an error message and if the instrument goes back to local? If not, try doing the same but use the go to local function before closing. See what are the error results coming from each function.

Do you have a GPIB card installed in your PC? What brand is it?

Angel

Share this post


Link to post
Share on other sites

Angel,

I don't have a GPIB card as you can see in the script.

ASRL9 is a serial interface. I already meantioned that the problem might have something to do with that.

In the UDF i've seen peaces of script that can only be used by GPIB.

Could the Visa.au3 UDF be wrong?

Share this post


Link to post
Share on other sites

Angel,

I don't have a GPIB card as you can see in the script.

ASRL9 is a serial interface. I already meantioned that the problem might have something to do with that.

In the UDF i've seen peaces of script that can only be used by GPIB.

Could the Visa.au3 UDF be wrong?

the reason why I ask if you have a GPIB card is that the VISA library requires the VISA drivers, and normally those are installed when you install a GPIB card. If you didn't install one, where did you get the drivers from and from which vendor?

Have you tried, as I said, opening, going to local and closing the connection?

Of course there might be a problem with the library. I have tested it extensively with the GPIB interface, not with the serial interface. However, the function calls that must be used for both cases are the same, according to the VISA standard. Therefore if it works for GPIB (which it does) there should be no reason why it wouldn't work for Serial interface.

I know that many instruments that use the serial port are very "picky". Sometimes it is hard to get them working. You should make sure that you are using the right serial interface settings (speed, bits, parity, etc). These could very easily be the cause of the problem. In particular, when you connect you have not stablished the speed of the port, etc. It is when you try to send the command then _wait_ for the answer that these become important.

Can you confirm that you are using the right parameters?

Angel

Share this post


Link to post
Share on other sites

Angel,

I'm really using the latest Agilent Visa Libraries (version 14.1).

From within these drivers there's a testtool (Visa Assistant) to check the connection. From within that tool I can open a connection, read DMM info and Disconnect.

I also have Agilent vee 7.5 development installed and the programs made with that work great.

I'm aware of problems with serial ports on different kinds of computers, but because all other software is working great and AutoIt isn't, I'm really worried AutoIt isn't working with serial interfaces.

Greetings,

Harrie.

Share this post


Link to post
Share on other sites

I'm really worried AutoIt isn't working with serial interfaces.

It could be. As I said he main purpose if the libraries is to work with GPIB cards. That has been fully tested and verified and it works for sure. The serial interface is a plus and I have not really tested it.

Another possibility could be due to the fact that you are using the Agilent drivers, while I used the National Instruments drivers. That could cause the problem as well. Finally, it is VERY easy to misconfigure a serial interface. Are you sure that you are using exactly the right settings for the serial interface (bitrate, stop bits, parity, etc)?

Angel

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...