Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

No IVI Soft Front Panel Function

I am following the application note for controlling instruments via GPIB using IVI Controls.
It says to load the CWIviScope control. Place a scope control on the form.

When I place the scope control on the form it comes up with the following error :-

Invalid Primative Type: System.Reflection.Missing. Only CLS Compliant Primative Types Can Be Used Consider Using CodeObjectCreateExpression

What am I doing wrong, I am following the application note to the letter.

Any help appreciated
0 Kudos
Message 1 of 17
(5,278 Views)
I forgot to mention. I am running Measurement Studio 7.1 Standard & Visual basic .net
I was referring to application note AN169

I also seem to be unable to find the controls CWGPIB and CWVISA

Is there something wrong with my installation of Measurement Studio?
0 Kudos
Message 2 of 17
(5,264 Views)
The IVI ActiveX controls are not supported in Visual Studio .NET. We are working on a Knowledge Base that documents this fact.

The CWGPIB and CWVISA controls should work in Visual Studio .NET. You probably don't have them because you installed support for Visual Studio .NET. These controls are intended for use in Visual Basic 6.0. If you have the Measurement Studio Professional package or the Measurement Studio Enterprise package, you should have received a second CD that includes Visual Studio 6.0 support. The ActiveX controls are on that CD.

I highly recommend, however, that you use the native .NET VISA and GPIB class libraries with Visual Basic .NET rather than the ActiveX controls. The .NET class libraries are more full featured, exhibit better performance, and should be much more natural to use in Visual Basic .NET than the ActiveX controls. Measurement Studio 7.1 Professional and Enterprise also include the Instrument I/O Assistant to help you write .NET VISA and GPIB code using these class libraries. I recommend that you check out Getting Started with the Measurement Studio Libraries and Tools in the Measurement Studio documentation for help getting started with the libraries and the Instrument I/O Assistant. Here are some specific links that should work if you have Measurement Studio Documentation installed:

Getting Started
Using the NI-488.2 Class Library
Using the VisaNS .NET Class Library
Creating a Measurement Studio 488.2 or VISA Application

To address your original post, Measurement Studio 7.1 also includes a wizard that generates C# or VB.NET wrapper code for communicating with IVI, VXIPlug&Play, and legacy C instrument drivers. You just download the instrument driver of your choice, run the wizard, point it at the instrument driver function panel (.fp) file, and it will generate code that you can use to communicate with your instrument. You would use the IVI Scope class driver to get equivalent functionality to CWIVIScope, but you would probably be better off using the IVI specific driver for your particular instrument. Here is a link to more information in the Measurement Studio Documentation:

Calling Instrument Drivers from .NET Languages.


Let us know if you have more questions, if this works for you, or if there a reason you want to use the ActiveX controls instead of the native .NET interfaces.
Message 3 of 17
(5,258 Views)
I have taken your advice and looked further in to the IVI class drivers. I have used the wizard to wrap the .fp file, and I get IvIDmm.vb file in my visual basic.net project.
Please excuse my ignorance, but I have been unable to find out how to call ony of the functions of the driver. Are there any examples of how to do this using Visual Basic.net ? I can't find any documentation to cover this, only ho to create the driver.
I have tried putting the following line in, but it says it is not declared
IvIDmm_Logical_Name("SampleDmm")

I am probably doing something completely wrong, but I have only made fairly basic VB programs before.

Note I have only measurement studio 7.1 standard so do not have the wizards

Thankyou for your assistance

Regards

Matthew
0 Kudos
Message 4 of 17
(5,256 Views)
I agree that the help on what to do after generating the wrapper is a bit lacking. I've filed a bug report to fill this documentation out in a future version.

To use the generated code, you should first compile your project. Then, you need to create an instance of the instrument driver class that was generated. You will make all calls into the driver using the instance. This instance is equivalent to the CWIviDmm that you were used to dropping in the non-visible area of the VB 6.0 form. The code will look something like the following (this assumes that you chose "IviDmm" as the wrapper name):

Dim myDmm As New IviDmm("SampleDmm", False, False)
myDmm.ConfigureMeasurement(IviDmmConstants.DcVolts, -1.0, 0.001)

Dim value As Double
myDmm.Read(1000, value)

For information on the methods (functions) and constants, you need to look at the comments that are generated into the .vb source file. This information is pulled directly from the .fp file, so you'll need to do some mapping between the C documentation and corresponding VB constructs as you go through it. I think that once you see how a few of the parameters map, you'll get the hang of it.

To ease your overall transition, I recommend that you spend some time getting yourself familiar with VB.NET, in general. The transition from VB 6.0 to VB.NET is not entirely straightforward, so Microsoft has prepared quite a bit of content to help make it easier. Here are some resources to get you started:

http://www.vbdotnetheaven.com/Code/Apr2003/006.asp
http://msdn.microsoft.com/vbasic/using/
http://www.vbtutor.net/
Message 5 of 17
(5,241 Views)
This might help too...I had some similar trouble at first when using the Wrappers created from the .NET Instrument Driver Wizard. Here is the post I made and the solution I supplied to myself 😉

http://forums.ni.com/ni/board/message?board.id=232&message.id=1194
CLA, CCVID, Certified Instructor
Message 6 of 17
(5,229 Views)
Thankyour for all the help so far, I can now send commands to the DMM, and get the model details returned. Things are getting better.

The problems I have now communicating with the Keithley 2001 DVM are, when I try and read a value I get a different reading to that on the DMM display. I get the message 'Undefined Header', but it still seems to continue.
I have connected a 9V DC source to the DMM, and the DMM display reads 9.525V When I send the Fetch or Read command to the DMM the computer reads 1.4343534e-308

Here is the code I am sending

Dim value As Double
Dim writedata As String
Dim range As Double
Dim resolution As Integer
Dim ErrorMessage As String

range = 2 'Measurement Range
resolution = 0.0001 'Measurement resolution

myDmm.reset()
myDmm.ConfigureMeasurement(KE2000Constants.DcVolts, range, 0.0001) 'Set to measure DC
myDmm.Initiate() 'Must preceed a fetch
myDmm.Fetch(5000, value)

'Get Error Message
Dim readb As Integer
Dim readbuffer As New System.Text.StringBuilder(600)
myDmm.error_query(ErrorMessage, readbuffer)
ErrorMessage = readbuffer.ToString

TextBox3.Text = ErrorMessage
TextBox2.Text = value

Any indication to what I am doing wrong? I am using the IVI driver for the Keithley 2000 DMM as opposed to the 2001, as I can't find a suitable driver that works specifically for the 2001, could that be the problem?

Regards

Matthew
0 Kudos
Message 7 of 17
(5,202 Views)
No Ideas anyone?
0 Kudos
Message 8 of 17
(5,178 Views)
Hello Matt,
I believe you've also been in contact with Vesna Jadric from the instrument driver group about this? I haven't seen the command sets for either the 2000 or 2001 DMM's, but the fact you're getting an "Unknown Header" error indicates that there's a mismatch in the commands the two models take. The junk value you're getting back from the driver could either be the value in an uninitalized variable in the C driver layer, or possibly (but I think less likely) a byte order problem in how the data is coming back from the instrument. I know you had also downloaded the legacy driver for the 2001 and were not able to get it working. From what I saw, this is a very old driver that does not ship with a dll - so I'm guessing that after you ran the wizard on it and tried to use it, you were getting a DllNotFoundException. If you want to use that driver from .NET, you'll first need to create a project to create a dll for the driver. However, from what I saw of the code for it, I wouldn't recommend that approach - as I said, the driver is rather old (circa 1994) and doesn't look like it was ever meant to be built into a shared library. It might be possible for you to modify the code for the 2000 driver to match the commands of the 2001 and rebuild it into a custom dll you could use from your .NET code.
Alternatively, have you tried contacting keithley to see if they offer a Vxi Plug and Play or IVI Driver for the 2001 model?
0 Kudos
Message 9 of 17
(5,163 Views)
Thankyou again for your comments. I have tried using the dll for the legacy Keithley 2001 driver, but had no luck at all with that. I have also not progressed any further obtaining sensible results from using the Keithley 2000 driver.
I have emailed Keithley regarding an IVI driver for the 2001, but they have not responded to my email.
I am now in a bit of a muddle, I do not have the knowledge to create a IVI drver myself for the Keithley 2001, so I have bought a GPIB card and Measurment Studio, and still have no way of communicating with the Keithley 2001.
All I need to do is read AC voltages back from the Keithley to the computer, is there any way I can do this with what I have got? I am getting closer to my deadline, and no closer to a result.
Any help would be greatly appreciated

Matthew
0 Kudos
Message 10 of 17
(5,138 Views)