Вы находитесь на странице: 1из 8

# EE4107

## Exercise 6: Control and Simulation in

LabVIEW
In this task you will learn how to use the Simulation palette in LabVIEW.

You need the LabVIEW Control Design and Simulation Module for this Task.

## Below we see the Simulation palette in LabVIEW:

The foundation for the simulations is the Control & Simulation Loop, which is located in the upper
left corner in the Simulation palette. The Control & Simulation Loop is very similar to an ordinary
While loop, but it has built-in features and is optimized for simulation purposes.

It is recommended that you watch the video Simulation Palette Overview (about 15

Example:

= +

## The block diagram for this equation is as follows:

Faculty of Technology, Postboks 203, Kjlnes ring 56, N-3901 Porsgrunn, Norway. Tel: +47 35 57 50 00 Fax: +47 35 57 54 01

LabVIEW Implementation:

We can easily implement this block diagram and plot the results in LabVIEW:

Lets set = 0.25 and = 2. When we run the simulation, we get the following results:

Simulation Parameters:

In the example the following simulation parameters are used (right-click on the Simulation Loop
border and select Configure Simulation parameters):

Transfer Function:

We can also find the transfer function for the system using Laplace:

= + ()

() /
= = = =
() + 1 + 1 + 1

## With = 0.25 and = 2 we get:

() 8
= =
() 4 + 1

From the plot above we see that this is correct ( = 8 and = !" = 4).

In the Continuous Linear Systems palette in LabVIEW we have a block for defining a transfer
function:

## This gives the same results:

Note! The order of the coefficients are different in LabVIEW and MathScript.

## We define a transfer function in LabVIEW like this:

Try with different values for and and see whats happen are the results according to the theory
for 1.order transfer functions?

In this task we will use LabVIEW and the LabVIEW Control Design and Simulation Module to simulate
a simple model of a bacteria population in a jar.

birth rate=bx

## Set b=1/hour and p=0.5 bacteria-hour

We will simulate the number of bacteria in the jar after 1 hour, assuming that initially there are 100
bacteria present.

Draw Block Diagram for the system using pen and paper.

Simulate the system in LabVIEW, where you follow these steps:

1. Start LabVIEW and use the Control and Simulation Loop from Control Design and Simulation
Palette in LabVIEW
2. Drag in the necessary Blocks from the palette (including the plot).
3. Use the Connection Wire from the Tools palette and draw the necessary wires.
4. Configure Simulation Parameters (right-click on the Control and Simulation Loop border)

## Task 2: Spring-mass damper system

Use LabVIEW Control Design and Simulation Module and the Control and Simulation Loop in
order to create a simulation of a spring-mass damper system.

1
= ( )

Where.

is a mass

## is the position of the mass

is the first derivative of the position, which equals the velocity of the mass

is the second derivative of the position, which equals the acceleration of the mass

Draw Block Diagram for the system using pen and paper.

Implement and simulate the system in LabVIEW.

Simulate and plot the position (), the velocity (), and the acceleration () in 3 different plots.

## In the simulations you may set = 9.8, = 1, = 1 = 100

Then try to set = 10 and see the difference. Try also different values for and and see what
happens. Try to explain the results.

In this task you will use the example General PID Simulator.vi as a base for your simulation. Use
the NI Example Finder (Help Find Examples in the LabVIEW menu) in order to find the VI in
LabVIEW.

Run the example and see how it is implemented and how it works.

## You find all the PID functions in the PID palette:

Change ! and ! so the unit is seconds instead of minutes on your Front Panel (User Interface).

The functions PID.vi and PID Advanced.vi requires that ! and ! is in minutes, while its normal
to use seconds as the unit for these parameters. You can use the following piece of code in order to
transform them:

## Run simulations and find proper values for ! ! and ! .

Basic LabVIEW programming:

## Tutorial: Introduction to LabVIEW: http://home.hit.no/~hansha/?tutorial=labview

LabVIEW Starter: http://home.hit.no/~hansha/training/labview/starter

## Control and Simulation:

http://home.hit.no/~hansha/?lab=control_simulation