From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Use NI-VISA control Ethernet communication with VNA

Solved!
Go to solution
My VB code doesn’t show any error message but my PC to test equipment (VNA) Ethernet connection just doesn’t work. I use OpenChoice Instrument Manager from Tektronix to monitor IP connection and it detected VNA's IP . But the value my VBA code reading back from VNA buffer (variable feedbk as in below commands ) is always empty. I expect to see “100 connections accepted” as shown in OpenChoice . My code is stat = viOpenDefaultRM(defaultRM) stat = viOpen(defaultRM, "TCPIP::10.85.148.61::5000::SOCKET", VI_NULL, 20000, sesn) ( after above line executed, stat=0 which I think means viOpen is success) stat = viSetAttribute(sesn, VI_ATTR_TMO_VALUE, 15000) feedbk = Space(80) status ("Waiting for VNA connection") stat = viBufRead(sesn, feedbk, Len(feedbk), Actual_Length) ( I expect the readback value in feedbk is “100 connections accepted” but it is always 0) Any suggestions is appreciated
0 Kudos
Message 1 of 15
(3,933 Views)

Hi xinli,

 

I was looking at the documentation for this function and it's a little confusing.  However, I think you need to pass a pointer to your feedback string, instead of the feedback string itself.

 

Have a great day,

 

Chris

Applications Engineer
National Instruments
0 Kudos
Message 2 of 15
(3,920 Views)

Chris,

 

Thanks for the reply.

 

Would you please give an example how to pass pointer to string?

 

Regards

 

Xin

0 Kudos
Message 3 of 15
(3,918 Views)

Hi Xin,

 

Check out this article for pointers in VB:  http://www.codeproject.com/KB/vbscript/how_to_do_pointers_in_visual_basic.aspx?df=100&forumid=1232&e...

 

Also, what is the value of your stat variable after the viBufRead() ?

 

Most devices must have a command sent out over TCP/IP before they will return information.  Is this not true for your device?

 

Have a great day,

 

Chris 

Applications Engineer
National Instruments
0 Kudos
Message 4 of 15
(3,909 Views)

Thanks, Chris

 

I will double check what "stat" is after viBufRead() . I rememer it is a negative number.

 

This code works before even it is not stable. Once a while is no connection and I need to restart my PC or VNA and finally it will connect. But now it look really dead.

 

On my PC I have TekVisa and NI-VISA (Tekvisa to control Tektronix equipment and NI-VISA for VNA). A few days ago I ran my VBA code for VNA testing, my code complains some functions not defined. I think when I updated TekVISA a few days ago,  TekVISA replaces some dll files from NI_VISA (for example VISA32.dll). Then I install latest NIVISA again (5.0.3), hope to recover my code.

 

After I add VISA library to my VB code, I got this error message

 

" VI_NULL : constant expression required" in below command

 stat = viOpen(defaultRM, "TCPIP::xx.xx.xxx.xx::5000::SOCKET", VI_NULL, VI_NULL, sesn)

 

Then I input visa32.bas and the error message is gone. I think install of  NI-VISA may put it somewhere than VBA project expects.  Now my Ethernet connection is really dead.

 

Regards

0 Kudos
Message 5 of 15
(3,905 Views)

Chris,

 

The "stat" values are as

 

1) stat = viOpenDefaultRM(defaultRM)

    stat=0      defaultRM=58317368

 

2)  stat = viOpen(defaultRM, "TCPIP::10.85.148.61::5000::SOCKET", VI_NULL, 20000, sesn)

      stat=0      defaultRM=58317368   sesn=58302528

 

3) stat = viBufRead(sesn, feedbk, Len(feedbk), Actual_Length)

    stat= -1073707339   feedbk="                ..."

 

 ( I expect the readback value in feedbk is “100 connections accepted”)

 

According to the equipment programming document, it has no command sent out over TCP/IP before return information.

 

Thanks

0 Kudos
Message 6 of 15
(3,891 Views)

Hi Xin,

 

Is your stat variable a string?  From looking at the documentation, it looks like that functions should be returning a string.  What you've posted looks like you are representing it as a number.

 

Have a great day,

 

Chris

Applications Engineer
National Instruments
0 Kudos
Message 7 of 15
(3,885 Views)

Chris,

 

I define "stat" as Vistatus. " feedbk" is string so I expect see readback string in variable "feedbk"

 

stat = viBufRead(sesn, feedbk, Len(feedbk), Actual_Length)

 

 

Thanks

 

Xin

0 Kudos
Message 8 of 15
(3,879 Views)

Hi Xin,

 

As I said before, the documentation here is a little fuzzy.  I'm working with R&D right now to find out exactly what that error code means.  I'll get back to you as soon as I hear something.

 

Have a great day,

 

Chris

Applications Engineer
National Instruments
0 Kudos
Message 9 of 15
(3,865 Views)

Chris,

 

Thanks for the help.

 

I checked online for similar problem and found one may help us. You can google it "Problems with the tekvisa_dll in instrument". Their solution is to change equipment IP address. I will give a try and let you know. 

 

Regards

 

Xin

 

0 Kudos
Message 10 of 15
(3,860 Views)