Is there any Visual basic 2010 example code for transferring a file from PNA to PC via GPIB ? Thanks to Google, I found code for Labview, VEE, VB6, C++, RMB but not for VB2010.
Thanks in advance for your help
Try this code. I verified this was working with an N5242A and FW A.10.49.11. I used the VISA.NET library (version 5.7), which comes with the latest IO Libraries (www.keysight.com/find/iosuite). I used Command Expert to figure out the right command to use (www.keysight.com/find/commandexpert).
Imports Ivi.VisaImports Ivi.Visa.FormattedIOModule Module1 Sub Main() Dim session As IMessageBasedSession session = GlobalResourceManager.Open("GPIB0::16::INSTR") Dim formattedIO = New MessageBasedFormattedIO(session) formattedIO.PrintfAndFlush(":MMEMory:TRANsfer? ""%s""", "c:\users\public\documents\Network analyzer\filename.txt") Dim file As Byte() file = formattedIO.ReadBinaryBlockOfByte() session.Dispose() System.IO.File.WriteAllBytes("filename.txt", file) End SubEnd Module
VB.NET 2010 source code is attached.
Minor update to the above post after I tweaked it and verified it worked.
Many Thanks for your quick answer
Unfortunately, I got an error message hereunder - May be I forgot some thing
I'm not an expert. Are VB.NET 2010VB and Visual Basic 2010 express using the same code ?
Yes the code should be the same.
You probably have a different version of VISA.NET installed. Look in Windows Programs and Features for VISA.NET Shared Components. What version is listed?
Then, in Visual Studio, go to Project --> Add Reference... --> Navigate to the .NET tab and look for the Ivi.Visa component that has the same version as what is installed on your system, select it and click OK. The blue squiggles should then disappear from your code and it should compile.
You'll also need to change the VISA address to the address that your instrument is using (you can find that in Connection Expert)
After checking, I found that I forgot to upgrade IO Suite on my computer. I follow your recommendations and now compilation is Ok.
I'll try with a VNA tomorrow and I'll will come back to you.
In any case, thanks a lot for your help.
Last question : How I proceed to replace ("GPIB0::16::INSTR") by the alias name of the VNA ?
In Connection Expert, select the instrument address. On that "details" screen there should be an option to Add/edit an alias. Set it there, then you should be able to use that instead of GPIB0::16::INSTR
I have tested the code with different VNA and everything works well. It is perfect ! Thanks a lot
I have done many tests with this code and it was working without any problem as long as I kept the maximum number of measurement points below 6401 on VNA. When I increase this number of points (12801 for ex), I got an IO timeout message (see hereunder).
do you have any idea to solve this issue ?
Increase your timeout, before that ReadBinaryBlockOfByte() call. To do that:
session.TimeoutMilliseconds = 10000
The default timeout is 2000 ms (2 seconds).
Ok, It works. I can now transfer the data files whatever the number of points chosen on VNA. Thanks
Retrieving data ...