Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Querying Agilent E4407B with No Results...Help!

I'm very new to VB .NET and Measurement Studio, so please forgive me if this gets confusing.
 
I want to create a very simple program using the VISA class library that will query a spectrum analzyer and display the results of that query in a textbox.  The code is as follows:
 
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     Dim mySession As MessageBasedSession = CType(ResourceManager.GetLocalManger().Open(GPIB0::18::INSTR), MessageBasedSession)
     TextBox1.Text = mySession.Query("IDN?\n")
     mySession.Dispose()
End Sub
 
When I run the program, I get a "Query Unterminated" on the spetrum analzyer and then the program terminates due to a timeout experiration on the Query().  What is going on?
 
Also, what is the difference between the synchronous/asynchronous methods (i.e. BeginRead/Read, BeginWrite/Write), and which ones should I be using?
 
Once I can understand the fundamentals, I would like to create another program that will capture the display on the specan and plot the points on a WaveformGraph.  Here is a snippet of code that I will be using:
 
     Dim s As String
     mySession.Write("TDF P;TRA?")
     Dim traceA As String = mySession.ReadString()
     Dim TraceArray() As String = traceA.Split(Chr(44))
     For Each s In TraceArray
          WaveformGraph1.PlotYAppend(Double.Parse(s))
     Next
     mySession.Dispose()
 
Is this somewhat correct?  Any help is greatly appreciated.  Thanks!
 
Aaron
0 Kudos
Message 1 of 3
(3,456 Views)

Hi Aaron,

You might want to try an example program to see if you can get it up and running.  You can find them in C:\Program Files\National Instruments\MeasurementStudioVS2005\DotNET\Examples\VISA. 

As for the asynchronous methods, there is a KnowledgeBase that describes this in great detail and may be helpful to you.

Hope this helps!

Adam W
Applications Engineering
National Instruments

0 Kudos
Message 2 of 3
(3,422 Views)
Your program has a very simple problem:  Note the asterisk in line 4.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     Dim mySession As MessageBasedSession = CType(ResourceManager.GetLocalManger().Open(GPIB0::18::INSTR), MessageBasedSession)
     TextBox1.Text = mySession.Query("*IDN?\n")
     mySession.Dispose()
End Sub

The Agilent spectrum analyzers give the "query unterminated" error any time a particular query is not understood.

Good luck,
Joe

0 Kudos
Message 3 of 3
(3,394 Views)