Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
What is Developer Zone?
United States

Document TypeTutorial
NI Supported: Yes
Publish Date: Aug 04, 2009


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links -Products and Services

Getting Started with LabVIEW NI SoftMotion and C Series Drive Interfaces

1 Ratings | 5.00 out of 5
Read in  |  Print |  PDF

Overview

This tutorial demonstrates how to develop a motion application using the National Instruments LabVIEW NI SoftMotion Module and NI 951x C Series drive interfaces. The application uses an NI CompactRIO reconfigurable embedded system with LabVIEW, LabVIEW NI SoftMotion, and NI-Motion driver software to perform a series of two-axis moves. While developing this application, you can learn the concepts and techniques of developing motion applications with the NI RIO Scan Interface. With the RIO Scan Interface, you can access C Series modules directly from the LabVIEW Real-Time Module.

Table of Contents

  1. Required Components
  2. LabVIEW NI SoftMotion Module Overview
  3. Setting Up the Hardware
  4. Installing Software on and Configuring the Controller
  5. Creating a Project in Scan Interface Mode
  6. Adding NI SoftMotion Resources to the LabVIEW Project
  7. Configuring Axes for Stepper Drive Interface Modules
  8. Testing the System Using the Interactive Test Panel
  9.  Configuring the Timed Loop
  10. Creating a Move Profile
  11. Deploying, Testing, and Using the VI
  12. Connecting to Servo and Stepper Drives
  13. What You Have Learned
  14. Additional Resources

Required Components

 The following software is required for this tutorial.

  • LabVIEW 2009 or later
  • LabVIEW Real-Time Module 2009 or later 
  • NI-RIO 3.2.0 or later
  • LabVIEW NI SoftMotion Module 2009 or later 

The following hardware is required for this tutorial.

  • CompactRIO controller and chassis that offer Scan Interface mode
    or
    NI 9144 distributed chassis
  • Two NI 9512 single-axis stepper drive interfaces
  • Power supply for the controller
  • Separate power supplies for the modules
  • Ethernet connection and cable

Even if you do not have the specified hardware, you can follow the steps in the "LabVIEW NI SoftMotion Module Tutorial" section of this document and perform offline configuration to learn concepts about using this module with LabVIEW.

LabVIEW NI SoftMotion Module Overview

With the LabVIEW NI SoftMotion Module, you can create deterministic motion control applications with the LabVIEW Real-Time Module using the function block programming paradigm and the RIO Scan Interface. The RIO Scan Interface enables you to use C Series modules directly from the LabVIEW Real-Time Module.

This document covers the application development for NI 951x C Series drive interfaces with the RIO Scan Interface. For information about using NI 951x modules with the LabVIEW FPGA Module, refer to the Getting Started Guide for NI 951x C Series Modules and LabVIEW FPGA, available from ni.com/manuals.

To perform a two-axis move with the NI SoftMotion function blocks as directed in this tutorial, use NI 9512 stepper drive interfaces in open-loop mode -- you do not need any additional feedback device or other hardware connections.

The settings configured in this tutorial may not be appropriate for your actual motion system. Hardware connections are minimized for demonstration purposes.

Setting Up the Hardware

Complete the following steps to set up the hardware for the application in this tutorial.

1. Install the real-time CompactRIO controller on the field-programmable gate array (FPGA) backplane if you are not using an integrated controller and backplane. Refer to the controller operating instructions for information about installing the controller.

2. Install the NI 9512 stepper drive interface modules in slots 1 and 2 of the chassis.

3. Connect the modules to a power supply. Refer to the module operating instructions for information about selecting an appropriate power supply.

4. Connect the controller to a power supply and an Ethernet network on the same subnet as the development computer. Refer to the controller operating instructions for information about wiring the controller to the power supply and Ethernet network.

5. Connect the module to a drive and other I/O, if available, using the NI 9512-to-P7000 Stepper Drives Connectivity Bundle, the NI 951x Cable and Terminal Block Bundle, or a custom cable for direct connectivity.

Installing Software on and Configuring the Controller

Complete the following steps to install software on the controller and configure it.

1. Launch the NI Measurement & Automation Explorer (MAX) configuration utility on the development computer.

2. Select the controller under Remote Systems in the Configuration pane. If you do not see the controller, you may need to disable the firewall on the development computer.

3. Verify that the Serial Number in the Identification section matches the serial number on the device.

4. If you do not want to format the disk on the controller, eliminating all installed software and files, power on the controller and skip to step 13.

5. Set the Safe Mode switch on the controller to the On position.

6. Power on the controller. If it is already powered on, press the Reset button on the controller to reboot it.

7. Right-click the controller under Remote Systems in the Configuration pane and select Format Disk. Click Yes on the dialog box that appears.

8. When MAX finishes formatting the disk, set the Safe Mode switch to the Off position and press the Reset button on the controller to reboot it.

9. Select the Obtain an IP address automatically radio button to assign an IP address or select the Use the following IP address radio button to specify a static IP address in the IP Settings section.

10. Type a descriptive name for the system in the Name field.

11. Click Apply above the Network Settings tab and let MAX reboot the system.

12. When the new system name appears under Remote Systems, expand the controller item in the tree, right-click Software, and select Add/Remove Software.

13. Select a recommended software set that includes NI-RIO 3.2.0 or later with NI Scan Engine support and the following add-ons enabled:

• LabVIEW NI SoftMotion Module

• NI Scan Engine support for LabVIEW NI SoftMotion Module

• NI-Motion driver software

14. Click Next to install the selected software on the controller. Click Help if you need information about installing recommended software sets.

15. After MAX finishes installing software on the controller, close MAX.

Creating a Project in Scan Interface Mode

Scan Interface mode enables you to use C Series modules directly from LabVIEW Real-Time. Modules that you use in Scan Interface mode appear directly under the chassis item in the Project Explorer window. Unlike most C Series modules, NI 951x interfaces are not directly configurable from the Project Explorer window and no I/O variables are directly available under the module.

Use a LabVIEW project to manage VIs, targets, and I/O modules on the development computer. Complete the following steps to create a LabVIEW project.

1. Launch LabVIEW.

2. Click the Empty Project link in the Getting Started window to display the Project Explorer window. You can also select File»New Project to display the Project Explorer 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.

4. Right-click the top-level project item in the Project Explorer window and select New»Targets and Devices from the shortcut menu to display the Add Targets and Devices dialog box.

5. Make sure that the Existing target or device radio button is selected.

If you do not have hardware installed, you can select the New target or device radio button to display a list of targets and devices that you can create without a physical target or device present. Throughout this tutorial, you can perform similar offline configuration steps to follow along and learn about using CompactRIO and LabVIEW.

6. Expand Real-Time CompactRIO.

7. Select the CompactRIO controller to add to the project and click OK.

8. If you have LabVIEW FPGA installed, the Select Programming Mode dialog box appears. Select Scan Interface to put the system into Scan Interface mode.

Use the CompactRIO Chassis Properties dialog box to change the programming mode in an existing project. Right-click the CompactRIO chassis in the Project Explorer window and select Properties from the shortcut menu to display this dialog box.

9. Click Discover in the Discover C Series Modules? dialog box if it appears.

10. Click Continue. LabVIEW adds the controller, the chassis, and all the modules to the project.

11. When LabVIEW finishes discovering hardware, select File»Save Project and save the project as 951x_Tutorial.lvproj.

When you have finished these steps your LabVIEW project should look similar to the image in Figure 1.

 

Figure 1. Project Explorer Window with Modules in Scan Interface Mode

Adding NI SoftMotion Resources to the LabVIEW Project

Now create NI SoftMotion resources tied to the C Series modules. You use the motion I/O resources in your VIs instead of I/O variables. Refer to the NI SoftMotion Module book of the LabVIEW Help for more information about motion I/O resources and NI SoftMotion.

Adding Axes to the Project

NI SoftMotion axes are tied to a specific C Series module in the project and allow configuration of the I/O present on the module. To configure and use the NI 951x modules in Scan Interface mode, you must add axes to the RT target and use the motion I/O resource associated with that axis in your VIs.

Complete the following steps to add an NI SoftMotion axis to the project.

1. Right-click the target 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 2.

2. Click Add New Axis twice so that both NI 9512 modules are associated with NI SoftMotion axes. Axes are automatically bound to an available module. You can double-click the axis name to rename the axis and give it a descriptive name, but you cannot use the same name for two different axes.

Figure 2. Axis Manager Dialog Box

3. Click Change Binding to open the Resource Binding dialog box and change the hardware the axis is associated with, if necessary.

4. Click OK to close the Axis Manager dialog box. All axes are added to the Project Explorer window. You cannot associate more than one axis with the same C Series module.

Adding Coordinates to the Project

NI SoftMotion axes can be grouped into coordinate spaces. Coordinate spaces are logical, multidimensional groups of axes. Like axes, coordinate spaces have associated I/O resources that you use as resource inputs.

Complete the following steps to add a coordinate space to the project.

1. Right-click the target in the Project Explorer window and select New»NI SoftMotion Coordinate Space from the shortcut menu to open the Configure Coordinate Space dialog box.

2. Select Axis 1 and Axis 2 from the Available Axes column and use the arrows to move them into the Coordinate Axes column.

 

Figure 3. Configure Coordinate Space Dialog Box

When using coordinate resources, target position and other coordinate information is contained in a 1D array with axis information provided in the order that axes are added using this dialog box.

3. Click OK to close the Configure Coordinate Space dialog box.

Your project now contains the axes and coordinate spaces you need for the application. Your LabVIEW project should look similar to Figure 4.

 

Figure 4. Completed Project with Motion Resources

Configuring Axes for Stepper Drive Interface Modules

In this section, configure the axes associated with your NI 9512 C Series modules using the Axis Configuration dialog box. This dialog box includes configuration options for stepper drive command signals, feedback devices, motion and digital I/O, trajectory, and axis setup. Figure 5 shows the parts of the Axis Configuration dialog box for NI 9512 C Series modules. Items that are not applicable to your configuration are greyed out.

 

Figure 5. Axis Configuration Dialog Box for NI 9512 Modules

Complete the following steps to configure the axes.

1. Right-click the axis in the Project Explorer window and select Properties from the shortcut menu to open the Axis Configuration dialog box.

2. 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.

3. Also on the Axis Setup page, confirm that the Axis Enabled and Enable Drive on Transition to Active Mode checkboxes contain checkmarks. These selections configure the axes to automatically activate when you run a VI.

Disable these options to prevent axes from automatically activating.

4. If the modules do not have physical signal 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.

5. Configure any additional I/O settings according to your system requirements.

6. Click OK to close the Axis Configuration dialog box.

7. Repeat steps 1 through 6 for Axis 2.

Caution: 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 Deploying and Running VIs on an RT Target in the LabVIEW Help for more information about deployment and troubleshooting tips.

8. 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.

Testing the System Using the Interactive Test Panel

Use the Interactive Test Panel to test and debug your motion system and configuration settings on the selected axis. With the Interactive Test Panel, you can perform a simple straight-line move and monitor move and I/O status information, change move constraints, get information about errors and faults in the system, and view position or velocity plots of the move. If you have a feedback device connected to your system, you can also obtain feedback position and position error information.

Complete the following steps to test your setup after configuring your axes using the Axis Configuration dialog box:

1. Right-click the axis in the Project Explorer window and select Interactive Test Panel from the shortcut menu.

2. Set the desired position, move mode, and move constraints using the tabs. Refer to the NI SoftMotion Module book of the LabVIEW Help for detailed information about the items available in this dialog box.

3. Click the Start button on the bottom of the dialog box to start the move with the configured options.

4. Use the Status and Plots tabs to monitor the move while it is in progress.

Creating a VI in Scan Interface Mode

In this section, create a VI that uses the motion I/O resources from the modules you added to the project. Refer to the Real-Time Module book of the LabVIEW Help for more information about Scan Interface mode and the NI Scan Engine.

 Configuring the Timed Loop

A Timed Loop synchronized to the NI Scan Engine enables your time-sensitive motion function blocks to execute at the scan rate. Any code placed inside a Timed Loop is guaranteed to execute once per scan period. Memory allocation should be minimized in Timed Loops to avoid introducing jitter into the system.

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 the controller item in the Project Explorer window 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.

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.

5. Under Loop Timing Attributes, set the Period to 5 scans. This step is optional but allows the Timed Loop to execute synchronized to the NI Scan Engine but at a slower rate. The Configure Timed Loop dialog box should look similar to Figure 7.

Figure 7. Configuring the Timed Loop

6. Click OK.

Creating a Move Profile

This example uses the NI SoftMotion Line and Read function blocks to create a simple move profile and monitor the position during the move.

Complete the following steps to set up the move:

1. Place a Line function block inside the Timed Loop.

2. Right-click the execute control and select Create»Control from the shortcut menu to add controls to the front panel for this input.

3. Repeat step 2 for the position, velocity, acceleration, and acceleration jerk inputs to add controls to the front panel for each of these inputs.

4. Wire the deceleration input to the acceleration input and the deceleration jerk input to the acceleration jerk input. In some applications, you may require your deceleration values to differ from your acceleration values, but this application keeps them the same.

5. Drag the Coordinate Space 1 resource from the LabVIEW Project on to the block diagram outside the Timed Loop and wire it to the resource input on the function block.

6. Place a second Line function block inside the Timed Loop.

7. Wire the error terminals and resource terminals of the Line function blocks together.

8. Wire the done output of the first Line function block to the execute input of the second Line function block.

9. Wire the velocity, acceleration, deceleration, acceleration jerk, and deceleration jerk inputs of the second Line function block to the controls created in step 3. This configures the second function block to use the same move constraint values as the first function block.

10. Right-click the position input and select Create»Control from the shortcut menu to add a control for the second position to the front panel.

11. Add a Merge Errors VI to the block diagram and wire the error out outputs of the Read function block and second Line function block to the Merge Errors VI.

12. Right-click the error out output of the Merge Errors VI and select Create»Indicator from the shortcut menu to add an indicator to the front panel.

13. Wire the error out output to the edge of the Timed Loop.

14. 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.

15. Wire the error in input to the shift register created on the other side of the Timed Loop.

16. 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 will use the LabVIEW Real-Time module, all function block arrays and clusters are initialized outside the Timed Loop to prevent jitter in the system. Place a Read function block inside
the Timed Loop below the two Line function blocks.

Reading the position and plotting is generally executed on the host by reading data published by the target and not in the deterministic Timed Loop. Reading is included in this example for simplicity.

17. Connect the resource and error in inputs to the resource and error in input wires from the first Line function block.

18. Create a constant for the position[] input and enter 0 for the first two elements of the array. Move the position[] constant outside the Timed Loop. This initializes the array so that the function block does not need to allocate any memory.

19. 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 the following when you have completed these steps:

Figure 8. Block Diagram

Switch to the front panel.

23. In the position[] array, enter 5000 for the first two elements of the array. This specifies an x,y position of 5000, 5000.

24. In the position[] 2 array, enter 0 for the first two elements of the array. This moves the x and y axis back to 0, 0.

25. Keep the velocity, acceleration, and jerk values at their defaults for now.

26. Add a waveform chart to the front panel.

27. Switch to the block diagram and connect the position[] out terminal from the Read function block to the waveform chart indicator. Your front panel should look similar to Figure 9 when you have completed these steps.

 

Figure 9. Front Panel

28. Save the VI.

29. Save the project.

Deploying, Testing, and Using the VI

Complete the following steps to deploy, test, and use the VI.

1. Run the VI. LabVIEW deploys the VI, and all modules and I/O variables the VI uses, to the controller.

2. Pulse the execute control to start execution.

3. On the front panel, verify that the position graph updates.

4. Stop the VI by clicking the Stop button.

5. Change any of the input parameters, run the VI, and pulse execute again to see how the different parameters interact.

Connecting to Servo and Stepper Drives

NI 951x C Series drive interfaces for CompactRIO offer direct connectivity to hundreds of stepper and servo drives and motors. These motion modules provide servo or stepper drive interface signals for a single axis. In addition, they offer a full set of motion I/O, including inputs for a home switch and limit switches, quadrature incremental encoder inputs for position feedback, and digital input and digital output lines. NI 951x drive interfaces include a processor to run the spline interpolation engine and a patented NI step generation algorithm or control loop.

Now examine the process of connecting to NI P7000 Series stepper drives. For information about connecting to third-party, P-command stepper or servo drives, refer to the NI SoftMotion help that installs with the LabVIEW NI SoftMotion Module.

Connecting to P7000 Series Stepper Drives

This section contains information about connecting the NI 9512 stepper drive interface to P7000 Series stepper drives using the NI 9512-to-P7000 Stepper Drives Connectivity Bundle. This product contains a cable to directly connect the NI 9512 D-Sub with the P7000 Series stepper drive, and a 37-pin terminal block and cable to connect the NI 9512 MDR connector to other I/O.

Complete the following steps to connect the NI 9512 drive interface to the P70530 DC drive or the P70360 AC drive and other I/O. Figure 10 shows a simplified connection diagram.

1. Install the module in the chassis as specified in the chassis documentation.

2. Connect the module D-Sub connector to the Command I/O connector on the P7000 Series drive using the NI 9512-to-P7000 cable. This cable provides connection for the stepper outputs, Drive Enable output, and Drive Fault signal.

3. Connect the power supply to the NI 9512-to-P7000 direct connect cable +24 V input.

4. Connect the module MDR connector to the 37-pin terminal block using the terminal block cable.

5. Connect other I/O signals from the hardware device to the 37-pin terminal block or custom cable. Refer to Figure 11 for the terminal block pinout.

a. Connect the Forward Limit, Reverse Limit, and Home inputs on the terminal block to the limit and home sensors.

b. Connect the encoder inputs to the encoder, if you are using an optional encoder for position feedback.

c. Connect any additional I/O using the provided terminals.

6. Connect the drive power supply to the P7000 drive.

 

Figure 10. NI 9512-to-P7000 Series Drive Connection Diagram

Note: When connecting only the MDR connector to the terminal block, all D-Sub signals on the terminal block are no connects (NC). Figure 11 shows the 37-pin terminal block pinout when connecting only the MDR connector.

 

Figure 11. NI 9512 37-Pin Terminal Block MDR-Only Pin Assignments

7. Install software on your controller, create a LabVIEW project, and add NI SoftMotion axes.

8. Right-click the axis in the Project Explorer window and select Properties from the shortcut menu to open the Axis Configuration dialog box.

9. Change the default axis settings for the following items in the Axis Configuration dialog box for proper operation with the P7000 drives:

a. Right-click the axis and select Properties from the shortcut menu to display the Axis Configuration dialog box.

b. On the Stepper page, set Output Type to Single-Ended.

c. On the Motion I/O page Drive Signals tab, set the Drive Enable signal Output Type to Sourcing.

d. On the Digital I/O page, map the Drive Fault/Alarm functionality to DI 1, and set the Input Type to Sourcing.

10. Right-click the controller item in the Project Explorer window and select Deploy All to deploy the axis information.

Connecting to Servo Drives

Servo Axis Configuration

Servo axes can operate only in closed-loop mode, so a feedback device is required. If you are using an NI 9514 or NI 9516 drive interface module, you must configure additional options for the feedback device, servo control loop, and drive command output for the servo drive. Figure 6 shows the parts of the Axis Configuration dialog box for NI 9514 and NI 9516 C Series modules. Items that are not applicable to your configuration are grayed out.

 

Figure 6. Axis Configuration Dialog Box for NI 9514 and NI 9516 Modules

Using the Gain Tuning Test Panel

Use the Gain Tuning Test Panel to tune the control-loop settings and determine the relative stability of the servo axis. Refer to "Using the Gain Tuning Panel" in the NI SoftMotion LabVIEW Help for detailed information about the Gain Tuning Panel and servo system tuning instructions.

Right-click the axis in the Project Explorer window and select Interactive Test Panel from the shortcut menu to access the Gain Tuning Panel.

What You Have Learned

This tutorial examined the following concepts about developing motion applications using LabVIEW NI SoftMotion and NI 951x C Series modules.

  • NI 951x modules differ from most C Series modules in that they are not directly configurable from the Project Explorer window when you are using Scan Interface mode, and no I/O variables are directly available under the module.
  • You must use NI SoftMotion to add axes to the RT target and associate them with NI 951x modules in order to configure and use them in Scan Interface mode. You then use the motion I/O resources associated with those axes in your VIs.
  • NI SoftMotion axes are configured using the Axis Configuration dialog box.
  • NI SoftMotion function blocks allow you to create deterministic motion control applications using the function block programming paradigm.
  • NI SoftMotion function blocks provide status outputs for advanced state monitoring.

Additional Resources

 

1 Ratings | 5.00 out of 5
Read in  |  Print |  PDF

Reader Comments | Submit a comment »

 

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/).