Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Can AFG3102 be controlled by VBA?

Solved!
Go to solution

Hello,

 

I am new to PC control of instruments and I need to use AFG3102 to stimulate the oscilloscope in order to test it.

 

I've seen in previous posts that Visual Basic and C# may be used for PC control of AFG3102 but I would like to use VBA (for Excel) in order to be able to present the stimuli and results in the Excel sheets.

 

Can anybody help me with this? First, is it possible to control AFG3102 via VBA and Excel, and if yes, can anybody direct me how to do it?

 

Thanks in advance!

0 Kudos
Message 1 of 9
(5,323 Views)

Hello Taniusha,

       The IVI Specific Driver for your instrument can be found here.  You should first install NI-VISA and NI-ICP from the current Device Drivers.  Here is some additional documentation to help you get started:

 

Using IVI Specific Drivers in Visual Basic .NET, Visual C# or Visual Basic 6 Applications

 

Cheers,

 

NathanT

0 Kudos
Message 2 of 9
(5,320 Views)

Hello NathanT,

 

Thank you very much for your quick reply.

 

I see, however, that all the links you suggested refer to Visual Basic. I need to control AFG3102 from VBA (Visual Basic for Applications) for Excel. Is there any way to do it not from VB but from VBA?

 

I need VBA because I need to present the inputs and outputs in Excel sheets and also, for VBA I guess I wouldn't need Visual Studio but only Excel.

 

Thanks again,

Taniusha

 

 

0 Kudos
Message 3 of 9
(5,314 Views)
Solution
Accepted by topic author taniusha

Hello Taniusha,

      I am not well-versed in the differences and similarities between VB and VBA.  Most any development environment will have a mechanism that allows you to call into external code, it is just might be easier for certain types of external code.

 

      If you just need to store the data in an Excel file, there are other options outside of having your code execute in Excel.  The simple implementation is to just store your data in a format that Excel can easily read.  The more complex implementation is to use ActiveX to programmatically control Excel.

 

Cheers,

 

NathanT

0 Kudos
Message 4 of 9
(5,281 Views)

Hi NathanT,

 

Thank you very much for your answers.

 

The reason why I prefer Excel VBA to VB is that for Excel VBA not only I can make the user interface easy to use and nice to look, but for Excel VBA I don't need to buy any Visual Studio or similar environment. I found the instructions how to use Matlab, as well, but Matlab applies to the same story: it needs to be payed for.

 

So that is why I am trying to figure out how to control AFG3102 only through Excel VBA.

 

 

Having in mind the problem of buying any addition software, could you (or anybody else) reccomend any other solution, appart from VB or Matlab?

 

Thank you very much,

Regards,

Taniusha

0 Kudos
Message 5 of 9
(5,248 Views)

 


@taniusha wrote:

Hi NathanT,

 

Thank you very much for your answers.

 

The reason why I prefer Excel VBA to VB is that for Excel VBA not only I can make the user interface easy to use and nice to look, but for Excel VBA I don't need to buy any Visual Studio or similar environment. I found the instructions how to use Matlab, as well, but Matlab applies to the same story: it needs to be payed for.


Microsoft offers free versions of their development tools. They're called the "Express" editions. They can create applications just like the full Visual Studio, but they have some limitations, such as using Click-Once technology for installations. I use the C# one at work (for development of in-house programs, not for instrument programming).

 

0 Kudos
Message 6 of 9
(5,246 Views)

Hello Taniusha,

      smercucuio's suggestion of the Express editions is a good one.  My favorite solution for instrument control is LabVIEW, which is has a full featured evaluation license for 30 days.  If you are a student, you can check and see if your school might already has an academic site license for LabVIEW.

 

Cheers,

 

NathanT

0 Kudos
Message 7 of 9
(5,222 Views)

NathanT, smercurio_fc,

 

Thank you very much for your help!

 

I have succeeded in sending commands from VBA to AFG3102. For now, it is only to see if connection is obtained, so I still have to work on sending the generated waveforms.

 

I have installed TekVISA and used the ActiveX control: I added Tvc1 to a UserForm in VBA and now I can use Tvc1's methods and properties. I found the method to receive a waveform from an oscilloscope (GetWaveform method) but I still need to find a method to send the generated waveform to a signal generator.

 

Thanks again

 

 

0 Kudos
Message 8 of 9
(5,134 Views)

Hello taniusha,

       I am happy to hear that you are successfully communicating with your instrument.

 

Cheers,

 

NathanT

0 Kudos
Message 9 of 9
(5,118 Views)