Copyright: Help Contents Copyright (c) 1998-2003 by PMC Corp.


Servo Tuning
Servo Tuning v2.7

Welcome to the online help for the Servo Tuning Program. Help provides assistance with installation issues, some servo tuning background information, and a description of the Servo Tuning Program operation.

The Servo Tuning Program will operate with any of our motion control cards via the PC-Bus or Ethernet interface. Make certain that your motion controller is installed and properly connected to the servo amplifier / motor before you attempt to run Servo Tuning.

Contents

 What's New

 Why Tune a Servo

 PID Defined

 Servo Tuning Program Controls

 Gantry Mode Operation

 A Servo Tuning Tutorial

 Glossary

 Contacting Technical Support


What's New

Version 2.7 (note there was never a version 2.6 release) adds support for Ethernet controllers, and provides anumber of enhancements and bug fixes to the enhanced operating modes (such as gantry mode).

In Version 2.5 support has been added for data capture from the auxiliary encoder of an open loop stepper axis (requires a Multiflex controller). The test setup dialog has also been re-organized as a tabbed dialog. See the online help section on Test Setup for details.

Version 2.4 of Tuning further expands the data capture modes of the program by adding a repeat option to permit capturing motor data during a series of repeated moves or repeated cycles. See the online help section on Test Setup for details.

New to Version 2.3 of Tuning is support for gantry mode operation, Tuning's Gantry Mode supports two (identical) motor axes that are physically tied together. See the help section on Gantry Mode for details. To use this version of the Servo Tuning Program you must have Version 3.0 of the Motion Control API installed on your computer.


Why Tune a Servo Motor
Why Tune a Servo Motor?

A servo is a closed loop system, described in the dictionary as:

An automatic system in which the output is constantly compared with the input through some form of feedback. The error (or difference) between the two quantities can be used to bring about the desired amount of control.

In typical servo systems:

•	The output is a +/- 10 volt (torque or velocity) command that is applied as an input to a servo amplifier

•	The input described in the dictionary definition comes from an encoder. An encoder is an opto-electric device that generates two pulse trains that are shifted in phase by 90 degrees

•	In order for a servo system to perform properly, the difference (error) between the input and output is multiplied by a set of gain values which results in a new output, bringing about the desired amount of control

Servo tuning is the process in which the gain values are determined. From one servo axis to another the gain values will change depending on differences between the motion controller, motor, encoder, and load. When a user attempts to move an axis without first tuning the servo (determining the gain values) the motion controller will not be able to calculate the appropriate output command to apply to the servo amplifier. One of the two following undesirable results will probably be observed:

•	The axis will not move at all

•	The axis moves but does not stop at the target, oscillation will probably be present

Imagine a seesaw, with the +/- 10 volt torque/velocity command on one side and the response of the motor/load (feedback from an encoder) on the other side.

Until the servo is tuned, the system is effectively out of balance. Only after a servo has been tuned can the controller calculate the appropriate torque/velocity command output for a given user defined motion.


PID Defined

Now that we know what the PID filter does (it calculates the level of the torque/velocity command), lets try to understand how it works. A PID filter has three components or terms:

•	Proportional gain (P)

•	Integral gain (I)

•	Derivative gain (D)

Proportional gain

The Proportional gain is the primary component or term of the PID filter. The command voltage output is equal to proportional gain multiplied by current position error. Proportional gain units are volts per encoder counts of position error. For example, if the proportional gain is 1.0, and the axis is 5 encoder counts from where it is supposed to be, the MC300 command voltage output will be:

Proportional gain X position error = Command voltage output

1.0 volt X 5 counts of error = 5.0 volts

A slingshot is a good example of how proportional gain works. Pull the rock back to shoot (increase the position error) and the restoring force of the elastic band increases (the command voltage output increases). The farther back the rock is pulled, the greater the restoring force (the greater the command voltage output), and the further the rock will fly. Let the rock go, the elastic returns to (or near) its target, position error is zero, and there is no more  restoring force (command voltage = 0).

Derivative gain

Derivative gain is used to dampen overshoot and oscillation, which are the typical side affects of proportional gain. Referring once again to the analogy of a slingshot. The dampening effects of derivative gain are similar to shooting that same slingshot in a container of water.

Prepare to shoot by pulling back slowly on the rock and the water provides minimal resistance. But let the rock go and the water will significantly reduce the velocity at which the rock travels. The amount of dampening is proportional to the velocity of the rock.

In much the same way, the derivative term of the PID filter dampens the responsiveness of a servo system by opposing a change in the position error.

Derivative gain dampens the responsiveness of a servo. This is accomplished by reducing the torque/velocity command based on a change in the position error from one servo loop to another. Imagine manually rotating the shaft of a servo motor. The graphs below depict how the servo system would respond. The first graph plots the response of a servo using only proportional gain, the second graph demonstrates the benefits of adding derivative gain.

Without derivative gain, only mechanical friction is available to dampen the servo. It approaches the target with too much force and overshoot occurs. With the addition of derivative gain not only is the settling time reduced by 25 milliseconds, overshoot has been significantly reduced.

While derivative gain is typically associated only with dampening a servo it is possible for it to actually increase servo instability. If the derivative gain term is calculated every servo loop it may tend to fight against the properties of proportional gain. Defining the Derivative Sampling Period sets the interval between derivative gain term calculations. For typical servo systems the derivative term calculation interval should be increased to 2 (high friction servos) to 12 (high inertial servos) servo loop updates.

Integral gain

Typically integral gain comes in to play only at the end of a move. It is used to push the axis those last few counts to the target. Without integral gain the optimal balance between accuracy, repeatability, and servo stability would be almost impossible to achieve.

Near the end of a move the axis may stop short of the target due to friction in the mechanics. If only proportional and derivative gains are used, the axis will remain short of the target, and the torque/velocity command output will remain at a non-zero value.

This chart of command voltage, axis velocity, and following error demonstrates the problem caused by friction. The controller attempts to decelerate the axis (time = 3 seconds through time = 10 seconds) but friction causes the axis to stop two and a half seconds early. The axis is short of the target and the following error begins to increase.

Integral gain provides a restoring force that increases over time. It is used to correct a static position error at the end of a move.

In the previous example, friction caused the motor to stop moving prematurely. With the addition of integral gain the axis will now reach the target.

As in the previous example, at around 7.5 seconds system friction is greater than the drive current and the motor stops. At this point the following error begins to increase because the controller is still trying to move the axis to the target position.

The increasing following error causes the integral gain to increase the command output voltage level. The axis resumes its motion until it reaches the target.

While integral gain is typically only used to correct a position error at the end of a move, it is a part of every servo loop calculation. If the integral gain value is set too high it will cause an axis to oscillate during the entire motion. This occurs because integral gain applies a restoring force as a factor of time. The greater the integral gain value, the shorter the accumulated error time factor, the greater the likelihood that integral gain will cause the controller to calculate an excessive command output.

Integral gain sets the accumulated error time constant, in other words it defines how quickly the controller will attempt to correct static position error. However integral gain does not provide any mechanism for setting or limiting the level of the command output. This is accomplished by setting the Integration Limit. The value of the integration limit is used by the PID loop to calculate the level of the command output that will be used to correct the static position error.

PID Filter Summary

•	Proportional gain is the primary term; it is what starts an axis moving. The responsiveness of a servo (stiff or soft) is determined by proportional gain.

•	Derivative gain acts to dampen the responsiveness of the servo.

•	Increasing the Derivative Sampling Period for high performance servo controllers improves system dampening and increases servo stability

•	Integral gain is used to overcome friction. It moves the axis those last few encoder-counts to the target.

•	Integration Limit sets the maximum command signal that can be applied by the integral gain.


Servo Tuning Program Controls

The Servo Tuning Program includes the important tuning controls on its main window, permitting you to perform most tuning functions without having to spend your time digging through menus and dialog boxes.

The Control Panel

The control panel, located on the left edge of the Servo Tuning main window, permits you to change motor settings and test motor operation. Readouts at the top the control panel display the currently selected axis number and the position of that axis.

Beneath the readouts is the Motor control. This control enables or disables the currently selected axis. An axis must be enabled in order to perform measurements. If an axis is enabled the Motor LED on the control panel will glow green, a motor error condition will cause this LED to glow red. Click on the Motor On button to clear errors.

Next comes the Trajectory Generator control. Initial tuning is performed with the Trajectory Generator off. The Trajectory Generator control panel LED will glow yellow when the Trajectory Generator is enabled. You can only plot Optimal Position data when the Trajectory Generator is enabled (Optimal Position data plots in yellow).

The Test controls permit you to run a new test in the positive (Step Plus) or negative (Step Minus) directions, clear the plot (Clear), and zero the position of the axis (Zero). The specific test parameters (time, distance, etc.) are set from the Test Setup option on the Setup menu.

The bottom-most slider controls allow independent adjustment of the Proportional (P or Kp), Integral (I or Ki) , and Derivative (D or Kd) gains. The range of these slider controls is set by using the + (zoom in) and - (zoom out) buttons near the top of each control, or from the Panel Setup option on the Setup menu. The control range is specified as a percentage of full scale (controller specific scaling is handled automatically by the Servo Tuning Program). A separate readout underneath each of the P, I, and D sliders gives the current setting, in controller units.

File Menu

New clears the currently displayed data curves, similar to the Clear button on the control panel. Open allows you to read in and display a previously stored set of tuning data. Save As stores the current data in comma separated values (CSV) format, suitable for importing into Microsoft Excel and similar programs.

Select Controller displays all of the currently installed motion controllers and allows you to select which controller to use. Reset Controller will cause the motion controller to execute a reset, restoring all parameters to their default values. A warning dialog (with the option to cancel) is displayed prior to the reset.

Checking Auto Initialize will cause the Servo Tuning Utility to initialize the axes using values saved in the MCAPI.INI file (these settings are shared among MCAPI applications) each time the Servo Tuning application is started. If you do not initialize your axes the settings will revert to the controller defaults every time the PC is re-booted. It is also possible to initialize your axes by importing an MCCL file or by initializing them from a separate program before Servo Tuning is run. When you exit Servo Tuning you will be asked if you wish to save any changes you have made to the Auto Initialize settings.

The Import/Export MCCL menu options are used to process MCCL command files. MCCL, or Motion Control Command Language, is the text based command language used by PMC's motion control cards. Selecting Import MCCL will prompt you to select an MCCL command file to read and send to the motion control card. Export MCCL writes the current motion control card settings to an MCCL file for later use.

If you have a printer attached to your PC, Print will produce a printout of the current display and test settings.

Exit terminates the Servo Tuning Program. You will be prompted to save your updated servo tuning settings.

Setup Menu

Axis Setup brings up the servo setup dialog. From here you can edit the motion parameters, PID filter values, and limit switch settings of the currently selected axis. If you make changes within this dialog any current test results will be cleared.

Scaling Setup changes the scale factors for the currently selected axis (if the motion controller supports scaling).

PID Setup lets you set the range for the PID slide controls on the control panel.

Test Setup allows you to specify the length of the test move, number of data points collected, the delay prior to data collection (requires MCAPI 2.0d or higher), and display settings. If you make changes within this dialog any current test results will be cleared.

Test Menu

The Test Menu duplicates the key functions of buttons on the control panel. This menu also includes keyboard accelerators (shortcuts) for each of these controls.

Help Menu

Help will launch the windows help system and display the help file for the Servo Tuning Utility (this file).

If you have an installed web browser and an Internet connection, you may select Visit PMC on the Web to connect to the PMC web site. Updates to the Servo Tuning Utility and PMC’s other software are available free of charge on the PMC web site.

Select About for information about the Servo Tuning Utility, including the program version.


Gantry Mode Operation

A gantry is a motion system where two or more motor axes are physically connected. The gantry motor axes are commanded to move in unison, and their combined efforts result in motion of the gantry system.

Servo tuning allows you to specify two axes on a motion controller that are to be tuned simultaneously, with identical motion profiles for both axes. By default, both axes will share PID parameters, scale factors, accelerations, decelerations, velocities, and limit switch settings.

The gantry axes will share the same test distance, dwell, delay, cycle mode, and plotting settings. These settings are shared regardless of the Share Motor Settings option for motor parameters. Enabling or disabling the Motor or the Trajectory Generator of a gantry axis from the Tuning control panel will affect both gantry axes.

When gantry mode is enabled axes configured for gantry mode operation will have the word "gantry" included in the current axis number display on the Tuning control panel.

From the Servo Tuning test setup dialog you may enable Gantry mode by checking the Gantry Mode checkbox. Designate one of the axes on the motion controller as the master axis and a separate (but identical) axis as the slave.

By default the Share Motor Settings checkbox will be checked. It is recommended that you leave this option checked, at least through initial tuning. In gantry mode with Share Motor Settings enabled any changes to one of the gantry axes from the front panel PID sliders, Axis Setup Dialog, and Scaling dialog will automatically be applied to both gantry axes.

If you clear the with Share Motor Settings checkbox the you will be able to adjust each axis individually. If the axis become significantly different the gantry may fail to operate or may operate erratically.


PID Setup Dialog

The PID setup dialog allows you to independently set the range for each of the PID slide controls. The control range is specified as a percentage of full scale (controller specific scaling is handled automatically by the Servo Tuning Program). A separate readout underneath each of the P, I, and D sliders gives the current setting, in controller units.

On the DCX-PCI300, DCX-AT300 and DCX-AT200 the proportional gain has a range of 0 to 10. Integral and derivative gains must be between 0 and 20.0.

For the DCX-AT100, DCX-PC100, and the DC2 all three gains have a maximum range of 0 to 32,767.


Test Setup Dialog

The test dialog configures the step response test and how the test data is displayed. If you make changes to the test setup the data plot window is cleared.

The Motion box contains the controls for the actual test motion. Distance sets the step response distance the motor will be commanded to move. You should enter this value as a positive number and use the Control Panel Step Plus and Step Minus buttons to control direction. This value is expressed in whatever units the controller is configured for (by default encoder counts). Next is the Time, in milliseconds, during which data will be collected. The Delay feature allows you to delay before beginning data capture. Delay uses the built-in delay feature on the DCX-AT300 controller, and simulates the delay in software for all other controller models. Servo Tuning will warn you if the test parameters are outside the capability of the currently selected motion controller.

Selecting the Cycle option in the Motion box enables cycle mode moves. In a cycle mode move the axis moves the distance specified in the test settings described above, dwells for a preset amount of time (specified in the Dwell settings), then returns to the starting position.

The Repeat mode settings allow you to repeat the current single move or cycle move 2 or more times. Enabling the repeat option and setting count to a value of 1 or higher will cause the current move and cycle options to be repeated count times. If a single move (cycle mode disabled) has been selected the result will be a stair-step move sequence. If cycle mode is enabled the results will be more like a sine curve. The value for Repeat Dwell will be used to generate a dwell between repeat sequences.

See the help section on Gantry Mode for details about gantry mode settings.

Plot options permit you to specify which curves will be plotted. Options may be grayed in this box if the controller does not support the particular curve, or when the Multi Plot Style has been selected (Multi pre-selects a number of the plotting options). The option to plot the auxiliary encoder position was added in version 2.5 of Servo Tuning. Auxiliary Encoder plotting is supported only for open loop stepper axes on the Multiflex family of controllers (the Multiflex controller must have been ordered with Auxiliary Encoder support. Use the scale factor to match the auxiliary encoder counts to the pulse output (auxiliary encoder position multiplied by the scale factor should equal the pulse count. When Auxiliary Encoder plotting is enabled the error plot will represent the difference between the optimal position (pulse count) and the auxiliary encoder position.

The Plot Style options determine the basic formatting of the graphical display. The default setting is Multi – the actual and optimal trajectory data will be plotted on the first graph, Following Error is plotted alone on the second graph, and Torque (if available) is plotted alone on the third graph. The Single plot style plots all the data on a single graph, and Separate gives each data set a separate graph. Some of the Plot Styles allow you to further customize them by enabling individual data sets using the options in the "Plot" group.

The plotting controls permit you to speed up the data display by reducing the number of data points plotted. This is particularly useful for slow interfaces such as the RS232 serial interface. By only plotting every other or even every fourth data point the plot time is cut by a factor of 2X or 4X, respectively. The only potential problem is that some fine detail (such as very high frequency oscillation) may be masked. If you use the plotting controls to speed up data display you should always run at least one final step response test with plotting set to Every Data Point to verify that there is no masked high frequency component.


Tutorial

A servo system is tuned by applying a command output or step response, plotting the resulting motion, and adjusting parameters of the digital PID filter until an acceptable system response is achieved. Step response is an output command by the motion controller to a specific position. The typical step response distance used for tuning a servo is 100 encoder counts. If, however, the system requires:

•	Very short duration moves (less than 100 msec’s)

•	Very small following error value (less than 20 encoder counts)

then a step response distance of 50 encoder counts is recommended. If the servo system is moving a high inertial load (minimal friction) then the step response should be increased to 200 – 1000 encoder counts. There is a ‘loose’ relationship between the step response and the following error of the system. The shorter the step response while tuning the servo, the lower the following error will be during application motion.

	Note: Using a short step response (5 - 20 counts) may result in an unstable system that oscillates during and after a commanded move.

From the Windows Start menu open the Servo Tuning program (Programs | Motion Control | Motion Integrator | Servo Tuning). From the Tuning Program menu bar select Setup | Test Setup. Configure the Test Setup dialog as shown (these settings will command a step response of 100 encoder counts plot window time period of 500 msec’s):

From the menu bar select Setup | Servo Setup. Configure the Servo Setup dialog as shown:

While setting proportional and derivative gain, the step response should occur with the Trajectory Generator disabled. This will result in the magnitude of the output signal being determined only by a PD filter, the controller will not apply a maximum velocity or ramping (acceleration/deceleration). You may enable or disable the Trajectory Generator using the buttons on the main screen of Servo Tuning. A status LED near the buttons indicates the current state of the Trajectory Generator.

Setting Proportional Gain

Proportional gain controls the responsiveness of a servo system. Set the slide controls for ‘I’ (Integral gain) and ‘D’ (Derivative gain) to 0. Set the slide control for ‘P’ for .05. Turn the Motor On. Make sure the Trajectory Generator is off. Press the Step Plus button, the motor should move and a position versus time plot will be displayed.

Adjust the proportional gain until the plotted path crosses the target three times (no more, no less) and stops within 5% of the target.

If no plotted position path is shown:

•	If the Motor On LED is still on, the proportional gain is to low. Increase ‘P’ by 100%.

•	If the Motor On LED is off  an error has occurred. The most likely cause is a following error has occurred which would indicate that the servo is reversed phased. Open the Servo Setup dialog box and select the Reverse Phase option or ‘swap’ the phase A and B connections from the encoder to the DCX servo module. Turn the motor back on and proceed with the tuning process. If a position path plot is still not displayed refer to the Troubleshooting chapter of this manual.

Setting Derivative Gain

Derivative gain acts as a dampening factor for the servo system. The DCX-PCI300 defaults to calculating the derivative term every time the PID filter is executed (every 125 usec’s). For many servo systems this will cause the derivative term to be too large, which may cause a buzzing or grinding noise.  For most servo systems it is recommneded that the derivative term be calculated every 4 to 8 servo loops. Open the Servo Setup dialog and set the derivative sampling period to 0.00075 (every 6 servo loops). For high inertia (heavy load with minimal friction) applications, the derivative sampling period should be set to between .001 and .002.

Add a little Derivative gain and then move the motor. Repeat this process until the amount of overshoot (difference between the target and the most positive position) is between 20% to 25%. The goal is to identify the derivative gain setting that:

•	Limits overshoot to between 20% to 25%

•	The final position is as close to the target as possible

Setting the Integral Gain

Due to friction, ‘sticktion’, amplifier offset, etc. most servo systems are unable to settle at the target if using only proportional and derivative gain. Integral gain provides a restoring force that increases with time. It is used to correct a static position error of a servo system. If the servo is unable to repeatedly position within +/- one encoder count of the target Integral Gain will, in most cases, position the servo at the target.

To configure the Servo Tuning utility for setting the integral gain:

•	Enable the trajectory generator.

•	Define trajectory parameters (max. velocity, acceleration, and deceleration) in the Servo Setup dialog

•	Define a typical application move distance and duration in the Test Setup dialog

For this example:

•	Maximum velocity = 100,000 counts per second

•	Acceleration and deceleration = 100,000 counts per second per second

•	Move distance = 3,000 counts

•	Plot window time = 700 msec’s

With the trajectory generator enabled, a step response will cause two plot traces to be displayed in the upper window. The blue trace is a plot of the actual positions of the servo. The yellow trace is a plot of the calculated (or optimal) positions of the servo. The optimal positions are the result of calculations by the DCX based on the trajectory parameters (max. velocity, acceleration, and deceleration) defined in the Servo Setup dialog. With the Trajectory Generator enabled a plot of the following error (red trace in the middle window) is also displayed. Select the Step Plus button to move the axis.

Without executing another move, slowly increase the integral gain (I slide control) until the position readout indicates that the axis has reached the target position of the move.

If the ‘I’ control has reached 50% and the axis has not reached the target either:

•	The Integral Limit is too low, limiting the restoring force that the integral gain can apply. Double the value in the Servo Setup dialog.

•	The Integral gain slide control range needs to be increased. In the PID setup dialog double the value for the integral gain upper limit.

Once the position readout indicates that the axis is at the target execute another move (Step Plus). If the axis stops and settles within one encoder count of the target the servo has been successfully tuned. If the position readout indicates that the servo is unable to settle, reduce the setting of the integral gain (I term). Execute additional moves until the axis settles at the target.

Saving the Tuning Parameters

Once an axis has been tuned you should save the PID and trajectory parameters. Select Save All Axis Settings from the File menu. Selecting this option will load all servo settings into the MCAPI.INI file (in the Widows folder). In addition when you elect to close the Servo Tuning program it will prompt the user about saving the settings.

Electing to save servo settings using the Auto Initialize menu option causes the Servo Program to call the MCAPI Common Dialog function MCDLG_SaveAxis( ). All servo parameters (PID, Trajectory, Limits, Scaling, etc.) will be saved in the dialog. To restore these servo parameters from your application program, include a call to the reciprocal function MCDLG_RestoreAxis( ) during program startup.


Glossary

Accuracy

A measure of the difference between the expected position and actual position of a motion system.

Actuator

Device which creates mechanical motion by converting energy to mechanical energy.

Critical Damping

A system is critically damped when the response to a step change in desired velocity or position is achieved in the minimum possible time with little or no overshoot.

DAC

The digital-to-analog converter (DAC) is the electrical interface between the motion controller and the motor amplifier. It converts the digital voltage value computed by the motion controller into an analog voltage. The more DAC bits, the finer the analog voltage resolution.

Dead Band

A range of input signals for which there is no system response.

Encoder

A type of feedback device which converts mechanical motion into electrical signals to indicate actuator position or velocity.

Following Error

The difference between the calculated desired trajectory position and the actual position.

Inertia

The measure of an object's resistance to a change in its current velocity. Inertia is a function of the object's mass and shape.

Limits

Motion system sensors that alert the motion controller that the physical end of travel is being approached and that motion should stop.

MCAPI

The Motion Control Application Programming Interface - this is the programming interface used by Windows programmers to control PMC's family of motion control cards.

MCCL

Motion Control Command Language - this is the command language used to program PMC's family of motion control cards.

Micro Stepping

Stepper drive systems have a fixed number of electromechanical detents or steps. Micro stepping is an electronic technique to break each detent or step into smaller parts. This results in higher positional resolution and smoother operation.

Position Error

see following error.

Position Move

Unlike a velocity move, a position move includes a predefined stopping position. The trajectory generator will determine when to begin deceleration in order to ensure the actual stopping point is at the desired target position.

PWM

Pulse Width Modulation is a method of controlling the average current in a motors phase windings by varying the duty cycle of transistor switches.

Repeatability

The degree to which the positioning accuracy for a given move performed repetitively can be duplicated.

Resonance

A condition resulting from energizing a motor at a frequency at or close to the motor's natural frequency.

Resolution

The smallest positioning increment that can be achieved.

Resolver

A type of feedback device which converts mechanical position into an electrical signal. A resolver is a variable transformer that divides the impressed AC signal into sine and cosine output signals. The amplitude of these signals represents the absolute position of the resolver shaft.

Slew

That portion of a move made at constant, non-zero velocity.

Tachometer

A device attached to a moving shaft that generates a voltage signal directly proportional to rotational speed.

Velocity Move

A move where no final stopping position is given to the motion controller. When a start command is issued the motor will rotate indefinitely until it is commanded to stop.