Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Hands-On: Develop Powerful Motion Applications with NI CompactRIO and SolidWorks

3 ratings | 4.67 out of 5
Print | PDF

Overview

This tutorial provides a step-by-step training for creating simulated motion control virtual prototypes with NI LabVIEW and SolidWorks. It guides the user through connecting LabVIEW to SolidWorks and creating a motion control application that performs straight line and arc move functions.

Exercise 1: Configuring and Controlling a Motion Axis with NI SoftMotion (20 min)

In this first exercise, you will configure and program a motion axis using the new LabVIEW 2009 NI SoftMotion Module.

1.       Launch LabVIEW either from the taskbar shortcut icon or from Start->All Programs->LabVIEW 2009.

2.       Click Empty Project from the Getting Started launch screen.

3.       Right-click on My Computer and select New » NI SoftMotion Axis. Then click Add New Axis. A new simulated axis is created. Click OK.

 

4.       In the Project Window, right-click on Axis 1 and select Properties to open the Axis Configuration window.


[+] Enlarge Image

5.       Take some time to navigate through the Axis Configuration Interface. Our application requires some changes from the default settings so navigate to the Axis Configuration page and select Enable Drive on Transition to Active Mode.


[+] Enlarge Image

6.       In the LabVIEW project explorer, right-click My Computer and select Properties. Click on Scan Engine and check the box to Start Scan Engine on Deploy. Set the Scan Period to 5 ms, then click OK.


[+] Enlarge Image

7.       In the Project Explorer, select My Computer and Axis 1 (use the Ctrl or Shift key to select multiple items). Then right-click and select Deploy. This loads all of your configuration settings to the Scan Engine.

8.       Right Click on Axis 1 and selectInteractive Test Panel to validate the configuration settings and test an individual axis.

9.       Hit the green Run Button  to spin the simulated motor. Try changing the Target Position and Move Constraints and observe the results.  Explore the different tabs to see additional features of the test panel. When you are done, close the panel.


[+] Enlarge Image

10.   Let’s start developing a Real-Time Motion Application. Within the LabVIEW Project right-click on the My Computer system and select New>>VI.

11.   On the LabVIEW VI block diagram, right-click the white block diagram area to display the functions palette. Then click the arrows () at the bottom of the palette to expand the view.

12.   Next move your mouse over the Vision and Motion palette to expand it. Navigate to the NI SoftMotion Module sub-palette and from there into the Function Blocks palette. Click the thumb-tack () to lock down the palette.

13.   Click the Line function and then click again on a white area of the block diagram to drop it down.

14.   Now you will wire up your Straight Line Move function. First, navigate to the LabVIEW Project Explorer, click Axis 1 and drag it to your block diagram to the left of the resource terminal. Hover your mouse over the right terminal of the Motion Resource icon and note that your mouse changes to the wiring tool (). Left click to begin wiring, then move your mouse over the left edge of the resource terminal and click again to complete the wiring.

15.   Right-click the left edge of the execute terminal, then right click and navigate to Create » Control.

16.   Follow the same approach to create a control for the position and velocity terminals. Then right click the error out and done terminals and select Create » Indicator for those signals as well. When you are finished your block diagram should look similar to that shown below. To keep the diagram tidy, click the Clean Up Diagram Button ().


[+] Enlarge Image

17.   Right click on the Straight-Line Move function and Select Method>>Relative.

18.   Now you will place your Straight-Line Move function inside a Timed Loop Structure to synchronize its execution with the Scan Engine. To do this, right-click an empty part of the block diagram to display the functions palette. Then navigate to Programming » Structures » Timed Structures » Timed Loop.


[+] Enlarge Image

19.   To draw the Timed Loop, click the block diagram to the top-left of the Straight Line Move function. Then click again to the bottom-right of the function

20.   Now right-click the Loop Condition terminal () of the Timed Loop and select Create Control.

21.   Double click the upper left corner of the Timed Loop structure and set the Loop Timing Source to Synchronize to Scan Engine. Then click OK.


[+] Enlarge Image

22.   Right-click the position control and select Replace>Num Ctrls>Pointer Slide. Resize the controls and indicators as desired. Your completed block diagram and front panel should appear similar to the following.


[+] Enlarge Image

23.   Navigate to File » Save and save your VI as “Straight Line Move.vi” on the desktop.

24.   Run () your motion control application. Enter the desired target position and then push the execute button. You can restart the movement by releasing the execute button changing the position setting and pushing the execute button again. When you are finished, save and close the LabVIEW project.


 

Bonus Exercise: Add a Read function and Waveform Chart

 

25.       As an optional bonus, add a SoftMotion Read function to the block diagram and a Waveform Chart to the front panel as shown below. Use a Bundle function from the Cluster, Class & Variant palette to collect the position and velocity of the simulated motor then wire the cluster to the chart.


[+] Enlarge Image

 

Exercise 2: Connect to SolidWorks to create a digital prototype (20 min)

In this exercise, you will open a 3D CAD model of a 3-axis stage designed in SolidWorks and control it using LabVIEW.

1.       Launch SolidWorks from Start->All Programs->SolidWorks 2009->SolidWorks 2009 SP4
->SolidWorks
.

2.       To make sure the SolidWorks Motion is active, navigate to Tools->Add Ins and mark the check boxes on the left and the right.

3.       Open the prebuilt SolidWorks 3D CAD model “Full Assembly v04.SLDASM” located in the folder “..\Exercise 2 (SolidWorks)\Cell Phone Test Machine\Cell Phone Test Machine.SLDASM”.

4.       In the bottom left corner, click on Motion Study 1. Note that the motion study type is set to Motion Analysis.


[+] Enlarge Image

5.       Launch LabVIEW from the taskbar shortcut icon or from Start->All Programs->LabVIEW 2009. If LabVIEW is already running, close any open projects. Click Empty Project from the Getting Started launch screen.

6.       In the LabVIEW project explorer, right-click My Computer and select New » SolidWorks Assembly. Click the OK Button in the pop-up window that shows the file path. The SolidWorks assembly and distance motors are added to the project.


[+] Enlarge Image

7.       In the LabVIEW project explorer, right-click My Computer and select Properties. Click on Scan Engine and check the box to Start Scan Engine on Deploy.


[+] Enlarge Image

8.       Now right-click My Computer and select New » NI SoftMotion Axis.In the Axis Manager, click Add New Axis. This creates a new motion axis in LabVIEW and binds it to a SolidWorks motor resource. Click Add New Axis two more times. If necessary, click Change Binding until your configuration matches that shown below. Click OK.

9.       Right-click on Axis 1 and select Properties. Click the left icon to configure the axis settings as shown below.


[+] Enlarge Image

10.   Select Enable Drive on transition to Active Mode. This eliminates the need to use the Power function in your LabVIEW application. Click OK.


[+] Enlarge Image

11.   Repeat the last two steps for the other two axes.

12.   Right-click on My Computer and select New>NI SoftMotion Coordinate Space. Configure the coordinate space as shown below.


[+] Enlarge Image

13.   Right-click My Computer and navigate to New » VI. On the LabVIEW VI block diagram, right-click the white block diagram area to display the functions palette. Then click the arrows () at the bottom of the palette to expand the view. Next move your mouse over the Vision and Motion palette to expand it, navigate to the NI SoftMotion Module sub-palette and from there into the Function Blocks palette. Click the thumb tack () to lock down the palette.


[+] Enlarge Image

14.   Click the Arc function and then click on a white area of the block diagram to drop it down.

 

15.   Now you will configure your Arc Move function. First drag Coordinate Space 1 to your block diagram to the left of the resource terminal. Hover your mouse over the right terminal of the Motion Resource icon and note that your mouse changes to the wiring tool (). Left click to begin wiring, then move your mouse over the left edge of the resource terminal and click again to complete the wiring.

 

16.   Right-click the left edge of the execute terminal, then right click and navigate to Create » Control.

 

17.   Follow the same approach to create a control for the radius, start angle and travel angle terminals. Then right click the error out and done terminals and select Create » Indicator for those signals as well. When you are finished your block diagram should look similar to that shown below. To keep the diagram tidy Click the Clean Up Diagram Button ().

18.   Now you will place your Straight-Line Move function inside a Timed Loop Structure to synchronize its execution with the Scan Engine. To do this, right-click an empty part of the block diagram to display the functions palette. Then navigate to Programming » Structures » Timed Structures » Timed Loop.


[+] Enlarge Image
19.   To draw the Timed Loop, click the block diagram to the top-left of the Straight Line Move function. Then click again to the bottom-right of the function. Now right-click the Loop Condition terminal () of the Timed Loop and select Create Control.


[+] Enlarge Image

 

20.   Double click the upper left corner of the Timed Loop structure and set the Loop Timing Source to Synchronize to Scan Engine. Then click OK.


[+] Enlarge Image

21.   Your completed block diagram and front panel should appear similar to the following. Navigate to File » Save and save your VI as “Arc Move.vi” on the desktop. Next save the project.


[+] Enlarge Image

22.   In the Project Explorer, select all of the motion items from My Computer to Coordinate Space 1 (use the Ctrl or Shift key to select multiple items). Thenright-click and select Deploy.

23.   The Conflict Resolution dialogue appears to let you know that the Scan Engine Period is greater than 5 milliseconds. This is normal for simulation so click Apply to continue.


[+] Enlarge Image

24.   The SolidWorks simulation should be running. If not, right-click on My Computer >>Utilities>>Scan Engine Mode. This is used to switch between Active and Configuration mode. Since this is your first deployment, you should already be in Active mode as shown below.


[+] Enlarge Image

25.   Run the LabVIEW VI. Set the radius to 50 (mm). Then push the execute button and see how digital prototype moves. Try experimenting with different settings for the arc move. Since moves are triggered by the rising edge of the execute function, you can restart the movement by releasing the execute button and pushing it again.

26.   When you are done. Switch the Scan Engine to configuration mode and close the project.

Bonus Exercise: Add a Straight-Line Move function

 

In this optional bonus exercise, add a straight line move that is wired in sequence so it begins executing when the Arc Move function is done. Build the application shown below. Be sure to set the target position[] values before running. To prevent an intermittent error from being lost, the error status is latched from one iteration of the loop to the next using a shift register (). To create a shift register, right-click on the border of the Timed Loop and select Add Shift Register.


[+] Enlarge Image

Reader Comments | Submit a comment »

Excuse me.My computer has installed Labview2010,NI SoftMotion,SolidWorks 2010.I creat a new project and click 'my computer' buy right ,I can not find 'axis'in the 'craeat new',but the'solidworks assembly can be found.Why? Thanks a lot.
- 宇 宋, 重庆大学. lqj532640901@sina.com - Dec 13, 2011

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).