Contact an Expert

Thread: 34972A Controlling Via Visual Basic .Net 2010


Permlink Replies: 5 - Pages: 1 - Last Post: Apr 30, 2012 7:52 AM Last Post By: hognala Threads: [ Previous | Next ]
rjrodrig

Posts: 59
Registered: 04/05/12
34972A Controlling Via Visual Basic .Net 2010
Posted: Apr 5, 2012 11:06 PM
Click to report abuse...   Click to reply to this thread Reply
Hi All,

I am new to the 34972A instrument, and I am trying to create a Visual Basic .Net 2010 application to Gather data from 16 channels and to toggle some I/O.

Ran a tutorial using the Console demo. It works, but it bugs me that I have to do this:

Imports Ivi.Visa.Interop
Imports Agilent.CommandExpert.ScpiNet.Ag3497x_1_13

Module Module1

Sub Main()

'Dim I34972A As New Ivi.Visa.Interop.ResourceManager
'Dim I34972A As Ag3497x = New Ag3497x(LXI)
'UsbTransport = I34972A.Transport.Visa.ResourceName.Get
'Dim I34972A As Ag3497x = New Ag3497x(UsbTransport)

Console.WriteLine("Connecting to 34972A LXI Data Acquisition/Switch Unit...")
Console.WriteLine()

Dim I34972A As Ag3497x = New Ag3497x("USB0::0x0957::0x2007::my49007650::0::INSTR")
Dim IDN As String = Nothing

I34972A.SCPI.IDN.Query(IDN)

Console.WriteLine("*IDN query returns: " & IDN)
Console.WriteLine()
Console.WriteLine(" Press any key to exit...")
Console.ReadKey()
End Sub

It works fine, but I want to do this more intelligently by identifying all available transports ( I have 3 other USB instruments)

I want to programmatically discover what the transport name is.

I don't know how to instantiate Ag3497x class so I have access to all the methods and properties. Above I am forced to enter a string "USB0::0x0957...." I want to discover how many devices are connected and choose the appropriate transport. I don't want to hard code it.

Does any one know how to :

1. instantiate the "new" class
2. programmatically discover all available transports
3. open the transport
4. Write data to it
5. close the transport.

I would really appreciate any help you can provide!

Regards,

rjrodrig@yahoo.com

hognala

Posts: 199
Registered: 04/09/07
Re: 34972A Controlling Via Visual Basic .Net 2010
Posted: Apr 6, 2012 3:37 PM   in response to: rjrodrig in response to: rjrodrig
Click to report abuse...   Click to reply to this thread Reply
You can use VISA COM to find all of the instruments that are connected to your PC. Then, you can use the generic SCPI-99 SCPI.NET driver to send *IDN? to all of the instruments that you have connected to see if they are the 34972A you are looking for. Then you can use the 34972A SCPI.NET driver to actually send commands to the instrument.

The key steps in setting up your project will be:

Add a Reference to VISA COM 3.0 using the COM tab in Visual Studio's Add Reference dialog.
Add a Reference to both the SCPI-99 and 34972A SCPI.NET drivers using the Browse tab in Visual Studio's Add Reference dialog
  • The SCPI.NET drivers will be in the following locations:
    • Windows XP: C:\Documents and Settings\All Users\Agilent\Command Expert\ScpiNetDrivers
    • Windows 7: C:\ProgramData\Agilent\Command Expert\ScpiNetDrivers

Check out the attached VS2010 VB.NET example Console Application that shows how to do it.
hognala

Posts: 199
Registered: 04/09/07
Re: 34972A Controlling Via Visual Basic .Net 2010
Posted: Apr 6, 2012 3:38 PM   in response to: hognala in response to: hognala
Click to report abuse...   Click to reply to this thread Reply
here are the attachments mentioned above....
rjrodrig

Posts: 59
Registered: 04/05/12
Re: 34972A Controlling Via Visual Basic .Net 2010
Posted: Apr 9, 2012 4:11 PM   in response to: hognala in response to: hognala
Click to report abuse...   Click to reply to this thread Reply
Thank you so much for your reply. I figure there has to be a way of polling for all the instruments and selecting the one I want. thank you that answers my question. I will start my development now.

RR
rjrodrig

Posts: 59
Registered: 04/05/12
Re: 34972A Controlling Via Visual Basic .Net 2010
Posted: Apr 28, 2012 5:51 PM   in response to: rjrodrig in response to: rjrodrig
Click to report abuse...   Click to reply to this thread Reply
Does anyone know how to package the Command expert drivers so the VB application runs as a standalone application? VB.net creates all dependencies so all dll files and COM objects instantiated are brought into the installer to create the installer (i.e., setup.exe and Installer.msi files).

Turns out when I install the created installer from VB.net 2010 into another fresh pc that does not have IO libraries and command expert, the Packaged application will not run!

I was under the impression that once I package the DLL file Ag3497x_1_13.dll, Agilent.CommandExpert.Common.dll, Agilent.commandexpert.InstrumentAbstraction.dll, Agilent.CommandExpert.Scpi.dll, AgSCPI99_1_0.dll, and IVI.Visa.Interop.dll, the application could run on any PC without depending on Command expert suite, or IO libraries suite. Clearly I am either doing something wrong, or I am not including the correct items.

In the computer that does not have CE, and IO Libs, I get a similar message to this message. I didn't copy the error since I got it on another PC. I googled the error and it has to do with the drivers not being able to be registered by regsvr32.

Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154

The visual Basic 2010 installer generates a warning which makes me think something is wrong with my setup or the driver itself. The funny thing is that I can't tell if I always got the error because in debug mode as I am developing the code, I never saw this error. It is likely that I never saw any errors because VB.net is talking to Command expert and other drives, and IO libraries which are installed in my development PC. Maybe I have everything it needs to run, unlike the pc which does not have CE and IO Libs. My code will not run!

WARNING: Unable to find dependency 'IVI.VISA.INTEROP' (Signature='A128C98F1D7717C1' Version='3.0.0.0') of assembly 'Agilent.CommandExpert.Scpi.dll'

The other PC does not have CE and IO libs, so my code won't run in that pc.

I am sure someone at Agilent ran into this very same issue, and perhaps someone at Agilent tell me what additional files I need to add to the installer, VB.net commands to include so the installer executes during the installation if any, path location where additional files need to go (i.e., system32 etc...), and any batch files (*.bat) and how to load them into vb for the installer for it to run it all from my generated setup.exe?

I don't believe I have all the necessary files to make my program run identically to my development machine. I seriously doubt the answer will be to install Command Expert and IO libs in order for my application in any machine! That is not the case in LabView for sure.

I am attaching a picture of the VB.net Installer, and all the dependencies files it brought in automatically. Also the warning I am getting. I believe there are more files that need to be installed in different locations for this work. I just don't know what that is.

Creating an installer with just those DLL files, it does not work!

Help please!

Edited by: rjrodrig on Apr 28, 2012 5:51 PM

hognala

Posts: 199
Registered: 04/09/07
Re: 34972A Controlling Via Visual Basic .Net 2010
Posted: Apr 30, 2012 7:52 AM   in response to: rjrodrig in response to: rjrodrig
Click to report abuse...   Click to reply to this thread Reply
Ok, so 2 separate answers for you here:

Command Expert .dll's

1) The Command Expert .dll's can be packaged in your installer. The following information is taken from the "Deploying SCPI.NET Applications" topic in the Command Expert help file:

Without a Command Expert Installation
To install your application on a target PC without installing Command Expert on that PC:

Install your application's files

Make sure the following files (copied from your Command Expert installation) are present alongside your deployed application on the target PC:
Any referenced SCPI.NET drivers.
Agilent.CommandExpert.Common.dll
Agilent.CommandExpert.InstrumentAbstraction.dll
Agilent.CommandExpert.Scpi.dll

2) See the Command Expert help file topic "File Locations" to determine where the above Command Expert DLL files and SCPI.NET driver files are installed on your development PC.

Ivi.Visa.Interop (the VISA COM PIA)


This file is techincally installed with the VISA Shared Components. It is provided by the IVI Foundation, but it is not sufficient unto itself. You also need the whole Agilent IO Libraries Suite installed to make your I/O work. There is no good way to package it into your installer, and it is quite large (several hundred Megabytes). So, the general recommendation is that you make the user install the IO Libraries separately (it will install this Ivi.Visa.Interop for you). Then, tell your installer not to include Ivi.Visa.Interop

Point your RSS reader here for a feed of the latest messages in all forums