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

VIS SIM Getting Started Guide

Embed Size (px)

DESCRIPTION

Getting Started Guide

Citation preview

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

    Getting Startedwith VisSim

  • 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)

    BlocksBlocks 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

    1 Getting Started with VisSim

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

    STEP 1

    STEP 2

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

    STEP 3

    STEP 4

    Wire the other blocks together.

    STEP 5

    STEP 6

    Select const from the Signal Producer menu with aleft-click.

    Left -click at this point and keep themouse button held down.

    Drag a wire to a connection port onthe summingJunction

    Release the mouse button to place thewire

    Move the mouse pointer over the topconst block

    Right-click to fire up the const Propertiesmenu. Change its value to 2.

    Click OK to get back to the simulation.

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

    Eureka!

    Move the mouse overthe worksheet

    Left -click toplace the block

    Move the mouse point over one of thebranches of the summingJunction

    Hold down the Ctrl key and press the right-mouse button to change the sign of the branchQuick Tip...

    2Getting Started with VisSim

  • Creating Compound BlocksCompound 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

    STEP 3

    Drag a selection box around the following blocks Releasing the mouse button gives the following

    Select Create Compound Block from the Edit menu andmake the following changes

    Clicking OK creates the compound block in yourworksheet

    13 Getting Started with VisSim

  • Simulating a Spring-Mass Damper ArmLet's try something a little less trivial - a classical spring-mass damper arm.

    Where K = Spring ConstantB = Constant DampingM = Massx = 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 thederivate with the highest degree on the LHS:

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

    The initial condition (x(0) = 3) is set in the second integrator block (by right-clicking on the block to bring upthe Integrator Properties menu).

    To form the whole equation in VisSim we need to 1) Multiply the position by K2) Multiply the velocity by B3) Add these two quantities together with a summingJunction4) Multiply the sum by -1/M with a gain block5) Wire the output of the gain block to the input of the acceleration block

    The completed simulation would look like:

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

    Quick Tip...

    4Getting Started with VisSim

  • Optimising a PID Control LoopIntroduction

    We'll now develop a model of a classical PID Control Loop and optimise the gains so that we minimise rise-time and overshoot.

    The model will consist of three sections: 1) the control loop, 2) a "cost" function that measures how close weare to our optimisation goal, and 3) the parameters that we want to vary to minimize the cost function.

    1. The Control LoopAssemble the following blocks to form the control loop

    2. The Cost FunctionThe cost functions measures how far we are from our stated goal of reducing steady state error and the timeto set-point.

    Algorithmically, it can be thought of as:1) Find the difference between the Input and the Output2) 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

    5 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

    6Getting Started with VisSim

  • Optimising a PID Control Loop continued...

    Adept Scientific plc Amor Way, Letchworth,Herts, SG6 1ZATel: 01462 480055 Fax: 01462 480213 Email: [email protected] Webstore: www.adeptstore.co.uk

    Adept Scientific ApsNordre Jernbanevej 13c,3400 Hillerd, Denmark Tel: +45 48 25 17 77 Fax: +45 48 24 08 47 Email: [email protected] 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: [email protected] Webstore: www.adeptstore.de

    Adept Scientific Inc.PO Box 34015Bethesda, MD 20827, USATel: +1 800 724 8380 Fax: +1 240 465 0422Email: [email protected] Webstore: www.adeptstore.com

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

    If you require further assistance please contact your local office

    www.adeptstore.com

    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 output2) If the difference is negative (i.e. overshoot) multiply the error by 10. If the difference is positive,

    let the signal pass through without modification3) 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