0% found this document useful (0 votes)
58 views

Exercise - Control and Simulation in LabVIEW

The document discusses using LabVIEW's simulation palette to simulate control systems. It provides examples of implementing differential equation models of bacteria population and a spring-mass damper system. It also demonstrates using the simulation loop and PID control blocks to simulate and analyze PID control of a system. Users are tasked with drawing block diagrams, implementing the examples in LabVIEW, and exploring the effects of varying simulation parameters.

Uploaded by

lemaitinh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Exercise - Control and Simulation in LabVIEW

The document discusses using LabVIEW's simulation palette to simulate control systems. It provides examples of implementing differential equation models of bacteria population and a spring-mass damper system. It also demonstrates using the simulation loop and PID control blocks to simulate and analyze PID control of a system. Users are tasked with drawing block diagrams, implementing the examples in LabVIEW, and exploring the effects of varying simulation parameters.

Uploaded by

lemaitinh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Control

Engineering

University College of Southeast Norway

Exercise: 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.

Example:

Given the following dynamic system (differential equation):

𝑥 = −𝑎𝑥 + 𝑏𝑢

The block diagram for this equation is as follows:

http://home.hit.no/~hansha

2

LabVIEW Implementation:

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

Let’s set 𝑎 = 0.25 and 𝑏 = 2. When we run the simulation, we get the following results:

Control Engineering
3

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:

𝑠𝑥 𝑠 = −𝑎𝑥 𝑠 + 𝑏𝑢(𝑠)

This gives the following transfer function:

𝑥(𝑠) 𝑏 𝑏/𝑎 𝐾
𝐻 𝑠 = = = =
𝑢(𝑠) 𝑠 + 𝑎 1 𝑠 + 1 𝑇𝑠 + 1
𝑎

This means 𝐾 = 𝑏/𝑎 and 𝑇 = 1/𝑎

With 𝑎 = 0.25 and 𝑏 = 2 we get:

𝑥(𝑠) 8
𝐻 𝑠 = =
𝑢(𝑠) 4𝑠 + 1

From the plot above we see that this is correct (𝐾 = 8 and 𝑇 = 𝑇67 = 4𝑠).

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

Control Engineering
4

Then we can easily use the transfer function block instead:

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 what’s happen – are the results according to the theory
for 1.order transfer functions?

Control Engineering
5

Task 1: Bacteria Simulation


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.

The mathematical model for the bacteria population is as follows:

birth rate=bx

death rate = px2

Then the total rate of change of bacteria population is:

𝒙 = 𝒃𝒙 − 𝒑𝒙𝟐

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.

Task 1.1
Draw Block Diagram for the system using “pen and paper”.

Task 1.2
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)
5. Start the Simulation. The Simulation result should be present in a plot.

Control Engineering
6

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.

The differential equation for the system is as follows:

1
𝑥= (𝐹 − 𝑐𝑥 − 𝑘𝑥)
𝑚

Where.

𝐹 is an external force applied to the system

𝑐 is the damping constant of the spring

𝑘 is the stiffness of the spring

𝑚 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

Task 2.1
Draw Block Diagram for the system using “pen and paper”.

Task 2.2
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

Control Engineering
7

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

Task 3: PID Control


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.

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

Task 3.2
Replace the function “PID.vi” with the more advanced function “PID Advance.vi” instead.

Note! Make sure to save it with another name!

You find all the PID functions in the PID palette:

Task 3.3

Control Engineering
8

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

The functions “PID.vi” and “PID Advanced.vi” requires that 𝑇O and 𝑇P is in minutes, while it’s 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 𝐾Q 𝑇O and 𝑇P .

Additional Resources
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

Here you will find additional tasks, tutorials and other resources.

Control Engineering

You might also like