Professional Documents
Culture Documents
Equation to be implemented:
1. Launch LabVIEW.
2. Choose File > New VI. LabVIEW opens both a blank front panel and a blank block diagram.
3. Ctrl +T tiles the two windows.
4. Observe the menu bars.
5. Click Window > Show Tools Palette – explain tools
6. Click Window > Show Functions (Controls) Palette
7. Build the front panel
Click Window > Show Controls Palette > Numeric Indicators, select a thermometer and place it on the front panel.
Observe the block diagram.
Note the change in the menu bar. LabVIEW allows you to type the desired label. Label your thermometer Deg C and
click on the Enter Text icon.
Right click on the thermometer and select Visible Items > Digital Display. A digital display is added to your
thermometer.
Right click on the thermometer and select Change to control.
Place another thermometer and label it Deg F. Adjust the Fahrenheit scale by typing 250. Right click on the thermometer
and select Visible Items > Digital Display.
Cosmetics (font size, rearrange and align objects).
8. Build the block diagram
Select from Functions>Numeric a multiply block and place it close to Deg C. Note the broken arrow in the menu bar.
Select from Functions>Numeric a numeric constant and place it close to the multiply block.
Select from Functions>Numeric an add block and place it close to Deg F.
Select from Functions>Numeric a numeric constant and place it close to the summing block.
Change operating tool to wiring tool.
Wire the Deg C terminal to one of the multiply block inputs.
Wire the numeric constant to the other input of the multiply block.
Wire the output of the multiply block to one of the inputs of the summing block.
Wire the second numeric constant to the other input of the summing block.
Note that the arrow is not broken anymore.
Wire the output of the add block to the Deg F terminal.
Change tool to writing tool.
1
Type 1.8 for the constant of the multiply block and 32 for that of the summing block.
Shortcut. Instead of placing a numeric constant from the Controls Palette and wire it to the input of a block, place the
mouse on the input of the block, right click and select Create > Constant and type the desired value for the constant.
Another way to wire objects is to place the mouse on an object and press space. The tool changes automatically to the
wiring tool. Draw the wire between objects and press space again. The wiring tool changes to operating tool.
Cosmetics (rearrange objects).
9. Save the VI. Name it C to F.
1. Select File>Open>C to F to open the front panel of your VI. Optionally Window>Show Diagram.
2. Click on the Run button (arrow). Change the Deg C value and run again. Note the new Deg F value. The default value for Deg C
is 0. If you want to start the execution with another value, type that value and select Make Current Values Default. Save the VI
and open it again. Observe the default values.
3. Click on Run Continuously. Change the Deg C value while the VI is running and observe the changes. Stop execution.
4. Click on Highlight Execution and then on Run. The moving dots show the data flow.
5. You can run your VI step by step. Use Start Single Stepping, Step Over and Step Out buttons located on the menu bar.
1. Open C to F.vi.
2. Remove a wire from an input of the multiply block and note that the Run arrow breaks. Click however on Run. A dialog box
appears on the screen that indicates the errors and warnings. Another solution is to click on Window > Show Error List.
3. Rewire (undo).
4. Remove a wire from the output of the add block and note that the run arrow does not break. Run the VI. Note the malfunction of
the VI despite a non broken arrow. Rewire.
5. Place a probe at the output of the multiply block and another one at the output of the summing block.
6. Run the VI step by step and observe the values indicated by the probes. Check the operations.
7. Change the value of 1.8 to 18 and run the VI again. Observe the probes. Identify and correct the error.
Every VI displays an icon in the upper right corner of the front panel and block diagram windows. An icon is a graphical
representation of a VI. It can contain text, images or a combination of both. If you use a VI as a subVI, the icon identifies the subVI
on the block diagram of the VI. The default icon contains a number that indicates how many new VIs you have opened since
launching LabVIEW.
1. Right click the icon in the upper right corner of the front panel or block diagram and select Edit Icon.
2. Click 16 or 256 colors.
3. Place a checkmark in the Show Terminals checkbox to show an outline of the connector pane on the editing area. The
connector pane is only a guide. It will not appear in your final icon.
4. Use the tools on the left side of the Icon Editor window to create the icon design in the editing area. The normal size image
of the icon appears in the appropriate box to the right of the editing area.
2
Complete the following steps to assign terminals to controls and indicators in a connector pane.
1. Open a new VI and place 4 thermometers on the front panel (2 Celsius as controls and 2 Fahrenheit as indicators).
2. On the block diagram place two times the subVI C to F and properly wire their inputs and outputs.
3. Show Context Help. Place cursor over a subVI and observe what the Context Help window displays.
4. Run the VI.
3
4. On the front panel add above the Deg C control a Toggle Switch from Controls > Boolean. Label the two positions C and F,
respectively.
5. On the block diagram wire the Boolean terminal to the case selector.
6. Run the VI. Note the displayed Fahrenheit temperature does not correspond to the input value. On the block diagram right click
on the case border and exchange case roles by selecting Make This Case True (False).
7. Run the VI again and check it operates properly.
8. Save the VI under a different name.
4
INTRODUCTION TO LABVIEW – Part Two
Device Device
#1 #2
Standard interface
The serial interface RS 232 is one of the simplest and most widespread interfaces. Its drawbacks are that it limits to two the number
of devices that can be interconnected and the transfer rate is low.
A simplified schematic of two devices connected via RS 232 is shown in fig. 2. Each device has two data lines (TxD – Transmit Data
and RxD – Receive Data) a minimum of two control lines (RTS – Request To Send and CTS – Clear To Send) and a ground line
(GND).
TxD RxD
RxD TxD
RTS CTS
CTS RTS
GND GND
Device #1 Device #2
The communication protocols defined by the RS 232 standard can be hardware or software.
In one of the hardware protocols the lines RTS and CTS are used. Suppose that device #1 wants to receive data from device #2. To
that purpose device #1 asserts its RTS line LOW, so the CTS input of device #2 will be LOW enabling device #2 to transmit. Device
#2 will actually transmit data only after receiving a corresponding command from device #1.
In the software protocol control lines are not used. Communication between the two devices is controlled with XON – XOFF
characters.
5
Exercise 1. Serial communication with a TDS 210 oscilloscope
Objective. To create a VI able to send commands to the oscilloscope and to get and display the received data.
The front panel of the VI should have at least:
1. one VISA resource name control
2. one string type control that will be used to send commands to the oscilloscope
3. one string type indicator that will display the “answer” of the oscilloscope.
The block diagram will contain a sequence consisting of the following frames:
1. VISA Close
2. VISA Open
3. VISA Configure Serial Port
4. VISA Write
5. VISA Read
6. VISA Close
All of the functions above can be found in the Functions palette > Instrument I/O > Serial except VISA Open which can be found
in the Functions palette > Instrument I/O > VISA > VISA Advanced.
Tips
1. Wire the Visa resource name control to the corresponding input of all VISA blocks used (in every frame!).
2. Use the following to configure the serial port: Baud rate 9600, Data bits 8, Parity 0 (None), Stop bits 10 (1,0 bits !), Flow
control 0 (None).
3. Attach at the end of the control string a LF (Line Feed) constant that can be found in the Functions palette > String. Use
Concatenate Strings that can be found in the Functions palette > String.
4. Wire the output of the Concatenate Strings block to the write buffer input of the VISA Write.
5. Wire a constant at the byte count input of the VISA Read. Set it to 400.
6. Optionally, you may add a first indicator (label it Transmitted byte count) and wire it at the return count of the VISA
Write, and a second indicator (label it Received byte count) and wire it at the return count of the VISA Read.
Type RS232? in the control string box. In the Operate submenu choose Make Current Values Default. Run the VI and observe its
front panel.
Now type RS232:BAU 4800 in the control string box and run the VI. Observe the front panel. Observe also the parameters of serial
communication on the oscilloscope. What happened? Now type RS232:BAU 2400 and run the VI. What happens? Try to explain.
Reinitialize to 9600 the baud rate of the oscilloscope. Type DAT:SOU CH1;ENC RPB;STAR 1;STOP 2500;WID 1;:CURV? in
the control string box and run the VI. Observe the front panel. Try to explain the content of the indicator string box.
Now add a Waveform Graph on the front panel of the VI. In the block diagram add a String To Byte Array function. Wire its
input at the read buffer output of the VISA Read. Wire the input of Waveform Graph to the String To Byte Array output. Type
DAT:SOU CH1;ENC RPB;STAR 1;STOP 2500;WID 1;:CURV? in the control string box and run the VI continuosly. Observe
the front panel. Optionally, you may change the colour, width, Y scale and X scale of the Waveform Graph. You may also try to
send other commands to the oscilloscope (for details see the Programmer Manual for TDS200-, TDS1000- and TDS2000-Series
Digital Oscilloscope or visit www.tektronix.com).