Basic Programing For Electronics-Chap 2-1-2024
Basic Programing For Electronics-Chap 2-1-2024
phenikaa-uni.edu.vn
Chapter 2 : Basic LabVIEW Programming
Contents:
1. LabVIEW Programming Development
2. Loops and Waveform Graphs
3. Data Files and Character Strings
4. Important Programming Structures: cases, shift registers...
phenikaa-uni.edu.vn
Outline
Display
Load data
Save data
PC
3
phenikaa-uni.edu.vn
2.1 LabVIEW Programming Development
Graph-based programming:
Graphical icons
Create VI
Create Project:
Includes many VIs
4
phenikaa-uni.edu.vn
2.1 LabVIEW Programming Development
Switching: Ctrl + E
Graph-based programming:
Graphical icons
5
phenikaa-uni.edu.vn
2.1 LabVIEW Programming Development
Text-based example Graphic-based example
#include<iostream.h>
#include<stdlib.h> “Plus” operator
(function)
Int main()
Variables
{
Int a, b; // Variable Variables
cout << “Enter a, b”;
cin >> a >> b;
cout << (a+b) // “Plus”
} Numeric:
control
Numeric:
indicator
phenikaa-uni.edu.vn
2.1 LabVIEW Programming Development
➢ Front panel ➢ Block diagram
▪ Controls Palette ▪ Terminals
▪ Controls, Indicators ▪ Variables & Constant
▪ Nodes
▪ Functions palette
▪ Search for Controls, VIs & Functions
7
phenikaa-uni.edu.vn
2.1 LabVIEW Programming Development
Front panel (user interface): simulate instrument devices
• Controls: knobs, push buttons, numeric, ... -> Input
• Indicators: graphs, LEDS, numeric, ... -> Output
8
phenikaa-uni.edu.vn
2.1 LabVIEW Programming Development
Right-click on Front panel ->
Controls pallet
Numeric: control & indicator
can be switched (right-click)
9
phenikaa-uni.edu.vn
2.1 LabVIEW Programming Development
Right-click on
Front panel ->
Controls pallet
10
phenikaa-uni.edu.vn
2.1 LabVIEW Programming Development
Block diagram (G-code): program the front panel objects
• Terminals, variables, constants, (nodes) functions, structures, wires
• subVIs
Variables
Block diagram Front panel
11
phenikaa-uni.edu.vn
2.1 LabVIEW Programming Development
Block Diagram
Example
Wires Indicator
Control terminals
terminals
Constant
Structure Node
(function)
12
phenikaa-uni.edu.vn
2.1 LabVIEW Programming Development
Block Diagram
Terminals: Inputs or outputs
Controls = Inputs
Variables Indicator
Indicators = Outputs Control
Wires
terminals
Constants = Fixed values terminals
Nodes:
build-in functions (+,-,*,/...)
Constant
Or VIs (functions)
Structure Node
(function)
13
phenikaa-uni.edu.vn
2.1 LabVIEW Programming Development
Wires
*Broken wire: Do nối hai đối tượng với các kiểu dữ liệu không tương thích
phenikaa-uni.edu.vn
2.1 LabVIEW Programming Development
Block
Diagram
Right-click on
Block diagram
-> Functions
-> Search
Toolbox
functions
Or load VIs
15
phenikaa-uni.edu.vn
2.1 LabVIEW Programming Development
Block Diagram
View Variable as Icon
Select variable Un-tick
-> Right click -> View as icon
16
phenikaa-uni.edu.vn
2.1 LabVIEW Programming Development
Block Diagram
Practice: Create the block diagram shown below
You can change the name of indicators, controls,
and constants by double-clicking the label and
typing in the desired name.
If there is no label showing, right-click the desired
object and select Visible Items → Label.
Front panel
Summary:
• Common tools and IDE of LABVIEW
• Front panel, block diagram, functions pallet, controls pallet
17
phenikaa-uni.edu.vn
Thanks for your attention!
Q&A
phenikaa-uni.edu.vn