For further support information, refer to the Technical Support and Professional Services appendix. To comment
on National Instruments documentation, refer to the National Instruments Web site at ni.com/info and enter
the info code feedback.
The media on which you receive National Instruments software are warranted not to fail to execute programming instructions, due to defects
in materials and workmanship, for a period of 90 days from date of shipment, as evidenced by receipts or other documentation. National
Instruments will, at its option, repair or replace software media that do not execute programming instructions if National Instruments receives
notice of such defects during the warranty period. National Instruments does not warrant that the operation of the software shall be
uninterrupted or error free.
A Return Material Authorization (RMA) number must be obtained from the factory and clearly marked on the outside of the package before
any equipment will be accepted for warranty work. National Instruments will pay the shipping costs of returning to the owner parts which are
covered by warranty.
National Instruments believes that the information in this document is accurate. The document has been carefully reviewed for technical
accuracy. In the event that technical or typographical errors exist, National Instruments reserves the right to make changes to subsequent
editions of this document without prior notice to holders of this edition. The reader should consult National Instruments if errors are suspected.
In no event shall National Instruments be liable for any damages arising out of or related to this document or the information contained in it.
E
XCEPTASSPECIFIEDHEREIN, NATIONAL INSTRUMENTSMAKESNOWARRANTIES, EXPRESSORIMPLIED, ANDSPECIFICALLYDISCLAIMSANYWAR RANTYOF
MERCHANTABILITYORFITNESSFORAPARTICULARPURPOSE . CUSTOMER’SRIGHTTORECOVERDAMAGESCAUSEDBYFAULTORNEGLIGENCEONTHEPART OF
N
ATIONAL INSTRUMENTSSHALLBELIMITEDTOTHEAMOUNTTHERETOFOREPAIDBYTHECUSTOMER. NATIONAL INSTRUMENTSWILLNOTBELIABLEFOR
DAMAGESRESULTINGFROMLOSSOFDATA, PROFITS, USEOFPRODUCTS, ORINCIDENTALORCONSEQUENTIALDAMAGES, EVENIFADVISEDOFTHEPOSS IBILITY
THEREOF. This limitation of the liability of National Instruments will apply regardless of the form of action, whether in contract or tort, including
negligence. Any action against National Instruments must be brought within one year after the cause of action accrues. National Instruments
shall not be liable for any delay in performance due to causes beyond its reasonable control. The warranty provided herein does not cover
damages, defects, malfunctions, or service failures caused by owner’s failure to follow the National Instruments installation, operation, or
maintenance instructions; owner’s modification of the product; owner’s abuse, misuse, or negligent acts; and power failure or surges, fire,
flood, accident, actions of third parties, or other events outside reasonable control.
Copyright
Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying,
recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent of National
Instruments Corporation.
Trademarks
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.
®
is the registered trademark of Apple Computer, Inc. Other product and company names mentioned herein are trademarks or trade
FireWire
names of their respective companies.
Patents
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.
WARNING REGARDING USE OF NATIONAL INSTRUMENTS PRODUCTS
(1) NATIONAL INSTRUMENTS PRODUCTS ARE NOT DESIGNED WITH COMPONENTS AND TESTING FOR A LEVEL OF
RELIABILITY SUITABLE FOR USE IN OR IN CONNECTION WITH SURGICAL IMPLANTS OR AS CRITICAL COMPONENTS IN
ANY LIFE SUPPORT SYSTEMS WHOSE FAILURE TO PERFORM CAN REASONABLY BE EXPECTED TO CAUSE SIGNIFICANT
INJURY TO A HUMAN.
(2) IN ANY APPLICATION, INCLUDING THE ABOVE, RELIABILITY OF OPERATION OF THE SOFTWARE PRODUCTS CAN BE
IMPAIRED BY ADVERSE FACTORS, INCLUDING BUT NOT LIMITED TO FLUCTUATIONS IN ELECTRICAL POWER SUPPLY,
COMPUTER HARDWARE MALFUNCTIONS, COMPUTER OPERATING SYSTEM SOFTWARE FITNESS, FITNESS OF COMPILERS
AND DEVELOPMENT SOFTWARE USED TO DEVELOP AN APPLICATION, INSTALLATION ERRORS, SOFTWARE AND
HARDWARE COMPATIBILITY PROBLEMS, MALFUNCTIONS OR FAILURES OF ELECTRONIC MONITORING OR CONTROL
DEVICES, TRANSIENT FAILURES OF ELECTRONIC SYSTEMS (HARDWARE AND/OR SOFTWARE), UNANTICIPATED USES OR
MISUSES, OR ERRORS ON THE PART OF THE USER OR APPLICATIONS DESIGNER (ADVERSE FACTORS SUCH AS THESE ARE
HEREAFTER COLLECTIVELY TERMED “SYSTEM FAILURES”). ANY APPLICATION WHERE A SYSTEM FAILURE WOULD
CREATE A RISK OF HARM TO PROPERTY OR PERSONS (INCLUDING THE RISK OF BODILY INJURY AND DEATH) SHOULD
NOT BE RELIANT SOLELY UPON ONE FORM OF ELECTRONIC SYSTEM DUE TO THE RISK OF SYSTEM FAILURE. TO AVOID
DAMAGE, INJURY, OR DEATH, THE USER OR APPLICATION DESIGNER MUST TAKE REASONABLY PRUDENT STEPS TO
PROTECT AGAINST SYSTEM FAILURES, INCLUDING BUT NOT LIMITED TO BACK-UP OR SHUT DOWN MECHANISMS.
BECAUSE EACH END-USER SYSTEM IS CUSTOMIZED AND DIFFERS FROM NATIONAL INSTRUMENTS' TESTING
PLATFORMS AND BECAUSE A USER OR APPLICATION DESIGNER MAY USE NATIONAL INSTRUMENTS PRODUCTS IN
COMBINATION WITH OTHER PRODUCTS IN A MANNER NOT EVALUATED OR CONTEMPLATED BY NATIONAL
INSTRUMENTS, THE USER OR APPLICATION DESIGNER IS ULTIMATELY RESPONSIBLE FOR VERIFYING AND VALIDATING
THE SUITABILITY OF NATIONAL INSTRUMENTS PRODUCTS WHENEVER NATIONAL INSTRUMENTS PRODUCTS ARE
INCORPORATED IN A SYSTEM OR APPLICATION, INCLUDING, WITHOUT LIMITATION, THE APPROPRIATE DESIGN,
PROCESS AND SAFETY LEVEL OF SUCH SYSTEM OR APPLICATION.
This manual provides information about the NI-Motion driver software,
including background, configuration, and programming information.
The purpose of this manual is to provide a basic understanding of the
NI-Motion driver software, and provide programming steps and examples
to help you develop NI-Motion applications.
This manual is intended for experienced LabVIEW, C/C++, or other
developers. Code instructions and examples assume a working knowledge
of the given programming language. This manual also assumes a general
knowledge of motion control terminology and development requirements.
This manual pertains to all NI motion controllers that use the NI-Motion
driver software.
Conventions
The following conventions appear in this manual:
<>Angle brackets that contain numbers separated by an ellipsis represent a
range of values associated with a bit or signal name—for example,
AO <3..0>.
[ ]Square brackets enclose optional items—for example, [
»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.
This icon denotes a tip, which alerts you to advisory information.
This icon denotes a note, which alerts you to important information.
This icon denotes a caution, which advises you of precautions to take to
avoid injury, data loss, or a system crash.
boldBold 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.
monospace boldMonospace bold text indicates a portion of code with structural
significance.
monospace italicMonospace italic text indicates a portion of code that is commented out.
Documentation and Examples
In addition to this manual, NI-Motion includes the following
documentation to help you create motion applications:
•Getting Started with NI-Motion for NI 73xx Motion Controllers—This
document provides installation instructions and general information
about the NI-Motion product.
•Getting Started: NI SoftMotion Controller for Ormec ServoWire SM Drives—Refer to this document for information about
getting started with the NI SoftMotion Controller for Ormec.
•Getting Started: NI SoftMotion Controller for Copley CANopen Drives—Refer to this document for information about getting started
with the NI SoftMotion Controller for CANopen.
•NI-Motion VI Help—Refer to this document for specific information
about NI-Motion LabVIEW VIs.
•NI-Motion Function Help—Refer to this document for specific
information about NI-Motion C/C++ functions.
•Measurement & Automation Explorer Help for Motion—Refer to this
document for configuration information.
•NI-Motion ReadMe—Refer to this HTML document for information
about hardware and software installation and information about
changes to the NI-Motion driver software in the current version. This
document also contains last-minute information about NI-Motion.
•Application notes—For information about advanced NI-Motion
concepts and applications, visit
ni.com/appnotes.nsf/.
NI-Motion User Manualxivni.com
About This Manual
•NI Developer Zone (NIDZ)—Visit the NI Developer Zone, at
ni.com/zone, for example programs, tutorials, technical
presentations, the Instrument Driver Network, a measurement
glossary, an online magazine, a product advisor, and a community area
where you can share ideas, questions, and source code with motion
developers around the world.
•Motion Hardware Advisor—Visit the National Instruments Motion
Hardware Advisor at
ni.com/devzone/advisors/motion/ to
select motors and stages appropriate to the motion control application.
In addition to the NI Developer Zone, you can find NI-Motion C/C++
and Visual Basic programming examples in the
FlexMotion\Examples
default directory is
NI-Motion
.
folder where you installed NI-Motion. The
Program Files\National Instruments\
NI-Motion\
You can find LabVIEW example programs under
examples\Motion
in the directory where you installed LabVIEW. You can find
LabWindows
™
/CVI™ examples under samples\Motion in the directory
where you installed LabWindows/CVI.
You can find the NI-Motion C/C++ and LabVIEW example code
referenced in this manual in the
This user manual provides information about the NI-Motion driver
software, motion control setup, and specific task-based instructions for
creating motion control applications using the LabVIEW and C/C++
application development environments.
NI-Motion is the driver software for National Instruments 73xx motion
controllers and the NI SoftMotion Controller. You can use NI-Motion to
create motion control applications using the included library of LabVIEW
VIs and C/C++ functions.
National Instruments also offers the Motion Assistant and NI-Motion
development tools for Visual Basic.
NI-Motion Architecture
The NI-Motion driver software architecture is based on the interaction
between the NI motion controllers and a host computer. This interaction
includes the hardware and software interface and the physical and
functional architecture of the NI motion controllers.
Figure 1-1. NI Motion Control Hardware and Software Interaction
Note
The last block in Figure 1-1 is not applicable to the NI SoftMotion Controller.
NI Motion Controller Architecture
This section includes information about the architecture for both the 73xx
family of NI motion controllers and the NI SoftMotion Controller.
NI 73xx Architecture
NI 73xx controllers use a dual-processor architecture. The two processors,
a central processing unit (CPU) and a digital signal processor (DSP), form
the backbone of the NI motion controller. The controller plugs into a
variety of slots, including PCI slots, or to a PC using a high-speed serial
interface, such as IEEE 1394 (FireWire
Application Development Environments:
LabVIEW, Visual Basic, and C++
®
).
NI-Motion User Manual1-2ni.com
Chapter 1Introduction to NI-Motion
The controller CPU is a 32-bit micro-controller running an embedded real
time, multitasking operating system. This CPU offers the performance and
determinism needed to solve most complex motion applications. The CPU
performs command execution, host synchronization, I/O reaction, and
system supervision.
The DSP has the primary responsibility of fast closed-loop control with
simultaneous position, velocity, and trajectory maintenance on multiple
axes. The DSP also closes the position and velocity loops, and directly
commands the torque to the drive or amplifier.
Motion I/O occurs in hardware on an FPGA and consists of
limit/home switch detection, position breakpoint, and high-speed capture.
This ensures very low latencies in the range of hundreds of nanoseconds
for breakpoints and high-speed captures. Refer to Chapter 12,
Synchronization, for information about breakpoints and high-speed
capture.
The motion controller processor is monitored by a watchdog timer, which
is hardware that can be used to automatically detect software anomalies and
reset the processor if any occur. The watchdog timer checks for proper
processor operation. If the firmware on the motion controller is unable to
process functions within 62 ms, the watchdog timer resets the motion
controller and disallows further communications until you explicitly reset
the motion controller. This ensures the real-time operation of the motion
control system. The following functions may take longer than 62 ms to
process.
•Save Defaults
•Reset Defaults
•Enable Auto Start
•Object Memory Management
•Clear Buffer
•End Storage
These functions are marked as non-real-time functions. Refer to the
NI-Motion Function Help or the NI-Motion VI Help for more information.
Figure 1-2 illustrates the physical architecture of the NI motion controller
hardware.
Host Computer
Microprocessor
Running a Real-Time
Operating System
PC
Supervisory/
Communications/
User-defined Onboard
Programs
Watchdog
Timer
Figure 1-2. Physical NI Motion Controller Architecture
Because the NI SoftMotion Controller is not a hardware device, information about
Tip
its architecture is not covered in this section. Refer to the NI SoftMotion Controller
Architecture section for information about the functional architecture that is specific to the
NI SoftMotion Controller.
NI Motion Controller Functional Architecture
Functionally, the architecture of the NI 73xx motion controllers and the
NI SoftMotion Controller is generally divided into four components:
supervisory control, trajectory generator, control loop, and motion I/O. For
the NI SoftMotion Controller, the motion I/O component is separate from
the controller. Refer to Figure 1-3 and Figure 1-4 for an illustration of how
the components of the 73xx and NI SoftMotion Controller interact.
NI Motion Controller
Processor (DSP)
Encoders and Motion I/O
Digital Signal
Control Loop and
Trajectory Generation
FPGAs
NI-Motion User Manual1-4ni.com
Chapter 1Introduction to NI-Motion
Figure 1-3 shows the components of the NI 73xx motion controllers.
Typical NI 73xx Motion Controller Architecture
Supervisory Control
Host
Host
Bus
Microcontroller running RTOS/DSPs/FPGAs
Trajectory Generation
Figure 1-3. Typical NI 73xx Motion Controller Functional Architecture
Figure 1-4 shows the components of the NI SoftMotion controller.
NI SoftMotion Controller Architecture
Supervisory Control
Trajectory Generation
Bus
Any CPU on a real-time environment
Software is separate from the I/O
Control Loop
Control Loop
To drive
From
feedback
Analog & Digital I/O
& sensors
To drive
From
feedback
Analog & Digital I/O
& sensors
Figure 1-4. NI SoftMotion Controller Functional Architecture
Figure 1-5 illustrates the functional architecture of NI motion controllers.
Supervisory Control
(ms)
User API
Interface
Supervisory
Control
Commands for
Trajectory Generator
Trajectory Generation
(ms)
Cruise
Jerk
Accel
Velocity
Time
dt
Set Point
Jerk
Decel
Interpolation
Control Loop (µs)
(with Interpolation)
PID
Output
Event Monitoring Interface
I/O
New
Set Point
Updated
Updates Trajectory
Generator Based on
I/O And User
Response
Feedback
Sensor
Figure 1-5. NI Motion Controller Functional Architecture
The following list describes how each component of the 73xx controllers
and the NI SoftMotion Controller functions:
•Supervisory control—Performs all the command sequencing and
coordination required to carry out the specified operation
–System initialization, which includes homing to a zero position
–Event handling, which includes electronic gearing, triggering
outputs based on position, updating profiles based on user defined
events, and so on
–Fault Detection, which includes stopping moves on a limit switch
encounter, safe system reaction to emergency stop or drive faults,
watchdog, and so on
•Trajectory generator provides path planning based on the profile
specified by the user
•Control loop—Performs fast, closed-loop control with simultaneous
position, velocity, and trajectory maintenance on one or more axes
NI-Motion User Manual1-6ni.com
Chapter 1Introduction to NI-Motion
The control loop handles closing the position/velocity loop based on
feedback, and it defines the response and stability of the system. For
stepper systems, the control loop is replaced with a step generation
component. To enable the control loop to execute faster than the
trajectory generation, an interpolation component, or spline engine, the
control loop interpolates between setpoints calculated by the trajectory
generator. Refer to Figure 1-5 for an illustration of the spline engine.
•Motion I/O—Analog and digital I/O that sends and receives signals
from the rest of the motion control system. Typically, the analog output
is used as a command signal for the drive, and the digital I/O is used
for quadrature encoder signals as feedback from the motor. The motion
I/O performs position breakpoint and high speed capture. Also, the
supervisory control uses the motion I/O to achieve certain required
functionality, such as reacting to limit switches and creating the
movement modes needed to initialize the system.
NI SoftMotion Controller Architecture
The NI-Motion architecture for the NI SoftMotion Controller uses standard
PC-based platforms and open standards to connect intelligent drives to a
real-time host. In this architecture, the software components of the motion
controller run on a real-time host and all I/O is implemented in the drives.
This separation of I/O from the motion controller software components
helps to lower system cost and improve reliability by improving
connectivity. Open standards, such as IEEE 1394 and CANopen, are
used to connect these components.
NI SoftMotion Controller for Ormec
When you use the NI SoftMotion Controller with an Ormec device, you can
daisy chain up to 15 drives together and connect them to the real-time host.
The real-time isochronous mode of the IEEE 1394 bus is used to transfer
data between the drives and the host. Figure 1-6 shows the NI SoftMotion
Controller component architecture that applies when the controller is used
with an Ormec device.
The supervisory control and trajectory generation loops execute every
millisecond. If the control loop is configured to execute faster than every
millisecond, the trajectory data is interpolated before the control loop
uses it.
Ormec DriveNI SoftMotion Controller on Host Device*
Supervisory
Control
*Host device is a PC or PXI chassis running the
LabVIEW Real-Time Module for RTX Targets
**I/O includes encoder implementation
Figure 1-6. NI SoftMotion Controller Functional Architecture for Ormec
Trajectory
Generation
Control
Loop
I/O**
IEEE 1394 Bus
NI SoftMotion Controller for CANopen
When you use the NI SoftMotion Controller with a CANopen device, you
can daisy chain up to 15 drives together and connect them to the real-time
host. The real-time Process Data Objects (PDOs) defined by the CANopen
protocol are used to transfer data between the drives and host.
All I/O required by the motion controller is implemented by CANopen
drives that support the Device Profile 402 for Motion Control. Currently,
the NI SoftMotion Controller supports only CANopen drives from Copley
Controls Corp. When used with CANopen devices, the Supervisory
Control and Trajectory Generation components of the NI SoftMotion
Controller execute in a real-time environment that is running LabVIEW
Real-Time Module (ETS).
If your motion control system uses 8 axes or fewer, the supervisory control
and trajectory generation loops execute every 10 milliseconds. If your
motion control system uses more than 8 axes, the supervisory control and
trajectory generation loops execute every 20 milliseconds. When you use
the NI SoftMotion Controller with a CANopen drive, the drive implements
the control loop and interpolation.
NI-Motion User Manual1-8ni.com
Chapter 1Introduction to NI-Motion
NI SoftMotion Controller
on Host Device*
Supervisory
Control
*Host device is a PC or PXI chassis running the
LabVIEW Real-Time Module
**I/O includes encoder implementation
Figure 1-7. NI SoftMotion Controller Functional Architecture for CANopen
Trajectory
Generation
Spline
Engine
CAN Bus
CANopen Drive
Control
Loop
I/O**
In this configuration, the I/O and the control loop execute on the CANopen
drive. The NI SoftMotion Controller uses an NI-CAN device to
communicate to the CAN bus.
NI SoftMotion Controller Communication Watchdog
The supervisory control in the NI SoftMotion Controller continuously
monitors all communication with the drives connected to the host. If any
drive fails to update its data in the host loop update period, the axis
corresponding to that drive is disabled and the communication watchdog
status bit, which is returned by the Read Per Axis Status function, is set to
TRUE. Similarly, all drives connected to the NI SoftMotion Controller are
configured to go into a fault state if the data from the
NI SoftMotion Controller is not updated every host loop update period on
the drives.
The communication watchdog functionality ensures that the NI SoftMotion
Controller operates in real time.
Tip To get an axis or axes out of the communication watchdog state, reset the
This chapter describes the basic form of an NI-Motion application and its
interaction with other I/O, such as a National Instruments data and/or image
acquisition device.
Creating a Generic NI-Motion Application
Figure 2-1 illustrates the steps for creating an application with NI-Motion,
and describes the generic steps required to design a motion application.
Figure 2-1. Generic Steps for Designing a Motion Application
Adding Measurements to an NI-Motion Application
Figure 2-2 illustrates an expanded view of the topics covered in Part III,
Programming with NI-Motion, of this manual. For information about items
in the diagram, refer to Chapter 12, Synchronization.
NI-Motion User Manual2-2ni.com
Chapter 2Creating NI-Motion Applications
1
Define control mechanism for I/O
Breakpoints*
2a
Define breakpoint position
Enable a breakpoint
Set data or image acquisition
device to trigger on breakpoint
Re-enable the breakpoint
after each occurrence
(absolute/relative/modulo
breakpoints only)
Synchronization
High-speed capture**
2b
Define triggering input type
Enable high-speed capture
Read the captured position
Re-enable high-speed capture
after each occurrence
(non-buffered high-speed
capture only)
Chapter 12:
* Breakpoints cause a digital output to change state when a specified position is reached
by an encoder. Breakpoints are not supported by the NI SoftMotion Controller when it is
used with an Ormec or CANopen device.
** A high-speed capture records the position of an encoder when a digital line is used as
a trigger. High-speed captures are not supported by NI SoftMotion Controller for
CANopen. You can use two high-speed captures per axis when you are using the
NI SoftMotion Controller with an Ormec device.
Figure 2-2. Input/Output with Data and Image Acquisition
Note If you are using RTSI to connect your motion controller to a National Instruments
data or image acquisition device, be aware that the NI SoftMotion Controller does not
support RTSI.
NI-Motion User Manual2-4ni.com
Configuring Motion Control
Motion control is divided into two parts: configuration and execution.
Part II of this manual discusses configuring the hardware and software
components of a motion control system using NI-Motion.
When your motion control system includes a servo motor, you must tune
and calibrate the system to ensure proper performance. This chapter covers
general information about tuning and calibrating your servo system using
control loop parameters. Refer to Measurement & Automation Explorer Help for Motion for more information about and instructions for tuning
servo motors in Measurement & Automation Explorer (MAX).
NI SoftMotion Controller Considerations
This section includes information you need if you are using the
NI SoftMotion Controller.
NI SoftMotion Controller for CANopen
This chapter does not apply if you are using the
NI SoftMotion Controller for CANopen because the control loop is
implemented on the drive. Refer to the drive documentation for
information about tuning the servo motors you are using with the CANopen
drive.
3
NI SoftMotion Controller for Ormec
If you are using the NI SoftMotion Controller for Ormec with an Ormec
ServoWire drive in position mode, you must tune the control loop using the
drive configuration utility provided by Ormec.
Using Control Loops to Tune Servo Motors
Tuning maximizes the performance of your servo motors. A servo system
uses feedback to compensate for errors in position and velocity.
For example, when the servo motor reaches the desired position, it cannot
stop instantaneously. There is a normal overshoot that must be corrected.
The controller turns the motor in the opposite direction for the amount of
distance equal to the detected overshoot. However, this corrective move
also exhibits a small overshoot, which must also be corrected in the same
manner as the first overshoot.
A properly tuned servo system exhibits overshoot as shown in Figure 3-1.
Overshoot
Commanded
Position
Time
0
Settling Time
Figure 3-1. Properly Tuned Servo Motor Behavior
The amount of time required for the motors to settle on the commanded
position is called the settling time. By tuning the servo motors, you can
affect the settling time, the amount of overshoot, and various other
performance characteristics.
Control Loop
NI motion servo control uses control loops to continuously correct errors in
position and velocity. You can configure the control loop to perform a
Proportional, Integral and Derivative (PID) loop or a more advanced
control loop, such as the velocity feedback (PIV) or velocity feedforward
(PIVff) loops.
The following are common variables relating to the PID control loop.
Kp (Proportional Gain)
The proportional gain (Kp) determines the contribution of restoring force
that is directly proportional to the position error. This restoring force
functions in much the same way as a spring in a mechanical system.
Each sample period, the PID loop calculates the position error, which is the
difference between the instantaneous trajectory position and the primary
feedback position, and multiplies the position error by Kp to produce the
proportional component of the 16-bit DAC command output.
An axis with too small a value of Kp is unable to hold the axis in position
and is very soft. Increasing Kp stiffens the axis and improves its disturbance
torque rejection. However, too large a value of Kp often results in
instability.
Ki (Integral Gain)
The integral gain (Ki) determines the contribution of restoring force that
increases with time, ensuring that the static position error in the servo loop
is forced to zero. This restoring force works against constant torque loads
to help achieve zero position error when the axis is stopped.
Each sample period, the position error is added to the accumulation of
previous position errors to form an integration sum. This integration sum is
scaled by dividing by 256 prior to being multiplied by Ki.
In applications with small static torque loads, this value can be left at its
default value of zero (0). For systems having high static torque loads, this
value should be tuned to minimize position error when the axis is stopped.
Although non-zero values of Ki cause reduced static position error, they
tend to cause increased position error during acceleration and deceleration.
This effect can be mitigated through the use of the Integration Limit
parameter. Too high a value of Ki often results in servo loop instability.
National Instruments therefore recommends that you leave Ki at its default
value of zero until the servo system operation is stable. Then you can add a
small amount of Ki to minimize static position errors.
NI-Motion User Manual3-4ni.com
Chapter 3Tuning Servo Systems
Kd (Derivative Gain)
The derivative gain (Kd) determines the contribution of restoring force
proportional to the rate of change (derivative) of position error. This force
acts much like viscous damping in a damped spring and mass mechanical
system. A shock absorber is an example of this effect.
The PID loop computes the derivative of position error every derivative
sample period. A non-zero value of Kd is required for all systems that use
torque block amplifiers, where the command output is proportional to
motor torque, for the servo loop operation to be stable. Too small a Kd
value results in servo loop instability.
With velocity block amplifiers, where the command output is proportional
to motor velocity, it is typical to set Kd to zero or a very small positive
value.
Kv (Velocity Feedback)
You can use a primary or secondary feedback encoder for velocity
feedback. Setting the velocity feedback gain (Kv) to a value other than
zero (0) enables velocity feedback using the secondary encoder, if
configured, or the primary encoder if a secondary encoder is not
configured.
Kv is used to scale this velocity feedback before it is added to the other
components in the 16-bit DAC command output. Kv is similar to derivative
gain (Kd) except that it scales the velocity estimated from encoder
resources only. The derivative gain scales the derivative of the position
error, which is the difference between the instantaneous trajectory position
and the primary feedback position. Like the Kd term, the velocity feedback
derivative is calculated every derivative sample period and the contribution
is updated every PID sample period.
Velocity feedback is estimated through a combination of speed-dependent
algorithms. Velocity is measured based on the time elapsed between each
encoder count.
Vff (Velocity Feedforward)
The velocity feedforward gain (Vff) determines the contribution in the
16-bit DAC command output that is directly proportional to the
instantaneous trajectory velocity. This value is used to minimize following
error during the constant velocity portion of a move and can be changed at
any time to tune the PID loop.
Velocity feedforward is an open-loop compensation technique and cannot
affect the stability of the system. However, if you use too large a value for
Vff, following error can reverse during the constant velocity portion, thus
degrading performance, rather than improving it.
Velocity feedforward is typically used when operating in PIVff mode
with either a velocity block amplifier or substantial amount of velocity
feedback (Kv). In these cases, the uncompensated following error is
directly proportional to the desired velocity. You can reduce this following
error by applying velocity feedforward. Increasing the integral gain (Ki)
also reduces the following error during constant velocity but only at the
expense of increased following error during acceleration and deceleration
and reduced system stability. For these reasons, increasing Ki is not a
recommended solution.
Tip In PIVff mode, the Kd and Kv gains are set to zero.
Velocity feedforward is rarely used when operating in PID mode with
torque block amplifiers. In this case, because the following error is
proportional to the torque required, rather than the velocity, it is typically
much smaller and does not require velocity feedforward.
Aff (Acceleration Feedforward)
The acceleration feedforward gain (Aff) determines the contribution in the
16-bit DAC command output that is directly proportional to the
instantaneous trajectory acceleration. Aff is used to minimize following
error (position error) during acceleration and deceleration and can be
changed at any time to tune the PID loop.
Acceleration feedforward is an open-loop compensation technique and
cannot affect the stability of the system. However, if you use too large a
value of Aff, following error can reverse during acceleration and
deceleration, thus degrading performance, rather than improving it.
Kdac
Kdac is the Digital to Analog Converter (DAC) gain. Use the following
equation to calculate Kdac:
Kdac
20 V represents the ±10 V range in the motion controller.
NI-Motion User Manual3-6ni.com
20 V
-----------=
16
2
Dual Loop Feedback
Chapter 3Tuning Servo Systems
Ga
Ga is the Amplifier Gain.
Kt
Kt is the Torque Constant of the motor. Kt is represented in Newton Meters
per Amp.
1/J
1/J represents the motor plus load inertia of the motion system.
Ke
Ke represents the conversion factor to revolutions. This may involve a
scaling factor.
Motion control systems often use gears to increase output torque, increase
resolution, or convert rotary motion to linear motion. The main
disadvantage of using gears is the backlash created between the motor and
the load. This backlash can cause a loss of position accuracy and system
instability.
The control loop on the motion system corrects for errors and maintains
tight control over the trajectory. The control loop consists of three main
parts—proportional, integral and derivative—known as PID parameters.
The derivative part estimates motor velocity by differentiating the
following error (position error) signal. This velocity signal adds, to the
loop, damping and stability. If backlash is present between the motor and
the position sensor, the positions of the motor and the sensor are no longer
the same. This difference causes the derived velocity to become ineffective
for loop damping purposes, which creates inaccuracy in position and
system instability.
Using two position sensors for an axis can help solve the problems caused
by backlash. As shown in Figure 3-3, one position sensor resides on the
load and the other on the motor before the gears. The motor sensor is used
to generate the required damping and the load sensor for position feedback.
The mix of these two signals provides the correct position feedback with
damping and stability.
You can enable dual-loop feedback on the NI motion controller by mapping an
encoder as the secondary feedback for the axis, and then using the velocity feedback gain
instead of the derivative gain to dampen and stabilize the system, as shown in Figure 3-4.
Figure 3-3. Dual Loop Feedback
Figure 3-4. Dual Loop Feedback Algorithm
NI-Motion User Manual3-8ni.com
Velocity Feedback
Chapter 3Tuning Servo Systems
You can configure the NI motion controller for velocity feedback using the
Kv (velocity feedback) gain. Using Kv creates a minor velocity feedback
loop. This is very similar to the traditional analog servo control method of
using a tachometer for closing the velocity loop. This type of feedback is
necessary for systems where precise speed control is essential.
You can use a less expensive standard torque, or current mode, amplifier
with the velocity feedback loop on NI motion controllers to achieve the
same results you would get from using velocity amplifiers, as shown in
Figure 3-5.
ΣΣ
Figure 3-5. Velocity Feedback
Setting any non-zero value for Kv allows you to use the Kv term instead of
or in addition to the Kd term to stabilize the system.
Velocity feedback gain (Kv) is similar to derivative gain (Kd) except that it
scales the velocity estimated from encoder resources only. The derivative
gain scales the derivative of the position error, which is the difference
between the instantaneous trajectory position and the primary feedback
position. Like the Kd term, the velocity feedback derivative is calculated
every derivative sample period, and the contribution is updated every PID
sample period, as shown in Figure 3-6.
Velocity amplifiers close the velocity loop using a tachometer on the
amplifier itself, as shown in Figure 3-7. In this case, the controller must
ensure that the voltage output is proportional to the velocity. Use the
velocity feedforward term (Vff) to ensure that there is minimum following
error during the constant velocity profiles.
Figure 3-7. NI Motion Controllers with Velocity Amplifiers
NI-Motion User Manual3-10ni.com
Chapter 3Tuning Servo Systems
Figure 3-8 describes how to use NI motion controllers with velocity
amplifiers.
Figure 3-8. NI Motion Controllers with Velocity Amplifiers Algorithm
You typically use velocity feedforward when using controllers with
velocity amplifiers. The uncompensated following error is directly
proportional to the specified velocity. You can reduce the following error
by applying velocity feedforward. Increasing the integral gain (Ki) also
reduces the following error during constant velocity, but at the expense of
increased following error during acceleration and deceleration and reduced
system stability.
Note National Instruments does not recommend increasing Ki.
Velocity feedforward is rarely used when operating in PID mode with
torque block amplifiers. In this case, following error is typically much
smaller because it is proportional to the torque required rather than to the
velocity. When operating in PID mode with torque block amplifiers,
velocity feedforward is not required.
You can use the C/C++ functions and LabVIEW VIs, included with
NI-Motion, to configure and execute motion control applications. Part III
of this manual covers the NI-Motion algorithms you need to use all the
features of NI-Motion.
Each task discussion uses the same structure. First, a generic algorithm
flow chart shows how the component pieces relate to each other. Then, the
task discussion details any aspects of creating the task that are specific to
LabVIEW or C/C++ programming, complete with diagrams and code
examples.
Part III
Note The LabVIEW block diagrams and C/C++ code examples are designed to illustrate
concepts, and do not contain all the logic or safety features necessary for most functional
applications.
Refer to the NI-Motion Function Help or the NI-Motion VI Help for
detailed information about specific functions or VIs.
Part III covers the following topics:
•What You Need to Know about Moves
•Straight-Line Moves
•Arc Moves
•Contoured Moves
•Reference Moves
•Blending Moves
•Electronic Gearing and Camming
•Acquiring Time-Sampled Position and Velocity Data
This chapter discusses the concepts necessary for programming motion
control.
Move Profiles
The basic function of a motion controller is to make moves. The trajectory
generator takes in the type of move and the move constraints and generates
points, or instantaneous positions, in real time. Then, the trajectory
generator feeds the points to the control loop.
The control loop converts each instantaneous position to a voltage or to
step-and-direction signals, depending on the type of motor you are using.
Move constraints are the maximum velocity, acceleration, deceleration, and
jerk that the system can handle. The trajectory generator creates a velocity
profile based on these move constraint values.
4
There are two types of profiles that can be generated while making the
move: trapezoidal and s-curve.
Trapezoidal
When you use a trapezoidal profile, the axes accelerate at the acceleration
value you specify, and then cruise at the maximum velocity you load.
Based on the type of move and the distance being covered, it may be
impossible to reach the maximum velocity you set.
The velocity of the axis, or axes, in a coordinate space never exceeds the
maximum velocity loaded. The axes decelerate to a stop at their final
position, as shown in Figure 4-1.
The acceleration and deceleration portions of an s-curve motion profile are
smooth, resulting in less abrupt transitions, as shown in Figure 4-2. This
limits the jerk in the motion control system, but increases cycle time. The
value by which the profile is smoothed is called the maximum jerk or
s-curve value.
Time
Figure 4-1. Trapezoidal Move Profile
Velocity
Time
Figure 4-2. S-Curve Move Profile
Basic Moves
There are four basic move types:
•Reference Move—Initializes the axes to a known physical reference
such as a home switch or encoder index
•Straight-Line Move—Moves from point A to point B in a straight
line. The move can be based on position or velocity
•Arc Move—Moves from point A to point B in an arc or helix
NI-Motion User Manual4-2ni.com
Chapter 4What You Need to Know about Moves
•Contoured Move—Is a user-defined move; you generate the
trajectory, and the points loaded into the motion controller are splined
to create a smooth profile
The motion controller uses the specified move constraints, along with the
move data, such as end position or radius and travel angle, to create a
motion profile in all the moves except the contoured moves. Contoured
moves ignore the move constraints and follow the points you have defined.
Coordinate Space
With the exception of the arc move, you can execute all basic moves on
either a single axis or on a coordinate space. A coordinate space is a logical
grouping of axes, such as the XYZ axis shown in Figure 4-3. Arc moves
always execute on a coordinate space.
If you are performing a move that uses more than one axis, you must
specify a coordinate space made up of the axes the move will use, as shown
in Figure 4-3.
Z
X, Y, Z
Y
X
Figure 4-3. 3D Coordinate Space
Use the Configure Vector Space function to configure a coordinate space.
This function creates a logical mapping of axes and treats the axes as part
of a coordinate space.The function then executes the move generated by the
trajectory generator on the vector, and treats all the move constraints as
vector values.
Multi-Starts versus Coordinate Spaces
Coordinate spaces always start and end the motion of all axes
simultaneously. You can use multi-starts to create a similar effect without
grouping axes into coordinate spaces. Using a multi-start automatically
starts all axes virtually simultaneously. To simultaneously end the moves,
you must calculate the move constraints to end travel at the same time. In
coordinate spaces, this behavior is calculated automatically.
Trajectory Parameters
Use trajectory parameters to control the moves you program in NI-Motion.
All trajectory parameters for servo axes are expressed in terms of
quadrature encoder counts. Parameters for open-loop and closed-loop
stepper axes are expressed in steps. For servo axes, the encoder resolution,
which is expressed in counts per revolution, determines the ultimate
positional resolution of the axis.
For stepper axes, the number of steps per revolution depends upon the type
of stepper drive and motor you are using. For example, a stepper motor with
1.8°/step (200 steps/revolution) used in conjunction with a 10X microstep
drive has an effective resolution of 2,000 steps per revolution. Resolution
on closed-loop stepper axes is limited to the steps per revolution or encoder
counts per revolution, whichever value is more coarse.
Floating-point versus fixed-point parameter representation and time base
are two additional factors that affect the way trajectory parameters are
loaded to the NI motion controller as compared to how they are used by the
trajectory generators.
The NI SoftMotion Controller uses a 64-bit floating point trajectory
generator. The ranges for all move constraints are the full 64-bit range,
which includes maximum velocity, maximum acceleration, maximum
deceleration, maximum acceleration jerk, maximum deceleration jerk, and
velocity override percentage. All arc parameters that use floating point also
support the full 64-bit floating point range.
NI 73xx Floating-Point versus Fixed-Point
Note The information in this section applies only to NI 73xx motion controllers. These
restrictions are not applicable to the NI SoftMotion Controller.
You can load some trajectory parameters as either floating-point or
fixed-point values, but the internal representation on the NI motion
controller is always fixed-point. You must consider this functionality when
working with onboard variables, inputs, and return vectors. This
functionality also has a small effect on parameter range and resolution.
NI-Motion User Manual4-4ni.com
Chapter 4What You Need to Know about Moves
NI 73xx Time Base
Velocity and acceleration values are loaded in counts/s, RPM, RPS/s,
steps/s, and so on, which are all functions of seconds or minutes. However,
the trajectory generator updates target position at the Trajectory Update
Rate, which is programmable with the Enable Axes function. This means
that the range for these parameters depends on the update rate selected, as
shown in the following examples.
Table 4-1 lists minimum and maximum update rates for acceleration and
velocity in various units.
NI 73xx Velocity in RPM
Velocity values in RPM are converted to an internal 16.16 fixed-point
format in units of counts (steps) per sample period (update period) before
being used by the trajectory generator. NI-Motion can control velocity to
1/65,536 of a count or step per sample.
Table 4-1 shows the minimum and maximum velocity in counts/min. Use
the formula shown in the Calculation Based on Units column to determine
the counts/min value to RPM.
Table 4-1. Velocity in Counts/Min
Update RateMINMAX
62.5 µs14.648438 counts/minFor servo motors, the
125 µs7.324219 counts/min
187.5 µs4.882813 counts/min
maximum counts/min is
1.2 billion independent
of the update rate.
250 µs3.662109 counts/min
312.5 µs2.929688 counts/minFor stepper motors, the
375 µs2.441406 counts/min
437.5 µs2.092634 counts/min
500 µs1.831055 counts/min
maximum counts/min
value is dependent on the
controller:
You can calculate this minimum velocity increment in RPM with the
following formula:
minimum RPMVmin
1
-----
×60×
Ts
×=
1
---
R
whereVmin = 1/65,536 counts/sample or steps/sample
Ts = sample period in seconds per sample
60 = number of seconds in a minute
R = counts or steps per revolution
or
1
minimum RPMMIN
---
×=
R
You also can calculate the minimum velocity using the formula shown in
the Calculation Based on Units column in Table 4-1.
For a typical servo axis with 2,000 counts per revolution operating at a
250 µs update rate, the minimum RPM increment is
1
----------------
65,536
1
----------------
×60
250 µs
1
------------
××0.00183105 RPM=
2000
or
1
3.662109
------------
×0.00183105 RP M=
2000
You can calculate the maximum velocity in RPM with the following
equation:
1
maximum RPMVmax60×
---
×=
R
whereVmax = 20 MHz for servos
8 MHz for steppers on a NI 7350 controller
4 MHz for steppers on a NI 7330, NI 7340, or NI 7390
motion controller
R = counts/steps per revolution
NI-Motion User Manual4-6ni.com
Chapter 4What You Need to Know about Moves
and is constrained by acceleration/deceleration according to the following
equation:
velocity ≤ (65,536 × deceleration) – acceleration
where velocity is in counts/sample and acceleration and deceleration are in
counts/sample
2
.
From the example, the maximum RPM is
2010
×()60
6
1
-------------
××600,000 RPM=
2,000
RPM values stored in onboard variables are in double-precision IEEE
format (f64).
NI 73xx Velocity in Counts/s or Steps/s
Velocity values in counts/s or steps/s are also converted to the internal
16.16 fixed-point format in units of counts or steps per sample (update)
period before being used by the trajectory generator. Although the motion
controller can control velocity to 1/65,536 of a count or step per sample, it
is impossible to load a value that small with the Load Velocity function, as
shown in the following formula:
1
Velocity in counts or steps/sVmin
whereVmin = 1/65,536 counts/sample or steps/sample
Ts = sample period in seconds per sample
-----
×=
Ts
Even at the fastest update rate, Ts = 62.5 × 10
1
----------------
65,536
×0.244 counts or steps/s=
1
---------------------------
62.510
6–
×
–6
The Load Velocity function takes an integer input with a minimum value of
1 count/s or step/s. You cannot load fractional values. If you need to load a
velocity slower than one count or step per second, use the Load Velocity
in RPM function.
You can calculate the maximum velocity with the following equation:
whereVmax = 20 MHz for servos
and is constrained by acceleration/deceleration according to the following
equation:
maximum velocityVmax=
8 MHz for steppers on a NI 7350 controller
4 MHz for steppers on a NI 7330, NI 7340, or NI 7390
motion controller
velocity ≤ (65,536 × deceleration) – acceleration
where velocity is in counts/sample and acceleration and deceleration are in
counts/sample
2
.
NI 73xx Acceleration in Counts/s
Acceleration and deceleration values are converted to an internal
16.16 fixed-point format in units of counts/s
trajectory generator.
Table 4-2 shows the minimum and maximum acceleration update rates in
counts/sec
Table 4-2. Acceleration Update Rate in Counts/Sec
Update RateMAXMIN
62.5 µs2,048,000,000 counts/sec
125 µs2,048,000,000 counts/sec
187.5 µs910,222,222 counts/sec
250 µs512,000,000 counts/sec
312.5 µs327,680,000 counts/sec
375 µs227,555,556 counts/sec
437.5 µs167,183,673 counts/sec
500 µs128,000,000 counts/sec
2
.
2
2
2
2
2
2
2
2
3906 counts/sec
977 counts/sec
434 counts/sec
244 counts/sec
156 counts/sec
109 counts/sec
80 counts/sec
61 counts/sec
2
2
before being used by the
2
Calculation Based
on Units
2
Accel
2
2
2
2
Accel
2
2
2
= MAX
max
= MIN
min
NI-Motion User Manual4-8ni.com
Chapter 4What You Need to Know about Moves
You can calculate the minimum acceleration increment with the following
formula:
2
1
-----
minimum acceleration/decelerationAmin
×=
Ts
whereAmin = 1/65,536 counts/sample
2
or steps/sample
2
Ts = sample period in seconds per sample
For a typical servo axis with 2,000 counts per revolution operating at the
250 µs update rate, calculate the minimum acceleration/deceleration
increment using the following equation:
---------------
65536
1
---------------
×244 counts/second
250µ s
2
1
=
2
You can calculate the maximum acceleration/deceleration using the
following equation:
2
1
maximum acceleration/decelerationAmax
whereAmax = 32 counts/sample
2
-----
×=
Ts
Ts = sample period in seconds per sample
and is constrained according to the following equations:
acceleration ≤ 256 × deceleration
deceleration ≤ 65536 × acceleration
NI 73xx Acceleration in RPS/s
Acceleration and deceleration values in RPS/s are converted to an internal
16.16 fixed-point format in units of counts/sample
being used by the trajectory generator.
Table 4-3 shows the minimum and maximum acceleration update rates in
counts/sec
You can calculate the minimum acceleration increment in RPS/s with the
following formula:
RPS/sAmin
2
2
2
2
2
2
2
2
×
Calculation Based
on Units
±RPS/s
= MAX×1/r
max
where r = counts/revolution
±RPS/s
= MIN×1/r
min
where r = counts/revolution
2
1
-----
Ts
×=
1
---
R
whereAmin = 1/65,536 counts/sample2 or steps/sample
2
Ts = sample period in seconds per sample
R = counts or steps per revolution
or
1
RPM/sMIN
---
×=
R
For a typical servo axis with 2,000 counts or steps per revolution operating
at the 250 µs update rate, calculate the minimum RPS/s increment using the
following equation:
1
----------------
65,536
---------------
250µs
1
2
1
------------
××0.122070 RPS/s=
2000
or
1
------------
244
×0.122=
2000
NI-Motion User Manual4-10ni.com
Chapter 4What You Need to Know about Moves
You can calculate the maximum RPS/s using the following equation:
2
maximum RPS/sAmax
-----
×
Ts
1
×=
1
---
R
whereAmax = 32 counts/sample
2
Ts = sample period in seconds per sample
R = counts or steps per revolution
and is constrained according to the following equations:
acceleration ≤ 256 × deceleration
deceleration ≤ 65536 × acceleration
or
1
MAX
---
×
r
For a typical servo axis with 2,000 counts or steps per revolution operating
at the 250 µs update rate, calculate the maximum RPS/s increment using the
following equation:
2
---------------
32
250µs
1
1
------------
××256,000 RPS/s=
2000
RPS/s values stored in onboard variables are in double-precision
IEEE format (f64).
NI 73xx Velocity Override in Percent
The Load Velocity Override function takes a single-precision
floating-point (f32) data value from 0 to 150%, but velocity override is
internally implemented as a velocity scale factor of 0 to 384 with an
implicit fixed denominator of 256. NI-Motion uses the velocity override to
increase the speed of the calculation for the sake of calculation speed—the
division is a shift right by eight bits. The resolution for velocity override is
therefore limited to 1/256, or about 0.39%.
Note The conversion from floating-point to fixed-point is performed on the host
computer, not on the motion controller. To load velocity override from an onboard variable,
you must use the integer representation of 0 to 384, where 384 corresponds to 150%.
Note If the distance of the move is too small, it may not be possible to reach the
commanded maximum move constraints. In such instances, NI-Motion adjusts the move
constraints lower to reach the commanded position.
NI 73xx Arc Angles in Degrees
The Load Circular Arc, Load Helical Arc, and Load Spherical Arc
functions take angle parameters in degrees as double-precision
floating-point values. These values are converted to an internal
16.16 fixed-point representation where the integer part corresponds to
multiples of 45° (for example, 360° is represented as 0x0008 0000).
Use the following formula to convert from floating-point to fixed point:
whereQ = quotient, the integer multiple of 45°
Angle in degrees
----------------------------------------QR+=
45°
R = remainder
Angle in 16.16 formatQ.
=
·R
--------
65,536×
45°
For example, 94.7° is represented in 16.16 format as follows:
4.7°
Angle in 16.16 format2.
----------
45°
65,536×
0x0002.1ABD==
The minimum angular increment is
1
----------------
65.536
Note The conversion from floating-point to fixed-point is performed on the host
45°×0.000687°=
computer, not on the motion controller. To load arc functions from onboard variables,
you must use the 16.16 fixed-point representation for all angles.
NI-Motion User Manual4-12ni.com
NI 73xx Arc Move Limitations
The following are limitations to the velocity and acceleration of arc moves.
National Instruments recommends that you use the loop timings discussed
in the following sections.
Status Display
When you are displaying status information to the user, such as position,
move status, or velocity, an update rate faster than 60 ms has no value.
In fact, there is no need to update a display any faster than 22 Hz because
the human eye can detect flicker only at refresh rates slower than 22 Hz.
However, you might see flicker in monitors at around 60 Hz, because of
interference with artificial light from light bulbs that run on a 60 Hz AC
signal. The recommended standard is 60 ms because one might need
multiple function calls within one loop to acquire all the necessary data.
Graphing Data
When acquiring data for graphing or tracking purposes, a 10 ms update
time suits most applications. MAX, for example, updates its motion graphs
every 10 ms. This update time equates to 100 samples every second and
provides enough resolution for typical applications. Consider how accurate
the graph display is when choosing the timing for the loop.
Event Polling
Use a polling interval of 5 ms when polling for a time-critical event that
must occur before the program continues. This interval is fast enough to
satisfy most time-critical polling needs, although certain high-speed
applications may require a faster interval. Consider the allowable response
time when choosing a polling interval.
For example, to synchronize the motion with the acquisition in an
application where a user places an object under the scan area and clicks a
Scan button, you create periodic breakpoints every 10 counts to trigger a
data acquisition over RTSI. In this example, the loop needs only to read the
position and wait for the move to complete before ending the scan.
Although the program polls for an event (move complete), no action is
being triggered by the move complete. Because there is no need for
instantaneous action, there is no need to update the position any faster than
60 ms, and 60 ms is acceptable for monitoring the move complete status
as well.
NI-Motion User Manual4-14ni.com
Straight-Line Moves
A straight-line move executes the shortest move between two points.
Position-Based Straight-Line Moves
Position-based straight-line moves use the specified target position to
generate the move trajectory. For example, if the motor is currently at
position zero, and the target position is 100, a position-based move creates
a trajectory that moves 100 counts (steps).
The controller requires the following information to move to another
position in a straight line:
•Start position—Current position, normally held over from a previous
move or initialized to zero
•End position—Also known as the target position, or where you want
to move to
•Move constraints—Maximum velocity, maximum acceleration,
maximum deceleration, and maximum jerk
5
Tip When you are using the NI SoftMotion Controller, you can load separate acceleration
and deceleration jerk values
The motion controller uses the given information to create a trajectory that
never exceeds the move constraints and that moves an axis or axes to the
end position you specify. The controller generates the trajectory in real
time, so you can change any of the parameters while the axes are moving.
Straight-Line Move Algorithm
The straight-line move algorithm includes the following procedures:
•Load target position—Specifies the end position
•Load the move constraints—Loads the velocity, acceleration,
Tip You must load the move constraints only if they are different from what was
previously loaded.
The start position is always the current position of the axis or axes. You can
load the end position as either an absolute position to move to or as a
position relative to the starting position. Although you can update any
parameter while the move is in progress, the new parameter is used only
after a subsequent Start or Blend Move.
5 Load S-Curve Time
6 Set Operation Mode
7 Load Target Position
8 Start Motion
910
11
9 Check Move Complete Status
10 Read per Axis Status
11 Read per Axis Status
12 Motion Error Handler
Figure 5-3. 2D Straight-Line Move in LabVIEW
128
NI-Motion User Manual5-4ni.com
C/C++ Code
Chapter 5Straight-Line Moves
The following example code is not necessarily complete, and may
not compile if copied exactly. Refer to the
examples folder on the
NI-Motion CD for files that are complete and compile as is.
1D Straight-Line Move Code
// Main Function
void main(void)
{
u8 boardID;// Board identification number
u8 axis; // Axis number
u16 csr = 0;// Communication status register
u16 axisStatus;// Axis status
u16 moveComplete;
//Variables for modal error handling
u16 commandID;// The commandID of the function
u16 resourceID;// The resource ID
i32 errorCode;// Error code
///////////////////////////////
// Set the board ID
boardID = 1;
// Set the axis number
axis = NIMC_AXIS1;
////////////////////////////////
// Set the velocity for the move (in counts/sec)
err = flex_load_velocity(boardID, axis, 10000,
0xFF);
CheckError;
//Get the command ID, resource ID, and the
error code of the //modal error from the
error stack on the device
flex_read_error_msg_rtn(boardID,&commandI
D, &resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,
resourceID);
//Read the communication status registerflex_read_csr_rtn(boardID,&csr);
nimcDisplayError(err,0,0);
return;// Exit the Application
}
2D Straight-Line Move Code
// Main Function
void main(void)
{
u8 boardID;// Board identification number
u8 vectorSpace;// Vector space number
u16 csr = 0;// Communication status register
u16 axisStatus;// Axis status
u16 status;
u16 moveComplete;
//Variables for modal error handling
u16 commandID;// The commandID of the function
u16 resourceID;// The resource ID
i32 errorCode;// Error code
// Set the board ID
boardID = 1;
// Set the vector space
vectorSpace = NIMC_VECTOR_SPACE1;
nimcDisplayError(err,0,0);
return;// Exit the Application
}
Velocity-Based Straight-Line Moves
Some motion applications require moves that travel in a straight line for a
specific amount of time at a given speed. This type of move is known as
velocity profiling or jogging.
You can use a motion control application to move a motor at a given speed
for a specific time, and then change the speed without stopping the axis.
The sign of the loaded velocity specifies the direction of motion. Positive
velocity implies forward motion and negative velocity implies reverse
motion.
Tip You can change the move constraints during a velocity move.
NI-Motion User Manual5-10ni.com
Algorithm
Chapter 5Straight-Line Moves
Figure 5-4 is a generic algorithm applicable to both C/C++ and VI code.
Loading a second velocity and executing Start Motion causes the motion
controller to accelerate or decelerate to the newly loaded velocity using the
acceleration or deceleration parameters last loaded. The axis decelerates to
a stop using the Stop Motion function. The velocity profile created in the
example code is shown in Figure 5-5.
The following example code is not necessarily complete, and may
not compile if copied exactly. Refer to the
NI-Motion CD for files that are complete and compile as is.
// Main Function
void main(void)
{
84
5 Set Operation Mode
6 Start Motion
7 Read per Axis Status
8 Load Velocity
9 Start Motion
10 Read per Axis Status
11 Stop Motion
12 Motion Error Handler
Figure 5-6. Velocity-Based Straight-Line Move in LabVIEW
examples folder on the
u8 boardID;// Board identification number
u8 axis; // Axis number
u16 csr = 0;// Communication status register
u16 axisStatus;// Axis status
i32 moveTime1;// Time for the 1st segment
i32 moveTime2;// Time for the 2nd segment
i32 initialTime;
i32 currentTime;
//Variables for modal error handling
u16 commandID;// The commandID of the function
u16 resourceID;// The resource ID
// Move time for the first segment
moveTime1 = 5000; //milliseconds
// Move time for the second segment
moveTime2 = 10000; //milliseconds
//------------------------------------------------//First segment
//------------------------------------------------// Set the velocity for the move (in counts/sec)
err = flex_load_velocity(boardID, axis, 10000,
0xFF);
CheckError;
// Set the operation mode to velocity
err = flex_set_op_mode(boardID, axis,
NIMC_VELOCITY);
CheckError;
// Start the move
err = flex_start(boardID, axis, 0);
CheckError;
// Wait for the time for first segment
initialTime = timeGetTime();
NI-Motion User Manual5-14ni.com
Chapter 5Straight-Line Moves
do
{
// Check the following error/axis off status
err = flex_read_axis_status_rtn(boardID, axis,
&axisStatus);
CheckError;
// Read the communication status register and check the modal //errors
err = flex_read_csr_rtn(boardID, &csr);
CheckError;
// Check the modal errorsif (csr & NIMC_MODAL_ERROR_MSG)
{
err = csr & NIMC_MODAL_ERROR_MSG;
CheckError;
}
// Get the current time and check if time is over for thefirst //segment
currentTime = timeGetTime();
if((currentTime - initialTime) >= moveTime1)
break;
Sleep (100); //Check every 100 ms
}while (!(axisStatus) && !(axisStatus &
NIMC_FOLLOWING_ERROR_BIT) && !(axisStatus &
NIMC_AXIS_OFF_BIT)); //Exit on following error/axis
off
//------------------------------------------------// Second segment
//------------------------------------------------// Set the velocity for the move (in counts/sec)
err = flex_load_velocity(boardID, axis, 6568, 0xFF);
CheckError;
// Start the move - to update the velocity
err = flex_start(boardID, axis, 0);
CheckError;
// Wait for the time for second segment
initialTime = timeGetTime();
do
{
// Check the following error/axis off status
err = flex_read_axis_status_rtn(boardID, axis,
&axisStatus);
nimcDisplayError(err,0,0);
return;// Exit the Application
}
Velocity Profiling Using Velocity Override
You also can use Load Velocity Override to shift from one velocity to
another while executing moves. When you use this function, you indicate
the new velocity in terms of a percentage of the originally loaded velocity
instead of explicitly stating the velocity you want to change to.
For example, 120 percent of an original velocity of 10,000 changes the
velocity to 12,000.
The transition between velocities follows all other move constraints.
The following example code is not necessarily complete, and may
not compile if copied exactly. Refer to the
examples folder on the
NI-Motion CD for files that are complete and compile as is.
// Main Function
void main(void)
{
u8 boardID;// Board identification number
u8 axis;// Axis number
u16 csr = 0;// Communication status register
u16 axisStatus;// Axis status
i32 moveTime1;// Time for the 1st segment
i32 moveTime2;// Time for the 2nd segment
i32 initialTime;
i32 currentTime;
//Variables for modal error handling
u16 commandID;// The commandID of the function
u16 resourceID;// The resource ID
i32 errorCode;// Error code
///////////////////////////////
// Set the board ID
boardID = 3;
// Set the axis number
axis = NIMC_AXIS1;
// Move time for the first segment
moveTime1 = 5000; //milliseconds
// Move time for the second segment
moveTime2 = 10000; //milliseconds
////////////////////////////////
// Wait for the time for second segment
initialTime = timeGetTime();
do
{
// Check the following error/axis off status
err = flex_read_axis_status_rtn(boardID, axis,
&axisStatus);
CheckError;
// Read the communication status register and check the modal //errors
err = flex_read_csr_rtn(boardID, &csr);
CheckError;
// Check the modal errorsif (csr & NIMC_MODAL_ERROR_MSG)
{
err = csr & NIMC_MODAL_ERROR_MSG;
CheckError;
}
// Get the current time and check if time is over for the second //segment
currentTime = timeGetTime();
if((currentTime - initialTime) >= moveTime2)
break;
An arc move causes a coordinate space of axes to move on a circular,
spherical, or helical path. You can move two-dimensional vector spaces in
a circle only on a 2D plane. You can move a 3D vector space on a spherical
or helical path.
Each arc generated by the motion controller passes through a cubic spline
algorithm that ensures the smoothest arc. This also ensures negligible
chordal error, which is error caused when two points on the surface of the
arc join with each other using a straight line. A cubic spline algorithm
generates multiple points between every two points of the arc, ensuring
smooth motion, minimum jerk, and maximum accuracy at all times. The
data path is shown in Figure 6-1.
Circular Arcs
Tip For the NI SoftMotion Controller, the arc generation also uses acceleration jerk and
deceleration jerk while calculating the arc move.
Note When you use an NI 73xx motion controller to move a motor in an arc, you can use
only trapezoidal profiles. You do not use jerk to calculate the profile for arc moves.
Arc Generation
Figure 6-1. Arc Move Data Path
A circular arc defines an arc in the XY plane of a 2D or 3D coordinate
space. The arc is specified by a radius, starting angle, and travel angle.
Also, like all coordinate space moves, the arc uses the values of move
constraints—maximum velocity, maximum acceleration, and maximum
deceleration.
To move axes in a circular arc, the motion controller needs the following
information:
•Radius—Specifies the distance from the center of the arc to its edge
•Start Angle—Orients the arc on its plane using the starting point as an
axis to spin around. Because the starting point for a new arc is fixed
based on the current position, moving its center around the starting
point alters the orientation of a new arc. For example, Figure 6-2 shows
the effect of changing the start angle from 0° to 180°.
1
0°180°
2
1 Original Arc2 Arc with 180° Start Angle
Figure 6-2. Rotating Start Angle
•Travel Angle—Indicates how far the arc travels in a 360° circle. For
example, a travel angle of 90° executes a quarter-circle, a travel angle
of 360° creates a full circle, and a travel angle of 720° creates two full
circles. A positive travel angle always creates counterclockwise
circular motion. A negative travel angle reverses the direction to create
clockwise circular motion, as shown in Figure 6-3.
The following example code is not necessarily complete, and may
not compile if copied exactly. Refer to the
NI-Motion CD for files that are complete and compile as is.
// Main Function
void main(void)
{
32
5 Load Circular Arc
6 Start Motion
7 Check Move Complete Status
7
98
8 Read per Axis Status
9 Read per Axis Status
10 Motion Error Handler
Figure 6-5. Circular Arc Move in LabVIEW
examples folder on the
u8 boardID;// Board identification number
u8 vectorSpace;// Vector space number
u16 csr = 0;// Communication status register
u16 axisStatus;// Axis status
u16 status;
u16 moveComplete;
//Variables for modal error handling
10
NI-Motion User Manual6-4ni.com
Chapter 6Arc Moves
u16 commandID;// The commandID of the function
u16 resourceID;// The resource ID
i32 errorCode;// Error code
///////////////////////////////
// Set the board ID
boardID = 1;
// Set the vector space number
vectorSpace = NIMC_VECTOR_SPACE1;
////////////////////////////////
// Configure a 2D vector space comprising of axes 1
nimcDisplayError(err,0,0);
return;// Exit the Application
}
A 3D spherical arc defines a 2D circular arc in the X'Y' plane of a
coordinate system that is transformed by rotation in pitch and yaw from the
normal 3D coordinate space (XYZ), as shown in Figures 6-6 and 6-7.
In the transformed X'Y'Z' space, the 3D arc is reduced to a simpler 2D arc.
The 3D arc is defined as a 2D circular arc in the X'Y' plane of a transformed
vector space X'Y'Z'. This transformed vector space, X'Y'Z', is defined in
orientation only, with no absolute position offset. Its orientation is relative
to the XYZ vector space, and is defined in terms of pitch and yaw angles.
When rotating through the pitch angle, the Y and Y' axes stay aligned with
each other while the X'Z' plane rotates around them. When rotating through
the yaw angle, the Y' axis never leaves the original XY plane, as the
newly-defined X'Y'Z' vector space rotates around the original Z-axis.
The radius, start angle, and travel angle parameters also apply to a spherical
arc that defines the arc in two dimensions.
The following example code is not necessarily complete, and may
not compile if copied exactly. Refer to the
NI-Motion CD for files that are complete and compile as is.
// Main Function
void main(void)
{
4
3
7
5 Load Spherical Arc
6 Start Motion
7 Check Move Complete Status
8 Read per Axis Status
8
9
10
9 Read per Axis Status
10 Read per Axis Status
11 Motion Error Handler
Figure 6-9. Spherical Arc Move in LabVIEW
examples folder on the
u8 boardID;// Board identification number
u8 vectorSpace;// Vector space number
u16 csr = 0;// Communication status register
u16 axisStatus;// Axis status
u16 status;
u16 moveComplete;
//Variables for modal error handling
u16 commandID;// The commandID of the function
u16 resourceID;// The resource ID
i32 errorCode;// Error code
11
NI-Motion User Manual6-10ni.com
Chapter 6Arc Moves
///////////////////////////////
// Set the board ID
boardID = 1;
// Set the vector space number
vectorSpace = NIMC_VECTOR_SPACE1;
////////////////////////////////
// Configure a 3D vector space comprising of axes 1,
nimcDisplayError(err,0,0);
return;// Exit the Application
}
A helical arc defines an arc in a 3D coordinate space that consists of a circle
in the XY plane and synchronized linear travel in the Z-axis. The arc is
specified by a radius, start angle, travel angle, and Z-axis linear travel.
Linear travel is the linear distance traversed by the helical arc on the Z-axis,
as shown in Figure 6-10.
X
Z
4
Y
X
123
1 Side View of Helix2 Top View of Helix3 Isometric View of Helix4 Linear Travel
The following example code is not necessarily complete, and may
not compile if copied exactly. Refer to the
NI-Motion CD for files that are complete and compile as is.
// Main Function
void main(void){
34
5 Load Helical Arc
6 Start Motion
7 Check Move Complete Status
8 Read per Axis Status
7
8
9
10
9 Read per Axis Status
10 Read per Axis Status
11 Motion Error Handler
Figure 6-12. Helical Arc Move in LabVIEW
examples folder on the
u8 boardID;// Board identification number
u8 vectorSpace;// Vector space number
u16 csr = 0;// Communication status register
u16 axisStatus;// Axis status
u16 status;
u16 moveComplete;
//Variables for modal error handling
u16 commandID;// The commandID of the function
u16 resourceID;// The resource ID
i32 errorCode;// Error code
nimcDisplayError(err,0,0);
return;// Exit the Application
}
NI-Motion User Manual6-18ni.com
Contoured Moves
A contoured move moves an axis or a coordinate space of axes in a pattern
that you define. The trajectory generator on the motion controller is not
used during a contoured move. The controller takes position data in the
form of an array, and splines the data before outputting it to the DACs or
stepper outputs, as shown in Figure 7-1.
7
Overview
User-Defined
Points
Figure 7-1. Contoured Move Data Path
All positions in a contouring buffer are relative to the current position when
starting. There is an assumed 0 point that the firmware adds to the front of
the buffer of points. For example, if the contour buffer is [10, 20, 30, 40],
the positions are [0, 10, 20, 30, 40] in the firmware.
When a contour move starts it takes a snap shot of the current position
according to the following equation:
StartPosition = currentPosition.
The start position is added to each point in the buffer to get the actual
position to move through according to the following equation:
Point = StartPosition + bufferPosition[n].
If the current position is 100, and the buffer is [10, 20, 30, 40], the contour
move follows these points: [100, 110, 120, 130, 140].
The difference between absolute contouring and relative contouring is how
the points in the buffer are treated. The previous example was of an absolute
contour move. A relative contour move treats the points as deltas according
to the following formula:
Point[n] = Point[n-1] + bufferPosition[n]
For a relative contour move that starts at position 100 and includes a buffer
with the following values: [10, 20, 30, 40], the points the contour move
follows are [100, 110, 130, 160, 200].
For contoured moves, no two consecutive points can differ by more than
15
2
– 1. For absolute position mode, the first position in the array passed to
the controller must be less than 2
must be less than 2
15
controller can be greater than 2
Arbitrary Contoured Moves
Contoured moves are useful when you want to generate a trajectory that
cannot be constructed from straight lines and arcs. To ensure that the
motion is smooth with minimum jerk, the motion controller creates
intermediate points using a cubic spline algorithm.
15
– 1, and any two consecutive points
– 1. For relative position mode, no point passed to the
15
– 1.
The move constraints commonly used to limit other types of moves, such
as maximum velocity, maximum acceleration, maximum deceleration,
and maximum jerk, have no effect on contoured moves. However, the
NI Motion Assistant prototyping tool can remap a user-defined trajectory
based on specified move constraints, preserving move characteristics and
move geometry.
NI-Motion User Manual7-2ni.com
Contoured Move Algorithm
Set Operation Mode
Specify absolute or
relative contouring
Configure the buffer
on the device
Write Buffer
Write the array of points and the
number of points you are writing
Start Motion
Loop Waiting for Move Complete
Update Contoured Data (Optional)
Chapter 7Contoured Moves
• Set the Buffer Type as Position
• Total Points is the total number of
countoured points you want to load
• Buffer Size is the size of the buffer you
want to create on the device
• Set Old Data Stop to TRUE if you do
not want old data to be used
• Requested Interval is the time interval
between points
All contoured moves are relative, meaning motion starts from the position
of the axis or axes at the time the contouring move starts. This behavior is
similar to the way arc moves work. Depending on the operation mode you
use, you can load absolute positions in the array or relative positions, which
imply incremental position differences between contouring points.
Absolute versus Relative Contouring
If an axis starts at position 0 and uses either of the following sets of
contouring points, the axis ends up at position 28. If the axis starts at
position 10, it ends up at position 38 in both cases.
13610141822252728
Figure 7-3. Absolute Contouring Buffer Values
1234444321
Figure 7-4. Relative Contouring Buffer Values
NI-Motion User Manual7-4ni.com
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.