mt01910981.schoolwires.net · Web viewIntroduction to the SHS/SJHS English Guide
Introduction - Student Web Serverstudent.fgcu.edu/mtparraj/LabVIEW.doc · Web viewIntroduction...
Transcript of Introduction - Student Web Serverstudent.fgcu.edu/mtparraj/LabVIEW.doc · Web viewIntroduction...
Networking with LabVIEW
Author: Marco Parra, Jr.
Course: Computer Networks (CEN4516)
Professor: Janusz Zalewski
Florida Gulf Coast University
Fort Myers, Florida
December 2, 2005
1. Introduction
LabVIEW is a programming language which has been created mainly for data
acquisition (or DAQ in LabVIEW terminology). As such LabVIEW has been used as an
interface for hardware tools to interact with software tools. By acting as a software
interface, LabVIEW is able to get signals from a variety of hardware and give
instructions to the hardware to be controlled so it behaves in a desired manner.
According to Bruce Mihura, author of the book LabVIEW for Data Acquisition
and developer for LabVIEW at National Instruments (NI), states the one of the simplest
ways to create a DAQ Virtual Instrument (way programs are created in LabVIEW or VI
for short) is by using NI’s Measurement & Automation Explorer (or MAX). MAX is a
tool that works along any DAQ device that generates an analog signal and is capable of
automatically recognizing any device attached to it [1]. Also, by using MAX it is possible
to analyze the data acquired and produce graphs and produce readings through the
LabVIEW software.
Knowing that LabVIEW was created to collect data from hardware connected to a
computer card, the next question rises. How does data acquisition happen? Before we go
into the workings of data collection, let us borrow some terms from Bruce Mihura that
will help us understand how this process is done.
Channel: An electrical connection to a signal. This might be in the form of an
analog input.
Sample: The conversion of an electrical signal into a digital value.
Scan: The collection of one or more samples, across one or multiple channels.
Amplifiers and Multiplexers: Devices that take an electrical signal and scale it
accordingly for further processing. However if only one channel is to be used, an
amplifier can do the job for reading that channel, but if many signals need to be
read at the same time a multiplexer can be used so there is only one amplifier
reading various signals.
All definitions are taken from LabVIEW for Data Acquisition by Bruce Mihura.
So what will happen when data is collected is that an electrical signal representing the
data to be collected and analyzed goes through a channel provided by the DAQ device,
then an amplifier or multiplexer will take that signal an scale it so it can be understood by
following devices that process this signal. Upon this, an ADC (or analog to digital
converter get de processed signal from the amplifier and assign it a digital value which
can be understood by LabVIEW [1]. In addition, this process can be done backwards to
generate an analog output to be understood by certain DAQ devices. Here a digital signal
is generated upon a command given by LabVIEW, this signal is converted into an analog
one by a DAC (not an ADC-look at the letters) scaled by an amplifier and sent to the
DAQ device.
In addition to analog signals, there are digital signals which may be easier to deal
with. Because this type of signal only has two values, like 0 and 5 Volts, and since it is
already in a digital format, which a computer can understand, there is no need for an
ADC to interpret this signal.
So now that we understand how data is collected through a series of signals, from
an instrument to a computer. How can LabVIEW understand these signals and produce
data which is meaningful to us or a given problem? Well, to oversimplify matters and just
spend a little more time on data acquisition rather than networking, to have LabVIEW
understand the input of any device coming into the computer the first step is to use MAX
to recognize any device you want to plug in. Then, you have to assign a number to the
device you are working on in LabVIEW so the software can recognize it and from here
everything else is just programming and smooth sailing, hopefully.
To start programming any data collection application, LabVIEW provides a
structure panel with many tools which are already developed and ready to be
implemented in a program so LabVIEW can read the desired input. This variety of tools
comes from the data acquisition panel which looks like this:
From this panel we can see the building blocks available in LabVIEW to start
building an application which makes use of DAQ devices. From left to right and top to
bottom, the displayed functions in this panel are: Analog Input, Analog Output, Digital
IO, Counter, Calibration and Configuration, Signal Conditioning, and the DAQ Channel
Name Constant which allows LabVIEW to incorporate DAQ names into any VI.
As on the following example, provided by NI’s LabVIEW tutorials [2], this flow
diagram was created with the intent of reading a continuous analog input.
[2].
As illustrated on the VI above, there are an input limits, device number, and
channel number, which serve as parameters for the function “AI 1-SCAN” which returns
a reading from the DAQ device’s input board directly and finally the VI creates a graph
of from the input received in a Cartesian (x, y) coordinate plane.
Finally, I’ll make some statements about other data collection software and
technologies. First there is SciTech from SCI technologies, which is a SCADA system
used in various industries and relies on ladder logic to control a variety of variable
frequency drives and systems relay systems. This system can actually be coupled with a
real time operating system in order to collect data and issue desired commands ion order
to control the drives which in order may control, a pump a switch, and many other
systems. Unfortunately, writing about these technologies in great extent would be the
topic of another paper.
2. Problem Definition and Solution
On today’s world it is rare for a computer to complete a variety of projects all by
itself. With the rise of the internet and communication among computers, integration of
computer resources and sharing of data is a must now. Protocols like TCP/IP and UDP,
make it possible to use standard processes which multiple platforms can use to
communicate with each other, share resources, and execute commands to perform desired
operations. Take this for example: an operator on an assembly line needs to make a subtle
change to one of the parameters in which machinery works to assemble a product.
Therefore by the use of networking and LabVIEW or comparable software, a parameter
can be changed on a machine all the way across the plant; machinery can be turned on
and off wirelessly by using radio telemetry units or data can be collected from miles
away.
Unfortunately, LabVIEW was not created with networking in mind. Therefore, it
could not be considered as one of the leading technologies in this field. However this
does not stop this technology from offering routine that take advantage of these protocols
in order to produce an extended usability and allow for certain DAQ devices in a certain
computer to be used by another one. Some of the protocols used by LabVIEW are
illustrated in the communications palette.
[2]
By glancing at this palette, it is easy to see the LabVIEW makes use of ActiveX
controls, Data Sockets (enabling socket programming), HiQ (which according to the
book don’t have any relevance to networking and I don’t know what they are for),
TCP/IP controls (which allow for a reliable transmission of data), and UDP (a lightweight
protocol that is used because its performance) [3].
[2]
In LabVIEW, many network protocols work in the same manner. They all start
by opening a connection for the desired protocol with the symbol. Afterwards
reading ad writing through such connection can be done by the read symbol and
write symbol which allow for the transfer of data. Then, of course, you have to
create a listener by which VIs can receive connections and a waiter so VIs can
standby until connections are established and data is received and finally at the end
of the VI execution, you have to close the connection created .
3. Description of Technology
So, after all this reading about LabVIEW, what exactly is it? The
Laboratory Virtual Instrument Engineering Workbench or LabVIEW is a powerful tool
designed to work with instrumentation and develop analysis software. Originally created
by National Instruments in Texas, LabVIEW is the brainchild of James Truchard, Jeffrey
Kodosky, and William Nowlin which by working on sonar applications for the Navy they
were also looking for a way to connect their equipment to the computers used at the time.
Faced with this challenge, they created an interface bus and created prototype of what
later would become a “virtual instrument” or LabVIEW project [4].
Unlike C/C++, JAVA, PERL, FORTRAN, and many other programming
languages which are mainly text based, LabVIEW uses graphical elements that represent
commands, functions, and other programming actions. In addition, by putting these
graphical elements together and connecting them with a series of wires, users are able to
develop virtual instruments by using a terminology similar to that used by scientists and
engineers. Therefore, by making use of its graphical nature, LabVIEW is a programming
language comprised of two parts-the front panel and the block diagram.
The front panel is mainly constructed out of “real things” that people recognize in
everyday life, instruments like gages, switches, graphs, sliders and other instruments
serve as the building blocks for an interface with the user.
[2]
As seen in the VI above, taken form the demos present in LabVIEW [2], it is
made clear why LabVIEW is called a graphical language. In the demo, which simulates
the vibration of a given object, it is visible that all the inputs to the VI are given through
this interface which is entirely graphical. The “acquisition rate” is placed in the form of a
slider, the “set velocity” is placed in form of a dial and a digital control, and the outputs
are given in the form of a gage and a couple waveform charts.
On the other hand, the block diagram is where the actual programming takes
place. As its name states it, this part of the diagram is composed of different blocks that
serve different functions and are connected by wires so functions can interact with each
other.
[2]
By observing the block diagram above, it is possible to see many of the blocks
that make the code for a VI, and the connections they make so parameters and variables
can be passed from one block to the next one. In addition, by means of this diagram, we
can also see that abstract concepts like loops and if statements are represented in
LabVIEW by mean of an arrow going in a circle encapsulating most of the code shown in
the diagram and if statements shown by a frame with a true on the top encapsulating
some more code.
4. Programming Example/Application
The example shown for this report was obtained from the LabVIEW tutorials, and
it is designed to get the system time from one host and send it to the other [2].
Starting with the client, we can see that the front panel is just made out of an input
to determine the port of connection and another one to determine where to connect and a
button to stop the program.
[2]
However, in the block diagram we can see that this VI starts by taking the input
provided by the “machine” and “port” fields. Afterwards, the VI tries to open a
connection and goes into a while loop in which this client VI set out to read any input
provided by the server with and displays it on the “date-time” text field. Upon pressing
the “STOP” button, the VI will exit the loop, notify the server that the client is stopping
by writing in formation into the TCP connection and finally it closes the connection.
Like the client side for the program, the front panel for the server is very simple, it
only shows the port number for connection and the number of connections established.
[2]
However, the code for the server is not as simple as that for the client. For starters, the
first step this VI takes is to recognize the input provided by the port field and then sets up
a connection listener and a waiter in order to put the program on standby until a
connection is accomplished. Upon this step, the VI enters a loop in which it gets the
system time through the symbol and writes it to a string which in turn is connected
to the TCP writer in case there is a connection. Following this, there is an “if” statement
to take care of what to do in the case there are no connections or if all clients quit-which
is to close TCP connections and not to send anything. Finally, upon pressing the stop
button the VI will exit the “while” loop close all TCP connections to existing clients and
exit.
5. Conclusion
After viewing the capabilities that LabVIEW brings, it is visible to see that this
technology brings benefits that no other provides. By using graphical elements, the task
of programming is made more intuitive so more attention can be shifted towards a
solution to a given problem rather than on coding. In addition, by being able to provide
an actual module that gives LabVIEW networking capabilities, tasks of data acquisition
and measurements can be made from miles away all with intuitive programming. Also,
by being able to interface with other programming languages, LabVIEW would have the
capability of using the networking capabilities of these other languages like C++.
6. References
[1] B. Mihura, LabVIEW for Data Acquisition, Upper Saddle River, New Jersey, 2001.
[2] National Instruments Corporation, LabVIEW 6i software and tutorials, 2000.
[3] National Instruments Corporation, Using LabVIEW with TCP/IP and UDP, 2000.
[4] R. H. Bishop, Learning With LabVIEW 6i, Upper Saddle River, New Jersey, 2001.