VI High 22: How to Program a Tektronix DPO/MSO/MDO 2000/3000/4000 Series Oscilloscope with LabVIEW - Part 3: Acquiring Data and Configuring Channels
This episode picks up where VI High 20 and 21 left off, after exploring the instrument driver and getting the scope recognized in MAX. Start there or go to sixclear.com/tek for the full, free tutorials.
In this episode we’ll take a look at acquiring a signal from the scope and programming configuration parameters for optimal viewing. Visit sixclear.com/tek for 30+ minutes of video tutorials on programming this scope.
For more on programming in LabVIEW, check out Sixclear LabVIEW Fundamentals at sixclear.com/labviewtraining.
Experience level: Basic
(start transcription)
Going back now to our example, we can drop down this VISA Resource Name and see the resources that we viewed in MAX. So we’ll choose MDO_Scope and we’ll leave the channel and timeout as default. Before clicking the run button let’s take a look at what we’re actually acquiring. In this case, we have connected channel 1 of the oscilloscope to a digital pulse train coming from the MDO demo board. That pulse train is running at about 1.25MHz and 3.5V peak to peak.
Going back to LabVIEW we’ll click on the run button and see the waveform here on the front panel. Alright, we’re acquiring our signals. Now we notice, going back to the scope that the settings I previously viewed have changed. So LabVIEW, through the instrument driver, is changing the settings of the scope and, even if I stop the LabVIEW VI, those settings are retained by the scope. So why were the settings changed? Because we’re using the Auto-setup VI here. As we see in the Context Help, this VI “Configures the oscilloscope to evaluate all input waveforms and determine the optimum conditions for displaying the waveform.” And admittedly, that looks pretty good.
So what if we want to set different configuration parameters for our incoming signal? Well let’s start programming a new VI somewhat similar to this but where we set our custom configuration parameters. So I’ll open up a new VI, go the appropriate instrument driver palette, and the first thing I’ll call is the Initialize VI, and I’ll create a control off of the VISA Resource input. I’ll also want to create a constant off the Reset input and set the Boolean to False. If I leave this true then the scope will be reset to default each time I run this VI, much like pressing the Default Setup button on my scope front panel. So you can imagine I adjust my panel display by hand on my scope a certain way to view my signal and then I run this VI and with a True going to Reset, then my scope display goes back to the default settings which are not my personally preferred settings for viewing my signal. If I leave that as False, it won’t do that.
Then I’ll go to my Configure palette and I see Auto-setup.vi, which is what the last example used, but this time I’ll choose Configure Channel.vi. I place it down and, looking at my Context Help, I see that the only bold, and thus required, input is the VISA Resource Name. And it gets this input from the VISA Resource Name Out coming from my Initialize VI. So we’ll wire these together and connect the error clusters as well to ensure proper error handling. My Context Help shows me what configuration settings I can edit. So let’s first choose something simple like Vertical Range. The default value is shown in parentheses, 10V. So I will create a control, double-click on it to go the front panel, and change the value to 2V. I’ll leave all the other settings as default, including the Channel which is channel 1, and then I’ll place down the Read VI from my Data subpalette. You see it has this dropdown menu at the bottom, we call this an explicitly polymorphic VI, and by selecting some item here, I am choosing the polymorphic instance. For now, we’ll leave it at Single Waveform since we’re only reading from one channel. I’ll connect up the wires and leave my Channel input as the default channel 1. Since I’m reading the data, I’m going to want to display it, so I’ll do that on a Waveform Graph that I find on the front panel. Make it a bit bigger. I’ll flip back to the block diagram and wire to the Waveform Graph from the Waveform Graph output. Finally, I’ll call the Close VI, wire it up and put down a Simple Error Handler from my Dialog and User Interface palette to appropriately handle errors. We see LabVIEW successfully completing our auto-wiring.
If I run my VI like this then I am only acquiring one finite set of data points, or record, with a default size of 10,000 points. If I want to, on the other hand, acquire continuously, it’s simple, I’ll just wrap a While Loop around the Read VI. So let’s move these over, hold down Shift, click and drag to keep them in the same access, and then go get a While Loop. I’ll need a condition to stop the loop, so I’ll right-click on the Conditional Terminal and create a control. This creates a front panel Stop button. It’s also a very good idea to stop the loop in the case of an error. To do that, I’ll pull up an Or function from my Boolean palette. I’ll delete the wire currently going to my Conditional Terminal from my Stop button. Move this over, right-click on that wire and clean it up, and then wire from the output of the Or function to my Conditional Terminal. Now I need to pull the error out of this error cluster, so I’ll take an Unbundle by Name function from the Cluster, Class & Variant palette, and wire the error cluster into the input and leave the Status as default, which is the Boolean in the error cluster indicating whether an error has occurred, then wire the output of the Unbundle by Name to the top input of the Or function, and now this VI will stop if I click on the Stop button or if an error occurs. Now, if I have LabVIEW 2011 and beyond I can actually just wire the error cluster directly into the top input of my Or function without using the Unbundle by Name. So I’ll do that. It looks a bit cleaner. So I’ll go back to my Front Panel, choose the VISA Resource Name, and run this, and I see the data continuously showing up on my Front Panel. That’s very pleasing.
Now if you were paying attention, you noted that earlier I said that the pulse train had a peak-to-peak amplitude of 3.5V but I just put my Vertical Range at 2V, so that means the waveform is being truncated and we can actually see that at the bottom. So I can always change the vertical range though I will need to stop the VI first since the new configuration is only being read and applied to the scope before the While Loop begins. So I’ll put this value back to 10V. Perfect.
I should also mention that while this is running continuously, I can go adjust the settings directly on the Front Panel of my scope, so here I am adjusting the vertical range, and here I’m adjusting the horizontal scale. It’s important to note that LabVIEW is not writing to those configuration values right now, it only wrote to them when I called the Initialize and Configure Channel VIs so they can be independently manipulated while I’m viewing them in LabVIEW.
(end transcription)