Beruflich Dokumente
Kultur Dokumente
About LabView
LabView is a highly adaptable
programming GUI (Graphic User
Interface)
LabView compiles the code into
machine instructions, much like the
programming language C
This language is used extensively
throughout a wide variety of industries
VI
Wires
Local and Global Variables
Front Panel
Block Diagram
Connector Panel
VIs
When using LabView, you are
actually creating segments of code
called VIs (virtual instruments). A
sub-VI works just like a VI, but you
can use a sub-VI within a VI. VIs are
composed of three parts, which are
the front panel, the block diagram,
and the connector panel.
Wires
Wires are a
visual
representatio
n of how
different
functions
connect to
each other in
the block
diagram.
Variables
The color of a variable denotes
the type of data that it contains.
Orange means numeric.
The
picture of
a globe
shows
that it is a
These two
variables
have their
borders
filled in.
That shows
that they
are
configured
to be read
from. The
others are
set up to
have data
Local Variables
There are two types of variables in
LabView. The purpose of either one is to
transfer data throughout your code. The
first is a local variable, which allows you
to read or write to a control or indicator
on the front panel. This allows you to
force a controls value with the code, or
use an indicator to store data. These can
store all types of data, such as numeric
values, strings, T/F values, or arrays.
Global Variables
A Global variable is identical in
function to a local variable. The
difference between them is where the
data is saved. A local variable saves
the data to the front panel of the VI
that its in; this makes them only be
useable in that VI. A global variable is
saved in a special global variable VI,
and all VIs within the project can use it.
Front Panel
The front panel of each VI is where you
will actually use the program. This is
where you place all of your controllers
(they allow you to set a value), indicators
(they show you the current value of
whatever you wire them to), and
anything else you want in your functional
program. You can add buttons for T/F
logic, and many other graphical options.
Block Diagram
The block diagram is where you write
your actual code. You use wires to
connect different inputs, outputs,
functions, and values. All of the code
runs parallel, which means that it follows
the wire left to right. Because of this,
you must be careful not to read and write
to a variable or file without forcing the
code to do so in the order that you want
it to.
Here you
can see a
very simple
block
diagram
I have the
end result
wired to
an
indicator.
This will
allow me
to see the
output in
the front
panel
Connector Panel
The connector panel allows you to
turn a VI into a function. This makes
it easy to simplify code. The
connector panel has a picture that
you make of the code to represent
the function. You can then add
terminals to the picture to allow you
to wire parts of the code to other Vis.
Block
diagram
=
+
Front Panel
Math in LabView
Ive already shown a few examples of basic
math in LabView. All there is to it is to wire
inputs and constant values to a math
function, then wire the output wherever it
needs to go. Just remember that LabView
calculates the program left to right along
the wire, and its easy. All math functions
are in a tool palette that you can access by
right clicking the bloc diagram (this goes for
all functions, in either the block diagram or
the front panel).
Robot Main.vi
Robot Main.vi is the first vi that your
robot will run when it boots up. The
purpose of this vi is to run the other
vis in the proper sequence. Because
it will already be properly configured
for most anything that you will do, I
highly suggest that you dont mess
with the code here if you dont know
exactly what you are doing.
Begin.vi
This .vi is where you open all motors,
sensors, and control inputs (joysticks and
other such things). Opening one of these
objects in the code creates a RefNum for
the said object. The RefNum is the
system that the cRIO will use to keep
track of which object is connected to
which data port, be it through PWM or
any other port. This program will only
run once.
This is an
example of
how you open
a motor and a
input, but
everything
you plan to
use must be
opened here.
This is the
actual
Begin.vi as it
comes. Right
now it opens a
joystick, the
camera, and a
motor pair for
later use.
Autonomous Independent.vi
Autonomous Independent (or auton for
short) is the code for the section of the
game when the robot will drive itself.
Because of that, any code here must be
independent from driver control. The
basic auton .vi that comes with FRC
LabView gives a good example for how to
set up your auton, but the code is too
large for me to show here while making it
easy to follow. Youll use the motors that
you open in Begin here as well as Teleop.
Teleop.vi
Teleop.vi is the section of code that runs
while the driver is in control of the robot.
Here is where you will want to use the
joysticks that you opened in begin.vi,
along with the motors. The joysticks
output both an x and a y numeric value,
so youll need to associate one value with
throttle, then use the value to control a
motor with the set speed motor function.
Disabled.vi
Whenever your robot is on but not in
either auton or teleop it will be in the
disabled state. While you can do
whatever you need to here, personally I
recommend that you at least use this
state to reset all variables to whatever
they need to be for the beginning of
teleop or auton. We also make it display
the outputs from all of our sensors for
hardware diagnostic purposes.
Finished.vi
Finished.vi is the last segment of your
code that will run before you shut down
your robot. Here you should close
anything that you opened in begin.vi, as
well as save any data that you might want
to save (like camera images for calibration
purposes). In all reality, you dont need to
close the objects that you already opened,
as powering down your robot will clear the
memory. It is just good practice to do so,
to avoid memory leaks.
Questions?