Getting Started with NI SoftMotion™ for SolidWorks This tutorial demonstrates how to set up and design motion simulations using NI SoftMotion for SolidWorks. You will use the LabVIEW Project to connect to a preconfigured SolidWorks motion study, create and configure NI SoftMotion axes for the motors in the SolidWorks assembly, and use NI SoftMotion Express VIs to create a trajectory for the SolidWorks simulation. Tip If you encounter any problems, refer to the Tips and Troubleshooting section for assistance. This document covers how to use NI SoftMotion Express VIs with your existing SolidWorks assemblies to create and evaluate motion profiles for your system. For information about using SolidWorks refer to the SolidWorks documentation. Contents Required Components .............................................................................................................. 2 Required Software ............................................................................................................ 2 Optional Hardware and Software ..................................................................................... 2 Related Documentation .................................................................................................... 3 Overview of NI SoftMotion for SolidWorks............................................................................ 3 Step 1: Setting Up the LabVIEW Project ................................................................................. 5 Creating the LabVIEW Project File ................................................................................. 6 Adding the SolidWorks Assembly to the Project ............................................................. 6 Adding Axes to the Project............................................................................................... 8 Adding Coordinates to the Project.................................................................................... 9 Step 2: Configuring the Axes ................................................................................................... 12 Step 3: Creating a Motion Profile and Running the Simulation............................................... 13 Creating a Move Profile ................................................................................................... 13 Deploying, Running, and Stopping the Simulation.......................................................... 14 Step 4: Deploying to Hardware (Optional)............................................................................... 15 Tips and Troubleshooting ......................................................................................................... 17 Receive Error -77095........................................................................................................ 17 Simulation Appears Jittery ............................................................................................... 17 Worldwide Support and Services ............................................................................................. 18 Required Components This section lists the software used in the tutorial. This section also lists documents you may find helpful while completing the tutorial. Required Software The following software is required for this tutorial: LabVIEW 2011 (32-bit) or later LabVIEW NI SoftMotion Module Standard 2011 or later SolidWorks 2009 Service Pack 2.1 or later and SolidWorks Motion Simulation with the SolidWorks Motion add-in enabled from the Tools»Add-ins menu in SolidWorks. This is included with SolidWorks Premium, Simulation Premium, or Simulation Professional. When you enable the SolidWorks Motion add-in from the Add-Ins dialog box in SolidWorks, place a checkmark in both the left and right checkboxes. This automatically enables the SolidWorks Motion add-in when SolidWorks launches. Tip You can download a free trial of the required National Instruments software from ni.com/ labview/family. Optional Hardware and Software The following additional hardware and software is required to complete the Step 4: Deploying to Hardware (Optional) section of this tutorial: Software – LabVIEW Real-Time Module 2011 or later – NI-RIO 4.0.0 or later Hardware – NI real-time controller • CompactRIO controller and chassis that support the RIO Scan Interface Tip To determine if your controller and chassis support the RIO Scan Interface go to ni.com/info and enter the Info Code rdsoftwareversion. or • NI 9144 distributed chassis and compatible RT controller – Two NI 9512 single-axis stepper drive interface modules – Power supply for the controller – A separate power supply for the modules – Ethernet connection and cable 2 | ni.com | Getting Started with NI SoftMotion for SolidWorks Tip Even if you do not have the hardware used in this tutorial, you can follow the steps and perform offline configuration to learn concepts about using CompactRIO with LabVIEW. Related Documentation The following documents contain information that you may find helpful as you read this tutorial: • Getting Started with NI 951x C Series Modules and LabVIEW—Use this document to learn about using the NI 951x modules with LabVIEW, including information about the LabVIEW NI SoftMotion Module. To access this document, select Start»All Programs» National Instruments»LabVIEW»LabVIEW Manuals»Getting_Started_NI_951x_ Modules_LabVIEW.pdf. • LabVIEW NI SoftMotion Module Help—Use this help file to learn about using NI SoftMotion in LabVIEW including information about NI SoftMotion VIs and functions and using NI SoftMotion with the LabVIEW Project. To access this help file from LabVIEW, select Help»LabVIEW Help, then expand the NI SoftMotion Module book on the Contents tab. • LabVIEW Help—Use the LabVIEW Help to access information about LabVIEW programming concepts, step-by-step instructions for using LabVIEW, and reference information about LabVIEW VIs, functions, palettes, menus, tools, properties, methods, events, dialog boxes, and so on. The LabVIEW Help also lists the LabVIEW documentation resources available from National Instruments. Access the LabVIEW Help by selecting Help»LabVIEW Help. • Getting Started with LabVIEW—Use this document as a tutorial to familiarize yourself with the LabVIEW graphical programming environment and the basic LabVIEW features you use to build data acquisition and instrument control applications. Access the Getting Started with LabVIEW PDF by selecting Start»All Programs»National Instruments» LabVIEW»LabVIEW Manuals»LV_Getting_Started.pdf. • SolidWorks Help Note Refer to the software documentation for installation information. Overview of NI SoftMotion for SolidWorks Using NI SoftMotion with SolidWorks to simulate your system with actual motion profiles allows you to simulate mechanical dynamics, including mass and friction effects, cycle times, and individual component performance before specifying a single physical part and connecting it to an actual control algorithm. Digital prototyping offers the ability to visualize and optimize the design and evaluate different design concepts before incurring the cost of physical prototypes. Integrating motion simulation with CAD simplifies design because the simulation uses information that already exists in the CAD model, such as assembly mates, couplings, and material mass properties. The NI SoftMotion Module provides easy to use APIs for programming the motion control system for users with little or no motion control programming experience. Getting Started with NI SoftMotion for SolidWorks | © National Instruments | 3 Typical applications for the LabVIEW NI SoftMotion Module with NI SoftMotion for SolidWorks include the following: • Motion trajectory design—You can build complex motion profiles containing a series of sequential or concurrent move operations composed of multi-axis straight-line moves, contoured moves, arc moves, and even complex moves using electronic gearing and camming. • Visualization—By animating your 3D SolidWorks assembly using the motion control profiles and timing/sequencing logic you have designed in LabVIEW, you can quickly evaluate the feasibility of the overall conceptual design for your machine. Visualizing the working machine as a virtual prototype helps to validate the overall conceptual design for the machine very early in the development. This fosters better communication with customers and between design team members and helps to close the loop on the design requirements, must-have features, and engineering trade-offs. • Collision detection—The collision detection feature in SolidWorks enables you to validate your motion profile designs using your actual 3D CAD model. You can check for interferences, evaluate the need for interlock control logic to prevent collisions, optimize your motion profiles to minimize unnecessary dead time, quickly evaluate what-if scenarios, and safely test new control system logic without the risk of damaging your physical machine. After your machine has been designed, prototyped and deployed to the field, collision detection can also be used to validate new motion profiles before downloading them to machines operating at your customer site, reducing the risk of unplanned downtime due to programming mistakes. • Throughput time studies—By validating your motion system design using a simulation that includes the actual motion profile constraints and the mechanical dynamics of your machine such as mass and friction, you can accurately calculate an estimate for the cycle time throughput of your machine. • Motor, drive, and transmission sizing—Motor torque and velocity requirements depend on the acceleration characteristics of your motion profile and the mechanical dynamics of the payload and transmission components such as lead screws. Using NI SoftMotion, you can calculate the required motor torque and velocity charts for your motion profiles. 4 | ni.com | Getting Started with NI SoftMotion for SolidWorks Figure 1 shows how the NI SoftMotion Module works with your SolidWorks assembly, and how you can use the same APIs after simulation to deploy to hardware. Figure 1. NI SoftMotion Module with SolidWorks and Hardware LabVIEW Real-Time Module Non Real-Time Host HMI and Axis Settings: LabVIEW Project NI SoftMotion Motion Manager Supervisory Control Trajectory Generator User VI Axis Interface CompactRIO with NI Scan Engine NI SoftMotion APIs NI 951x cRIO Axis Communication Module cRIO Chassis NI 951x C Series Module(s) LabVIEW/ SolidWorks Co-Simulation EtherCAT Chassis with NI Scan Engine Motion Manager Supervisory Control Trajectory Generator Axis Data SolidWorks Axis Communication Module NI 951x EtherCAT Axis Communication Module EtherCAT C Series Chassis NI 951x C Series Module(s) EtherCAT Drive with NI Scan Engine EtherCAT Drive Communication Module EtherCAT Drive SolidWorks Assembly Step 1: Setting Up the LabVIEW Project Before you can start designing motion profiles for your SolidWorks simulation, you need to import the information from your SolidWorks assembly into the LabVIEW Project and create NI SoftMotion axes for the simulated motors included in your assembly. Refer to the Working with SolidWorks Assemblies topic in the NI SoftMotion Module book of the LabVIEW Help for a list of caveats and recommendations to consider when creating and using SolidWorks assemblies with the NI SoftMotion Module. Tip Getting Started with NI SoftMotion for SolidWorks | © National Instruments | 5 Creating the LabVIEW Project File Complete the following steps to create the LabVIEW Project. Depending on which version of LabVIEW you are using the steps are slightly different. Creating a Project in LabVIEW 2012 1. Launch LabVIEW. 2. Select File»Create Project or Project»Create Project to display the Create Project dialog box. You can also click the Create Project button on the Getting Started window. The Create Project dialog box includes a list of templates and sample projects you can use to ensure that the project you create uses reliable designs and programming practices. 3. Select Blank Project from the list of templates. 4. Click Finish. 5. Select Help and make sure that Show Context Help is checked. You can refer to the context help throughout the tutorial for information about items on the block diagram. Creating a Project in LabVIEW 2011 SP1 or Earlier 1. Launch LabVIEW. 2. Select File»New Project or Project»New Project to display the Create Project dialog box. You can also click the Empty Project link on the Getting Started window. 3. Select Help and make sure that Show Context Help is checked. You can refer to the context help throughout the tutorial for information about items on the block diagram. Adding the SolidWorks Assembly to the Project Complete the following steps to add the SolidWorks assembly to the LabVIEW Project: 1. Launch SolidWorks and open the Sorting Machine.SLDASM file from the <labview>\examples\motion\SolidWorks\SolidWorks Files directory. This model simulates an assembly that takes test tubes from one location and moves them to another. Verify that the SolidWorks Motion add-in available from the Tools»Add-ins menu in SolidWorks contains a checkmark in both the left and right checkboxes. This automatically enables the SolidWorks Motion add-in when SolidWorks launches. Note This tutorial focuses on using an arc move to transport the test tubes to a rotary table. At this point, the assembly and motion study must be ready to simulate with all the constraints and motors properly configured. Refer to the SolidWorks Help for more information about setting up a SolidWorks assembly. Use the NI Example Finder, available in LabVIEW at Help»Find Examples to find additional examples using NI SoftMotion for SolidWorks. Tip 6 | ni.com | Getting Started with NI SoftMotion for SolidWorks 2. Right-click My Computer in the Project Explorer window and select New»SolidWorks Assembly from the shortcut menu to open the Import SolidWorks Motors from Assembly File dialog box. 3. Select the SolidWorks assembly to add to the LabVIEW project. If a SolidWorks assembly is currently open, the Import SolidWorks Motors from Assembly File dialog box contains the path of this assembly. Click Browse to select a different assembly file if necessary. 4. Click OK. The selected SolidWorks assembly is added to the Project Explorer window, including all motors contained in the SolidWorks motion study. Note If the SolidWorks assembly contains multiple motion studies, choose the motion study to add to the project using the Select Motion Study dialog box. To change the motion study used in the project after adding the assembly, right-click the SolidWorks assembly item in the project tree and select Change Motion Study from the shortcut menu. The following figure shows the Project Explorer window with a SolidWorks assembly added. Figure 2. SolidWorks Assembly in the LabVIEW Project Getting Started with NI SoftMotion for SolidWorks | © National Instruments | 7 5. Right-click the SolidWorks assembly in the Project Explorer window and select Properties from the shortcut menu to open the Assembly Properties dialog box. In the Data Logging Properties section, specify a name for the log file and place a checkmark in the Log Data checkbox. This will log position, velocity, acceleration, and torque data for the simulation to the specified file name in LabVIEW Measurement (.lvm) format. Note Each simulation overwrites the selected log file. To create a new log file for the next simulation you must change the file name before starting the simulation. Adding Axes to the Project To simulate using the SolidWorks motors included in the model, you need to associate the motors with NI SoftMotion axes. The NI SoftMotion axes are used when creating motion profiles using NI SoftMotion VIs and functions. Complete the following steps to add NI SoftMotion axes to the project: 1. Right-click My Computer in the Project Explorer window and select New» NI SoftMotion Axis from the shortcut menu to open the Axis Manager dialog box, shown in Figure 3. Figure 3. Axis Manager Dialog Box 2. Select Add New Axis. The new axis automatically binds to an available SolidWorks motor. Ensure that Axis 1 is associated with the X-Axis motor, and if it is not, double-click the name in the Bound Hardware column and select the correct motor. 3. Complete steps 1 through 2 for each additional axis. When you are finished, the Axis Manager dialog box will look similar to Figure 3. 4. (optional) Double-click the axis name to rename the axis and give it a descriptive name. 8 | ni.com | Getting Started with NI SoftMotion for SolidWorks 5. Click OK. All axes are added to the Project Explorer window as shown in the following figure. Figure 4. Project Explorer Window with a SolidWorks Assembly and NI SoftMotion Axes Adding Coordinates to the Project NI SoftMotion axes can be grouped into coordinate spaces so that you can perform coordinated moves using multiple axes simultaneously. The coordinate spaces are used as inputs to your motion applications when performing coordinate moves. Complete the following steps to add a coordinate space to the project: 1. Right-click My Computer in the Project Explorer window and select New» NI SoftMotion Coordinate Space from the shortcut menu to open the Configure Coordinate Space dialog box, shown in Figure 5. 2. Move Axis 1 and Axis 2 from the Available Axes column to the Coordinate Axes column using the arrow. Double-click the coordinate space name to rename the coordinate space and give it a descriptive name. Getting Started with NI SoftMotion for SolidWorks | © National Instruments | 9 Figure 5. Configure Coordinate Space Dialog Box Note When using coordinate resources, target position and other information is contained in a one-dimensional array with axis information provided in the order that axes are added using this dialog box. Refer to the NI SoftMotion Module book of the LabVIEW Help for more information. 3. Click OK to close the Configure Coordinate Space dialog box and add the new coordinate space to the LabVIEW Project. 10 | ni.com | Getting Started with NI SoftMotion for SolidWorks Your project is now set up with the axes and coordinate spaces you will use in the application. Your LabVIEW project should look similar to Figure 6. Figure 6. LabVIEW Project With NI SoftMotion Axes and Coordinates Getting Started with NI SoftMotion for SolidWorks | © National Instruments | 11 Step 2: Configuring the Axes Axes associated with SolidWorks motors are assumed to be servo motors. Since the axes are not associated with actual hardware, you only need to perform minimal configuration to get started. Once you set up your simulation, you can change configuration settings on the axes for easy deployment to the final hardware using the profiles you create. Complete the following steps to configure the axes for use in your simulation: 1. Right-click the axis in the Project Explorer window and select Properties from the shortcut menu to open the Axis Configuration dialog box. Figure 7 shows the parts of the Axis Configuration dialog box for SolidWorks axes. Refer to the NI SoftMotion Module book of the LabVIEW Help for detailed information about each configuration option. Figure 7. Axis Configuration Dialog Box for NI SoftMotion SolidWorks Axes Note The Axis Configuration dialog box user interface may not match this image exactly depending on which version of the LabVIEW NI SoftMotion Module you are using. 2. On the General Settings page ( ) confirm that the Axis Enabled and Enable Drive on Transition to Active Mode checkboxes contain checkmarks. This automatically activates all axes when the NI Scan Engine switches to Active mode. Tip You can also use Power to activate and enable axes. 3. Click OK to close the Axis Configuration dialog box. 4. Complete steps 1 through 3 for each remaining axis. 12 | ni.com | Getting Started with NI SoftMotion for SolidWorks Step 3: Creating a Motion Profile and Running the Simulation You create motion profiles for simulation with the SolidWorks assembly using the NI SoftMotion VIs and function on the NI SoftMotion palette. The NI SoftMotion Module offers Express VIs, properties and methods, and function blocks that allow you to perform straight-line moves, arc moves, contoured moves, gearing and camming operations, and read status and data information. Refer to the NI SoftMotion Module book of the LabVIEW Help for more information about using the NI SoftMotion VIs and functions. If you are new to LabVIEW, refer to Getting Started with LabVIEW, at Start» All Programs»National Instruments»LabVIEW»LabVIEW Manuals, for more information about creating, editing, and using LabVIEW VIs. Note Creating a Move Profile This example uses an existing NI SoftMotion Arc Express VI example with an NI SoftMotion coordinate resource to perform a circular arc move to deliver the test tube. Tip The NI SoftMotion palette is not visible by default. Refer to the Showing and Hiding Palette Categories topic in the LabVIEW Help for information about editing the palette view to make the NI SoftMotion VIs and functions more accessible. Complete the following steps to modify an existing example VI for your project: 1. Right-click the My Computer project tree item and select Add»File from the shortcut menu. 2. Navigate to the <LabVIEW>\examples\motion\ExpressVIs\Circular Arc Move folder and select the Circular Arc Move.vi file. 3. Open the VI from the project. 4. Navigate to the front panel and change the arc move parameters from the default values to the following: • radius: 50 • start angle: 180 • travel angle: 180 5. Keep the value for velocity at the default for now. You can change the velocity and run the simulation again to see how changes to the move constraints impact the system. 6. Save the VI. 7. Save the project. Getting Started with NI SoftMotion for SolidWorks | © National Instruments | 13 Figure 8 shows the Circular Arc Express VI example block diagram. Figure 8. NI SoftMotion Circular Arc Express VI Example 1 2 3 1 2 3 Arc Move Express VI. Read loop, for reporting axis status and data information. Stop loop, to allow user to stop the move while in progress. Deploying, Running, and Stopping the Simulation Complete the following steps to deploy and run the VI and start the SolidWorks simulation: 1. Right-click My Computer in the Project Explorer window and select Properties to display the My Computer Properties dialog box. 2. Select Scan Engine from the Category list and place a checkmark in the Start Scan Engine on Deploy checkbox. 3. Click OK to close the My Computer Properties dialog box. 4. Select the axes and coordinate items in the Project Explorer window, right-click and select Deploy from the shortcut menu. LabVIEW deploys all associated I/O resources and settings the VI uses. 5. Click Apply in the Conflict Resolution dialog box, if it appears. 6. Right-click My Computer in the Project Explorer window and select Utilities»Scan Engine Mode»Switch to Active to verify that the NI Scan Engine is in Active mode. If the Switch to Active option is disabled in the shortcut menu the NI Scan Engine is already in Active mode. 14 | ni.com | Getting Started with NI SoftMotion for SolidWorks 7. Right-click the SolidWorks assembly and select Start Simulation to start the SolidWorks simulation. 8. Run the VI. LabVIEW acts on the SolidWorks assembly using the move profile you created. 9. Right-click the SolidWorks assembly in the Project Explorer window and select Stop Simulation to stop the SolidWorks simulation. 10. Save the SolidWorks model, LabVIEW Project, and LabVIEW VI you created to apply any changes made. Step 4: Deploying to Hardware (Optional) In this section you will deploy the code written using the SolidWorks assembly to a CompactRIO system containing two NI 9512 C Series stepper drive interface modules. Complete the following steps to run your simulation code on an actual hardware target: Tip Refer to the Getting Started with NI 951x Modules and LabVIEW document, installed at labview\manuals, for detailed instructions for steps 1 through 3. 1. Add the RT target containing the NI 9512 C Series modules to the project. 2. Create an NI SoftMotion axis for each module, then add them to a coordinate space. Note You can also drag the axes created in the Adding Axes to the Project section of this document under the RT target and remap them to the NI 9512 modules using the Axis Manager dialog box. All configuration options you selected previously are maintained. 3. Configure the axes: a. Right-click the axis in the Project Explorer window and select Properties from the shortcut menu to open the Axis Configuration dialog box. b. On the General Settings page ( ), confirm that Loop Mode is set to Open-Loop. Axes configured in open-loop mode produce step output but do not require feedback from the motor to verify position. c. Also on the General Settings page, confirm that the Axis Enabled and Enable Drive on Transition to Active Mode checkboxes contain checkmarks. Note Disable these options to prevent axes from automatically activating when the NI Scan Engine switches to Active mode. d. If the modules do not have physical limit and home input connections, you must disable these input signals for proper system operation. To disable limits and home, go to the Limits & Home page ( ) and remove the checkmarks from the Enable checkboxes in the Forward Limit, Reverse Limit, and Home Switch sections. e. Configure any additional I/O settings according to your system requirements. Getting Started with NI SoftMotion for SolidWorks | © National Instruments | 15 Make sure that the units and scaling configured for Steps Per Unit on the Stepper page (if applicable) and Counts Per Unit on the Encoder page match your motion system requirements. Refer to the NI SoftMotion Module book of the LabVIEW Help for more information. Note 4. f. Click OK to close the Axis Configuration dialog box. g. Repeat steps a through f for Axis 2. Drag the VI from under the SolidWorks assembly project item to the cRIO target and update the resource associations to use the axes associated with the NI 9512 modules rather than the SolidWorks motors. Make sure all hardware connections are made and power is turned on before deploying the project. Deployment switches the NI Scan Engine to Active mode and enables your axes and drive, if connected, so that you can start a move immediately. Refer to the Deploying and Running VIs on an RT Target topic in the LabVIEW Help for more information about deployment and deployment troubleshooting tips. Caution 5. Right-click the controller item in the Project Explorer window and select Deploy All from the shortcut menu to deploy the axes, coordinate, and axis settings to the RT target. 6. Run the VI. The VI and all associated resources are deployed to the hardware target. 16 | ni.com | Getting Started with NI SoftMotion for SolidWorks Tips and Troubleshooting Receive Error -77095 (NIMCDM_solidworksMotionStudyTypeNotSupportedError) Verify that the SolidWorks Motion add-in is enabled from the Tools»Add-ins menu in SolidWorks and that there is a checkmark in both the left and right checkboxes. This automatically enables the SolidWorks Motion add-in when SolidWorks launches. If the SolidWorks Motion add-in is already enabled, also verify that the motion study type is set to Motion Analysis. Figure 9 shows the location of the motion study type dropdown list. Figure 9. Motion Study Type Selection Simulation Appears Jittery During simulation, motion on the axes appears jittery. This is a normal result of the memory-intensive simulation process and the fact that simulation time is not the same as actual time. When the simulation is played back, the timing is reflective of real-world time and the jitter disappears. Getting Started with NI SoftMotion for SolidWorks | © National Instruments | 17 Worldwide Support and Services The National Instruments Web site is your complete resource for technical support. At ni.com/support you have access to everything from troubleshooting and application development self-help resources to email and phone assistance from NI Application Engineers. Visit ni.com/services for NI Factory Installation Services, repairs, extended warranty, calibration, and other services. Visit ni.com/register to register your National Instruments product. Product registration facilitates technical support and ensures that you receive important information updates from NI. A Declaration of Conformity (DoC) is our claim of compliance with the Council of the European Communities using the manufacturer’s declaration of conformity. This system affords the user protection for electromagnetic compatibility (EMC) and product safety. You can obtain the DoC for your product by visiting ni.com/certification. If your product supports calibration, you can obtain the calibration certificate for your product at ni.com/calibration. National Instruments corporate headquarters is located at 11500 North Mopac Expressway, Austin, Texas, 78759-3504. National Instruments also has offices located around the world to help address your support needs. For telephone support in the United States, create your service request at ni.com/support and follow the calling instructions or dial 512 795 8248. For telephone support outside the United States, visit the Worldwide Offices section of ni.com/ niglobal to access the branch office Web sites, which provide up-to-date contact information, support phone numbers, email addresses, and current events. LabVIEW, National Instruments, NI, ni.com, the National Instruments corporate logo, and the Eagle logo are trademarks of National Instruments Corporation. Refer to the Trademark Information at ni.com/trademarks for other National Instruments trademarks. Other product and company names mentioned herein are trademarks or trade names of their respective companies. For patents covering National Instruments products/technology, refer to the appropriate location: Help»Patents in your software, the patents.txt file on your media, or the National Instruments Patents Notice at ni.com/patents. You can find information about end-user license agreements (EULAs) and third-party legal notices in the NI Softmotion Readme. Refer to the Export Compliance Information at ni.com/legal/export-compliance for the National Instruments global trade compliance policy and how to obtain relevant HTS codes, ECCNs, and other import/export data. © 2009–2012 National Instruments. All rights reserved. 372876E-01 Aug12