<?xml version="1.0" encoding="utf-8"?>
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" xmlns:q="http://cnx.rice.edu/qml/1.0" id="new" module-id="" cnxml-version="0.6">
  <title>LabVIEW 3D Control Simulation using SolidWorks 3D Models</title>
  <metadata xmlns:md="http://cnx.rice.edu/mdml/0.4">
  <!-- WARNING! The 'metadata' section is read only. Do not edit below.
       Changes to the metadata section in the source will not be saved. -->
  <md:content-id>m12977</md:content-id>
  <md:title>LabVIEW 3D Control Simulation using SolidWorks 3D Models</md:title>
  <md:version>1.4</md:version>
  <md:created>2005/08/09 15:46:02 GMT-5</md:created>
  <md:revised>2009/04/01 10:58:11.817 GMT-5</md:revised>
  <md:authorlist>
    <md:author id="eluther">
        <md:firstname>Erik</md:firstname>
        <md:othername>B</md:othername>
        <md:surname>Luther</md:surname>
        <md:fullname>Erik Luther</md:fullname>
        <md:email>erik.luther@ni.com</md:email>
    </md:author>
  </md:authorlist>
  <md:maintainerlist>
    <md:maintainer id="eluther">
        <md:firstname>Erik</md:firstname>
        <md:othername>B</md:othername>
        <md:surname>Luther</md:surname>
        <md:fullname>Erik Luther</md:fullname>
        <md:email>erik.luther@ni.com</md:email>
    </md:maintainer>
    <md:maintainer id="ewang">
        <md:firstname>Eric</md:firstname>
        <md:surname>Wang</md:surname>
        <md:fullname>Eric Wang</md:fullname>
        <md:email>eric.wang@ni.com</md:email>
    </md:maintainer>
  </md:maintainerlist>
  <md:license href="http://creativecommons.org/licenses/by/2.0/"/>
  <md:licensorlist>
    <md:licensor id="eluther">
        <md:firstname>Erik</md:firstname>
        <md:othername>B</md:othername>
        <md:surname>Luther</md:surname>
        <md:fullname>Erik Luther</md:fullname>
        <md:email>erik.luther@ni.com</md:email>
    </md:licensor>
  </md:licensorlist>
  <md:keywordlist>
    <md:keyword>Labview</md:keyword>
    <md:keyword>National Instruments</md:keyword>
    <md:keyword>Solidworks</md:keyword>
    <md:keyword>Virtual Instrument</md:keyword>
    <md:keyword>VRML</md:keyword>
  </md:keywordlist>
  <md:subjectlist>
    <md:subject>Science and Technology</md:subject>
  </md:subjectlist>
  <md:abstract>Importing a SolidWorks VRML into LabVIEW gives engineers and students the ability to integrate the power of SolidWorks 3D computer aided design with LabVIEW simulation.  It is extremely useful for test and simulation applications that require complex visualization of a 3D model.  To combine 3D visualization with simulation, you can use a combination of LabVIEW, the Simulation Module and the 3D Picture Control Toolkit.</md:abstract>
  <md:language>en</md:language>
  <!-- WARNING! The 'metadata' section is read only. Do not edit above.
       Changes to the metadata section in the source will not be saved. -->
</metadata>
  <content>

<section id="sect1">
      <title>3D Control Simulation in LabVIEW</title>
<para id="element-683">The LabVIEW development environment is an ideal platform for prototyping, designing, and deploying control alogithms.  As part of the prototyping step, 3D simulation can be used to assist in visualizing both the behavior of the plant and the effects of the control algorithm on the control plant.  In this demonstration, the LabVIEW Simulation Module and LabVIEW 3D Picture Control Toolkit are used to simulate the behavior and control of a <link url="http://www.quanser.com">Quanser Linear Inverted Pendulum</link>.
</para>


    <para id="element-230">Download the source code for the <link resource="LIP_Demo.zip">Linear Inverted Pendulum 3D Simulation</link> here.  This VI was created in LabVIEW 8.2 using the <link resource="http://zone.ni.com/devzone/cda/tut/p/id/4411">3D Picture Control Toolit add-on which is not a supported feature.</link>
</para><para id="eip-984"><emphasis>NEW: An updated version of this 3D demo, using the new supported 3D Picture Control, now ships with the Control Design and Simulation Module and can be found using the Example Finder within LabVIEW.</emphasis></para><figure id="element-493"><title>LabVIEW LIP Simulation Front Panel</title>
<media id="id14481959" alt=""><image src="LinearInvPendulum.gif" mime-type="image/gif"/></media>
<caption>Matrix A,B,C, and D define the controller for the simulation.  The Acceration of Gravity and Pendulum Length in centimeters can be cutomized by editing the plant model.  The Array of inital states allow the angle, angular velocity, and linear velocity variables to be defined before the simulation is executed.  The gains K1, K2, and K3 respresent the gain for the controller.</caption></figure>

<figure id="element-728"><title>LabVIEW LIP Simulation Block Diagram</title>
<media id="id14481997" alt=""><image src="LIP-bd.jpg" mime-type="image/jpeg"/></media>
<caption>This simulation utilizes the LabVIEW Simulation Module with the RK1 continuous time solver.  The controller is containined inside the 'Insert Control Code Here' box allowing students to design their own unique controller while the plant model and 3D simulaiton model are preserved.</caption></figure>

<para id="element-454">When downloading this VI, you must have a minimum of LabVIEW 8.0.1 with the LabVIEW Simulation Module installed, as well as the free 3D Picture Control Toolkit.  This 3D simualtion is one of many developed for educational purposes.  Other demonstrations include the 3D helicopter, auto suspension, and 3D rotational inverted pendulum. </para>   
</section>  
<section id="sect2">
      <title>Creating Your Own 3D Simulations</title>

<para id="element-29238">To create LabVIEW simulations using SolidWorks VRML97 export file format, you will need to create a program that contains three VI’s.  The top level VI contains the simulation loop and the state-space matrices information; the first subVI draws and updates the picture in accordance with the simulation parameters; the third and lowest level VI imports and parses the VRML97 file to create objects names and parent/child relationships for each object in your system.</para>

<para id="element-609">For the lowest level VI, you can load WRL files into LabVIEW using the 3D picture control toolkit VI called Read WRL file.vi, which reads a WRL file and creates the data necessary to render the scene into a picture control.  It is located in the Objects Functions Palette.  You can add objects to the system using the Insert Into Array.vi.  The first step needed in the VRML parser subVI is an indexed for loop with an unbundle.vi followed directly by a bundle.vi and you need to manually name each component of the system for reference.  After this is completed, use the Find Object.vi to create object refnums for each object and connect those to a case structure with an identical unbundled/bundle feature to assign parent/child relationships (this allows for the pendulum to move when the base moves and not the other way around).</para>

<para id="element-97">After you have successfully parsed the VRML97 file, the drawObject subVI can take your object array.  Once again use the Find Object.vi to create references for each object you would like move with the movement VI’s such as Translate Object To.vi and Rotate Object To.vi.  The drawObject.vi creates the camera and its controller as well as the light source.  It also performs the scene rendering and scene drawing.</para>

<para id="element-65">The top level VI is responsible for the simulation parameters and equations that describe the system.  The simulation dynamics can be altered on the fly using the CD Create State-Space Model.vi located in the Control Design Toolkit.  This VI allows the user to enter variable formulae into the state-space matrices and then alter the system very quickly by changing the variable values.  Combined with the 3D picture control toolkit, you can witness the visual effects of the variable values on the system immediately.</para>

<para id="element-976">This roughly outlined method describes the basic functions needed to perform a LabVIEW simulation with 3D visualization provided by SolidWorks VRML97 export.  The VRML parsing is only necessary because at the time of this writing, SolidWorks software does not provide object names and parent/child relationships with VRML97 export.
 </para>

</section>


</content>
  
</document>
