The following software is required for this tutorial.
• LabVIEW 2009 (32-bit) or later
• LabVIEW NI SoftMotion Module Standard or Premium
• SolidWorks 2009 Service Pack 2.1 or later and SolidWorks Motion Simulation with the Motion Simulation add-in enabled from the Tools menu in SolidWorks. This is included with SolidWorks Premium, Simulation Premium, or Simulation Professional. When you enable the Motion Simulation add-in from the Add-Ins dialog box in SolidWorks, place a checkmark in both the left and right checkboxes so you don’t have to reenable the add-in each time you use NI SoftMotion for SolidWorks. You can download a free 7-day trial of the required National Instruments software from ni.com/labview/family.
The following additional hardware and software is required to complete the "Step 4: Deploying to Hardware (Optional)" section of this tutorial:
• LabVIEW Real-Time Module 2009 or later
• NI-RIO 3.2.0 or later
• NI CompactRIO controller and chassis that support the RIO Scan Interface or• NI 9144 distributed chassis
• Two NI 9512 single-axis stepper drive interfaces
• Power supply for the controller
• A separate power supply for the modules
• Ethernet connection and cable
Even if you do not have the hardware used in this tutorial, you can follow the steps and perform offline configuration to learn about using CompactRIO with LabVIEW.
By using NI SoftMotion with SolidWorks to simulate your system with actual motion profiles, you can 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. Virtual prototyping (also known as digital prototyping) offers you 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. LabVIEW provides an easy-to-use, high-level function block programming language for programming the motion control system that is simple enough for users with little or no previous motion control programming experience. 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 multiaxis 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 — With the collision detection feature in SolidWorks, you can 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 you have designed, prototyped, and deployed your machine to the field, you can also use collision detection to validate new motion profiles before downloading them to machines operating at your customer site. This reduces 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 for SolidWorks, you can calculate the required motor torque and velocity charts for your motion profiles.
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.
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. Upon opening the model, navigate to Options»Add-ins and ensure that the SolidWorks Motion and SolidWorks Simulation add-ins are active. Next, select the Motion Study 1 tab in the lower left corner and ensure that the Motion Study type pull-down is set to Motion Analysis, as shown in Figure 1.
Figure 1. SolidWorks Motion Study Setup
This model simulates an assembly that takes test tubes from one location and moves them to another and the tutorial focuses on using an arc move to move 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.
2. Open an empty LabVIEW Project and right-click the My Computer item in the LabVIEW 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 Axes 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.
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. Figure 1 shows the Project Explorer window with a SolidWorks assembly added:
Figure 2. SolidWorks Assembly in the LabVIEW Project
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 and select OK. This logs position, velocity, acceleration, and torque data for the simulation to the specified file name in LabVIEW Measurement (.lvm) format.
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.
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 with the NI SoftMotion function blocks. Complete the following steps to add NI SoftMotion axes to the project:
1. Right-click the My Computer item in the Project Explorer window and select New»NI SoftMotion Axis from the shortcut menu to open the Axis Manager dialog box.
2. Select Add New Axis. The new axis automatically binds to an available SolidWorks motor.
Figure 3. Axis Manager Dialog Box
3. Click Add New Axis until all available SolidWorks motors are associated with NI SoftMotion axes.
4. Double-click the Axis Name of each axis to rename the axis more descriptively (e.g., Conveyor, Rotary Table, X Axis, Y Axis).
5. Click OK. All axes are added to the Project Explorer window as shown in Figure 4.
Figure 4. Project Explorer Window with a SolidWorks Assembly and NI SoftMotion Axes
You can group NI SoftMotion axes into coordinate spaces so that you can perform coordinated moves using multiple axes simultaneously. Use the coordinate spaces 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 4.
2. Move X Axis and Y Axis from the Available Axes column to the Coordinate Axes column using the arrow as shown in Figure 5. If desired, double-click the coordinate space name to rename the coordinate space and give it a descriptive name.
Figure 5. Configure Coordinate Space Dialog Box
3. Click OK to close the Configure Coordinate Space dialog box and add the new coordinate space to the LabVIEW project. Your project is now set up with the axes and coordinate spaces you need for the application. Your LabVIEW project should look similar to Figure 6.
Figure 6. LabVIEW Project with NI SoftMotion Axes and Coordinates
When using coordinate resources, target position and other information are contained in a 1D array with axis information provided in the order that axes are added using this dialog box.
Axes associated with SolidWorks motors are assumed to be servo motors. Because the axes are not associated with actual hardware, you need to perform only minimal configuration to get started. Once you have 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 for the X Axis and Y Axis 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 6 shows the parts of the Axis Configuration dialog box for SolidWorks axes. Items that are not applicable to your configuration are greyed out.
Figure 7. Axis Configuration Dialog Box for NI SoftMotion for SolidWorks Axes
2. On the Axis Configuration 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. (You can also use the Power function block in your VI to activate and enable axes.)
3. Click OK to close the Axis Configuration dialog box. Make sure to perform steps 1-3 for both the X Axis and Y Axis SoftMotion Axes.
You create motion profiles for simulation with the SolidWorks assembly using the NI SoftMotion function blocks on the NI SoftMotion»Advanced»Function Blocks palette. With these function blocks, you can perform straight-line moves, arc moves, contoured moves, gearing and camming operations, and read status and data information.
A Timed Loop synchronized to the NI Scan Engine allows your time-sensitive motion applications to execute at the scan rate. Any code placed inside a Timed Loop is guaranteed to execute once per scan period or at an interval you specify. You should minimize memory allocations in Timed Loops to avoid introducing jitter into the system. NI SoftMotion function blocks are typically used on hardware running a real-time OS to create deterministic motion control applications using the function block programming paradigm. When you use NI SoftMotion function blocks on Windows with a SolidWorks simulation, the timing of the NI Scan Engine is not guaranteed.
If your code does not need to run at the scan rate, you can use a while loop with a Wait Until Next ms Multiple function to control the loop rate. Complete the following steps to configure the Timed Loop:
1. Right-click My Computer and select New»VI from the shortcut menu to open a blank VI.
2. Place a Timed Loop on the block diagram of the VI. The Timed Loop is located on the Timed Structures palette.
3. Double-click the Input Node of the Timed Loop to open the Configure Timed Loop dialog box.
4. Under Loop Timing Source, for Source Type, select Synchronize to Scan Engine. You can click the Help button for information about synchronizing to the NI Scan Engine. The Configure Timed Loop dialog box should look similar to Figure 8.
Figure 8. Configuring the Timed Loop
5. Click OK.
This example uses the NI SoftMotion Arc function block with the NI SoftMotion coordinate resource to perform a circular arc move to move the test tube.
Complete the following steps to set up the arc move:
1. Place an Arc Move function block from the SoftMotion Function Blocks palette inside the Timed Loop.
2. Right-click the execute input and select Create»Control from the shortcut menu to add a control to the front panel for this input. Repeat this step for the radius, start angle, travel angle, velocity, and acceleration inputs and select Create»Control from the shortcut menu to add controls to the front panel for each of these inputs.
3. If desired, additional parameters such as deceleration and jerk can be added by double-clicking the Arc Move function block. In the Arc Move Function Block Properties dialog box, select the Visible? check box and set Data source to Terminal for any additional parameters. Click OK to finish the configuration.
4. Right-click the done output and select Create»Indicator from the shortcut menu to add an indicator to the front panel.
5. Drag the Coordinate Space 1 resource from the LabVIEW Project on the block diagram outside the Timed Loop and wire it to the resource input on the function block.
6. Right-click the error out output and select Create»Indicator from the shortcut menu to add an indicator to the front panel.
7. Wire the error out output to the edge of the Timed Loop.
8. Right-click the loop tunnel created for the error out output and select Replace with Shift Register from the shortcut menu. This transfers the error information to the next loop iteration.
9. Wire the error in input of the Arc Move function block to the shift register created on the left side of the Timed Loop.
10. Right-click the shift register and select Create»Constant from the shortcut menu to initialize the error cluster outside the Timed Loop. Because the final hardware uses the LabVIEW Real-Time Module, all function block arrays and clusters are initialized outside the timed loop to prevent jitter in the system.
11. Right-click the Timed Loop conditional terminal and select Create»Control from the shortcut menu to add a Stop button to the front panel. This allows you to stop execution of the VI at any time. Your block diagram should look similar to Figure 9 when you have completed these steps.
Figure 9. Tutorial VI Block Diagram
12. 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
13. Keep the values for velocity and acceleration at the defaults for now. You can change these values and run the simulation again to see how changes to the move constraints impact the system.
14. Save the VI.
15. Save the project.
Deploying the project and running the VI starts the SolidWorks simulation using the move profile you created. Complete the following steps to deploy and run the VI and start the SolidWorks simulation:
1. Right-click the My Computer item 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 My Computer, SolidWorks assembly, 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, switches the NI Scan Engine to Active mode, and starts the SolidWorks simulation. If presented with any conflict resolutions, select Apply. To ensure that your simulation deploys properly always deploy the NI SoftMotion axes and not only the My Computer item.5. Right-click the SolidWorks Assembly in the Project Explorer window and select Synchronize to Assembly...6. Right-click the SolidWorks Assembly in the Project Explorer window and select Start Simulation to begin the motion simulation in SolidWorks7. Run the VI. Pressing your execute control will cause LabVIEW to beginperforming the move profile you created. For subsequent simulations, you may need to manually switch to Active mode by selecting Utilities»Scan Engine Mode»Switch to Active, as the Scan Engine must be in active mode to interface with SolidWorks. 8. To stop you simulation, first stop the VI. Then, right-click the SolidWorks Assembly in the Project Explorer window and select Stop Simulation to stop the motion simulation in SolidWorks.9. Save the SolidWorks model, LabVIEW Project, and LabVIEW VI you created to apply any changes made.
The next step will be to deploy the code written using the SolidWorks assembly to a CompactRIO system containing two NI 9512 C Series stepper drive interfaces. For more information regarding working with C series motion modules in LabVIEW, please see the Getting Started with LabVIEW NI SoftMotion and C Series Drive Interfaces tutorial. Complete the following steps to run your simulation code developed in the previous steps on an actual hardware target:
1. Add the real-time target containing the NI 9512 C Series modules to the project.
2. Create an NI SoftMotion axis for each module, and then add them to a coordinate space.
You can also drag the axes created in the "Adding Axes to the Project" section of this document under the real-time 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 Axis Setup 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 Axis Setup page, confirm that the Axis Enabled and Enable Drive on Transition to Active Mode checkboxes contain checkmarks.
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 Motion I/O page and remove the checkmarks from the Enable checkboxes in the Forward Limit, Reverse Limit, and Home sections.
e. Configure any additional I/O settings according to your system requirements.
Make sure that the units and scaling configured for Steps Per Unit (if applicable) and Counts Per Unit match your motion system requirements. Refer to the LabVIEW NI SoftMotion Module help file for more information.
f. Click OK to close the Axis Configuration dialog box.
g. Repeat steps a through f for Axis 2.
4. Drag the VI created in your SolidWorks project to the CompactRIO target. LabVIEW automatically updates the resource associations to use the axes associated with the NI 9512 modules rather than the SolidWorks motors.
5. Double-click the Input Node of the Timed Loop to open the Configure Timed Loop dialog box. Under Loop Timing Attributes, set the Period to 5 scans. In most cases it is not necessary for the function blocks to run as fast as the scan rate.
6. 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.
7. 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 real-time target.
8. Run the VI. The VI and all associated resources are deployed to the hardware target.
For in-depth training, visit the Virtual Prototyping Training Portal.
Download the full Getting Started guide.
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.