# Backlash Compensation

In mechanical engineering, backlash, sometimes called lash or play, is clearance or lost motion in a mechanism caused by gaps between the parts. It can be defined as "the maximum distance or angle through which any part of a mechanical system may be moved in one direction without applying appreciable force or motion to the next part in mechanical sequence",[1]p. 1-8 and is a mechanical form of deadband. (from Wikipedia).

You might visualize backlash conceptually as maneuvering a sled connected to a car with a 1 foot long chain.  As long as we desire to move continuously in one direction without jerking, and there is enough drag (friction) to keep tension in the chain, the sled's position can be controlled well.  However when reversing  direction we quickly need to move the car 2 feet to take out the slack in the chain.  Moving too far can result in a jerk to the sled.  Moving too little and the position will be incorrect.

Even when moving smoothly in one direction there can be major problems when external forces are applied to the sled such as going down a hill (think of Z axis or climb cutting forces).

It's always better to reduce backlash rather than attempt to compensate for it.  However in some cases Software Backlash Compensation can work well.  To enable KFLOP's Software Backlash Compensation see the Backlash Compensation Settings here

There is currently one Backlash Compensation Mode called "Linear" that is applied within KFLOP for all motions.  Compensation for each axis is applied independently.  Whenever the trajectory of motion reverses direction the commanded position is advanced by the Backlash Amount in a linear manner as a function of time.  The rate at which the Backlash Amount is applied is determined by the Backlash Rate setting.

Note that the backlash is applied linearly over time (as a constant velocity) without any acceleration/deceleration.  The idea is that the backlash should be a tiny distance and needs to be applied quickly so acceleration/deceleration should not be necessary.  If this is an issue in your system you may try reducing the rate till the point where it isn't an issue or otherwise you may not use the compensation.

The Backlash Rate parameter allows control over how quickly or gradually the backlash is applied.  The optimal value is difficult to determine because it depends on the dynamics of your system.  Too quickly might create shock and jerk in the motion but too gradually will result in a period of time where the backlash is uncorrected.  Most systems should be able to perform the tiny backlash motion in a 10-100 millisecond time range.  However every system is different.  Also the max velocity of your drivers should be considered and never exceeded.  For example if your Drivers can only accept pulses up to 100KHz then the Backlash Rate should never be set larger than 100,000.  Note the backlash rate is additive to the velocity of the trajectory so the combined rate might be higher.  This is not normally an issue as in reality direction changes only occur at low velocities.

See the diagram below that shows how the Commanded Motor Position will be generated based on an example Desired Axis Trajectory.

The first step is to measure the amount of backlash in your system and convert it to counts or steps.  A test moving to the same place from different directions is normally performed and a dial indicator is used to measure the difference.  Another method is to move in one direction, stop, then command tiny incremental steps in the opposite direction and detect at what point the axis actually begins to move.  For example with a measured Backlash of 0.2mm and a system resolution of 640 Steps/mm, the Backlash Amount would be 0.2mm x 640 steps/mm = 128 steps.

Next choose a reasonable time for your system to make the compensation.  Let's assume we want to make the correction in 50 milliseconds.  Now compute the rate:  Backlash Rate = 128 steps / 0.050 seconds = 2560 steps/second