Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Measurement Studio and AWG 2041

Based on the Walkthrough: Creating a Measurement Studio Instrument I/O Application,
I have successfully setup the communication of the AWG 2041 via Serial.

It is able to identify the Vendor as Sony/Tek and Device as AWG 2041.
However, when I pressed the button 1, Unhandled Exception occur.
Why?
Also, I am more interested in capturing the data from the AWG 2041 to my notebook, but when I issue curv?,
there is always a TimeOut error.

Any help is appreciated.
thanks.
Sincerely,
Thiam Huat
 
0 Kudos
Message 1 of 4
(3,966 Views)
Hello Thiam,

I looked at your code and it seems to be written properly as compared to the .pdf instructions. Unfortunately I can't run the code because I don't have your instrument to test it on.

Could you give me more information on the Unhandled Exception error you experience? Does the Unhandled Exception come with an error message? It's likely that this error occurs at the VisaTaskResults results = myTask.Run(); line. Try placing a breakpoint at that line and stepping into the function to see where that Unhandled Exception exactly occurs.
Manooch H.
National Instruments
0 Kudos
Message 2 of 4
(3,940 Views)
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> NationalInstruments.VisaNS.VisaException: The resource is valid, but VISA cannot currently access it.  VISA error code -1073807246 (0xBFFF0072), ErrorResourceBusy
   at NationalInstruments.VisaNS.Internal.ErrorChecker.CheckStatusAndThrow(Int32 status, VisaHandle visaObject)
   at NationalInstruments.VisaNS.Session..ctor(String resourceName, AccessModes accessMode, Int32 openTimeout, String expectedResourceName)
   at NationalInstruments.VisaNS.SerialSession..ctor(String resourceName, AccessModes accessMode, Int32 openTimeout, Boolean checkResourceType)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType)
   at System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, Object[] args)
   at NationalInstruments.VisaNS.ResourceManager.Open(String resourceName, AccessModes accessMode, Int32 openTimeout)
   at My2041Project.VisaTask.OpenSession(String sessionName) in C:\Users\tth\Documents\Different_Tests\NI\MStudio Examples\AWG2041\My2041Project\VisaTask.cs:line 77
   at My2041Project.VisaTask..ctor(String sessionName) in C:\Users\tth\Documents\Different_Tests\NI\MStudio Examples\AWG2041\My2041Project\VisaTask.cs:line 91
   at My2041Project.VisaTask..ctor() in C:\Users\tth\Documents\Different_Tests\NI\MStudio Examples\AWG2041\My2041Project\VisaTask.cs:line 83
   at My2041Project.Form1.button1_Click(Object sender, EventArgs e) in C:\Users\tth\Documents\Different_Tests\NI\MStudio Examples\AWG2041\My2041Project\Form1.cs:line 24
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
My2041Project
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Users/tth/Documents/Different_Tests/NI/MStudio%20Examples/AWG2041/My2041Project/bin/Debug...
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.F...
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configura...
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
NationalInstruments.VisaNS
    Assembly Version: 8.1.20.222
    Win32 Version: 8.1.20.222
    CodeBase: file:///C:/Windows/assembly/GAC_32/NationalInstruments.VisaNS/8.1.20.222__4544464cdeaab541/NationalI...
----------------------------------------
NationalInstruments.Common
    Assembly Version: 8.1.20.415
    Win32 Version: 8.1.20.415
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/NationalInstruments.Common/8.1.20.415__4544464cdeaab541/Nationa...
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
 
0 Kudos
Message 3 of 4
(3,925 Views)
Hi Thiam,

I took a look at your project. You may be experiencing this error because of the way you have configured your VisaTask.mxb file. You mentioned in your original post that you wanted to capture data using the curv? command. Are you sure this is the correct command to use for the measurement you want to take?

The manner in which you have configured your task is confusing and somewhat complicated. What happens if you simplify the task and only query the curv? command. Open your project and open the VisaTask.mxb file. In your first Query and Parse step, instead of querying *idn? try querying the curv? command. Remove any additional steps so that your VisaTask.mxb file contains the Select Instrument step and a single Query and Parse step only. Then, click the Run this step button in the Query and Parse step. Does it timeout or does it return a value of the captured data?
Manooch H.
National Instruments
0 Kudos
Message 4 of 4
(3,898 Views)