Vous êtes sur la page 1sur 8

Getting Started

with VisSim

What is VisSim?
VisSim helps you model linear and non-linear dynamic systems - "anything that moves"

How does it work?


A VisSim simulation is constructed from three "layers":
1. Blocks
2. The "wires" connecting
those blocks
3. Simulation parameters (simulation time step, numerical integration method etc)

Blocks
Blocks are placed on the worksheet from the Blocks drop down menu
Blocks can generally be divided into three categories...
Blocks that produce signals that "travel" through the system
Blocks that consume signals - these are used to display the results
of your simulation
And everything else. These are typically used to transforms signals from one
form to another, create animations, or read in external data. At their simplest
level, they might add two signals together. At their most complex level, they
might be used to numerically integrate a signal over time or represent a transfer
function

Getting Started with VisSim

Hello World
Let's try the VisSim equivalent of "Hello World". We can't get much simpler than adding two numbers together!

STEP 1
Select const from the Signal Producer menu with a
left-click.

Move the mouse over


the worksheet

Left -click to
place the block

STEP 2
Place another const block on the worksheet, together with a summingJunction (from the Arithmetic menu) and a display
block (from the Signal Consumer menu)

STEP 3
Left -click at this point and keep the
mouse button held down.

Drag a wire to a connection port on


the summingJunction

Release the mouse button to place the


wire

Right-click to fire up the const Properties


menu. Change its value to 2.

Click OK to get back to the simulation.

STEP 4
Wire the other blocks together.

STEP 5
Move the mouse pointer over the top
const block

STEP 6
Select Go from the Simulate menu
(or press F5 or click the
button)

Quick Tip...

Eureka!

Move the mouse point over one of the


branches of the summingJunction

Hold down the Ctrl key and press the rightmouse button to change the sign of the branch

Getting Started with VisSim

Creating Compound Blocks


Compound blocks are a vital part of organising your simulations - they hide deeper levels of local complexity.
Let's try creating a compound block that can be used for a common operation - finding the derivative of a signal.

STEP 1
Assemble the following blocks. The centre portion (between the sinusoid and the plot block) is the derivative operation.

STEP 2
Drag a selection box around the following blocks

Releasing the mouse button gives the following

STEP 3
Select Create Compound Block from the Edit menu and
make the following changes

3
1

Getting Started with VisSim

Clicking OK creates the compound block in your


worksheet

Simulating a Spring-Mass Damper Arm


Let's try something a little less trivial - a classical spring-mass damper arm.
Where
K=
B=
M=
x=

Spring Constant
Constant Damping
Mass
Vertical Displacement

From Newton's Second Law, the equation of motion for the damped harmonic oscillation is

Integral equations are more numerically stable than differential equations. The first step is to isolate the
derivate with the highest degree on the LHS:

Integrating the acceleration gives the velocity. Integrating the velocity gives the position. Within VisSim, this
would look like:

The initial condition (x(0) = 3) is set in the second integrator block (by right-clicking on the block to bring up
the Integrator Properties menu).
To form the whole equation in VisSim we need to
1) Multiply the position by K
2) Multiply the velocity by B
3) Add these two quantities together with a summingJunction
4) Multiply the sum by -1/M with a gain block
5) Wire the output of the gain block to the input of the acceleration block
The completed simulation would look like:

Quick Tip...
In the simulation above we set the initial conditions for the position inside the integrator block. However, initial conditions can also be set within the
represent velocity at time t, with x(0) = 3. In VisSim, the position x(t) is given by
actual simulation environment itself. For example, let

Getting Started with VisSim

Optimising a PID Control Loop


Introduction

We'll now develop a model of a classical PID Control Loop and optimise the gains so that we minimise risetime and overshoot.
The model will consist of three sections: 1) the control loop, 2) a "cost" function that measures how close we
are to our optimisation goal, and 3) the parameters that we want to vary to minimize the cost function.

1. The Control Loop


Assemble the following blocks to form the control loop

2. The Cost Function


The cost functions measures how far we are from our stated goal of reducing steady state error and the time
to set-point.

Algorithmically, it can be thought of as:


1) Find the difference between the Input and the Output
2) Square it (in case the difference is negative).
3) Integrate this error over time to find the total error.

3. The Parameters.
We use parameterUnkown blocks to specify what parameters we want to vary to minimise the cost function

Getting Started with VisSim

The completed simulation should look like this.

Under Simulation>Simulation Properties set the following options.

Under Simulate>Optimization Properties, select the following options are selected.

Run the simulation and your plot block should look something like this

Getting Started with VisSim

Optimising a PID Control Loop continued...


There's plenty of overshoot. Let's penalise overshoot by modifying the cost function.

This can be thought of as:


1) Find the difference between the input and the output
2) If the difference is negative (i.e. overshoot) multiply the error by 10. If the difference is positive,
let the signal pass through without modification
3) Square the error (in case it is negative)
4) Integrate the error over time to find the total error.
Running the simulation gives this response

If you require further assistance please contact your local office


Adept Scientific plc
Amor Way, Letchworth,
Herts, SG6 1ZA
Tel: 01462 480055
Fax: 01462 480213
Email: info@adeptscience.co.uk
Webstore: www.adeptstore.co.uk

Adept Scientific Aps


Nordre Jernbanevej 13c,
3400 Hillerd, Denmark
Tel: +45 48 25 17 77
Fax: +45 48 24 08 47
Email: infodk@adeptscientific.dk
Webstore: www.adeptstore.dk

Adept Scientific GmbH,


Hamburger Allee 26-28,
60486 Frankfurt, Germany
Tel: +49 (0)69 97084114
Fax: +49 (0)69 97084141
Email: infode@adeptscience.de
Webstore: www.adeptstore.de

www.adeptstore.com
Copyright 2004 Adept Scientific plc. All rights reserved. All trademarks recognised. E&OE

Adept Scientific Inc.


PO Box 34015
Bethesda, MD 20827, USA
Tel: +1 800 724 8380
Fax: +1 240 465 0422
Email: info@adeptscience.com
Webstore: www.adeptstore.com

Vous aimerez peut-être aussi