# 0x2012 Position Controller¶

#### Parameter Tuning Guide for Position Controller with Cascaded Structure

##### Introduction

The cascaded control structure is the standard position control structure for SOMANET Drives. Its controller gains can be automatically set by the auto-tuning process, the results will be stored in the objects 2012:1 ... 2012:8. If auto-tuning is not applicable or manual modifications are necessary, the gains can be set manually. In the following, a procedure to do so is described. If a simple PID position controller is selected instead of the cascaded PID position controller, its gains are defined by the objects 2012:1 ... 2012:4.

##### Control Basics

The cascaded controller is usually used in PI-P form, i.e. inner loop (velocity control loop) is only using the proportional part of its PID controller and the outer loop (position controlling loop) is only using its proportional and integral part. The other form is P-PI form, i.e. inner loop is using proportional and integral part and outer loop uses only proportional part. The inner velocity control loop is responsible for calculating the torque reference. As a result, the integral limit of the velocity controller should be set to the maximum torque of your torque actuator. Moreover, the outer position control loop is responsible for controlling the reference velocity, and consequently, its integral limit should be set to the maximum velocity of your system.

##### Tuning Concept in Brief

For tuning the cascaded structure, we should first focus on the inner (velocity) loop. As it is the inner controlling loop, it should be faster than the outer position loop. However, if all parameters of the outer position controller are set to 0, the inner loop will be disconnected from the user position commands. As a result, we can increase the K_p of both position and velocity controllers with a ratio of 10 (K_p_velocity = 10 * K_p_position). Once the real position started to follow the reference position, we can stop increasing the K_p_position, and only focus on increasing K_p_velocity. At this stage, we can increase (sharpen) the velocity controller as much as possible. As a rule of thumb, increase K_p_velocity until you get close to the instability margin (at this margin, you will feel a vibration effect and some acoustic noise which is caused by controller sharpness). Now, you can reduce K_p_velocity to 90% of its value to increase the stability margin, and remove vibration noise. Once the velocity controller (the inner controlling loop) is tuned, it is time to tune the position controller (the outer controlling loop). To tune the position controller loop, we should start with the P part of its PID controller. Increase K_p_position until the entire position control gets close to instability margin. At this state, you will feel a vibration (or acoustic noise) which is because of too sharpened position control. At this step, reduce K_p_position to its 90% to increase the stability margin and remove the vibration/acoustic noise. So far, the proportional parts of both inner velocity loop and outer position loop are tuned, and we can focus on integrator part of the outer position or inner velocity loop (depends on the chosen structure of controller). Increasing the integrator constant will remove the steady-state error, but at the same time, it adds some overshoot at step responses. As a rule of thumb, you can increase K_i step by step until the following two conditions are met at the same time:

• the steady-state error is eliminated in a short enough period of time
• the overshoot is in its acceptable range

In the following section, the explained tuning concept is divided into separate systematic steps.

##### Tuning Steps
• Step 1. Set the PID constants of both controllers equal to 0. By default, the integral limit of the velocity controller should be set to motor maximum torque and the integral limit of the position controller should be set to motor maximum velocity. From this step forth, the step response of the position controller should always be evaluated.
• Step 2. In this step, the K_p constant of the velocity controller should be tuned. Increase the K_p of both position and velocity controllers with a ratio of 10 (K_p_velocity = 10 * K_p_position). Once the real position starts to follow the reference position, stop increasing the K_p_position and only focus on increasing the K_p_velocity. Increase (sharpen) the velocity controller as much as possible. As a rule of thumb, increase K_p_velocity until you get close to the instability margin (at this margin, you will feel a vibration effect and some acoustic noise which is because of controller sharpness). Now, you can reduce K_p_velocity to 90% of its value to increase the stability margin, and remove vibration noise.
• Step 3. Now that the velocity controller is tuned, it is time to tune the parameters of the PID position controller. Start with K_p_position, and increase it until you again get close to the instability margin, and then reduce K_p_position` to its 90%. So far, the proportional parts of both inner velocity loop and outer position loop are tuned.
• Step 4. In this step, increase K_i to eliminate the steady state error. As a suggestion start with K_i equal to 0.01, and in each step, increase it with a factor of 2. Increase K_i step by step until the following two conditions are met at the same time:
• the steady-state error is eliminated in a short enough period of time
• the overshoot is in its acceptable range

#### Parameter Tuning Guide for Position Controller with simple PID Structure (objects 2012:1...2012:4 only)

The Position Controller with Cascaded Structure is generally preferable over the simple PID controller. Apart from academic purposes, there are few reasons to use the simple PID controller.

##### Tuning Concept for Simple PID Controller

To tune the position controller loop, we should start with the P part of its PID controller. Increase K_p_position until the entire position control gets close to instability margin. At this state, you will feel a vibration (or acoustic noise) which is because of a position control that has been sharpened too much. At this step, reduce K_p_position to its 90% to increase the stability margin and remove the vibration/acoustic noise. Now increase K_i to eliminate the steady state error. As a suggestion start with K_i equal to 0.01, and in each step, increase it with a factor of 2. Increase K_i step by step until the following two conditions are met at the same time:

• the steady-state error is eliminated in a short enough period of time
• the overshoot is in its acceptable range
Name Index:Sub Type Bit Size Min Data Max Data Default Data Unit Access PDO Mapping
Position Loop Kp 0x2012:1 REAL 32 0 0 readwrite

The P-gain of the PID Position Control Loop. The value is given in [rpm/inc] for the cascaded position controller ([mNm/inc] for the simple PID position controller)

Name Index:Sub Type Bit Size Min Data Max Data Default Data Unit Access PDO Mapping
Position Loop Ki 0x2012:2 REAL 32 0 0 readwrite

The I-gain of the PID Position Control Loop. The value is given in [rpm/(inc*s)] for the cascaded position controller ([mNm/(inc*s)] for the simple PID position controller)

Name Index:Sub Type Bit Size Min Data Max Data Default Data Unit Access PDO Mapping
Position Loop Kd 0x2012:3 REAL 32 0 0 readwrite

The D-gain of the Position Control Loop [rpm*s/(inc)] for the cascaded position controller ([mNm*s/(inc)] for the simple PID position controller)

Name Index:Sub Type Bit Size Min Data Max Data Default Data Unit Access PDO Mapping
Position Loop integral limit 0x2012:4 UDINT 32 0 readwrite

Integrator limitation for anti-windup. Technique used is clamping and it prevents the integral term from accumulating above or below pre-determined bounds. Initially set to MAX (2,147,483,647 --> Integral limit DEACTIVATED), please set the maximal values for your integral limit manually. Limit should always be set in the driving shaft units, especially important, when the gear box is used in the setup.