LabVIEW Simulation Tutorial - Brushed DC Motor

download LabVIEW Simulation Tutorial - Brushed DC Motor

of 22

Transcript of LabVIEW Simulation Tutorial - Brushed DC Motor

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    1/22

    1/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    How to Simulate a Brushed DC Motor Using LabVIEW 8.2

    Jason Luecht, Matt Rosmarin, Mike Kleinigger - Research AssistantsDr. Kevin Craig, Professor of Mechanical Engineering

    RPI Mechatronics Laboratory 2007

    This tutorial describes the process necessary to use LabVIEW to simulate the response of a givendynamic system based on a mathematical model, i.e., a set of differential equations, derived fromthe physical model of the actual system. The physical system used in this tutorial is the brushedDC motor. The mathematical analysis, in this case the numerical solution of the nonlinearcoupled differential equations and resulting predicted dynamic response, is part of theEngineering System Investigation Process, the cornerstone of modern engineering practice.

    ( ) 1( )1

    ( )

    t

    app emf

    I t K B J

    diV K RI t

    L dt

    =

    =

    & &&

    &

    Physical Model Parameters

    J = motor inertia = 8.5E-6 kg-m2

    B = viscous damping coefficient = 3.7x10 6

    R = internal resistance = 1.85 L = internal inductance = 1.97 mHK t = torque constant = 4.24x10 -2 N-m/AK emf = back-emf constant = 4.24x10 -2 V/rad/s

    Vapp = applied voltage (volt) = angular position of motor shaft (rad)I(t) = current through the motor at time t (sec)

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    2/22

    2/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Screenshots of LabVIEW Simulation Files

    Plant

    Mechanical Subsytem

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    3/22

    3/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Electrical Subsystem

    Front Panel

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    4/22

    4/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    LabVIEW Simulation of the Brushed DC Motor

    Step 1 First, open LabVIEW 8.2. Once the Getting Started screen has appeared (Figure 3), underthe New menu select Empty Project. The project window will appear, then right-clickon My Computer New VI (Figure 4). A blank front panel will appear, and

    behind that, an empty block diagram (Figure 5).

    Figure 1

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    5/22

    5/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Figure 2

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    6/22

    6/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Figure 3

    Step 2Select the block diagram window. To do this you may either click the window to bring it

    into focus or press the Control and E keys simultaneously. This shortcut can also be used toswitch back to the front panel.

    Step 3We first need to add a simulation loop within which the equations will be implemented.Right-click in an empty space on the block diagram. You will be presented with theLabVIEW functions palette (Figure 4). If youd like, click the thumbtack in the top leftcorner of this window to fix it in place. Next click Control Design and Simulation, thenclick Simulation and finally click the Simulation Loop. Your cursor will change its iconand you can then click and drag to place the simulation loop onto the block diagram. If at a

    later time you wish to adjust the size of the loop, you may click to select it, then click anddrag the boxes which appear to adjust the size. Figure 6 shows our simulation loop.

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    7/22

    7/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Note: Everything inside of a simulation loop will be run according tosimulation time (right-click the black border of the loop and select

    properties to adjust). This loop is how LabVIEW designates what part ofthe block diagram defines a simulation.

    Figure 5

    Step 4Before implementing the equations, click File Save. Nowwe will begin by adding a numeric constant. Right-click to

    bring up the functions palette. From the Programminggroup (which is opened by default), select Numeric Numeric Constant and place this on the block diagram.

    Next, right-click on this block and select Change toControl (Figure 6).

    Figure 4

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    8/22

    8/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Figure 6 Figure 7

    Once this is complete, right-click the control and select Representation DoublePrecision (Figure 7). This will convert the control from its standard integer to a double(decimal value). You may also wish to change the label of this control to Vapp. Dothis by double-clicking the text, then typing. Once youve done this, repeat the procedureto create three more constant doubles, K emf , R, and L, and one control, Theta dot.Make sure each of these are set to double precision. Your block diagram should nowlook similar to Figure 8.

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    9/22

    9/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Figure 8

    Step 6 Next, right-click to bring up the functions palette, then select Control Design andSimulation Simulation Signal Arithmetic Multiplication (Figure 9). Placetwo multiplication blocks next to the controls and constants you have created. Then, wire theinputs from Theta dot and K emf into the terminals of one block. Wire R into themultiplication terminal of the other block (Figure 10).

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    10/22

    10/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Figure 9 Figure 10

    Next, add an addition block (Found under Control Design and Simulation Simulation Simulation Arithmetic). Double-click on this block to open its

    properties window. Change the icon shape to Rectangle then click on each of the inputsigns to change them to +, -, - as shown in Figure 11.

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    11/22

    11/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Figure 11

    Next, wire the output from Vapp into the + input of the addition block, wire thenwire the outputs from the two multiplication blocks into each of the - inputs. Next, addanother multiplication block and change its terminals to x and by double-clickingto bring up the configuration window. Connect the output of the addition block to thex input and connect L to the input as shown in Figure 12.

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    12/22

    12/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Figure 12

    Next, right-click on the output of the latest multiplication block and select Create Indicator. Re-label this block di/dt. We have now completed the basic blockdiagram for the electrical portion of our system. We will now add an integrator block tocompute the value of I(t). To do this, open the functions palette and select ControlDesign and Simulation Simulation Continuous Linear Systems

    Integrator Wire the input to this block to the output of the last multiplication block (towhich our di/dt indicator is now connected.)

    Now, right-click on the output of the integrator block and create a second indicator. Re-label this indicator I. Also connect the integrator output to the empty terminal on thefirst multiplication block, as shown in Figure 13.

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    13/22

    13/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Figure 13

    Next, we will want to encapsulate all that we have created thus far in order to reduce thecomplexity of the block diagram. To do this, select all of the blocks that we have placedinside the simulation loop by clicking and dragging a box around them. Then, selectEdit Create Simulation Subsystem (Figure 14).

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    14/22

    14/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Figure 14

    The selected blocks have now been incorporated into a separate VI, as shown in Figure15. So that we can easily see our inputs and outputs, right-click the subsystem and selectIcon Style Text Only.

    You may now want to start cleaning up your VI by neatly arranging wires and blocks. At

    any time, you may right-click on a wire and select Clean Up Wire. LabVIEW thenselects an optimal route for the wire to run. If you have loose/broken wires and you needto quickly remove, press Ctrl+B and LabVIEW automatically removes them.

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    15/22

    15/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Figure 15

    Step 7 Now we will begin to diagram the equations for the mechanical portion of the system. To dothis, first add three three constant doubles, three multiplication blocks, and one addition

    block. The three constants will be Kt, B and J. Wire them according to the equationgiven above, as shown in Figure 16.

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    16/22

    16/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Figure 16

    Next, add another integrator block (found under Control Design and Simulation Simulation Continuous Linear Systems), and connect it to the output of the finalmultiplication block. You should also right-click on this output and select Create Indicator. Next, delete the Theta dot control we created earlier. Connect in its place theoutput from the integrator, as shown in Figure 17.

    Finally, select the mechanical system blocks (Figure 17), and select Edit CreateSimulation Subsystem to create our mechanical subsystem.

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    17/22

    17/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Figure 17

    At any time, you can edit the contents of a subsystem by right-clicking and selectingOpen Subsystem. Do this now. You will notice that the output indicator connected tothe integrator has been labeled output change this to read omega then save andclose the subsystem (Figure 18)

    Figure 18

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    18/22

    18/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Figure 19

    1. At this point your block diagram should look similar to that of Figure 19. We will nowadd the necessary blocks to graph I(t) and omega. To do this, we will add the SimTimeWaveform block set. Right-click to open the functions palette then navigate to ControlDesign and Simulation Simulation Graph Utilities. Select the SimTimeWaveform blocks and place them on the block diagram. Click and drag a box around

    both to select them, then while holding the control key, click and drag to create copies of both blocks. Now, connect the I and omega outputs to the inputs of the SimTimeWaveform blocks (Figure 20).

    Note that holding the control key while dragging any block will create a copy of thatblock wherever you release your cursor.

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    19/22

    19/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Figure 20

    2. Now switch back to the front panel by pressing Ctrl+E. You will notice two graphwindows, one input, and one output. Take a moment to organize the front panel. Next,we will replace the default numeric control, Vapp, with a numeric slider. Right-clickthe control and select Replace Vertical Pointer Slide (Figure 21). Once that isdone, right-click the slider and select Visible Items Digital Display. This willallow us to key in a precise value.

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    20/22

    20/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Figure 21

    3. Before running the VI, we need to adjust the simulation parameters. Switch back to the block diagram, then right-click on the simulation loop border and select ConfigureSimulation Parameters. Change the Final time to 0.1 seconds, ODE Solver to Runge-Kutta 1 (Euler), and Step Size to 0.00001 seconds as shown in Figure 22. Then, click

    OK.

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    21/22

    21/22

    RPI Mechatronicshttp://mechatronics.rpi.edu

    Figure 22

    4. Before running the completed VI, you may wish to adjust the settings for the two graphs.Switch back to the front panel, then right-click on the graphs and select Chart HistoryLength. Enter 50000 for this value.

    Note: The Chart History Length is the number of waveforms the chart will keep inmemory. If this value is too small the chart will erase the oldest values.

    Next, right-click the graphs and select Properties (Figure 23). Under the Format andPrecision tab, you can adjust the number of digits which appear on the x and y axes.Clock OK when you are finished adjusting these values. You may also want to changethe range for the x-axis. To do this, double-click the final value and change it to 0.10.Also change the y-axis on the I(t) plot to range from 0 to 5, and the y-axis on the omega

    plot to range from 0 to 150. You will also want to uncheck Autoscale Y Axis. Finally,click the Run button (or press Ctrl+R) to view the simulation results (Figure 24).

  • 8/11/2019 LabVIEW Simulation Tutorial - Brushed DC Motor

    22/22

    22/22

    RPI Mechatronics

    Figure 23

    Figure 24