Documente Academic
Documente Profesional
Documente Cultură
Control Department
Mechatronics – 5th year
Networked I/O
PC Boards
Workstation
Getting Started with LabView
LabView – Laboratory Virtual Instrument Engineering Workbench
is a graphical (visual) programming from National instruments (NI).
The purpose is automating the usage of processing and measuring equipment in any
laboratory setup.
C language Dataflow programming language
Cross-platform
Getting Started with LabView
Graphical Programming for
Test, Measurement, and
Control
Benefits
• Rapid application
development with Express VIs
and easy-to-use graphical
environment
• Interactive measurement
assistants and powerful
redesigned DAQ interface for
connecting to all types of I/O.
• Allows creating stand-alone
executables.
• Included examples and the
documentation, makes it
simple to create small
applications .
Getting Started with LabView
Without With
Getting Started with LabView
Ethernet
extender
Programmable Logic
Pprogrammable logic Controller (PLC) controler ZELIO
( SCHNEIDER ELECTRIC)
monitoring using MODBUS/TCP protocol
Getting Started with LabView
Edge detection
Barcode reading
Ctrl+E
Run Stop
Reorder objects
Debugging features
Getting Started with LabView
Front panel Block Diagram
Controls palette
Tools palette
Getting Started with LabView
• LabView automatically selects the tool needed
• Available on the front panel and the block diagram
• A tool is a special operating mode of the mouse cursor
• Use the tools to operate and modify front panel and block diagram objects
• To show the tools palette, select Window » Show Tools Palette
Front Panel
• Controls = Inputs
• Indicators = Outputs
Block Diagram
• Accompanying “program”
for front panel
• Components wired
together
20
Context Help
• To display the Context Help window, select
Help » Show Context Help, press the <Ctrl-H> keys,
or press the Show Context Help Window button in
the toolbar
• Move cursor over object
to display help
21
Debugging Techniques
Finding Errors
Click on broken Run button. A window showing the
error appears
Execution Highlighting
Click on Execution Highlighting button; data flow is
animated using bubbles. Values are displayed on
wires.
22
Debugging Techniques
Probe
Right-click on wire and select probe and it shows
data as it flows through the wire segment
Breakpoints
Right-click on wire and select Set Breakpoint; pause
execution at the breakpoint.
Conditional Probe
Combination of a breakpoint and a probe. Right-click on
wire and select custom probe.
23
Debugging Techniques
Step Into, Over, and Out buttons for Single Stepping
Click on Step Into button to enable single stepping
Once Single Stepping has begun, the button steps
into nodes
24
Higher Institute for Applied Sciences and Technology (HIAST)
Control Department - Mechatronics – 5th year
Developing Modular
Applications
٣٠
After building a VI, create its icon and connector pane, than it could be
used as a SUB-VI in another VI.
Step I:
Right-click in the icon and select Edit Icon, and draw a new desired Icon.
Step II: Creating the connector
Right-click in the icon and select Show Connector, and select a suitable connector
acording to the number of inputs and outputs.
Step III: Assign the connector terminals
Step IV: Save the file like C2Fconverter.vi
LabView
Data Types
Prepared by: Eng. Al-Kayal Khaldoun
Kaldoun.kayal@hiast.edu.sy
Damascus 2013
Wiring the Block Diagram
Scalar 1D Array 2D Array
Numeric
Boolean
String
Dynamic
36
LabView Data Types
Numeric Conversion
Data Types
Data Types
Higher Institute for Applied Sciences and Technology (HIAST)
Control Department - Mechatronics – 5th year
LabView
Programming
Structures
Exercise:
Lets build a Second Timer using For Loop structure
which can count up to 60 sec.
The While Loop structure
The While Loop structure
The Formula Node is a window in the block diagram where you can write
textual program code following the C-syntax. Using a Formula Node structure
for mathematical expressions is often more convenient than building the
expression using elementary blocks in the ordinary way in LabVIEW since it
is easier to write and maintain textual mathematical expressions than
drawing equivalent block diagram code.
The Formula Node
The Formula Node
Example:
The Formula Node
Homework
The Math Script Node
The Math Script Node
The MathScript Node implements similar functions to the Formula Node but
with the additional functionality of a full .m file compiler, making it useful as a
textual language for signal processing, analysis(MatLab).
The Math Script Node
The Event structure
An event is an asynchronous notification that something has occurred.
Events can originate from the user interface, external I/O, or other parts of the
program.
The Event structure can have multiple cases, each of which is a separate event-
handling routine.
The Event structure
The Event structure includes a Timeout event, which allows you to control
when the Timeout event executes.
The Timeout terminal at the top left corner of the Event structure, specifies
the number of milliseconds to wait for an event before timing out.
LabView
Arrays
Prepared by: Eng. Al-Kayal Khaldoun
Kaldoun.kayal@hiast.edu.sy
Damascus 2013
LabView Arrays
LabView Arrays
Remember that you must assign a data object to the empty array shell
before using the array on the block diagram. If you do not assign a data
object, the array terminal will appear black with an empty bracket.
LabView Arrays
Creating Array Constants in The Block Diagram
Creating Array Constants in The Block Diagram
Array Controls and Indicators
1. Select the Array shell from the Controls 2. Place data object inside shell
palette
Add Dimension
for 2D arrays
Array Functions
Common Array Functions
Array Size
Initialize Array
Array Functions
Common Array Functions
Array Subset
The Build Array Function
Appending an element
Concatenate Inputs
Extracting an Element
Extracting a Row
Combination Result
LabView
Clusters
Prepared by: Eng. Al-Kayal Khaldoun
Kaldoun.kayal@hiast.edu.sy
Damascus 2013
Clusters
Error Cluster
Simple Error Handler
Use the Simple Error Handler to handle the error at the end of
the execution flow.
LabView
Strings
Prepared by: Eng. Al-Kayal Khaldoun Damascus 2013
Strings
A string is a sequence of characters (ASCII)
String Display Modes
Normal display code display
Password display
Hex display
String Functions
String Length
Concatenate Strings
(spaces here)
String Functions
String Subset
Match Pattern
Converting Numerics to Strings
Using Build Text
Converting Numerics to Strings
Using Format Into String function
Exercise
Lets build the following control using the Format into String function.
Converting Strings to Numerics
Using Scan From String function
Exercise
Exercise
Search and Replace String
Search and Replace String
Exercise:
Search and Replace String
Review Exercise
Extend the
previous example
to be able to
calculate more
functions as shown
right.
Higher Institute for Applied Sciences and Technology (HIAST)
Control Department - Mechatronics – 5th year
LabView
File I/O
Prepared by: Eng. Al-Kayal Khaldoun Damascus 2013
LabView File I/O
File I/O Programming Model -
Intermediate
Open/ Read
Close Check for
Create/ and/or
File Errors
Replace File Write to File
Write To Text File
Write To Text File
Example:
Read From Text File
Read From Text File
Example:
Formatting a Spreadsheet String
• Spreadsheets are popular tools for data handling and analysis
• There are many formats for spreadsheet data. One of the most popular
is tab-delimited:
– Columns are separated by a tab character
– Rows are separated by an end-of-line character
A spreadsheet yields:
LabView
Charts & Graphs
Prepared by: Eng. Al-Kayal Khaldoun
Kaldoun.kayal@hiast.edu.sy
Damascus 2013
LabView Charts & Graphs
LabView Charts & Graphs Type
Waveform Charts Example
Waveform Graphs Example
Waveform Graphs Example
Waveform XY Graphs Example
Higher Institute for Applied Sciences and Technology (HIAST)
Control Department - Mechatronics – 5th year
LabView
DAQ SYSTEM
Construct a testing
device for drawing
Diode Current / Voltage
characteristic ,using
DAQ system (NI USB-
6009)
Save measurements in
file.
Example of Using DAQ (NI USB-6009)
Terminal Assignments
Example of Using DAQ (NI USB-6009)
Example of Using DAQ (NI USB-6009)
Higher Institute for Applied Sciences and Technology (HIAST)
Control Department - Mechatronics – 5th year
Connecting to External
Devices
RS-232 Cable
Serial Communication
• RS-232
– DCE or DTE configurations Our application configuration
Baud rate : 9600 bit per s
– 9-pin or 25-pin
Data bits : 8 bits
• RS-422
Parity : no parity
– DCE or DTE
Stop bits : 1
– 8-pin
Flow control : no
• RS-485
– Multidrop
Serial Communication
•Configure
•Open
•Read / write
•Close
Serial communication
How to configure & open communication
while (1)
{
if(start==TRUE)
{
A=read_adc(0);
B=read_adc(1);
C=read_adc(2);
D=read_adc(3);
E=PINC;
printf("A%4dB%4dC%4dD%4dE%4dF%4d",A,B,C,D,E);
delay_ms(50);
}
};
Building SCADA System in LabView Environment
Final assignment