Motion Control With Labview
Motion Control With Labview
Contents
Introduction......................................................................................................................................................2
Conventions .....................................................................................................................................................4
NI SoftMotion Development Module Components.........................................................................................4
System Requirements ......................................................................................................................................5
Installing the NI SoftMotion Development Module........................................................................................6
Additional Installation Instructions for LabVIEW FPGA 7.1 Users........................................................6
NI SoftMotion Development Module Documentation ....................................................................................7
Typical Motion System....................................................................................................................................7
Supervisory Control..................................................................................................................................8
Trajectory Generator.................................................................................................................................9
Spline Engine............................................................................................................................................9
Control Loop.............................................................................................................................................9
I/O .............................................................................................................................................................10
Types of Moves ...............................................................................................................................................10
Arc Moves ................................................................................................................................................10
Straight-Line Moves .................................................................................................................................11
Blending....................................................................................................................................................12
Contouring .......................................................................................................................................................13
NI SoftMotion Development Module Examples .............................................................................................14
Compact FieldPoint ..................................................................................................................................15
cFP Motion Loop VI .........................................................................................................................15
Application VI ...................................................................................................................................17
M Series DAQ Device ..............................................................................................................................19
M Series Motion Loop VI .................................................................................................................20
Application VI ...................................................................................................................................22
cRIO-9104 ................................................................................................................................................25
cRIO Motion Loop VI .......................................................................................................................26
Application VI ...................................................................................................................................29
Introduction
This manual is designed to get you started with the NI SoftMotion Development Module for LabVIEW. It
includes overview information about the software as well as reference information for the example VIs that are
included with the NI SoftMotion Development Module.
The NI SoftMotion Development Module for LabVIEW provides VIs and functions that allow you to build
custom motion controllers using the LabVIEW Real-Time Module and National Instruments Reconfigurable
I/O (RIO) devices, data acquisition (DAQ) devices, or Compact FieldPoint (cFP).
The NI SoftMotion Development Module allows you to do path planning, trajectory generation, output control,
and PID loop control. The following illustration shows several options for using the NI SoftMotion
Development Module with National Instruments hardware products.
Refer to the documentation for the LabVIEW Real-Time Module, the LabVIEW FPGA Module, the LabVIEW
Simulation Module, and the LabVIEW Control Design Toolkit for information about system requirements,
installation, and configuration of these products.
© National Instruments Corporation 3 Getting Started with NI SoftMotion Development Module for LabVIEW
Conventions
The following conventions are used in this guide:
» The » symbol leads you through nested menu items and dialog box options to a final action. The sequence
File»Page Setup»Options directs you to pull down the File menu, select the Page Setup item, and select
Options from the last dialog box.
bold Bold text denotes items that you must select or click in the software, such as menu items and dialog box options.
Bold text also denotes parameter names.
italic Italic text denotes variables, emphasis, cross references, or an introduction to a key concept. Italic text also
denotes text that is a placeholder for a word or value that you must supply.
monospace Text in this font denotes text or characters that you should enter from the keyboard, sections of code,
programming examples, and syntax examples. This font is also used for the proper names of disk drives, paths,
directories, programs, subprograms, subroutines, device names, functions, operations, variables, filenames, and
extensions.
System Requirements
Platform and system requirements for the NI SoftMotion Development Module depend on the hardware you are
using. The following list contains basic system requirements that pertain to the software only.
• LabVIEW 7.1 or later
• LabVIEW Real-Time Module 7.1 or later
• LabVIEW FPGA Module 1.1 or later
© National Instruments Corporation 5 Getting Started with NI SoftMotion Development Module for LabVIEW
Installing the NI SoftMotion Development Module
Note To install the NI SoftMotion Development Module on a Windows 2000/XP system, you must be logged in with
Administrator privileges.
1. Insert the NI SoftMotion Development Module for LabVIEW CD into the CD-ROM drive.
If you have autorun enabled, autorun.exe runs automatically.
2. If you do not have autorun enabled, double-click autorun.exe.
3. Follow the onscreen instructions.
By default, the NI SoftMotion Development Module installation program adds the following items to the listed
directories in your LabVIEW installation location:
• examples\Motion\SoftMotion folder—Example VIs
• help folder—NI SoftMotion Development Module for LabVIEW Help
• manuals folder—This manual
Note The NI SoftMotion Development Module installation program also installs the readme_NISoftMotion.rtf file in
your LabVIEW folder.
Complete the following steps to add the NI SoftMotion palette icon to the LabVIEW Functions palette:
1. Launch LabVIEW.
2. Click Tools»Advanced»Edit Palette Views.
3. Select FPGA Hardware in Palette view.
The controller converts high-level commands from the user into command signals used by drives to move
actuators. The motion controller also monitors the system for error conditions, faults, and asynchronous events
that can cause the system to change speed, direction, or start/stop the actuators. Figure 2 illustrates the parts and
processes of a typical motion system.
© National Instruments Corporation 7 Getting Started with NI SoftMotion Development Module for LabVIEW
Trajectory Generation
(ms)
Cruise
rk
Je
Je
rk
Supervisory Control Control Loop (µs)
(ms) (with Interpolation)
Velocity
Dec
el
Acc
el
User API
Interface
Time
dt
Set Point
Supervisory Commands for
Interpolation PID Output
Control Trajectory Generator
Feedback
New
Event Monitoring Interface Set Point
Updated
Updates Trajectory
Generator Based on
I/O I/O And User
Sensor
Response
Supervisory Control
The supervisory control is the main loop of the motion control system. This loop intercepts commands from the
user and signals the trajectory generator to start or stop moves. The supervisory control loop also monitors all
I/O needed to perform initialization tasks, such as finding the reference or origin. This loop also monitors the
system for faults, and aids in synchronizing moves relative to changes in external conditions.
Note The NI SoftMotion Development Module does not contain VIs and functions for supervisory control. For examples of
supervisory control, refer to the NI SoftMotion Development Module Examples section of this manual.
Spline Engine
The Spline Engine function uses a cubic spline algorithm and four set points to calculate interpolated positions
between two positions from the trajectory generator.
Using the Spline Engine function results in smoother motion and allows you to run the trajectory generator loop
slower than the control loop.
Control Loop
The control loop creates the command signal based on the set point provided by the trajectory generator. In most
cases, the control loop includes both a position and a velocity loop, but in some cases the control loop may
include only a position loop.
The position is typically read from encoders, but also may be read from analog inputs. The velocity is calculated
from the position values that are read. The velocity also may be read directly from a velocity sensor, such as a
tachometer.
Because no feedback is required for stepper motors, the control loop converts the set point generated by the
trajectory generator into stepper signals (step/direction).
For control loop implementation, the NI SoftMotion Development Module provides LabVIEW source code for
an enhanced PID implementation of the control loop. The source code is installed to <LabVIEW>\examples\
motion\SoftMotion\ControlLoop.
Note The NI SoftMotion Development Module does not currently include source code to convert trajectory generator output
to stepper signals.
© National Instruments Corporation 9 Getting Started with NI SoftMotion Development Module for LabVIEW
I/O
Analog and digital I/O is required to send the command signals to the drives and receive feedback from the
actuators. Some servo motor drives use analog I/O to receive feedback. However, most I/O requirements for
motion controllers are digital. For example, feedback from quadrature encoders requires digital I/O.
Table 2 lists the NI SoftMotion Development Module VIs you use for decoding quadrature encoder signals.
Types of Moves
The following sections describe the types of moves commonly found in motion control systems.
Arc Moves
An arc move causes a coordinate space of axes to move on a circular, spherical, or helical path. You can move
a two-dimensional vector space on a circular path. You can move a three-dimensional vector space on a
spherical or helical path.
Function Use
Arc Move Read/Write Set or get the properties for a circular, helical, or spherical arc
move. All arc moves are treated as relative to the current
position. You can set or get arc move properties only from
coordinates.
Refer to the NI SoftMotion Development Module for LabVIEW Help for more information about the Arc Move
Read/Write function.
Straight-Line Moves
Straight-line moves use the desired target position to generate the move trajectory. For example, if the motor is
currently at position zero, and the target position is 100, the straight-line move creates a trajectory that moves
100 counts or steps.
Table 4 lists the NI SoftMotion Development Module function you use for straight-line moves.
Function Use
Straight Line Move Read/Write Set or get parameters for a straight line move. You can read and
write these properties for both axes and coordinates.
Refer to the NI SoftMotion Development Module for LabVIEW Help for more information about the Straight
Line Move Read/Write function.
© National Instruments Corporation 11 Getting Started with NI SoftMotion Development Module for LabVIEW
Blending
The NI SoftMotion Development Module allows you to blend moves. Blending is a software feature that
automatically creates a smooth transition between consecutive moves. Moves configured for blending execute
concurrently for a period of time, which results in continuous motion between moves.
Because the deceleration portion of the blended move is modified by the subsequent move, it may not reach its
end point. You can change the move constraints for each blended move to create a move profile that suits your
requirements. Figure 3 shows two blended moves.
Velocity Begin
Blend
Time
Blend Complete
Blending executes moves concurrently. When you blend the second move, both moves are executing. The first
move is generating its trajectory while the second move is waiting for the blending to complete. The second
move starts based on the user-specified blend mode. Blend mode options include blend at deceleration, blend
after profile complete, and blend after a specified delay.
Function Use
Trajectory Generator Method—Start Execute a blend when Type is set to Blend Motion.
Trajectory Generator Method—Start Multiple Execute a blend when Type is set to Blend Motion.
Move Constraints Read/Write Set the Blend Delay and Blend Mode properties.
Trajectory Generator Method—Execution Data Get the Blend Complete and Profile Complete
parameters of the Status property.
Refer to the NI SoftMotion Development Module for LabVIEW Help for more information about blending
functions.
Contouring
Contouring consists of a user-defined pattern of moves applied to an axis or a coordinate space of axes.
Contoured moves are appropriate when you need a trajectory that cannot be constructed from straight lines and
arcs. Instead of using the trajectory generator, the controller takes an array of position data during a contoured
move and splines the data before outputting it. This calculation ensures smooth motion by creating intermediate
points using a cubic spline algorithm. The basic trajectory move constraints—maximum velocity, acceleration,
and deceleration—have no effect on contoured moves.
All contoured moves are relative. Motion starts from the position of the axis, or axes, at the time the contouring
move starts. This is similar to the way arc moves are configured.
© National Instruments Corporation 13 Getting Started with NI SoftMotion Development Module for LabVIEW
Table 6 lists the NI SoftMotion Development Module functions you use to implement contouring in your
application.
Function Use
Contouring Move Read/Write Set and get the properties on a contouring buffer.
Contouring Move Create Buffer Create a buffer for contouring, and return a handle to
the buffer.
Contouring Move Delete Buffer Delete the contouring buffer.
Contouring Move Method—Check Buffer Space Retrieve the number of elements available for
updating.
Contouring Move Method—Enable Enable or disable a buffer.
Contouring Move Method—Stop Signal the final iteration of a continuous buffer, and
stop the move once the end of the buffer is reached.
Contouring Move Method—Update Points Replace points previously written to a buffer with
newer points.
Contouring Move Method—Write Points Write points to the buffer for the first time.
Refer to the NI SoftMotion Development Module for LabVIEW Help for more information about contouring
functions.
The Motion Loop VI performs the function of a motion controller in a typical motion control system. This VI
implements the code required to interact with I/O, read in trajectory generator information, calculate the move
profile, write the move profile information, and calculate the control output.
Compact FieldPoint
The following sections describe the Compact FieldPoint example installed with the NI SoftMotion
Development Module. This example uses a Compact FieldPoint device to independently control two motors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
© National Instruments Corporation 15 Getting Started with NI SoftMotion Development Module for LabVIEW
Table 7. Description of the cFP Motion Loop VI Block Diagram
Application VI
Figure 5 shows the block diagram for the cFP Main VI. This VI creates two independent straight-line moves
using two different axes.
Note For this example to work properly, the cFP Motion Loop VI must be running in the background. You can synchronize
the Motion Loop VI with the Application VI in one of several ways. For example, you can use a VI from the Advanced»
Synchronization»Rendezvous palette. Or, you can use the VI Server to dynamically run the VI. For information about
synchronizing VIs, refer to the Rendezvous VIs topic or the VI Server topic in LabVIEW Help. Also, refer to the What Is a
Rendezvous? and/or Dynamically Load and Run a VI without Opening its Front Panel Using VI Server and Rendezvous VIs
articles on the NI Developer Zone at ni.com/zone.
© National Instruments Corporation 17 Getting Started with NI SoftMotion Development Module for LabVIEW
1 2 3 4 5 6
© National Instruments Corporation 19 Getting Started with NI SoftMotion Development Module for LabVIEW
M Series Motion Loop VI
Figure 6 shows the block diagram of the M Series Motion Loop VI. This VI Implements a motion controller for
one coordinate, consisting of two axes, and one independent axis on the M Series DAQ devices.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
© National Instruments Corporation 21 Getting Started with NI SoftMotion Development Module for LabVIEW
Table 9. Description of the M Series Device Motion Loop VI Block Diagram (Continued)
Application VI
Figure 7 shows the block diagram of the M Series Gantry Cycle VI. This VI repeatedly cycles through a set of
given positions resulting in coordinate motion along the x- and y- axes and vertical motion along the z-axis.
Note For this example to work properly, the M Series Motion Loop VI must be running in the background. You can
synchronize the Motion Loop VI with the Application VI in one of several ways. For example, you can use a VI from the
Advanced»Synchronization»Rendzevous palette. Or, you can use the VI Server to dynamically run the VI. For information
about synchronizing VIs, refer to the Rendezvous VIs topic or the VI Server topic in LabVIEW Help. Also, refer to the What Is
a Rendezvous? and/or Dynamically Load and Run a VI without Opening its Front Panel Using VI Server and Rendezvous VIs
articles on the NI Developer Zone at ni.com/zone.
© National Instruments Corporation 23 Getting Started with NI SoftMotion Development Module for LabVIEW
Table 10. Description of M Series Gantry Cycle VI Block Diagram
Note In this example, the control loop runs on the FPGA, and the trajectory generator runs on the RT system.
© National Instruments Corporation 25 Getting Started with NI SoftMotion Development Module for LabVIEW
cRIO Motion Loop VI
Figure 8 shows the block diagram of the cRIO Motion Loop VI. This VI Implements a motion controller for
one coordinate, consisting of two axes, and one independent axis on the cRIO-9104.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
© National Instruments Corporation 27 Getting Started with NI SoftMotion Development Module for LabVIEW
Table 11. Description of cRIO Motion Loop VI Block Diagram (Continued)
Note For this example to work properly, the cRIO Motion Loop VI must be running in the background. You can synchronize
the Motion Loop VI with the Application VI in one of several ways. For example, you can use a VI from the Advanced»
Synchronization»Rendezvous palette. Or, you can use the VI Server to dynamically run the VI. For information about
synchronizing VIs, refer to the Rendezvous VIs topic or the VI Server topic in LabVIEW Help. Also, refer to the What Is a
Rendezvous? and/or Dynamically Load and Run a VI without Opening its Front Panel Using VI Server and Rendezvous VIs
articles on the NI Developer Zone at ni.com/zone.
1 2 3 4
© National Instruments Corporation 29 Getting Started with NI SoftMotion Development Module for LabVIEW
Table 12. Description of cRIO Gantry Cycle VI Block Diagram
National Instruments, NI, ni.com, and LabVIEW are trademarks of National Instruments Corporation. Refer to the Terms of Use section on
ni.com/legal for more information about 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, refer to the appropriate location:
Help»Patents in your software, the patents.txt file on your CD, or ni.com/patents.
371331B-01 Jan06
© 2004–2006 National Instruments Corporation. All rights reserved.