DCSIMG

MDO4053-3 Scope Automation thru USB using Excel VBA

Moderators: Buck, Hiker, notnomis, Super Mod

MDO4053-3 Scope Automation thru USB using Excel VBA

Postby vitz_12 on Tue Jan 07, 2014 1:27 pm

Hello,
I have task to automate the MDO4054 scope even a simple task like to just to set desired channel, vertical and horizontal scale and trigger value since I am still on the learning process, sorry about it.
The option I have is to use USB connecting the PC direct to scope, and using excel VBA.
My first question is, what driver do I need for me to be able to communicate with the scope thru USB?
Second, can anyone have a heart to share even a simple Excel VBA program to me for me to use as a start since I am still on the learning process?

Many thanks in advance.
vitz_12
 
Posts: 10
Joined: Mon Dec 09, 2013 1:46 pm

Re: MDO4053-3 Scope Automation thru USB using Excel VBA

Postby Hiker on Tue Jan 07, 2014 5:16 pm

You can refer to the MDO4000 series programmer’s manual, which can be downloaded from Tek.com by searching for 077051003. On page 21 of the .PDF file, it has a section for “Setting Up Remote Communications Software”. You can use either Tektronix VISA, which is downloadable from Tek.com by searching for 066093807 or you can use National Instruments VISA (see NI.com).

Additional information regarding how to use VISA for control is listed in our FAQ’s (search for FAQ ID: 1176403) and in the “Connectivity Software Programmer Manual, 077014000, both on Tek.com.

Since you are using Excel, download the “Tektronix Toolbars for Microsoft Office, V4.0.0, which can be downloaded from Tek.com by searching for 066133201. This will allow you to capture and graph the MDO’s data in Excel spreadsheets.

This should get you started.
Hiker

Tektronix Application Engineer
Anything I post here is user to user advice. For official technical support:
http://www.tek.com/webform/technical-support-request
Hiker
 
Posts: 145
Joined: Thu Jul 31, 2008 3:26 pm
Location: Beverton, Oregon

Re: MDO4053-3 Scope Automation thru USB using Excel VBA

Postby vitz_12 on Wed Jan 08, 2014 2:07 am

Thank you Hiker.
vitz_12
 
Posts: 10
Joined: Mon Dec 09, 2013 1:46 pm

Re: MDO4053-3 Scope Automation thru USB using Excel VBA

Postby vitz_12 on Wed Jan 08, 2014 12:59 pm

Hi Hiker,
I installed the TekVISA and the Tektronix Toolbar for MSOffice just like you mentioned from your previous reply, I can already control the instrument using the OpenChoice Instrument Manager included in TekVISA installation thru USB.
But using Excel VBA is still not, how will I know that the Toolbar was installed properly? I am assuming that I can see an additional Toolbar when I opened Excel, should I? Is there something I should set on my Excel like in the References (from MS VBA under Tools menu)? By the way, my Excel is version 2010 and I am using Windows 2007.

You might have a working simple codes there as simple as *IDN? query for me to use as a starting codes thru USB (most of the codes I am seeing in internet are for GPIB)? This will give me idea on how to set the instrument first before any other commands.

Rgds,
Beginners(vitz_12)
vitz_12
 
Posts: 10
Joined: Mon Dec 09, 2013 1:46 pm

Re: MDO4053-3 Scope Automation thru USB using Excel VBA

Postby Hiker on Wed Jan 08, 2014 5:45 pm

Yes, you have to configure the Excel Tool bar. Please refer to FAQ ID: 1072180 http://www.tek.com/support/faqs/how-do-i-install-and-use-tekxl-toolbars-microsoft-excel.

Unfortunately, we do not have programming examples for using Excel VBA to control the MDO.

For progamming commands you can refer to the MDO4000 series programmers manual http://www.tek.com/oscilloscope/mso4000-dpo4000-manual/mdo4000-mso4000b-and-dpo4000b-series.

You may also find our Oscilloscope Analysis and Connectivity Made Easy User Manual usefull in getting started. http://www.tek.com/oscilloscope/tds7254-manual/oscilloscope-analysis-and-connectivity-made-easy-user-manual

Happy programming.
Hiker

Tektronix Application Engineer
Anything I post here is user to user advice. For official technical support:
http://www.tek.com/webform/technical-support-request
Hiker
 
Posts: 145
Joined: Thu Jul 31, 2008 3:26 pm
Location: Beverton, Oregon

Re: MDO4053-3 Scope Automation thru USB using Excel VBA

Postby vitz_12 on Mon Jan 13, 2014 10:20 am

I followed the instruction from link "http://www.tek.com/support/faqs/how-do-i-install-and-use-tekxl-toolbars-microsoft-excel" with this statement:

"Open Excel 2010 and go to File>Options>Add-Ins and select Excel Add-Ins in the Manage dropdown menu at the bottom of the window and click Go. Click the checkbox next to the TekXL toolbar and click OK. (For some versions of Excel you will need to close reopen it.) You’ll notice that the Add-Ins tab has been added to Excel’s tab bar. Click on this tab and you will see 7 buttons on the upper left corner of the Excel window."

however, I can't find TekXL from the add-ins even the installation of ExcelToolbar was successful. There are several add-ins options but no TekXL.

Can I still automate the scope using Excel even without the Excel Toolbar, since I already installed the TekVISA and the OpenChoice can communicate with the scope? I am looking for references in VBA Tools Menu that is related to Tek, for me to click and add but there's none.
vitz_12
 
Posts: 10
Joined: Mon Dec 09, 2013 1:46 pm

Re: MDO4053-3 Scope Automation thru USB using Excel VBA

Postby cball on Mon Jan 13, 2014 4:02 pm

The Toolbar is a nice tool, but you don't need it for automation. Previous versions of it were open source, so you could look at them and modify your code.

In any case, if you are using TekVISA, you will most likely use the TVC (The Active X Control). The link Hiker posted to "Oscilloscope Analysis and Connectivity Made Easy User Manual" goes over this in great detail. It may be talking about GPIB hardware, but don't' worry about that too much. The only difference for you will be when you open your VISA object to the instrument. The descriptor you use will be for your USB Scope, rather than GPIB. For example. a USB descriptor will look something like USB0::0x0699::0x034E::C010271::INSTR while a GPIB one will be something like GPIB1::8::INSTR.

We do have several Matlab, Python and a C# example of coding here: http://www1.tek.com/forum/viewtopic.php?f=8&t=1789. The syntax wont be the same on the language side, but the instrument commands and algorithms may be useful.
Tektronix Application Engineer
Anything I post here is user to user advice. For official technical support:
http://www.tek.com/webform/technical-support-request
cball
 
Posts: 645
Joined: Fri Dec 17, 2010 11:17 pm
Location: Beaverton, OR

Re: MDO4053-3 Scope Automation thru USB using Excel VBA

Postby vitz_12 on Wed Jan 15, 2014 3:15 am

thanks cball.

I already have codes in VBA to start opening communication with the scope, but it's now working with run time error "HRESULT=80040011". Someone might know a display error like this and you can advise me what's wrong...?? :?
vitz_12
 
Posts: 10
Joined: Mon Dec 09, 2013 1:46 pm

Re: MDO4053-3 Scope Automation thru USB using Excel VBA

Postby vitz_12 on Thu Jan 16, 2014 3:11 am

I have this code in Excel VBA, but I can't communicate with the instrument, opening the communication seems not working on the sample code below,
someone might already encounter this and and please advise what's wrong.
Appreciate any feedback. thanks


Function AcquireIDN()

Dim ioMgr As VisaComLib.ResourceManager
Dim instrAny As VisaComLib.FormattedIO488
Dim idn As String

'instrAddress = 1
Set ioMgr = New VisaComLib.ResourceManager
Set instrAny = New VisaComLib.FormattedIO488
Set instrAny.IO = ioMgr.Open("USB::0x0699::0x040F::C012694::INSTR") '''I am having run time error '-2147221487 (80040011)' in this specific line...

instrument.WriteString "*IDN?"
idn = instrument.ReadString()
ActiveSheet.Cells(1, 1) = idn

End Function
vitz_12
 
Posts: 10
Joined: Mon Dec 09, 2013 1:46 pm


Return to Oscilloscope Technical Support