Welcome to the first hands-on experiment!
The objective of this part of the DC motor experiment is to implement the controller designed in part B and evaluate its performance.
The following is a list of the required equipment to perform this experiment:
Open q_servo_pos_cntrl.slx
file. Do not change anything except the PID gains.
Double-click on the Signal Generator block and ensure that a 0.4 Hz square wave input is being applied. Note that the gain blocks outside the Signal Generator block are introduced to generate the square wave with amplitude between 0 V to 0.4 V.
Check that the sampling time is set to 0.002 s (located under “Modeling” -> “Model Settings” -> “Solver Details”).
Turn on the power amplifier.
Open the position scope.
Save your data. No need to Build again unless you change any blocks or configuration settings in the model.
Sampling Time Test: Change the sampling time to 0.04 sec. To set the sampling time, you need to go to the block diagram file, and choose “Modeling” -> “Model Settings” -> “Solver Details”. Set the fixed step to 0.04 sec (it should have been 0.002 previously). Build, connect and Run PD Controller, observe the behaviour and save the data with an appropriate filename (e.g. - PD_sampling_0.04).
Double-click on the Signal Generator and set the following parameters to generate a triangular wave (i.e. ramp reference):
Signal Type = triangle
Amplitude = 1
Frequency = 0.4 Hz
Change the sampling time back to 0.002 sec (“Modeling” -> “Model Settings” -> “Solver Details”).
Note: Some results require simulation response. This would require running a simulation using your SIMULINK model from Part C Control Design using the model validation K and tau values. The command input will be identical to either the square wave signal or triangle signal implemented during the experiment. The attributes of the simulation will be mentioned in the corresponding section.
Any simulation results in this subsection will have the following attributes:
Command input: Square wave
Amplitude: Maximum of 0.4 and minimum of 0
Frequency: 0.4 Hz
Sampling time: 0.002 s (Go to "Modeling" -> "Model Settings" -> "Solver details" -> "Fixed-step size")
What is the effect of proportional controller gain on closed-loop system behaviour?
What is the effect of derivative controller gain on closed-loop system behaviour?
Compare the PD simulation (that shows zero steady-state error) and experimental (that shows a steady-state error) results to also discuss regarding the dead zone in the DC motor and how it affects the steady-state error.
Plot angle or rotary position (commanded and experimental) and control input Vm from Step 1.11.
What is the effect of sampling time on closed-loop system behaviour?
Any simulation results in this subsection will have the following attributes:
Command input: Triangle wave
Frequency: 0.4 Hz
Sampling time: 0.002 s (Go to "Modeling" -> "Model Settings" -> "Solver details" -> "Fixed-step size")
Mention the final PID gains after tuning.
The Quanser Rotary Servo Base Unit rotary servo plant, shown below, consists of a DC motor that is encased in a solid aluminum frame and equipped with a planetary gearbox. The motor has its own internal gearbox that drives external gears. The Rotary Servo Base Unit is equipped with two sensors: a potentiometer and an encoder. The potentiometer and the encoder sensors measure the angular position of the load gear using different methods.
The Rotary Servo Base Unit incorporates a Faulhaber Coreless DC Motor model 2338S006 and is shown in Figure 1c with ID #9. This is a high-efficiency, low-inductance motor that can obtain a much faster response than a conventional DC motor.
A rotary potentiometer, or pot, is a manually controlled variable resistor. See the example shown below. It typically consists of an exposed shaft, three terminals (A, W, and B), an encased internal resistive element shaped in a circular pattern, and a sliding contact known as a wiper. By rotating the shaft, the internal wiper makes contact with the resistive element at different positions, causing a change in resistance when measured between the centre terminal (W) and either of the side terminals (A or B). The total resistance of the potentiometer can be measured by clamping a multimeter to terminals A and B.
An incremental optical encoder is a relative angular displacement sensor that measures angular displacement relative to a previously known position. Unlike an absolute encoder, an incremental encoder does not retain its position information upon power loss. An incremental encoder outputs a series of pulses that correlate to the relative change in angular position. Encoders are commonly used to measure the angular displacement of rotating load shafts. The information extracted from an incremental encoder can also be used to derive instantaneous rotational velocities.
An incremental optical encoder typically consists of a coded disk, an LED, and two photo sensors. The disk is coded with an alternating light and dark radial pattern causing it to act as a shutter. As shown schematically above, the light emitted by the LED is interrupted by the coding as the disk rotates around its axis. The two photo sensors (A and B) positioned behind the coded disk sense the light emitted by the LED. The process results in A and B signals, or pulses, in four distinct states: (1) A off, B on; (2) A off, B off; (3) A on, B off; (4) A on, B on. Encoders that output A and B signals are often referred to as quadrature encoders since the signals are separated in phase by 90◦. The resolution of an encoder corresponds to the number of light or dark patterns on the disk and is given in terms of pulses per revolution, or PPR. In order to make encoder measurements, you need to connect the encoder to a counter to count the A and B signals. Then use a decoder algorithm to determine the number of counts and direction of rotation. Three decoding algorithms are used: X1, X2, X4.
X1 Decoder: When an X1 decoder is used, only the rising or falling edge of signal A is counted as the shaft rotates. When signal A leads signal B, the counter is incremented on the rising edge of signal A. When signal B leads signal A, the counter is decremented on the falling edge of signal A. Using an X1 decoder, a 1,024 PPR encoder will result in a total of 1,024 counts for every rotation of the encoder shaft. X2 Decoder: When an X2 decoder is used, both the rising and falling edges of signal A are counted as the shaft rotates. When signal A leads signal B, the counter is incremented on both the rising and falling edge of signal A. When signal B leads signal A, the counter is decremented on both the rising and falling edges of signal A. Using an X2 decoder, a 1,024 PPR encoder will generate a total of 2,048 counts for every rotation of the encoder shaft. X4 Decoder: When an X4 algorithm is used, both the rising and falling edges of both signals A and B are counted. Depending on which signal leads, the counter will either increment or decrement. An X4 decoder generates four times the number of counts generated by an X1 decoder resulting in the highest resolution among the three types of decoders. Using an X4 decoder, a 1,024 PPR encoder will generate a total of 4,096 counts for every rotation of the encoder shaft.
The angular resolution of an encoder depends on the encoder’s pulses per revolution (PPR) and the decoding algorithm used:
where N = 1, 2, or 4 corresponds to X1, X2, and X4 decoders respectively
While encoders are typically used for measuring angular displacement, they can also measure rotational speeds. The velocity can be found by taking the difference between consecutive angle measurements
In practice, determining rotational speeds by means of derivation of the discontinuous encoder output often results in signal noise. The ripple in the velocity signal due to sampling can be reduced by filtering. Applying a first-order low-pass filter to the measured velocity signal
Rearranging the filter transfer function above,
we can represent the filtering using the differential equation
Follow the steps and build the SIMULINK model below:
Follow these steps to read the motor velocity:
First, download and open q_servo_vel_direct.slx Simulink model.
Configure the model to apply a 0.4 Hz square wave voltage signal going between 0.5V and 2.5V.
Change the simulation time to 5 seconds from Simulation tab, stop time.
Go to Modelling tab and open modelling setting. Check that sample time is set to 0.002s and check that solver is set to ode1 (euler).
The velocity measurement using a direct derivative will be noisy. After the SIMULINK has run for 5 seconds and stopped, note down the velocity ripple (crest to peak or height within ripple). You can use the Cursor Measurements tool in the Scope for more accurate measurements. Save the speed data (wl) to plot in the report. Name the file such as integration_sampletime0.002s.
Increase the control loop rate of the QUARC controller by decreasing the sampling interval to 0.001 s, i.e. increasing the sampling rate to 1 kHz. Build, Connect and run the Simulink. Once SIMULINK has run for 5 seconds and stopped, note down the velocity ripple and examine the change in the ripple velocity measurement. Save the speed data (wl) to plot in the report. Name the file such as integration_sampletime0.001s.
Run the controller for a minute or two (stop time to inf). Depending on the data acquisition device you are using (e.g. Q2-USB or Q8-USB), you may notice a spike or discontinuity that occurs in the velocity estimation, as shown below (once the discontinuity occurs stop the simulation). Save the speed data (wl) to plot in the report. Name the file such as integration_wrapping.
Save the speed data (wl) to plot in the report. Name the file such as integration_lowpass. Save a screenshot of the Simulink model designed (block diagram).
Response plots from Step 7.
Response plots from Step 8.
Response plots with and without encoder wrapping from Step 9.
Compare the measured velocity ripple from Step 8 (without filter) with the measured velocity ripple from Step 10 (with filter). How much noise does the filter remove?
Completed SIMULINK block diagram with low-pass filter from Step 10.
Response plots from Step 10.
P Controller Test: To understand the behavior of a Proportional controller, implement a P controller by typing the values for to 0 and to 0 in the command window. Set as the value obtained in Step 5 of Part C Control Design.
To build the model, click down arrow on Monitor & Tune under Hardware tab and then Build for monitoring .
Press Connect button under Monitor & Tune and then press Start . Run the experiment for 5 seconds.
PD Controller Test: By introducing a derivative gain (), notice how the system characteristics change. Set and to the respective values found in Step 6 of Part C Control Design. will remain as 0. Connect and Start. Observe the behavior and save the data.
In the Simulink diagram, set the Amplitude gain block to and the Constant offset gain block to . This will generate a triangular wave with amplitude between 0 to .
PD Controller Test: This test is to determine the ramp response of the system with a PD controller. Set and to the respective values found in Step 6 of Part C Control Design. will remain as 0. Connect and Start. Observe the behavior and save the data.
PID Controller Test: In the respective controller gain blocks, change the current values of , and to the PID values found in Step 9 of Part C Control Design. Observe the behavior. Save the data only if there is no steady-state error.
PID Controller Tuning: If the PID controller test has not eliminated the steady-state error, tune the gain values (, and ) until the system ramp response has zero (or nearly zero) steady-state error. Save the data and gain values after the final tuning.
Plot angle or rotary position, i.e., commanded, experimental from Step 1.9, and simulation responses on one figure. Use the same gain value evaluated in Step 1.4 for the simulation response.
Plot angle or rotary position, i.e., commanded, experimental from Step 1.10, and simulation responses on one figure. Use the same and gain values evaluated in Step 1.10 for the simulation response.
Amplitude: Maximum of and minimum of 0
Plot angle or rotary position, i.e., commanded, experimental from Step 2.3, and simulation responses on one figure. Use the same and gain values evaluated in Step 2.4 for the simulation response.
Plot angle or rotary position, i.e., commanded, experimental from Step 2.5 (or 2.4 if applicable), and simulation responses on one figure. Use the tuned , and gain values evaluated in Step 2.6 for the simulation response.
A schematic diagram of the voltage dividing characteristic of a potentiometer is illustrated below. By applying a known voltage between terminals A and B (), voltage is divided between terminals AW and WB where:
When connected to an external shaft, a rotary potentiometer can measure absolute angular displacement. By applying a known voltage to the outside terminals of the pot, we can determine the position of the sensor based on the output voltage or which will be directly proportional to the position of the shaft. One of the advantages of using a potentiometer as an absolute sensor is that after a power loss, position information is retained since the resistance of the pot remains unchanged. While pots are an effective way to obtain a unique position measurement, caution must be used since their signal output may be discontinuous. That is, after a few revolutions potentiometers may reset their signal back to zero. Another disadvantage of most pots is that they have physical stops that prevent continuous shaft rotation.
where represents the position measurement sample and is the sampling interval of the control software. The resolution or ripple in the velocity measurement is given by
is rotational speed (rad/s) and is the resolution of the encoder given in Equation 1.1, and is the sampling interval. Note that the ripple velocity increases when the sampling period decreases.
where is the measured signal, is the filtered signal, and is the filter time constant. Low-pass filters are also often represented in terms of cutoff frequency :
where . The low-pass filter attenuates the high-frequency components of the signal higher than the cut-off frequency specified, i.e. passes signal with frequencies
The derivative can be approximated by the difference between the currently measured sample, , and the previous sample, :
Solving for ,
Thus the high-frequency error is reduced by a factor of . The ripple in the filtered velocity signal caused by the encoder is
Note: Filtering does add dynamics to the signal, i.e. small delay, as given by the term in Equation 1.3.
Encoder counters on data acquisition (DAQ) devices have a rated number of bits, n. For example, a DAQ with an 8-bit signed counter has a range between −128 and +127 (i.e. and ). When the encoder counts go beyond this range, the measured counts from the DAQ ends up wrapped. Consider the following example. If the encoder is measuring 100 counts, then the DAQ counter will output 100 (no wrapping). However, if the encoder is measuring 150 counts, then the 8-bit signed counter will read counts. Thus the encoder wraps and causes a discontinuity. This can be very problematic in closed-loop feedback control. The QUARC software includes an Inverse Modulus block that unwraps the counter signal and keeps a continuous signal. For more information, see the Inverse Modulus block in the QUARC documentation.
To build the model, click the down arrow on Monitor & Tune under the Hardware tab and then click Build for monitoring . This generates the controller code.
Click the Deploy button under Monitor & Tune, next click the Connect button, also under Monitor & Tune and then run SIMULINK by clicking Start .
This encoder wrapping is due to the range of the DAQ encoder counter. To remove the wrapping and maintain a continuous signal, use the QUARC Inverse Modulus block before Encoder: count to rad block. Build, connect and run your QUARC controller and ensure the signal is now continuous (i.e. no spike occurs). Save the speed data (wl) to plot in the report. Name the file such as integration_no_wrapping. Note : The Inverse Modulus block should be added to the output of the HIL Read Encoder and set to the where n is the bits of the DAQ encoder counter. Quanser Q2-USB has 16-bit encoder counter and Quanser Q8-USB has 24-bit encoder counter.
Add a low-pass filter with a time constant of s using the Simulink Transfer Fcn block. This translates into having a filter with a cutoff frequency of 1/0.01 = 100 rad/s. Run it for 5 seconds.
Given that the Rotary Servo Base Unit rotary encoder has 1024 PPR and the quadrature (X4) decoding is used in the DAQ, find the resolution of the encoder () using Eq. 1.1. Using this encoder resolution and Eq. 1.2, find the estimated velocity ripple of the Rotary Servo Base Unit for sampling interval 0.002 s. Compare this estimated velocity ripple with the measured velocity ripple from Step 7.
Using the encoder resolution () found in Result A.1 and Eq. 1.2, find the estimated velocity ripple for sampling interval 0.001 s. Compare this estimated velocity ripple with the measured velocity ripple from Step 8.
Using found in Result A.1, along with Eq. 1.4, and , find the estimated velocity ripple with filter. Compare the estimated velocity ripple with the measured velocity ripple from Step 10.
1
Top plate
12
Encoder
2
Bottom plate
13
Ball-bearing block
3
Posts
14
Motor
4
Motor pinion gear: 72-teeth (low-gear)
15
Motor Gearbox
5
Load gear: 72 teeth (low-gear)
16
Motor connector
6
Potentiometer gear
17
Encoder connector
7
Anti-backlash springs
18
Potentiometer connector
8
Load shaft (i.e. output shaft)
19
Bar inertial load
9
Motor pinion gear: 24-teeth (high-gear)
20
Disc inertial load
10
Load gear: 120-teeth (high-gear)
21
Thumb screws
11
Potentiometer
The objective of this experiment is to find a transfer function that describes the rotary motion of the Rotary Servo Base Unit load shaft. The dynamic model is derived analytically from classical mechanics principles and using experimental methods.
The angular speed of the Rotary Servo Base Unit load shaft with respect to the input motor voltage can be described by the following first-order transfer function:
where is the Laplace transform of the load shaft speed , is the Laplace transform of motor input voltage , is the steady-state gain, is the time constant, and is the Laplace operator. The Rotary Servo Base Unit transfer function model is derived analytically in Modeling Using First-Principles and its and parameters are evaluated. These are known as the nominal model parameter values. The model parameters can also be found experimentally. Modeling Using Experiment describes how to use the frequency response and bump-test methods to find and . These methods are useful when the dynamics of a system are not known, for example in a more complex system. After the lab experiments, the experimental model parameters are compared with the nominal values.
The DC motor armature circuit schematic and gear train is illustrated in Figure 7.
is the motor resistance, is the inductance, and is the back-emf constant.
The back-emf (electromotive) voltage depends on the speed of the motor shaft, , and the back-emf constant of the motor, . It opposes the current flow. The back emf voltage is given by:
Using Kirchoff’s Voltage Law, we can write the following equation:
Since the motor inductance is much less than its resistance, it can be ignored. Then, the equation becomes:
Solving for , the motor current can be found as:
In this section, the equation of motion describing the speed of the load shaft, , with respect to the applied motor torque, , is developed. Since the Rotary Servo Base Unit is a one degree-of-freedom rotary system, Newton’s Second Law of Motion can be written as:
where is the moment of inertia of the body (about its center of mass), is the angular acceleration of the system, and is the sum of the torques being applied to the body. As illustrated in Figure 7, the Rotary Servo Base Unit gear train along with the viscous friction acting on the motor shaft, , and the load shaft are considered. The load equation of motion is:
where is the moment of inertia of the load and is the total torque applied on the load. The load inertia includes the inertia from the gear train and from any external loads attached, e.g. disc or bar. The motor shaft equation is expressed as:
where is the motor shaft moment of inertia and is the resulting torque acting on the motor shaft from the load torque. The torque at the load shaft from an applied motor torque can be written as:
where is the gear ratio and is the gearbox efficiency. The planetary gearbox that is directly mounted on the Rotary Servo Base Unit motor (see Rotary Servo Base Unit User Manual for more details) is represented by the and gears in Figure 7 and has a gear ratio of
This is the internal gear box ratio. The motor gear and the load gear are directly meshed together and are visible from the outside. These gears comprise the external gear box which has an associated gear ratio of
The gear ratio of the Rotary Servo Base Unit gear train is then given by:
Thus, the torque seen at the motor shaft through the gears can be expressed as:
Intuitively, the motor shaft must rotate times for the output shaft to rotate one revolution.
We can find the relationship between the angular speed of the motor shaft, , and the angular speed of the load shaft, by taking the time derivative:
To find the differential equation that describes the motion of the load shaft with respect to an applied motor torque substitute (Eq 2.13), (Eq 2.15) and (Eq 2.7) into (Eq 2.8) to get the following:
Collecting the coefficients in terms of the load shaft velocity and acceleration gives
Defining the following terms:
simplifies the equation as:
In this section the electrical equation and the mechanical equation are brought together to get an expression that represents the load shaft speed in terms of the applied motor voltage.
The motor torque is proportional to the voltage applied and is described as
where is the current-torque constant (), is the motor efficiency, and is the armature current. See Rotary Servo Base Unit User Manual for more details on the Rotary Servo Base Unit motor specifications. We can express the motor torque with respect to the input voltage and load shaft speed by substituting the motor armature current given by Eq 2.5, into the current-torque relationship given in Eq 2.21:
To express this in terms of and , insert the motor-load shaft speed Eq 2.15, into Eq 2.21 to get:
If we substitute (Eq 2.23) into (Eq 2.20), we get:
After collecting the terms, the equation becomes
This equation can be re-written as:
where the equivalent damping term is given by:
and the actuator gain equals
A linear model of a system can also be determined purely experimentally. The main idea is to experimentally observe how a system reacts to different inputs and change structure and parameters of a model until a reasonable fit is obtained. The inputs can be chosen in many different ways and there are a large variety of methods. Two methods of modeling the Rotary Servo Base Unit are: (1) frequency response and, (2) bump test.
In Figure 8, the response of a typical first-order time-invariant system to a sine wave input is shown. As it can be seen from the figure, the input signal () is a sine wave with a fixed amplitude and frequency. The resulting output () is also a sinusoid with the same frequency but with a different amplitude. By varying the frequency of the input sine wave and observing the resulting outputs, a Bode plot of the system can be obtained as shown in Figure 9.
The Bode plot can then be used to find the steady-state gain, i.e. the DC gain, and the time constant of the system. The cuttoff frequency, , shown in Figure 9 is defined as the frequency where the gain is 3 dB less than the maximum gain (i.e. the DC gain) in dB. When working in the linear non-decibel range, the 3 dB frequency is defined as the frequency where the gain is , or about 0.707, of the maximum gain. The cutoff frequency is also known as the bandwidth of the system which represents how fast the system responds to a given input.
The magnitude of the frequency response of the Rotary Servo Base Unit plant transfer function given in equation Eq 2.1 is defined as:
where is the frequency of the motor input voltage signal . We know that the transfer function of the system has the generic first-order system form given in Eq 2.1. By substituting in this equation, we can find the frequency response of the system as:
Then, the magnitude of it equals
Let’s call the frequency response model parameters and to differentiate them from the nominal model parameters, and , used previously. The steady-state gain or the DC gain (i.e. gain at zero frequency) of the model is:
The bump test is a simple test based on the step response of a stable system. A step input is given to the system and its response is recorded. As an example, consider a system given by the following transfer function:
The step response shown in Figure 10 is generated using this transfer function with and .
The step input begins at time . The input signal has a minimum value of and a maximum value of . The resulting output signal is initially at . Once the step is applied, the output tries to follow it and eventually settles at its steady-state value yss. From the output and input signals, the steady-state gain is
where and . In order to find the model time constant, , we can first calculate where the output is supposed to be at the time constant from:
Then, we can read the time that corresponds to from the response data in Figure 10. From the figure we can see that the time is equal to:
From this, the model time constant can be found as:
Going back to the Rotary Servo Base Unit system, a step input voltage with a time delay can be expressed as follows in the Laplace domain:
where is the amplitude of the step and is the step time (i.e. the delay). If we substitute this input into the system transfer function given in Eq 2.1, we get:
We can then find the Rotary Servo Base Unit load speed step response, , by taking inverse Laplace of this equation. Here we need to be careful with the time delay and note that the initial condition is
The q_servo_modeling Simulink diagram shown in Figure 11a will be used to conduct the experiments. The Rotary Servo Base Unit subsystem contains QUARC blocks that interface with the DC motor and sensors of the Rotary Servo Base Unit system. The Rotary Servo Base Unit Model uses a Transfer Fcn block from the SIMULINK library to simulate the Rotary Servo Base Unit system. Thus, both the measured and simulated load shaft speed can be monitored simultaneously given an input voltage. We have implemented a first-order low-pass filter in integration but for modeling second-order low-pass filter has been implemented with cutoff frequency of rad/s damping ratio of 0.9.
Download the Modeling_files.zip and extract the files to desktop.
Open q_servo_modeling.m
SIMULINK file.
Double click on the "Rotary Servo Interface - Speed" subsystem to access the DAQ configuration
Configure DAQ: Double-click on the HIL Initialize block in the SIMULINK diagram and ensure it is configured for the DAQ device that is installed in your system (e.g. Q2-USB).
Open setup_servo_modeling.m
file to open the setup script for the q_servo_modeling SIMULINK model.
Run the script. Note: The calculated servo model parameter are default model parameters and do not accurately represent the Rotary Servo Base Unit system.
The frequency response of a linear system can be obtained by providing a sine wave input signal to it and recording the resulting output sine wave from it. In this experiment, the input signal is the motor voltage and the output is the motor speed. In this method, we keep the amplitude of the input sine wave constant but vary its frequency. At each frequency setting, we record the amplitude of the output sine wave. The ratio of the output and input amplitudes at a given frequency can then be used to create a Bode magnitude plot. Then, the transfer function for the system can be extracted from this Bode plot.
First, we need to find the steady-state gain of the system. This requires running the system with a constant input voltage. To create a constant input voltage follow these steps:
In the SIMULINK diagram, double-click on the Signal Generator block and ensure the following parameters are set: • Wave form: sine • Amplitude: 1.0 • Frequency: 0.4 • Units: Hertz
Set the Amplitude (V) slider gain to 0.
Set the Offset (V) block to 2.0 V. Note: Execution of steps 1 through 3 generates a step input of 2.0 V magnitude.
Set the Simulation stop time to 5 seconds.
Open the load shaft speed scope, Speed (rad/s), and the motor input voltage scope, Vm (V) .
The Rotary Servo Base Unit unit should begin rotating in one direction. The scopes should be reading something similar to figure below. Note that in the Speed (rad/s) scope, the yellow trace is the measured speed while the blue trace is the simulated speed (generated by Servo Model block).
Measure the speed of the load shaft and enter the measurement in Table B.1 below under the f = 0 Hz row. Since amplitude gain is set to 0, technically no sine input when f = 0 Hz is applied.
Note: No need to save wl variable data or scope plot.
Hint: The measurement can be done directly from the scope using the Cursor Measurements tool. Alternatively, you can use MATLAB commands max(wl(:,2))
to find the maximum load speed using the saved wl
variable. When the controller is stopped, the Speed (rad/s) scope saves data to the MATLAB workspace in the wl
parameter. It has the following structure: wl(:,1)
is the time vector, wl(:,2)
is the measured speed, and wl(:,3)
is the simulated speed.
Calculate the steady-state gain both in linear and decibel (dB) units, i.e. , as explained in Frequency Response. Enter the resulting numerical value in the f = 0 Hz row of Table B.1. Also, enter its non-decibel value in Table B.2 under the 'Frequency Response Experiment' section.
In this part of the experiment, we will send an input sine wave at a certain frequency to the system and record the amplitude of the output signal. We will then increment the frequency and repeat the same observation. To create the input sine wave:
In the SIMULINK diagram, double-click on the Signal Generator block and ensure the following parameters are set: • Wave form: sine • Amplitude: 1.0 • Frequency: 1.0 • Units: Hertz
Set the Amplitude (V)
slider gain to 2.0 V.
Set the Offset (V)
block to 0 V.
Set the Simulation stop time to 5 seconds.
The Rotary Servo Base Unit unit should begin rotating smoothly back and forth and the scopes should be reading a response similar to Figure 13 a) and b).
Measure the maximum positive speed of the load shaft at f = 1.0 Hz
input and enter it in Table B.1 below. As before, this measurement can be done directly from the scope using the Cursor Measurements tool or you can use MATLAB commands to find the maximum load speed using the saved wl
variable.
Calculate the gain of the system (in both linear and dB units) and enter the results in Table B.1.
Increase the frequency to f = 2.0 Hz
by adjusting the frequency parameter in the Signal Generator block. Measure the maximum load speed and calculate the gain. Repeat this step for each of the frequency settings in Table B.1.
In this method, a step input is given to the Rotary Servo Base Unit and the corresponding load shaft response is recorded. Using the saved response, the model parameters can then be found as discussed in Bump Test.
To create the step input:
Double-click on the Signal Generator block and ensure the following parameters are set: • Wave form: square • Amplitude: 1.0 • Frequency: 0.4 • Units: Hertz
Set the Amplitude (V)
gain block to 1.0 V.
Set the Offset (V)
gain block to 2.0 V.
Set the Simulation stop time to 5 seconds.
Open the load shaft speed scope, Speed (rad/s)
, and the motor input voltage cope,
Vm (V)
.
The gears on the Rotary Servo Base Unit should be rotating in the same direction and alternating between low and high speeds. The response in the scopes should be similar to Figure 14 a) and b).
Save wl data and name it as modeling_section#_Group#_step. Note down the magnitude of input voltage as this will be required to calculate the steady-state gain in the Results section.
Click the Stop button on the SIMULINK diagram toolbar (or select QUARC | Stop from the menu) to stop the experiment.
In this experiment, you will use the calculated values of K and from the frequency response experiment, bump test experiment, and nominal values calculated to see if it matches the measured response. To create a step input:
Double-click on the Signal Generator block and ensure the following parameters are set: • Wave form: square • Amplitude: 1.0 • Frequency: 0.4 • Units: Hertz
Set the Amplitude (V)
slider gain to 1.0 V.
Set the Offset (V)
block to 1.5 V.
Set the Simulation stop time to 5 seconds.
Open the load shaft speed scope, Speed (rad/s)
, and the motor input voltage scope, V_m (V)
.
The gears on the Rotary Servo Base Unit should be rotating in the same direction and alternating between low and high speeds and the scopes should be as shown in Figure 15 a) and b). Recall that the yellow trace is the measured load shaft rate and the purple trace is the simulated trace. By default, the steady-state gain and the time constant of the transfer function used in simulation are set to: K = 1 rad/s/V and = 0.1s. These model parameters do not accurately represent the system.
Notice that the model response does not match with the measured response.
Calculate the nominal values, and , using Eqs. 2.1, 2.26, 2.27, 2.28 and the specifications provided in Table A.1 and Table A.2 for the high-gear configuration. Note: Eq. 2.26 must be converted to the Laplace domain to obtain the transfer function, which should be simplified to resemble Eq. 2.1. This would yield the formulae to determine and . You may also refer to the lecture slides.
Enter the nominal values, and , that were found in Step 10 in the MATLAB Command Window. Update the parameters and examine how well the simulated response matches the measured one.
Save wl data and name it as modeling_section#_Group#_K#tau#.
If the calculations of the nominal values were done properly, then the model should represent the actual system quite well. Compare the responses you get by using the and values from the frequency response experiment, bump test experiment (this needs to be done while writing the report), and when using nominal values. Check which of the three responses matches the measured response best, and record this and as your model validation values. Use this set of values for controller implementation (next week). If there is no clear set of values that matches the measured response, take the average.
Note: Changing the model parameters can be done by manually changing the Servo Model Transfer Function block parameters OR by changing the K
and tau
parameters in the MATLAB Command Window and going to Simulation | Update Diagram in the SIMULINK model.
Using the MATLAB plot command and the data collected in Table B.1, generate a Bode magnitude plot. Make sure the amplitude and frequency scales are in decibels. When making the Bode plot, ignore the f = 0 Hz
entry as the logarithm of 0 is not defined.
Label the Bode plot where the gain is reduced by 3 dB from the DC gain and the corresponding frequency as the cutoff frequency. Time constant (units are seconds) of a first-order system is equal to the inverse of its cutoff frequency (units are rad/s). Enter the resulting time constant in Table B.2.
Hint: May use the Data Tips tool to obtain values from the MATLAB Figure.
Include the labelled Bode plot along with tabulated values of Table B.1 in the report.
Plot the maximum load speed response (saved in the MATLAB workspace under the wl
variable) from Step 9 in MATLAB.
Find the steady-state gain using the measured step response (Result B.1) and enter it in Table B.2 under the 'Step Response Experiment' section.
Hint: Use the MATLAB ginput
command to measure points off the plot.
Find the time constant from the obtained response (Result B.1) using Eqs. 2.35, 2.36 and 2.37, and enter the value in Table B.2 under the 'Step Response Experiment' section. Show the calculations in the report.
Create a MATLAB figure that shows the simulation nominal values response, the step response (generated by using the K and tau values calculated from the bump test experiment), the frequency response (generated by using the K and tau values calculated for frequency response experiment), the response you got from step 8, and the measured response as five plots on the same graph in the report. Provide two reasons why the nominal model might not represent the Rotary Servo Base Unit with better accuracy. Which response matches most closely with the measured response?
From the plots, describe how the gain and time constant affect the system's response.
Include the completed Table B.2.
Explain how well the nominal model, the frequency response model, and the bump-test model represent the Rotary Servo Base Unit system (you may refer to Result D.1).
To build the model, click the down arrow on Monitor & Tune under the Hardware tab and then click Build for monitoring . This generates the controller code.
Click the Deploy button under Monitor & Tune, followed by the Connect button and then run SIMULINK by clicking Start .
Click Connect button under Monitor & Tune and then run SIMULINK by clicking Start .
To build the model, click the down arrow on Monitor & Tune under the Hardware tab and then click Build for monitoring . This generates the controller code.
Click Connect button under Monitor & Tune and then run SIMULINK by clicking Start .
To build the model, click the down arrow on Monitor & Tune under the Hardware tab and then click Build for monitoring . This generates the controller code.
Click Connect button under Monitor & Tune and then run SIMULINK by clicking Start .
The objective of this experiment is to design a position control system for the motor to meet a given set of specifications in frequency-domain.
Now that we have identified the time constant and the DC gain for the system in the modeling part of this experiment, the next step is to design a position control system in order to convert the given DC motor into a position servo. A classical PID controller will be used to control the position of the motor subject to a given set of specifications, for example, bandwidth, steady-state error requirements, etc.
Recall that the transfer function of the motor from to in Modelling is approximated as
let , DC gain of the motor.
Since , where is the angular position of the motor, the transfer function from the applied voltage to the motor angular position is
The block diagram of a DC motor with a proportional controller is shown in Fig.1. In this case, the controller transfer function () is a simple gain . From Fig. 1, the closed-loop transfer function from the commanded angular position to the actual angular position is given by
Comparing the above transfer function to the standard form for a second-order system, i.e.,
we notice that the proportional gain affects the natural frequency (and hence the bandwidth) of the closed-loop system.
The block diagram of a DC motor with an inner loop angular rate (i.e., derivative) feedback and an outer loop angular position error (proportional) feedback is shown in Fig. 2. From Fig. 2, the closed-loop transfer function from the commanded angular position to the actual angular position is given by
Comparing the above transfer function with the standard form for a second-order system, we notice that the derivative gain affects the damping while the proportional gain affects the natural frequency of the closed-loop system.
The block diagram of a DC motor with an inner loop angular rate (i.e., derivative) feedback and an outer loop angular position error plus integral of angular position error (i.e., proportional plus integral) feedback is shown in Fig. 3.
From Fig. 3, the open-loop transfer function becomes
indicating that with integral feedback, the type of the system increases from 1 to 2 and hence, results in zero steady-state error to both ramp and step command inputs.
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 4. 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 V_{\text{max}} = 10.0 V \qquad \qquad \qquad \tag{3.2}
The most important difference between analog and digital control is that digital systems operate using a clock. The timing of this clock and the number of operations necessary to implement a controller place a limit on how frequently the controller can access sensors, make calculations, and modify the control inputs. (In addition, other elements of the control system themselves may introduce an additional time delay. For this reason, the sampling time of the digital system is an important parameter.) Digital controllers, in general, will have a maximum . Increasing the further will make the closed-loop system unstable.
The closed-loop DC motor system must meet the following specifications.
Bandwidth frequency of at least 25 rad/s (Bandwidth is an important measure of the frequency range over which the system output follows well the command signal. It is defined as the frequency at which the magnitude ratio is -3 dB in the closed-loop system frequency response plot. Sinusoidal inputs with frequencies less than the bandwidth frequency are tracked ‘reasonably well’ by the system.)
Phase margin of at least 70 deg. (Gain and phase margins are stability margins to accommodate model variations. A flight control system actuator is typically subject to varying load, resulting in model variations. Hence, it is important to design a controller with sufficient stability margins to accommodate such variations and other effects such as wear with usage.)
Zero steady-state error to both step and ramp commands.
Save root locus open-loop Bode, closed-loop bode and step response plots as separate figures.
In open-loop or closed-loop Bode plots, you should show Bandwidth frequency and Phase margin values.
In the step response plot, you should show the steady-state value.
Only for controlSystemDesigner or rltool only, you may use the Snipping tool and save the figures in a Word document.
For other Simulink-generated data, you need to use the plot
MATLAB command.
Results from each step below must be checked with TAs before proceeding to the next:
Using the model, i.e., K and tau values, you have obtained from the Modeling - Model Validation, input the transfer function (Equation 3.1) into MATLAB. Use K and tau from the model validation values.
First consider a proportional controller, i.e., C = Kp
. Input C = 1
into MATLAB.
Run controlSystemDesigner(G,C)
(you can alternatively run rltool(G,C)
for versions R2020b and older). Select ‘New Plot -> New Step’ to launch the step response plot (if it is not automatically launched). In the time response plot, only the ‘closed loop: r to y' (blue plot) should be visible. Always do this in all the labs. Select ‘New Plot -> New Bode’ and choose the appropriate option to launch the closed-loop Bode plot. In the closed-loop Bode response window, select the magnitude plot only and readjust the magnitude plot limits to -3.5 dB and -2.5 dB under properties and limits. The bandwidth frequency (defined above) can be read from the closed-loop Bode plot. It may be useful to add a grid to the bode plot.
Note: If the closed-loop Bode plot is not visible after adjusting magnitude plot limits, it indicates that the design specification is not met, which would require gain tuning. This will be performed in Step 5.
If Open-loop Bode Editor is not automatically launched. In Control System Designer or rltool, select ‘Open-loop Bode’ under ‘Tuning Methods -> Bode Editor’. The phase margin (PM) of the system can be read off the open-loop bode plot. Note: The LoopTransfer_C Bode is the open-loop Bode.
Change the controller gain by double-clicking ‘C’ under ‘Controllers and Fixed Blocks’ or by using your cursor on the root locus and check if all the design specifications can be met using a proportional controller, which would be optimal from a design standpoint. If not, at least select a value of such that the bandwidth is more than 25 rad/sec. Save the root locus, open and closed-loop Bode, time response plot and P gain.
Save a screenshot of the control structure that you now have in Control System Designer or rltool (go to Edit Architecture tab). This screenshot will be required to answer a question for the report (refer to Questions for Report).
Readjust the proportional and derivative gains (if necessary, by modifying the zeros, not the overall gain, ) such that bandwidth and phase margin specs are met.
Save the root locus plot, open and closed-loop system Bode plots, and time response plot as graphs. Also, save your gains (if you readjusted any values in Step 8, you must convert from the Control System Designer or rltool compensator format, back to our conventional gain representation – , , ).
Using the controller you have designed, obtain the closed-loop transfer function and save your result. (Do this in MATLAB using the transfer function variables of and , or export the closed-loop transfer function from Control System Designer or rltool(T_r2y), using the ‘Export’.) (May be listed as ‘IOTransfer_r2y’). In MATLAB, change the exported state space into a transfer function using tf(IOTransfer_r2y)
Obtain poles of the closed-loop system. Compute the natural frequency and damping of the dominant poles of the closed-loop system. You can do all this from your exported transfer function using the function damp()
. Save your results.
Construct a SIMULINK diagram using Fig. 3 as a guide. Use a transfer function block for the plant (use K and tau from the model validation). Add saturation of max 10V and min -10V block before the Plant transfer function. Set the solver type to Fixed-step with size of 0.002. Include the controller gains from your design. Do not use the transfer function block or the inbuilt PID controller block for the controller gains. Save your Simulink model for further use in Part C of the experiment. Save the Simulink block diagram as a .jpg or .png image.
Run the responses to a unit ramp input first with a PD controller (by setting Ki = 0
) and then with a PID controller (Ki = 1% Kp
). Run the simulation for about 30 sec.
Make comparison plots of ramp responses with PD and PID controllers (on the same plot) to show any differences between the two responses, especially in steady-state response (i.e., for t>>0, also you may zoom in to see the difference clearly). The difference can be more easily spotted by plotting the error variable (i.e. error between the commanded position and the actual position) for each controller. Save the comparison plot and error plot.
You must have your work checked out by one of the TAs before leaving the lab.
Note:
The plots for controller design, i.e., root locus, open-loop Bode, closed-loop Bode, and step response, must be shown as separate figures.
In open-loop or closed-loop Bode plots, you should show Bandwidth frequency and Phase margin values.
In the step response plot, you should show the steady-state value. This can be done by right-clicking on the plot -> "Characteristics" -> "Steady-state".
Only for controlSystemDesigner or rltool plots, you can include the plots as obtained using the Snipping tool.
For other Simulink-generated data, you need to use the plot
MATLAB command.
Root locus plot
Open-loop Bode plot
Closed-loop Bode plot
Time response plot
P (proportional) gain
Root locus plot
Open-loop Bode plot
Closed-loop Bode plot
Time response plot
PD (proportional and derivative) gains
Root locus plot
Open-loop Bode plot
Closed-loop Bode plot
Time response plot
PID (proportional, derivative and integral) gain values (mention if the gains are the same values or readjusted values from Step 8)
Closed-loop transfer function
Poles of the closed-loop system
Natural frequency of the closed-loop system dominant poles
Damping of the closed-loop system dominant poles
PID controller SIMULINK block diagram (image)
Plots comparing the ramp responses of PD and PID controllers (on the same figure)
Plots comparing the error variable of PD and PID controllers (on the same figure)
What is the difference between Fig. 2 and the control structure screenshot that you saved in Step 6? Hint: Focus on where is located in the control loop and what it is multiplied by.
Why is this difference between the two control structures acceptable when dealing with a step input?
Use and modify the Simulink model that you built in Step 12 for the two control structure cases (i.e., is multiplied by the derivative of error or speed directly). You may create two separate Simulink files or build two models within the same Simulink file. Run each Simulink with a unit step input and a unit ramp input for 5 seconds. Use the PD gains found in Step 6 (Result B.5) and set Ki = 0
. Create plots below to help you explain the question asked above:
Step responses (two plots on the same figure)
Ramp responses (two plots on the same figure)
Derivative of error signal and speed value in one figure for the step input from both models
Derivative of error signal and speed value in one figure for the ramp input from both models
Consider a proportional and derivative controller. In the compensator editor window under ‘C’, add a zero around -60. Using the cursor or manually input values, adjust the zero location of the controller first and see if the specification can be met. If adjusting the zero location cannot achieve the specification, readjust the proportional gain (if necessary) such that, at least, the bandwidth and phase margin specifications are met. (Note that with a PD controller for this system, the open-loop transfer function is still of Type 1. Hence, the zero steady-state error specification for ramp input cannot be met with a PD controller.) Save the root locus, open and closed-loop Bode, time response plot and PD gains. The compensator transfer function in Control System Designer or rltool in this step is of the form shown below. Use it to determine the gains and . Save these gains.
Consider a PID controller. Using and values you have obtained from the previous steps, edit the compensator (i.e. add poles and zeros to match the format below) to include integral feedback with the integral gain set to a small value (i.e., is 1% of ). The controller transfer function for this step is Hint: We have all PID values, plug into above controller transfer function and solve for A and B in form. This should give you value of . To put it in the compensator the zero locations are -1/A and -1/B.