i n t r oclass.ece.iastate.edu/ee330/mischandouts/ee330_labview_tutorial.pdflab 7: labview tutorial...
TRANSCRIPT
Lab 7: Labview Tutorial By Joseph Gamble
Intro In this document I will outline labview techniques that can be used in
the generation of a labview test script for lab 7. Purpose is to provide students
with a satisfactory guide to complete the automated testing environment for
lab 7 in ee330. The document will cover every single step in order to replicate
the code in case edits need to be made.
]\
Labview Flows
What Was Needed
In this section the steps in the generation of the labview code. Labview
is a visual software environment from National Instruments. It is expected to
be supported by National Instruments for quite a while and therefore can be
utilized within the EE 330 lab space for some time. It should be noted that
this tutorial has been developed for the 2019 version of the software. It is
unclear how the future version will work. The instructions will have pictures
intermittent throughout to aid in the explanation process.
What I Did
Find the “NI Labview 2019 (64-bit)” application on your computer and
open it. When the labview program first boots up, you have a screen where
you can select between opening up a new project or existing old project.
Opening Selection Menu to Select Between Old and New Projects
1
]\
In order to open a new project that can be run with the instruments,
click “Create Project” and select “Blank VI”. VI stands for virtual instrument
and allows you to connect to the bench instruments like power supply,
multimeter, etc. and edit their input and output to record data. After
selecting a blank VI project, two windows should pop up. One is the “Front
Panel” which houses the communication to outside devices and the other is
the “Block Diagram” which holds the way your program is run. On your
Front Panel right click and select “Classic > I/O > VISA Resource”. This allows
you to establish communication with the lab equipment. We will say that this
one is for the dc power supply. Double click the “Visa Resource Name” above
the I/O port to edit the name to whatever you want to call the DC power
supply. Note that the Block Diagram now has a VISA block.
Selecting a New Instrument Block
2
]\
We will now spend a good portion of time in the Block Diagram screen,
organizing our test flow. Let’s add a block to initialize the power supply to set
it up for communicating. Right click and go “Instrument I/O > Istr Drivers >
Agilent E363X >Initialize”. This allows you to place an initialization block into
the diagram. On the left side of your newly placed block there should be a
“VISA Resource Name” node that pops up when the cursor hovers over the
block so connect that line with your VISA I/O block.
Congrats! You have now programmed something in labview. Now we
need to set the serial interface for the DC power supply from this initialization
block. Right click the top port of the initialization block called “Serial
Configuration” and select “Create Control” which creates a serial
configuration block in your Front Panel. We won’t worry about it right now
and continue to develop our logic flow.
Selecting an initialization block
3
]\
Now generate a for loop. This will be where we sweep the Vgs value.
“Right Click > Structures > For Loop”. Go ahead and place a second For loop
inside the first. The interior for loop is for editing the Vds value.
Generating the For Loops
Right click the “N” in the upper left hand corner of the exterior for loop
and select “Create Constant”. This will set the number of iterations of the
loops. For the Vgs we are sweeping from .5V to 2.5V in steps of .5, so 5
iterations are required. In the inner loop we require a sweep from 0V to 2.5V
in steps of .05V so 51 iterations are required. Change the number of iterations
in the 2 loops accordingly.
Now we need to set two configuration blocks into the two for loops,
one for Vds and the other for Vgs. These will be the block that tell the DC
output voltage what to be. To get the block do “Right Click > Instrument I/O
> Istr Drivers > Agilent E363X > Configure > Output”. This block has several
lines in it that we need to connect. One is the “Voltage Level Line”. It needs
to be set according to the iteration which is held in the “i” block in the lower
left hand of the for loop. This can be done by placing numeric blocks (“Right
Click > Numeric”) within the Block Diagram with the correct logic to output
the correct voltage value (indexing starts at 0 in labview!!!). [HINT: Add
4
]\
numeric constant blocks to set values.] Do this for both the Vds and Vgs lines.
Also connect the “error in (no error)” line from the configure block to the
“error out” of your initialize block and the “visa resource name” of the
configure block to the “visa resource name out” of the initialization block. By
the end, your Block diagram should look something like this:
Configuration Blocks Placed with Iteration Logic
The configuration blocks correspond to two of your outputs on your
agilent E3631A, but you need to inform the code configuration block which is
which voltage input. For the sake of simplicity say the Vds is the +6 voltage
supply and the Vgs is your +25V (but they could be switched). If you hover
over and right click the left side of the configure block called “Channel (1:
5
]\
Channel 1” and select “Create Constant” a selection should appear
connected to the line that says Channel 1. The conversion from output line on
the voltage supply to channel number is +6 = Channel 1, +25 = Channel 2, -25
= Channel 3. For our sake, then the Vds control (internal for loop) will be
Channel 1, and the Vgs (outer loop) will be Channel 2.
We will need to close our connection to the voltage supply after we are
done running our sweep. By doing “Right Click > Instrument I/O > Istr
Drivers > Agilent E363X > Close” we can place a close block for the voltage
supply. Make sure it is placed outside of both of your for loops. Connect the
“error in (no error)” line from the close block to the “error out” of your Vds
configure block and the “visa resource name” of the close block to the “visa
resource name out” of the configure block. The lines will error as they leave
the for loop as the program doesn’t know how to handle a single value being
passed out of multiple iterations. Find the little boxes of the lines as they exit
the for loop “Right Click > Tunnel Mode > Last Value” which sets the data to
transfer at the end of the for loop iterations (when we want to close the
device). Your Block Diagram should now look like this:
All of Voltage Supply Components in Block Diagram
6
]\
At this point all of the components for the voltage supply are in the
Block Diagram open up the Front Panel which should still be open. The
“Serial Configuration” in the Front Panel that we created a while back
should be set right, but be sure Baud = 9600, Parity = 0, and data bits = 8. Now
we are going to make our second VISA resource, the multimeter. Again
“Classic > I/O > VISA Resource” and rename it to multimeter, or something
along those lines. A Visa Resource will appear in your Block Diagram. Go back
to your Block Diagram to begin routing your multimeter lines.
Generate another initialization block by doing “Instrument I/O > Istr
Drivers > Agilent E3446X >Initialize”. Note this is a different driver selection
then last as we are selecting a different bench device. Now place a block to
configure the multimeter to DC Current by using “Right Click > Instrument
I/O > Istr Drivers > Agilent E3446X > Configure > Measurement > Configure
Measurement” to place the block. After this route the “error in” and “VISA
resource name” lines between configure and initialize blocks as had been
done with the DC voltage supply. Here’s a look as to what the block diagram
should look like now:
Initialization Block within the Block Diagram
7
]\
On the configure block in your main Block Diagram page we need to
set the current range on the digital multimeter. If we don’t, the multimeter
jumps varying ranges, creating jumps in our output waveform.
So, on the “Measurement Function” of the multimeter configure block
“Right Click > Create Constant” which should make a selection menu pop
up. Select “DC Current” from this menu (as we want the multimeter to read
current). On “Autorange”, “Right Click > Create Constant” and click on the
appeared “T” to make it “F” to enable manual current range mode. Now we
need to set the current range by finding “Manual Range” on the same block
and on it doing “Right Click > Create Constant” and setting that constant to
.01 (10mA). By the end of all of this the Block Diagram should look like this:
Block Diagram with Multimeter Initialization and Configuration
Now that the block setup is done for the multimeter we can setup the
data taking portion of the Block Diagram. Place a “Data.vi” block by taking
8
]\
“Right Click > Instrument I/O > Istr Drivers > Agilent E3446X > Data >
Read.vi” and placing it within the interior loop. Connect its “error” pin and
“VISA resource name” pin to the multimeter configure block. Sweet! Now
we can take measurements! However, we don’t know whether we are
changing the value for the dc power supply or taking reads first within the
loop. Let's ensure there is no confusion by placing a “Flat Sequence” around
the two conditions. Find the structure by doing “Right Click > Structure >
Flat Sequence” and place it within the interior loop, moving the configure
into the flat sequence too. Now on the flat sequence “Right Click > Add
Frame After” and place the data read in the second frame. After all this the
Block Diagram should look like this:
Block Diagram with Reads and Vds Configuration within Sequence Frames
This structure will come out as a single value, and we need a way to
analyze the data as a chunk. Let’s format the individual chunks into a .csv file
(comma separated values). “Right Click > File I/O > Write Delimited
9
]\
Spreadsheet.vi” to create the “Write Delimited Spreadsheet.vi” block. On
the pin out of the block, for delimiter “Right Click > Create Constant” and
set the delimiter to “,”. For “Format”, “Right Click > Create Constant” and
set the value to “%.12f”. Finally, for “Transpose”, “Right Click > Create
Constant” and set the value to “T”.
We also need to drop a block to build the array for the data going into
the file generator, so create “Build Array” by following “Right Click > Arrays
> Build Array”. Route the right side of this build array block into the
spreadsheet writing block and under the “2D Data” pin. Route the left side of
the array building block into both of the For loops into the “Measurement”
pin of the “Read.vi” block. The tunneling of the measurements through the
for loops is a bit tricky. Change the interior loop tunneling to “indexing” and
the outer loop tunneling to “concatenating”. The Block Diagram should now
look like this:
Block Diagram with .csv File Generating Blocks
10
]\
The final action we need to take within the block diagram is to close the
multimeter. Create the “Close” block by doing “Right Click > Instrument I/O
> Istr Drivers > Agilent E3446X > Close”. Place the close block on the outside
of the for loops and route it’s relative “VISA resource name” and “error” to
the “Read.vi” block. It will be upset as the two lines pass through two for
loops. Change their tunneling mode to “Last Value” and they should be
happy. The final Block Diagram should look like this:
Final Block Diagram
Congrats! We are done with the Block Diagram! There is still something
to be done in the front panel. Turn on both your multimeter and Voltage
source. Go to the I/O selection window in the front panel and select the
channel address your devices are on. I have found it best to turn the
multimeter on and off, looking for the channel that opens and closes, while
the address of the voltage source can be found by selecting the “I/O config”
button on the bench device. Your front panel should now look like this:
11
]\
Hooray! You are all ready to run. Click the “Run” button in the top
toolbar. It looks like a small arrow pointing to the right. The values on the
multimeter and voltage source should flip around. The entire sweep should
take approximately 5 minutes to complete so have
a nice chat with the person next to you.
After the test is completed, a window should pop up letting you save
your new output file. Name is something reasonable and be sure to terminate
the name with a .csv for it can be opened with Excel. Good job! You have now
swept the value of Vds over various Vgs values for your MOSFET transistor.
12
]\
Appendix
Colors
Each color within the lab view is a reference to a different bus/data type. Here
are a few colors that may be helpful:
Error Bus:
Integer Value:
Floating Value:
Control Bus:
Array Bus:
Helpful Hints:
● Read direction carefully. Be sure not to skip steps or try to make the
system in your own way. It will be difficult for the TAs to help you debug
your code
● Save often. Labview has some issues that may cause it to crash
● DO NOT select the drop down from the front panel before saving. There
is a bug in Labview that will cause it to crash sometimes. If this issue
occurs, restart your session. If it does crash there is a good chance
labview saved some of your work!
13
]\
14