C. Position Control (Week 2)
Last updated
Was this helpful?
Last updated
Was this helpful?
The block diagram shown in Figure 16 is a general unity feedback system with a compensator (controller) and a transfer function representing the plant, . The measured output, , is supposed to track the reference signal and the tracking has to match certain desired specifications.
The output of this system can be written as:
By solving for , we can find the closed-loop transfer function:
Recall in the Integration laboratory experiment, the Rotary Servo Base Unit voltage-to-speed transfer function was derived. To find the voltage-to-position transfer function, we can put an integrator in series with the speed transfer function (effectively integrating the speed output to get position). Then, the resulting open-loop voltage-to-load gear position transfer function becomes:
As you can see from this equation, the plant is a second-order system. In fact, when a second-order system is placed in series with a proportional compensator in the feedback loop as in Figure 16, the resulting closed-loop transfer function can be expressed as:
where is the natural frequency and is the damping ratio. This is called the standard second-order transfer function. Its response depends on the values of and .
Consider a second-order system as shown in Equation 3.4 subject to a step input given by
with a step amplitude of . The system response to this input is shown in Figure 17, where the red trace is the response (output), , and the blue trace is the step input .
The maximum value of the response is denoted by the variable and it occurs at a time . The initial value of the response is denoted as . For a response similar to Figure 17, the percent overshoot is found using
From the initial step time, , the time it takes for the response to reach its maximum value is
This is called the peak time of the system.
In a second-order system, the amount of overshoot depends solely on the damping ratio parameter and it can be calculated using the equation
The peak time depends on both the damping ratio and natural frequency of the system and it can be derived as:
Generally speaking, the damping ratio affects the shape of the response while the natural frequency affects the speed of the response.
Steady-state error is illustrated in the ramp response given in Figure 18 and is denoted by the variable . It is the difference between the reference input and output signals after the system response has settled. Thus, for a time when the system is in steady-state, the steady-state error equals
where is the value of the steady-state input and is the steady-state value of the output.
We can find the error transfer function in Figure 16 in terms of the reference , the plant , and the compensator . The Laplace transform of the error is
Solving for from Equation 3.3 and substituting it in Equation 3.11 yields
We can find the steady-state error of this system using the final-value theorem:
In this equation, we need to substitute the transfer function for from Equation 3.12. The transfer function requires, , and . For simplicity, let as a compensator. The and were given by equations Equation 3.3 and Equation 3.5, respectively. Then, the error becomes:
Applying the final-value theorem gives
When evaluated, the resulting steady-state error due to a step response is
Based on this zero steady-state error for a step input, we can conclude that the Rotary Servo Base Unit is a Type 1 system.
The desired time-domain specifications for controlling the position of the Rotary Servo Base Unit load shaft are:
and
Thus, when tracking the load shaft reference, the transient response should have a peak time less than or equal to 0.20 seconds, an overshoot less than or equal to 5%, and the steady-state response should have no error.
The proportional-derivative (PD) compensator to control the position of the Rotary Servo Base Unit has the following structure
where is the proportional control gain, is the derivative control gain, is the setpoint or reference load shaft angle, is the measured load shaft angle, and is the Rotary Servo Base Unit motor input voltage. The block diagram of the PD control is given in Figure 19.
This is a variation of the classic PD control where the D-term is in the feedback path as opposed to in the forward path.
We need to find the closed-loop transfer function for the closed-loop position control of the Rotary Servo Base Unit. Taking the Laplace transform of Equation 3.20 gives
From the Plant block in Figure 19 and Equation 3.3, we can write
Substituting Equation 3.21 into Equation 3.22 and solving for gives the Rotary Servo Base Unit position closed-loop transfer function as:
In control design, a factor to be considered is saturation. This is a nonlinear element and is represented by a saturation block as shown in Figure 20. In a system like the Rotary Servo Base Unit, the computer calculates a numeric control voltage value. This value is then converted into a voltage, , by the digital-to-analog converter of the data-acquisition device in the computer. The voltage is then amplified by a power amplifier by a factor of . If the amplified voltage, , is greater than the maximum output voltage of the amplifier or the input voltage limits of the motor (whichever is smaller), then it is saturated (limited) at . Therefore, the input voltage is the effective voltage being applied to the Rotary Servo Base Unit motor.
The limitations of the actuator must be taken into account when designing a controller. For instance, the voltage entering the Rotary Servo Base Unit motor should never exceed
From our previous steady-state analysis, we found that the closed-loop Rotary Servo Base Unit system is a Type 1 system. In this section, we will investigate the steady-state error due to a ramp input when using PD controller.
Given the following ramp setpoint (input)
we can find the error transfer function by substituting the Rotary Servo Base Unit closed-loop transfer function in Equation 3.23 into the formula given in Equation 3.11. Using the variables of the Rotary Servo Base Unit, this formula can be rewritten as . After rearranging the terms we find:
Substituting the input ramp transfer function Equation 3.25 into the variable gives
Adding integral control can help eliminate steady-state error. The proportional-integral-derivative (PID) algorithm to control the position of the Rotary Servo Base Unit is shown in Figure 1.6. The motor voltage will be generated by the PID according to:
where is the proportional control gain, is the integral gain, is the derivative control gain, is the setpoint or reference load shaft angle, is the measured load shaft angle, and is the Rotary Servo Base Unit motor input voltage.
This is a variation of the standard PID control with the D-term in the feedback path as opposed to the feedforward path.
We need to find the closed-loop transfer function for the closed-loop position control of the Rotary Servo Base Unit. Taking the Laplace transform of Equation 3.28 gives
From the Plant block in Figure 21 and Equation 3.3, we can write
Substituting Equation 3.29 into Equation 3.30 and solving for gives the Rotary Servo Base Unit position closed-loop transfer function as:
To find the steady-state error of the Rotary Servo Base Unit for a ramp input under the control of the PID substitute the closed-loop transfer function from Equation 3.31 into Equation 3.11
Then, substituting the reference ramp transfer function Equation 3.25 into the variable gives
It takes a certain amount of time for the output response to track the ramp reference with zero steady-state error. This is called the settling time and it is determined by the value used for the integral gain.
In steady-state, the ramp response error is constant. Therefore, to design an integral gain the velocity compensation (the V signal) can be neglected. Thus, we have a PI controller left as:
When in steady-state, the expression can be simplified to
where the variable is the integration time.
Do problems 1 - 7
Calculate the maximum overshoot of the response (in radians) given a step setpoint of 45 deg and the overshoot specification given in Section 1.1.3. Hint: By substituting and step setpoint into Equation 3.6, we can obtain . Recall that the desired response specifications include 5% overshoot.
The Rotary Servo Base Unit closed-loop transfer function was derived in Equation 3.23 in Section 1.2.1. Find the control gains and in terms of and . Hint: Remember the standard second-order system equation.
Calculate the minimum damping ratio and natural frequency required to meet the specifications given in Section 1.1.3.
Based on the nominal Rotary Servo Base Unit model parameters, and , found in the Modeling laboratory experiment, calculate the control gains needed to satisfy the time-domain response requirements given in Section 1.1.3. (Use rad/(Vs) and ) (Need answers from Q2 and Q3)
In the PD controlled system, for a reference step of (i.e. 45 deg step) starting from position, calculate the maximum proportional gain that would lead to providing the maximum voltage to the motor. Ignore the derivative control (). Can the desired specifications be obtained based on this maximum available gain and what you calculated in Question 4? (Need answer from Q4)
For the PD controlled closed-loop system, find the steady-state error and evaluate it numerically given a ramp with a slope of rad/s. Use the control gains found in Question 4. (Need answer from Q4)
What should the integral gain be so that when the Rotary Servo Base Unit is supplied with the maximum voltage of V it can eliminate the steady-state error calculated in Question 6 in 1 second? (Need answers from Q4 and Q6) Hint: Start from Equation 3.35 and use , , the you found in Question 4 and found in Question 6. Remember that is constant.
The main goal of this laboratory is to explore position control of the Rotary Servo Base Unit load shaft using PD and PID controllers. In this laboratory, you will conduct the following experiments:
Step response with PD controller,
Ramp response with PD controller, and
Ramp response with PID controller.
In each experiment, you will first simulate the closed-loop response of the system. Then, you will implement the controller using the Rotary Servo Base Unit hardware and software to compare the real response to the simulated one.
First, you will simulate the closed-loop response of the Rotary Servo Base Unit with a PD controller to step input. Our goals are to confirm that the desired response specifications in an ideal situation are satisfied and to verify that the motor is not saturated. Then, you will explore the effect of using a high-pass filter, instead of a direct derivative, to create the velocity signal in the controller.
The s_servo_pos_cntrl
SIMULINK diagram shown in Figure 22 will be used to simulate the closed-loop position control response with the PD and PID controllers. The Rotary Servo Base Unit Model uses a Transfer Fcn block from the SIMULINK library. The PID Control subsystem contains the PID controller detailed in Section 1.3. When the integral gain is set to zero, it essentially becomes a PD controller.
Download the PositionControl_files.zip and extract the files to the desktop.
Open the setup_servo_pos_cntrl.m
file to open the setup script for the position control Simulink models.
Replace the default model parameters (K
and tau
) with the values calculated from the Modelling section in the setup script.
Run the script, which will generate the model parameters, specifications, and default PID gains. Note: The calculated PID gains are all set to zero by default and they need to be changed over the course of the experiment.
Enter the proportional and derivative control gains found in Pre-Lab Question 4 in the Matlab command window as kp
and kd
.
Set the integral gain to 0 in the Matlab window, denoted as ki
.
To generate a step reference, ensure the Signal Generator
is set to the following:
Signal type = square
Amplitude = 1
Frequency = 0.4 Hz
In the Simulink diagram, set the Amplitude (rad)
gain block to 0.4 (rad) to generate a step with an amplitude of 45.8 degrees (i.e. square wave goes between which results in a step amplitude of 0.8 rad).
Set the Manual Switch
such that the velocity of the motor load shaft is fed back directly.
Open the servo position Position (rad)
scope and the motor input voltage Vm (V)
scope.
Start the simulation. By default, the simulation runs for 5 seconds. The scopes should be displaying responses similar to Figure 23a and Figure 23b. Note that in the theta_l (rad)
scope, the yellow trace is the setpoint position while the purple trace is the simulated position (generated by the Rotary Servo Base Unit Model block). This simulation is called the Ideal PD response as it uses the PD compensator with the derivative block.
After each simulation run, each scope automatically saves its response to a variable in the MATLAB workspace. That is, the Position (rad)
scope saves its response to the variable called data_pos
and the Vm (V)
scope saves its data to the data_vm
variable. The data_pos
variable has the following structure: data_pos(:,1)
is the time vector, data_pos(:,2)
is the setpoint, and data_pos(:,3)
is the simulated angle. For the data_vm
variable, data_vm(:,1)
is the time and data_vm(:,2)
is the simulated input voltage.
Save Vm
and data_pos
data and name it suitably (e.g. posnctrl_section#_Group#_step).
Result: Generate a MATLAB figure showing the Ideal PD position response and the ideal input voltage.
Measure the steady-state error, the percent overshoot and the peak time of the simulated response.
Result: Does the response satisfy the specifications given in Section 1.1.3?
Hint: You can use the Cursor Measurements tool in the Simulink scopes or save the data and use MATLAB function : stepinfo()
.
When implementing a controller on actual hardware, it is generally not advised to take the direct derivative of a measured signal. Any noise or spikes in the signal becomes amplified and gets multiplied by a gain and fed into the motor which may lead to damage. To remove any high-frequency noise components in the velocity signal, a low-pass filter is placed in series with the derivative, i.e. taking the high-pass filter of the measured signal. However, as with a controller, the filter must also be tuned properly. In addition, the filter has some adverse effects (ex. filter could add some delays to the system).
Set the Manual Switch
block to the down position to enable the derivative and filter.
Start the simulation. The response in the scopes should still be similar to Figure 23a and Figure 23b. This simulation is called the Filtered PD response as it uses the PD controller with the high-pass filter block. Result: Generate a MATLAB figure showing the Filtered PD position and input voltage responses.
Measure the steady-state error, peak time, and percent overshoot. Result: Are the specifications still satisfied without saturating the actuator? Recall that the peak time and percent overshoot should not exceed the values given in Section 1.1.3. Discuss the changes from the ideal response. Hint: The difference in the response is minor. Make sure you use Cursor Measurements tool in the Simulink scope to take precise measurements.
In this experiment, we will control the angular position of the Rotary Servo Base Unit load shaft, i.e. the disc load, using the PD controller. Measurements will then be taken to ensure that the specifications are satisfied.
The q_servo_pos_cntrl
SIMULINK diagram shown in Figure 24 is used to implement the position control experiments. The Rotary Servo Interface - Position
subsystem contains QUARC blocks that interface with the DC motor and sensors of the Rotary Servo Base Unit system, as discussed in the Integration laboratory experiment. The PID Control subsystem implements the PID controller detailed in Section 1.3, except a low-pass filter is placed in series with the derivative to remove the noise.
From the extracted files, open q_servo_pos_cntrl
Simulink file.
Configure DAQ: Double-click on the HIL Initialize block in the Rotary Servo Interface
subsystem (which is located inside the Rotary Servo Interface - Position
subsystem) Simulink diagram and ensure it is configured for the DAQ device that is installed in your system (e.g. Q2-USB).
Open setup_servo_pos_cntrl.m
file and run the script.
Enter the proportional and derivative control gains found in Pre-Lab Question 4.
Set Signal Type in the Signal Generator
block to square to generate a step reference.
Set the Amplitude (rad)
gain block to 0.4 to generate a step with an amplitude of 45.8 degrees.
Open the load shaft position scope, Position (rad)
, and the motor input voltage scope, Vm (V)
.
When a suitable response is obtained, click on the Stop button in the SIMULINK diagram toolbar to stop running the code. As in the s_servo_pos_cntrl SIMULINK diagram, when the controller is stopped each scope automatically saves its response to a variable in the MATLAB workspace. Thus the theta_l (rad)
scope saves its response to the data_pos
variable and the Vm (V)
scope saves its data to the data_vm
variable.
Save the data in the MATLAB workspace with a suitable name. Result: Generate a MATLAB figure showing the PD position response and its input voltage.
Measure the steady-state error, the percent overshoot, and the peak time of the Rotary Servo Base Unit load gear. Result: Does the response satisfy the specifications given in Section 1.1.3?
Click the Stop button on the SIMULINK diagram toolbar to stop the experiment.
In this simulation, the goal is to verify that the system with the PD controller can meet the zero steady-state error specification without saturating the motor.
Similar to the Step Response experiment in Section 3.1, in this experiment you need to use the s_servo_pos_cntrl
Simulink diagram shown in Figure 22 in Section 3.1.1 again.
Clear the workspace and run the setup_servo_pos_cntrl.m
script in MATLAB.
Enter the proportional and derivative control gains found in Pre-Lab Question 4 and set the integral gain to 0.
Set the Signal Generator
parameters to the following to generate a triangular reference (which corresponds to a ramp input):
Signal Type = triangle
Amplitude = 1
Frequency = 0.8 Hz
Setting the frequency to 0.8 Hz will generate an increasing and decreasing ramp signal with the same slope used in the Pre-Lab Question 6. The slope is calculated from the Triangular Waveform amplitude, Amp, and frequency, f, using the expression:
In the SIMULINK diagram, set the Amplitude (rad)
gain block to .
Inside the PID Control
subsystem, set the Manual Switch
to the down position so that the High-Pass Filter
block is used.
Open the load shaft position scope, Position (rad)
, and the motor input voltage scope, Vm (V)
.
Start the simulation. The scopes should display responses similar to Figure 26a and Figure 26b.
Save the data in the workspace using a suitable name. Result: Generate a MATLAB figure showing the Ramp PD position response and its corresponding input voltage trace.
Measure the steady-state error. Result: Compare the simulation measurement with the steady-state error calculated in Pre-Lab Question 6.
In this experiment, we will control the angular position of the Rotary Servo Base Unit load shaft, i.e. the disc load, using a PD controller. The goal is to examine how well the system can track a triangular (ramp) position input. Measurements will then be taken to ensure that the specifications are satisfied.
As in the Step Response experiment in Section 3.1, in this experiment, you also need to use the q_servo_pos_cntrl
SIMULINK diagram shown in Figure 24 to implement the position control experiments.
Clear the workspace and run the setup_servo_pos_cntrl.m
script in MATLAB.
Enter the proportional and derivative control gains found in Pre-Lab Question 4.
Set the Signal Generator
parameters to the following to generate a triangular reference (i.e. ramp reference):
Signal Type = triangle
Amplitude = 1
Frequency = 0.8 Hz
In the Simulink diagram, set the Amplitude (rad)
gain block to .
Open the load shaft position scope, Position (rad)
, and the motor input voltage scope, Vm (V)
.
Save the data in the workspace using a suitable name. Result: Generate a MATLAB figure showing the Ramp PD position response and its corresponding input voltage trace.
Measure the steady-state error. Result: Compare it with the steady-state error calculated in Pre-Lab Question 6.
Design an experiment to see if the steady-state error can be eliminated when tracking a ramp input. First, simulate the response, then implement it using the Rotary Servo Base Unit system.
How can the PD controller be modified to eliminate the steady-state error in the ramp response? State your hypothesis and describe the anticipated cause-and-effect leading to the expected result. Hint: Look through Section 1.
List the independent and dependent variables of your proposed controller. Explain their relationship.
Your proposed controller, like the PD compensator, is a model-based controller. This means that the control gains generated are based on a mathematical representation of the system. Given this, list the assumptions you are making in this control design. State the reasons for your assumptions.
Give a brief, general overview of the steps involved in your experimental procedure for two cases: (1) Simulation, and (2) Experimental implementation. Note: In case of time constraints, follow the same steps for Simulation as per Section 3.2.1 and Experiment as per Section 3.2.2, except the value of ki (i.e., ki 0).
For each case, generate a Matlab figure showing the position response of the system and its corresponding input voltage.
In each case, measure the steady-state error.
For each case comment on whether the steady-state specification given in Section 1.1.3 was satisfied without saturating the actuator.
Pre-lab calculations.
Model parameters ( and ) and controller gains (, and ) implemented during the In-Lab Simulations and Experiments.
Response plots from In-Lab Simulations and Experiments (Section 3.1.1: Step 9, Step 2; Section 3.1.2: Step 8; Section 3.2.1: Step 9; Section 3.2.2: Step 8; Section 3.3: Step 5).
Corresponding measured peak time, percent overshoot and steady-state error for the response plots mentioned above (Section 3.1.1: Step 10, Step 3; Section 3.1.2: Step 9; Section 3.2.1: Step 10; Section 3.2.2: Step 9; Section 3.3: Step 6). Note: Peak time and percent overshoot are required only for step response simulation and experiment, not ramp response.
Answer all the questions asked in all the In-Lab simulations and experiments (Section 3.1.1: Step 10, Step 3; Section 3.1.2: Step 9; Section 3.2.1: Step 10; Section 3.2.2: Step 9; Section 3.3: Steps 1, 2, 3 and 7).
Build the model by clicking on the down arrow on Monitor & Tune under the Hardware tab and then select Build for monitoring . This compiles the Simulink diagram.
Click Connect button under Monitor & Tune and then run SIMULINK by clicking Start to begin running the controller. The scopes should display responses similar to Figure 25a and Figure 25b.
Build the model by clicking on the down arrow on Monitor & Tune under the Hardware tab and then select Build for monitoring .
Click Connect button under Monitor & Tune and then run SIMULINK by clicking Start to begin running the controller. The scopes should display responses similar to Figure 27a and Figure 27b.