VI High 23: LabVIEW 2011 New Feature - Wiring to the Error Cluster with an Or Function

So we want to stop a While Loop on error OR from a user clicking the Stop button on the front panel.

Before LabVIEW 2011, we used to have to unbundle the error cluster before wiring into an Or function going to the While Loop conditional terminal. Not anymore! See how it’s done in this quick video.

For more on programming in LabVIEW, check out the Sixclear LabVIEW Fundamentals course at http://www.sixclear.com/labviewtraining/.

Experience level: Basic

(start transcription)

“New in LabVIEW 2011 is a feature where we don’t need to explicitly unbundle the Boolean status from the error cluster. So instead of using the unbundle by name, I’ll just delete it, and wire the error cluster directly into the Boolean Or.

And LabVIEW is smart enough to pluck the Boolean Or out of this error cluster and use it for this Or comparison. Much easier.”

(end transcription)

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)

VI High 21: How to Program a Tektronix DPO/MSO/MDO 2000, 3000, or 4000 Series Oscilloscope with LabVIEW - Part 2: Exploring the instrument driver, finding examples, & recognizing the scope in MAX

This episode picks up where VI High 20 left off, after finding and installing the instrument driver. Start there or go to sixclear.com/tek for the full, free tutorials.

In this episode we’ll explore the structure of the instrument driver through the VI Tree and the driver palettes. We’ll then look at how to find LabVIEW examples that work out of the box and then start to take a look at how to recognize our instrument in MAX.

Visit sixclear.com/tek for 30+ minutes of video tutorials on programming this scope.

Experience level: Basic

 (start transcription)

“The most helpful place to start is at the VI tree. This is a non-executing VI purely used for documentation. I’ll go to the block diagram and I can see the programming flow for this scope, so I’ll use VIs in this order in order to build my code. First, I’ll initialize communication with my device, then I’ll use one or more of these configuration VIs to configure the scope according to my application needs. Context Help is especially valuable, Ctrl+H, as I can see helpful information about these VIs as I hover over them. So I see how to configure an individual channel, configure the timebase, the triggering, and so on. Notice that the description of the VI will tell me if it’s only to be used with a specific model series, for instance, the Configure RF Squelch VI can only be used with the MDO Series Oscilloscopes, and Configure Glitch Capture can only be DPO and MSO 2000 Series scopes. I have a couple VIs that fall into the Action/Status category, like storing a waveform and sending a software trigger,and then a few more VIs that have to deal with handling the data. The ones at the top are higher-level, meaning that they’re more abstracted and easier to use and below them we see the Low Level VIs that give us more control over the data acquisition and handling, but require a better understanding of how to program the device. Then we have a few optional Utility VIs, like performing self-tests and resetting the scope. Finally, I’ll close communication with the scope with this Close VI.

So we’ll close this VI tree. If it asks me to save, that’s fine, it just means I opened up this driver in a version of LabVIEW later than the one it was originally developed in. So I’ll just hit save so I don’t get this dialog box again. And let’s go back to the palette and see that it’s arranged in the categories we just explored: configure, action/status, data, utility and so on. Let’s delete this VI tree. LabVIEW asks if I want to save these according to the updated version of LabVIEW, again because my version of LabVIEW is later than the version in which they originally developed. So I will Save All.

And now, to get a good feeling of how to use this driver, let’s take a look at some examples that were installed with the driver. So we’ll go to the LabVIEW Example Finder here in Help»Find Examples. Staying on the Browse tab, we’ll go to Hardware Input and Output»Instrument Drivers»LabVIEW Plug and Play. Here are all the examples installed with the various instrument drivers on my machine. So we’ll scroll down to the Tektronix DPO MSO 2000 4000 Series examples. I’ll click on the first one and get some information about it. It uses autosetup to continuously acquire a waveform from a single channel. That’s pretty simple so let’s open it up and take a look at it. I’ll go to the block diagram, and here we see several of those VIs we saw in the VI tree: initialize, do an auto setup, acquire data continuously in a While Loop, and then close communication when we’re finished.

So let’s run this to see what happens. Before we can run it we need to identify the VISA Resource Name. What does this mean? NI-VISA is the underlying National Instruments driver that recognizes all non-National Instruments devices connected to our machine. For more information on VISA, the architecture of an instrument driver, and how they interact with our operating system, check out VI High, Sixclear’s LabVIEW programming blog. Specifically, episode 12: How to Install an Instrument Driver in LabVIEW.

Now, where can we see these VISA resources? The best place to go would be the Measurement and Automation Explorer, or MAX, that installs with NI-VISA. If you can’t find MAX in your Windows Start Menu, then make sure NI-VISA is installed by going to ni.com/drivers.

Now we’ve launched MAX and we’ll look to the left under My System. Now the scope that I’m using is connected to my computer using a USB cable. If we expand Devices and Interfaces, we’ll see all the devices and interfaces connected to my computer. One of them is this MDO4104-6 which NI-VISA is naming by default - this, which tells us the interface, USB, some unique hex character identifiers, and finally that it’s an instrument - INSTR. Now this is how it will be referenced in LabVIEW, and that’s kind of pain so I will rename this by right-clicking and giving it a meaningful alias, in this case MDO_Scope because we can’t have spaces. I’ll click Save and we see the name has been updated.”

(end transcription)