arrow-left

All pages
gitbookPowered by GitBook
1 of 5

Loading...

Loading...

Loading...

Loading...

Loading...

C. Control Design (Week 2)

hashtag
Objective

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.

hashtag
Experiment Notes

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 is approximated as

let , DC gain of the motor.

hashtag
Proportional (P) Control

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.

hashtag
Proportional-plus-Derivative (PD) Control

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.

hashtag
Proportional-plus-Integral-plus-Derivative (PID) Control

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.

hashtag
Controller Gain Limits

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

hashtag
Sampling Time

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.

hashtag
Design Specifications

The closed-loop DC motor system must meet the following specifications.

  1. 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.)

  2. 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.)

circle-exclamation

hashtag
Guidelines for saving plots

Results from each step below must be checked with TAs before proceeding to the next:

hashtag
Procedure

  1. 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.

  2. First consider a proportional controller, i.e., C = Kp. Input C = 1 into MATLAB.

circle-exclamation

You must have your work checked out by one of the TAs before leaving the lab.

hashtag
Results for Report

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

hashtag
(A) From Step 5

  1. Root locus plot

  2. Open-loop Bode plot

  3. Closed-loop Bode plot

hashtag
(B) From Step 6

  1. Root locus plot

  2. Open-loop Bode plot

  3. Closed-loop Bode plot

hashtag
(C) From Step 9

  1. Root locus plot

  2. Open-loop Bode plot

  3. Closed-loop Bode plot

hashtag
(D) From Step 10

  1. Closed-loop transfer function

hashtag
(E) From Step 11

  1. Poles of the closed-loop system

  2. Natural frequency of the closed-loop system dominant poles

  3. Damping of the closed-loop system dominant poles

hashtag
(F) From Step 12

  1. PID controller SIMULINK block diagram (image)

hashtag
(G) From Step 13

  1. Plots comparing the ramp responses of PD and PID controllers (on the same figure)

  2. Plots comparing the error variable of PD and PID controllers (on the same figure)

hashtag
Questions for Report

  1. 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.

  2. 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 quarter-step 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

A. Integration (Week 1)

hashtag
1. QUANSER Rotary Servo Base

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.

Figure 1 Rotary Servo Base
ID
Component
ID
Component

hashtag
2. Components & Sensors

hashtag
a) DC Motor

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.

hashtag
b) Potentiometer

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.

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.

hashtag
c) Encoders

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

hashtag
3. Velocity Estimation

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

​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.

hashtag
4. Filtering the Velocity Signal

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

​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

Rearranging the filter transfer function above,

we can represent the filtering using the differential equation

​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

circle-info

Note: Filtering does add dynamics to the signal, i.e. small delay, as given by the term in Equation 1.3.

hashtag
5. Encoder Counter Wrapping

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.

hashtag
Experiment

Follow the steps and build the SIMULINK model below:

Follow these steps to read the motor velocity:

  1. First, download and open q_servo_vel_direct.slx Simulink model.

  2. Configure the model to apply a 0.4 Hz square wave voltage signal going between 0.5V and 2.5V.

  3. Change the simulation time to 5 seconds from Simulation tab, stop time.

hashtag
Results for Report

hashtag
(A) From Step 7

  1. 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.

  2. Response plots from Step 7.

hashtag
(B) From Step 8

  1. 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.

  2. Response plots from Step 8.

hashtag
(C) From Step 9

  1. Response plots with and without encoder wrapping from Step 9.

hashtag
(D) From Step 10

  1. 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.

  2. 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?

  3. Completed SIMULINK block diagram with low-pass filter from Step 10.

D. Controller Implementation & Evaluation (Week 3)

hashtag
Objectives

The objective of this part of the DC motor experiment is to implement the controller designed in part B and evaluate its performance.

hashtag

Lab 1: Rotary Servo Base

Welcome to the first hands-on experiment!

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.

  • Step 10 - Closed loop TF
  • Run controlSystemDesigner(G,C) (you can alternatively run rltool(G,C) for versions R2020b and older).
    1. Select ‘New Plot -> New Step’ to launch the step response plot (if it is not automatically launched). In the time response plot, only the ‘IOTransfer_r2y' (closed-loop) should be visible. Always do this in all the labs.

    2. Select ‘New Plot -> New Bode’ and choose the appropriate option ‘IOTransfer_r2y' 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 KpK_pKp​ 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.

  • 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 specifications 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 GCGCGC 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 KpK_pKp​ and KdK_dKd​. Save these gains.

    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 ).

  • Consider a PID controller. Using KpK_pKp​ and KdK_dKd​ 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., KiK_iKi​ is 1% of KpK_pKp​). 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 Ki(1+As)(1+Bs)sK_i\frac{(1+As)(1+Bs)}{s}Ki​s(1+As)(1+Bs)​ form. This should give you value of AB=KdKi,A+B=KpKiAB = \frac{K_d}{K_i}, A+B = \frac{K_p}{K_i}AB=Ki​Kd​​,A+B=Ki​Kp​​. To put it in the compensator the zero locations are -1/A and -1/B.

  • Readjust the proportional and derivative gains (if necessary, by modifying the zeros, not the overall gain, KiK_iKi​) 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 – KpK_pKp​ , KdK_dKd​ , KiK_iKi​).

  • 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 GGG and CCC , 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 (located under “Modeling” -> “Model Settings” -> “Solver Details”). 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 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.

  • Time response plot
  • P (proportional) gain

  • Time response plot
  • PD (proportional and derivative) gains

  • Time response plot
  • PID (proportional, derivative and integral) gain values (mention if the gains are the same values or readjusted values from Step 8)

  • :
    1. Step responses (two plots on the same figure)

    2. Derivative of the error signal and speed value in one figure for the step input from both models

    3. Explain how the forward-feed and feedback derivative gain influence system behavior as observed in the input voltage plot.

    VmV_mVm​
    Ωl\Omega_lΩl​
    Ωl(s)Vm(s)=Aτs+1(2.1)\displaystyle\frac{\Omega_l(s)}{V_m(s)} = \frac{A}{\tau s+1} \qquad \qquad \qquad \tag{2.1}Vm​(s)Ωl​(s)​=τs+1A​(2.1)
    A=KA = KA=K
    θ˙=Ω\dot{\theta} = \Omegaθ˙=Ω
    θ\thetaθ
    G(s)=θ(s)Vm(s)=As(τs+1)(3.1)G(s) = \displaystyle\frac{\theta (s)}{V_m (s)} = \frac{A}{s(\tau s+1)} \qquad \qquad \qquad \tag{3.1}G(s)=Vm​(s)θ(s)​=s(τs+1)A​(3.1)
    HHH
    KPK_PKP​
    θc\theta_cθc​
    θ\thetaθ
    θ(s)θc(s)=AKpτs2+s+AKp=AKpτs2+1τs+AKpτ\frac{\theta(s)}{\theta_c(s)} = \frac{AK_p}{\tau s^2 + s + AK_p} = \frac{\cfrac{AK_p}{\tau}}{s^2 + \cfrac{1}{\tau}s + \cfrac{AK_p}{\tau}} θc​(s)θ(s)​=τs2+s+AKp​AKp​​=s2+τ1​s+τAKp​​τAKp​​​
    θ(s)θc(s)=ωn2s2+2ζωns+ωn2\frac{\theta(s)}{\theta_c(s)} = \frac{\omega_n^2}{s^2 + 2\zeta \omega_n s + \omega_n^2}θc​(s)θ(s)​=s2+2ζωn​s+ωn2​ωn2​​
    KpK_pKp​
    θc\theta_cθc​
    θ\thetaθ
    θ(s)θc(s)=AKpτms2+(1+AKd)s+AKp=AKpτms2+(1+AKd)τms+AKpτm\frac{\theta(s)}{\theta_c(s)} = \frac{AK_p}{\tau_m s^2 + (1 + AK_d)s + AK_p} = \frac{\cfrac{AK_p}{\tau_m}}{s^2 + \cfrac{(1 + AK_d)}{\tau_m}s + \cfrac{AK_p}{\tau_m}}θc​(s)θ(s)​=τm​s2+(1+AKd​)s+AKp​AKp​​=s2+τm​(1+AKd​)​s+τm​AKp​​τm​AKp​​​
    KdK_dKd​
    KpK_pKp​
    GHGHGH
    GH=(Kps+Ki)sA(τms+1+AKd)1sGH = \frac{(K_ps+K_i)}{s} \frac{A}{(\tau_ms+1+AK_d)}\frac{1}{s}GH=s(Kp​s+Ki​)​(τm​s+1+AKd​)A​s1​
    Vdac(t)V_{\text{dac}}(t)Vdac​(t)
    KaK_aKa​
    Vamp(t)V_{\text{amp}}(t)Vamp​(t)
    VmaxV_{\text{max}}Vmax​
    Vm(t)V_m(t)Vm​(t)
    V_{\text{max}} = 10.0 V \qquad \qquad \qquad \tag{3.2}
    TsT_sTs​
    TsT_sTs​
    TsT_sTs​
    G(s)G(s)G(s)
    KdK_dKd​
    KdK_dKd​
    Modelling
    Figure 1: Closed-loop block diagram for the position control of a DC motor using a proportional controller
    Figure 2: Closed-loop block diagram for the position control of a DC motor using a proportional-plus-derivative (PD) controller.
    Figure 3: Closed-loop block diagram for the position control of the DC motor using a proportional-plus-Integral-plus-derivative (PID) controller
    Figure 4. Actuator saturation.

    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

    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).

  • 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 .

  • 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.

    Sample velocity estimate usign direct derivative when running at 500 Hz

  • 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.

    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 2n2^n2n 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 Tf=0.01T_f = 0.01Tf​=0.01s 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.

    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 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

    VABV_{AB}VAB​
    VAB=VAW+VWBV_{AB} = V_{AW} + V_{WB}VAB​=VAW​+VWB​
    VAWV_{AW}VAW​
    VWBV_{WB}VWB​
    Δθ=2πN×PPR(1.1)\Delta \theta = \frac{2\pi}{N\times PPR} \qquad \qquad \qquad \tag{1.1}Δθ=N×PPR2π​(1.1)
    ω(k)=θ(k)−θ(k−1)h\omega (k) = \frac{\theta(k) - \theta(k-1)}{h}ω(k)=hθ(k)−θ(k−1)​
    θ(k)\theta(k)θ(k)
    kthk^{th}kth
    hhh
    Δω=Δθh(1.2)\Delta\omega = \frac{\Delta \theta}{h} \qquad \qquad \qquad \tag{1.2} Δω=hΔθ​(1.2)
    ω\omegaω
    Δθ\Delta \thetaΔθ
    hhh
    Yf(s)Y=1Tf(s)+1\frac{Y_f(s)}{Y} = \frac{1}{T_f(s) + 1}YYf​(s)​=Tf​(s)+11​
    YYY
    YfY_fYf​
    TfT_fTf​
    ωf\omega_fωf​
    Yf(s)Y=ωfs+ωf\frac{Y_f(s)}{Y} = \frac{\omega_f}{s+\omega_f}YYf​(s)​=s+ωf​ωf​​
    ωf=1/Tf\omega_f = 1 / T_fωf​=1/Tf​
    ω≤ωf.\omega \leq \omega_f .ω≤ωf​.
    sTfYf(s)+Yf(s)=Y(s)sT_fY_f(s) + Y_f(s) = Y(s)sTf​Yf​(s)+Yf​(s)=Y(s)
    Tfdyf(t)dt+yf(t)=y(t)T_f \frac{dy_f(t)}{dt} + y_f(t) = y(t)Tf​dtdyf​(t)​+yf​(t)=y(t)
    yf(t)y_f(t)yf​(t)
    yf(t−h)y_f(t − h)yf​(t−h)
    Tfyf(t)−yf(t−h)h+yf(t)=y(t)T_f\frac{y_f(t) - y_f(t-h)}{h}+y_f(t) = y(t)Tf​hyf​(t)−yf​(t−h)​+yf​(t)=y(t)
    yf(t)y_f(t)yf​(t)
    yf(t)=TfTf+hyf(t−h)+hTf+hy(t)(1.3)y_f(t) = \frac{T_f}{T_f + h}y_f(t-h)+\frac{h}{T_f + h}y(t) \qquad \qquad \qquad \tag{1.3}yf​(t)=Tf​+hTf​​yf​(t−h)+Tf​+hh​y(t)(1.3)
    h/(Tf+h)h/(T_f + h)h/(Tf​+h)
    Δyf(t)=hTf+hΔθh(1.4)\Delta y_f(t) = \frac{h}{T_f + h} \frac{\Delta \theta}{h} \qquad \qquad \qquad \tag{1.4}Δyf​(t)=Tf​+hh​hΔθ​(1.4)
    TfTf+hyf(t−h)\frac{T_f}{T_f + h}y_f (t-h)Tf​+hTf​​yf​(t−h)
    −27-2^{7}−27
    27−12^7-127−1
    (150+128)mod  256 − 128=−106(150+128) \mod 256 ~ − ~128 = −106(150+128)mod256 − 128=−106
    Δθ\Delta \thetaΔθ
    Δθ\Delta \thetaΔθ
    Δθ\Delta \thetaΔθ
    Tf=0.01sT_f = 0.01 sTf​=0.01s
    h=0.001sh = 0.001 sh=0.001s
    file-download
    30KB
    q_servo_vel_direct.slx
    arrow-up-right-from-squareOpen
    Figure 2 Potentiometer
    Figure 3 Schematic diagram of the voltage dividing characteristic of a rotary potentiometer.
    Figure 4 Output of an incremental encoder showing signals A and B when rotating in a clockwise manner.
    Figure 5 Comparison of the number of counts generated by the X1, X2, and X4 decoding algorithms
    Figure 6 SIMULINK model

    Motor Gearbox

    Equipment Required

    The following is a list of the required equipment to perform this experiment:

    hashtag
    Controller Implementation

    hashtag
    1. Step Response Experiments

    1. Open q_servo_pos_cntrl.slx file. Do not change anything except the PID gains.

    2. Double-click on the Signal Generator and ensure that the following parameters are set to generate a square wave (i.e. step reference):

      • Signal Type = square

      • Amplitude = 1

      • Frequency = 0.4 Hz

    3. In the Simulink diagram, set the Amplitude gain block to 0.2 and the Constant offset gain block to 0.2. Note that these gain blocks outside the Signal Generator block are introduced to generate the square wave with amplitude limits of 0 V and 0.4 V.

    4. Check that the sampling time is set to 0.002 s (located under “Modeling” -> “Model Settings” -> “Solver Details”).

    5. 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 .

    6. Turn on the power amplifier.

    7. To build the model, click down arrow on Monitor & Tune under Hardware tab and then Build for monitoring .

    8. Open the position scope.

    9. Press Connect button under Monitor & Tune and then press Start . Run the experiment for 5 seconds.

    10. Save your data. No need to Build again unless you change any blocks or configuration settings in the model.

    11. PD Controller Test: By introducing a derivative gain (), notice how the system characteristics change. Set and to the respective values found in . will remain as 0. Connect and Start. Observe the behavior and save the data.

    12. 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).

    hashtag
    2. Ramp Response Experiments

    1. 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

    2. 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 .

    3. Change the sampling time back to 0.002 sec (“Modeling” -> “Model Settings” -> “Solver Details”).

    4. 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 . will remain as 0. Connect and Start. Observe the behavior and save the data.

    5. PID Controller Test: In the respective controller gain blocks, change the current values of , and to the PID values found in . Save the data.

    6. Repeat the PID controller test with double the gain value for while keeping the same values of and , and save the data.

    hashtag
    Results and Questions for Report

    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 the triangle wave signal implemented during the experiment. The attributes of the simulation will be mentioned in the corresponding section.

    hashtag
    (A) Step Response

    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")

    You may generate the command input either using the Signal Generator block or by using the corresponding command input data saved in the Step Response experiments.

    hashtag
    i) P Controller

    1. Plot angle or rotary position, i.e., commanded, experimental from Step 1.10, and simulation responses on one figure. Use the same KpK_pKp​ gain value evaluated in Step 1.5 for the simulation response.

    2. What is the effect of proportional controller gain on closed-loop system behaviour?

    hashtag
    ii) PD Controller

    1. Plot angle or rotary position, i.e., commanded, experimental from Step 1.11, and simulation responses on one figure. Use the same KpK_pKp​ and KdK_dKd​ gain values evaluated in Step 1.11 for the simulation response.

    2. What is the effect of derivative controller gain on closed-loop system behaviour?

    3. 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.

    hashtag
    iii) Sampling Time

    1. Plot angle or rotary position (commanded and experimental) and control input Vm from Step 1.12.

    2. What is the effect of sampling time on closed-loop system behaviour?

    hashtag
    (B) Ramp Response

    Any simulation results in this subsection will have the following attributes:

    • Command input: Triangle wave

      • Amplitude: Maximum of π/3\pi/3π/3 and minimum of 0

      • Frequency: 0.4 Hz

    • Sampling time: 0.002 s (Go to "Modeling" -> "Model Settings" -> "Solver details" -> "Fixed-step size")

    You may generate the command input either using the Repeating Sequence block or by using the corresponding command input data saved in the Ramp Response experiments.

    hashtag
    i) PD Controller

    1. Plot angle or rotary position, i.e., commanded, experimental from Step 2.3, and simulation responses on one figure. Use the same KpK_pKp​ and KdK_dKd​ gain values evaluated in Step 2.4 for the simulation response.

    hashtag
    iii) PID Controller

    1. 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 KpK_pKp​, KdK_dKd​ and KiK_iKi​ gain values evaluated in Step 2.6 for the simulation response.

    2. Mention the final PID gains after tuning.

    file-download
    48KB
    q_servo_pos_cntrl.slx
    arrow-up-right-from-squareOpen

    B. Modeling (Week 1)

    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:

    Ωl(s)Vm(s)=Kτs+1(2.1)\frac{\Omega_l(s)}{V_m(s)} = \frac{K}{\tau s+1} \qquad \qquad \qquad \tag{2.1}Vm​(s)Ωl​(s)​=τs+1K​(2.1)

    where Ωl(s)\Omega_l(\mathrm{s})Ωl​(s) is the Laplace transform of the load shaft speed ωl(t)\omega_l(\mathrm{t})ωl​(t), Vm(s)V_m(\mathrm{s})Vm​(s) is the Laplace transform of motor input voltage vm(t)v_m(\mathrm{t})vm​(t), KKK is the steady-state gain, τ\tauτ is the time constant, and s\mathrm{s}s is the Laplace operator. The Rotary Servo Base Unit transfer function model is derived analytically in Modeling Using First-Principles and its KKK and τ\tauτ 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 KKK and τ\tauτ. 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.

    hashtag
    1. Modeling Using First-Principles

    hashtag
    a) Electrical Equations

    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:

    hashtag
    b) Mechanical Equations

    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 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:

    hashtag
    c) Combining the Electrical and Mechanical Equations

    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 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

    hashtag
    2. Modeling Using Experiments

    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.

    hashtag
    a) Frequency Response

    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:

    hashtag
    b) Bump Test / Unit Step Input Test

    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

    hashtag
    Experimental Setup

    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.

    1. Download the Modeling_files.zip and extract the files to desktop.

    2. Open q_servo_modeling.m SIMULINK file.

    3. Double click on the "Rotary Servo Interface - Speed" subsystem to access the DAQ configuration

    hashtag
    Frequency Response Experiment

    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.

    hashtag
    a) Steady-state gain

    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:

    1. 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

    2. Set the Amplitude (V) slider gain to 0.

    3. 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.

    hashtag
    b) Gain at varying frequencies

    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:

    1. 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

    2. Set the Amplitude (V) slider gain to 2.0 V.

    3. Set the

    hashtag
    Step Response Experiment

    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 .

    To create the step input:

    1. 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

    2. Set the Amplitude (V) gain block to 1.0 V.

    3. Set the Offset (V)

    hashtag
    Model Validation 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:

    1. 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

    2. Set the Amplitude (V) slider gain to 1.0 V.

    3. Set the Offset (V)

    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 control design (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.

    hashtag
    Tables for Report

    hashtag
    Table B.1 Collected frequency response data.

    hashtag
    Table B.2 Summary of results for the Rotary Servo Base Unit Modeling laboratory.

    hashtag
    Results for Report

    hashtag
    (A) Frequency Response Experiment

    1. Using the MATLAB plot command and the data collected in , 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 . Hint: May use the Data Tips tool to obtain values from the MATLAB Figure. Include the labelled Bode plot along with tabulated values of in the report.

    hashtag
    (B) Step Response Experiment

    1. Plot the maximum load speed response (saved in the MATLAB workspace under the wl variable) from Step 9 in MATLAB.

    2. Find the steady-state gain using the measured step response (Result B.1) and enter it in under the 'Step Response Experiment' section. Hint: Use the MATLAB ginput command to measure points off the plot.

    hashtag
    (C) Model Validation Experiment

    1. 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?

    2. From the plots, describe how the gain and time constant affect the system's response.

    hashtag
    (D) Additional Results

    1. Include the completed .

    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).

    hashtag
    Appendix

    hashtag
    Table A.1 Main Rotary Servo Base Unit Specifications

    hashtag
    Table A.2 Rotary Servo Base Unit Gearhead Specifications

    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.

  • 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) .

  • 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 .

  • 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 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

  • Offset (V)
    block to 0 V.
  • Set the Simulation stop time to 5 seconds.

  • Click Connect button under Monitor & Tune and then run SIMULINK by clicking Start .

  • 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 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 .

  • 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 .

  • 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).

  • 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 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 section.

  • Click the Stop button on the SIMULINK diagram toolbar (or select QUARC | Stop from the menu) to stop the experiment.

  • 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).

  • 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 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 and 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#.

  • 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 under the 'Step Response Experiment' section. Show the calculations in the report.
    RmR_mRm​
    LmL_mLm​
    KmK_mKm​
    eb(t)e_b(\mathrm{t})eb​(t)
    ωm\omega_mωm​
    kmk_mkm​
    eb(t)=kmωm(t)(2.2)e_b(\mathrm{t}) = k_m\omega_m(\mathrm{t}) \qquad \qquad \qquad \tag{2.2}eb​(t)=km​ωm​(t)(2.2)
    Vm(t)−RmIm(t)−LmdIm(t)dt−kmωm(t)=0(2.3)V_m(\mathrm{t}) - R_mI_m(\mathrm{t}) - L_m \frac{dI_m(\mathrm{t})}{dt} - k_m \omega_m(\mathrm{t}) = 0 \qquad \qquad \qquad \tag{2.3}Vm​(t)−Rm​Im​(t)−Lm​dtdIm​(t)​−km​ωm​(t)=0(2.3)
    LmL_mLm​
    Vm(t)−RmIm(t)−kmωm(t)=0(2.4)V_m(\mathrm{t}) - R_mI_m(\mathrm{t})-k_m\omega_m(\mathrm{t}) = 0 \qquad \qquad \qquad \tag{2.4}Vm​(t)−Rm​Im​(t)−km​ωm​(t)=0(2.4)
    Im(t)I_m(\mathrm{t})Im​(t)
    Im(t)=Vm(t)−kmωm(t)Rm(2.5)I_m(\mathrm{t}) = \frac{V_m(\mathrm{t}) - k_m\omega_m(\mathrm{t})}{R_m} \qquad \qquad \qquad \tag{2.5}Im​(t)=Rm​Vm​(t)−km​ωm​(t)​(2.5)
    ωl\omega_lωl​
    LmL_mLm​
    J⋅α=τ(2.6)J \cdot \alpha = \tau \qquad \qquad \qquad \tag{2.6}J⋅α=τ(2.6)
    JJJ
    α\alpha α
    τ\tauτ
    BmB_mBm​
    BlB_lBl​
    Jldωl(t)dt+Blωl(t)=τl(t)(2.7)J_l \frac{d\omega_l(\mathrm{t})}{dt} + B_l\omega_l(\mathrm{t}) = \tau_l(\mathrm{t}) \qquad \qquad \qquad \tag{2.7}Jl​dtdωl​(t)​+Bl​ωl​(t)=τl​(t)(2.7)
    JlJ_lJl​
    τl\tau_lτl​
    Jmdωl(t)dt+Bmωm(t)+τml=τm(t)(2.8)J_m \frac{d\omega_l(t)}{dt} + B_m\omega_m(t) +\tau_{ml}= \tau_m(t) \qquad \qquad \qquad \tag{2.8}Jm​dtdωl​(t)​+Bm​ωm​(t)+τml​=τm​(t)(2.8)
    JmJ_mJm​
    τml\tau_{ml}τml​
    τl(t)=ηgKgτml(t)(2.9)\tau_l(t) = \eta_gK_g\tau_{ml}(t) \qquad \qquad \qquad \tag{2.9}τl​(t)=ηg​Kg​τml​(t)(2.9)
    KgK_gKg​
    ηg\eta_gηg​
    N1N_1N1​
    N2N_2N2​
    Kgi=N2N1(2.10)K_{gi} = \frac{N_2}{N_1} \qquad \qquad \qquad \tag{2.10}Kgi​=N1​N2​​(2.10)
    N3N_3N3​
    N4N_4N4​
    Kge=N4N3(2.11)K_{ge} = \frac{N_4}{N_3} \qquad \qquad \qquad \tag{2.11}Kge​=N3​N4​​(2.11)
    Kg=KgeKgi(2.12)K_g = K_{ge} K_{gi} \qquad \qquad \qquad \tag{2.12}Kg​=Kge​Kgi​(2.12)
    τml(t)=τl(t)ηgKg(2.13)\tau_{ml} (t) = \frac{\tau_l(t)}{\eta_gK_g} \qquad \qquad \qquad \tag{2.13}τml​(t)=ηg​Kg​τl​(t)​(2.13)
    KgK_gKg​
    θm(t)=Kgθl(t)(2.14)\theta_m(t) = K_g\theta_l(t) \qquad \qquad \qquad \tag{2.14}θm​(t)=Kg​θl​(t)(2.14)
    ωm\omega_mωm​
    ωl\omega_lωl​
    ωm(t)=Kgωl(t)(2.15)\omega_m(t) = K_g\omega_l(t) \qquad \qquad \qquad \tag{2.15}ωm​(t)=Kg​ωl​(t)(2.15)
    JmKgdωl(t)dt+BmKgωl(t)+Jldωl(t)dt+Blωl(t)ηgKg=τm(t)(2.16)J_mK_g \frac{d\omega_l(t)}{dt} + B_mK_g\omega_l(t) +\frac{J_l \frac{d\omega_l(t)}{dt} + B_l\omega_l(t)}{\eta_gK_g}= \tau_m(t) \qquad \qquad \qquad \tag{2.16}Jm​Kg​dtdωl​(t)​+Bm​Kg​ωl​(t)+ηg​Kg​Jl​dtdωl​(t)​+Bl​ωl​(t)​=τm​(t)(2.16)
    (ηgKg2Jm+Jl)dωl(t)dt+(ηgKg2Bm+Bl)ωl(t)=ηgKgτm(t)(2.17)(\eta_gK_g^2J_m + J_l) \frac{d\omega_l(t)}{dt} + (\eta_gK_g^2B_m + B_l)\omega_l(t) = \eta_gK_g\tau_m(t) \qquad \qquad \qquad \tag{2.17}(ηg​Kg2​Jm​+Jl​)dtdωl​(t)​+(ηg​Kg2​Bm​+Bl​)ωl​(t)=ηg​Kg​τm​(t)(2.17)
    Jeq=ηgKg2Jm+Jl(2.18)J_{eq} = \eta_gK_g^2J_m+J_l \qquad \qquad \qquad \tag{2.18} Jeq​=ηg​Kg2​Jm​+Jl​(2.18)
    Beq=ηgKg2Bm+Bl(2.19)B_{eq} = \eta_gK_g^2B_m+B_l \qquad \qquad \qquad \tag{2.19} Beq​=ηg​Kg2​Bm​+Bl​(2.19)
    Jeqdωl(t)dt+Beqωl(t)=ηgKgτm(t)(2.20)J_{eq} \frac{d\omega_l(t)}{dt} +B_{eq}\omega_l(t) = \eta_gK_g\tau_m(t) \qquad \qquad \qquad \tag{2.20}Jeq​dtdωl​(t)​+Beq​ωl​(t)=ηg​Kg​τm​(t)(2.20)
    τm(t)=ηmktIm(t)(2.21)\tau_m(t) = \eta_mk_tI_m(t) \qquad \qquad \qquad \tag{2.21}τm​(t)=ηm​kt​Im​(t)(2.21)
    KtK_tKt​
    N⋅m/AN \cdot m / AN⋅m/A
    ηm\eta_mηm​
    ImI_mIm​
    Vm(t)V_m(t)Vm​(t)
    ωl(t)\omega_l(t)ωl​(t)
    τm(t)=ηmkt(Vm(t)−kmωm(t))Rm(2.22)\tau_m(t) = \frac{\eta_mk_t(V_m(t) - k_m\omega_m(t))}{R_m} \qquad \qquad \qquad \tag{2.22}τm​(t)=Rm​ηm​kt​(Vm​(t)−km​ωm​(t))​(2.22)
    VmV_mVm​
    ωl\omega_lωl​
    τm(t)=ηmkt(Vm(t)−kmKgωl(t))Rm(2.23)\tau_m(t) = \frac{\eta_mk_t(V_m(t) - k_mK_g\omega_l(t))}{R_m} \qquad \qquad \qquad \tag{2.23}τm​(t)=Rm​ηm​kt​(Vm​(t)−km​Kg​ωl​(t))​(2.23)
    Jeqdωl(t)dt+Beqωl(t)=ηgKgηmkt(Vm(t)−kmKgωl(t))Rm(2.24)J_{eq} \frac{d\omega_l(t)}{dt} +B_{eq}\omega_l(t) = \frac{\eta_gK_g\eta_mk_t(V_m(t) - k_mK_g\omega_l(t))}{R_m} \qquad \qquad \qquad \tag{2.24}Jeq​dtdωl​(t)​+Beq​ωl​(t)=Rm​ηg​Kg​ηm​kt​(Vm​(t)−km​Kg​ωl​(t))​(2.24)
    Jeqdωl(t)dt+(kmηgKg2ηmktRm+Beq)ωl(t)=ηgKgηmktVm(t)Rm(2.25)J_{eq} \frac{d\omega_l(t)}{dt} +\left (\frac{k_m\eta_gK_g^2\eta_mk_t}{R_m}+B_{eq}\right) \omega_l(t) = \frac{\eta_gK_g\eta_mk_tV_m(t) }{R_m} \qquad \qquad \qquad \tag{2.25}Jeq​dtdωl​(t)​+(Rm​km​ηg​Kg2​ηm​kt​​+Beq​)ωl​(t)=Rm​ηg​Kg​ηm​kt​Vm​(t)​(2.25)
    Jeqdωl(t)dt+(Beq,v)ωl(t)=AmVm(t)(2.26)J_{eq} \frac{d\omega_l(t)}{dt} +\left (B_{eq,v}\right) \omega_l(t) = A_mV_m(t) \qquad \qquad \qquad \tag{2.26}Jeq​dtdωl​(t)​+(Beq,v​)ωl​(t)=Am​Vm​(t)(2.26)
    Beq,v=kmηgKg2ηmkt+BeqRmRm(2.27)B_{eq,v} = \frac{k_m\eta_gK_g^2\eta_mk_t + B_{eq}R_m}{R_m} \qquad \qquad \qquad \tag{2.27}Beq,v​=Rm​km​ηg​Kg2​ηm​kt​+Beq​Rm​​(2.27)
    Am=ηgKgηmktRm(2.28)A_m = \frac{\eta_gK_g\eta_mk_t}{R_m} \qquad \qquad \qquad \tag{2.28}Am​=Rm​ηg​Kg​ηm​kt​​(2.28)
    uuu
    yyy
    ωc\omega_cωc​
    12\frac{1}{\sqrt{2}}2​1​
    ∣Gωl,v(ω)∣=∣Ωl(ωj)Vm(ωj)∣(2.29)|G_{\omega l,v}(\omega)| = \left |\frac{\Omega_l(\omega j)}{V_m(\omega j)}\right| \qquad \qquad \qquad \tag{2.29}∣Gωl,v​(ω)∣=​Vm​(ωj)Ωl​(ωj)​​(2.29)
    ω\omegaω
    VmV_mVm​
    s=jωs = j \omegas=jω
    ∣Ωl(ωj)Vm(ωj)∣=Kτωj+1(2.30) \left |\frac{\Omega_l(\omega j)}{V_m(\omega j)}\right| = \frac{K}{\tau \omega j + 1} \qquad \qquad \qquad \tag{2.30}​Vm​(ωj)Ωl​(ωj)​​=τωj+1K​(2.30)
    ∣Gwl,v(w)∣=K1+τ2ω2(2.31)|G_{wl,v}(w)| = \frac{K}{\sqrt{1+\tau^2\omega^2}} \qquad \qquad \qquad \tag{2.31}∣Gwl,v​(w)∣=1+τ2ω2​K​(2.31)
    Ke,fK_{e,f}Ke,f​
    τe,f\tau_{e,f}τe,f​
    KKK
    τ\tauτ
    Ke,f=∣Gwl,v(0)∣(2.32)K_{e,f} = |G_{wl,v}(0)| \qquad \qquad \qquad \tag{2.32}Ke,f​=∣Gwl,v​(0)∣(2.32)
    Y(s)U(s)=Kτs+1(2.33)\frac{Y(s)}{U(s)} = \frac{K}{\tau s + 1} \qquad \qquad \qquad \tag{2.33}U(s)Y(s)​=τs+1K​(2.33)
    K=5rad/VsK = 5 rad/VsK=5rad/Vs
    τ=0.05s\tau = 0.05sτ=0.05s
    t0t_0t0​
    uminu_{min}umin​
    umaxu_{max}umax​
    y0y_0y0​
    K=ΔyΔu(2.34)K = \frac{\Delta y}{\Delta u} \qquad \qquad \qquad \tag{2.34}K=ΔuΔy​(2.34)
    Δy=yss−y0\Delta y = y_{ss} - y_0Δy=yss​−y0​
    Δu=umax−umin\Delta u =u_{max} - u_{min}Δu=umax​−umin​
    τ\tauτ
    y(t1)=0.632(yss−y0)+y0(2.35)y(t_1) = 0.632(y_{ss}-y_0) + y_0 \qquad \qquad \qquad \tag{2.35}y(t1​)=0.632(yss​−y0​)+y0​(2.35)
    t1t_1t1​
    y(t1)y(t_1)y(t1​)
    t1t_1t1​
    t1=t0+τ(2.36)t_1 = t_0 + \tau \qquad \qquad \qquad \tag{2.36}t1​=t0​+τ(2.36)
    τ=t1−t0(2.37)\tau = t_1 - t_0 \qquad \qquad \qquad \tag{2.37}τ=t1​−t0​(2.37)
    t0t_0t0​
    Vm(s)=Ave(−st0)s(2.38)V_m(s) = \frac{A_ve^{(-st_0)}}{s} \qquad \qquad \qquad \tag{2.38}Vm​(s)=sAv​e(−st0​)​(2.38)
    AvA_vAv​
    t0t_0t0​
    Ωl(s)=KAve(−st0)(τs+1)s(2.39)\Omega_l(s) = \frac{KA_ve^{(-s t_0)}}{(\tau s + 1)s} \qquad \qquad \qquad \tag{2.39}Ωl​(s)=(τs+1)sKAv​e(−st0​)​(2.39)
    ωl(t)\omega_l(t)ωl​(t)
    t0t_0t0​
    ωl(t)=KAv(1−e(−t−t0τ))+ωl(t0)(2.40)\omega_l(t) = KA_v\left(1-e^{(-\frac{t-t_0}{\tau})}\right) + \omega_l(t_0) \qquad \qquad \qquad \tag{2.40}ωl​(t)=KAv​(1−e(−τt−t0​​))+ωl​(t0​)(2.40)
    2π×352\pi \times35 2π×35
    2V2V2V
    τ\tauτ
    KKK
    τ\tauτ
    KKK
    τ\tauτ
    τe,f\tau_{e,f}τe,f​
    Rotary Servo Base Unit User Manual
    Rotary Servo Base Unit User Manual
    file-archive
    32KB
    Modeling_files.zip
    archive
    arrow-up-right-from-squareOpen
    Bump Test
    Table B.1
    Table B.2
    Table B.1
    Table B.2
    Table B.2
    Figure 7 Rotary Servo Base Unit DC motor armature circuit and gear train
    Figure 8 Typical frequency response
    Figure 9 Magnitude Bode plot
    Figure 10 Input and output signal used in the bump test method
    Figure 11a q_servo_modeling Simulink diagram used to model Rotary Servo Base Unit.
    Figure 11b Rotary Servo Interface - Speed, second-oder low-pass filter implemented
    KdK_dKd​
    KiK_iKi​
    KpK_pKp​
    KdK_dKd​
    KpK_pKp​
    KdK_dKd​
    KiK_iKi​
    π/6\pi/6π/6
    π/6\pi/6π/6
    60∘60^{\circ}60∘
    KpK_pKp​
    KdK_dKd​
    KiK_iKi​
    KpK_pKp​
    KdK_dKd​
    KiK_iKi​
    KiK_iKi​
    KpK_pKp​
    KdK_dKd​
    Step 5 of Part C Control Design
    Step 6 of Part C Control Design
    Step 6 of Part C Control Design
    Step 9 of Part C Control Design
    Questions for Report
    wl(:,3)
    is the simulated speed.
    Calculate
    the steady-state gain both in linear and decibel (dB) units, i.e.
    , as explained in
    . Enter the resulting numerical value in the f = 0 Hz row of
    . Also, enter its non-decibel value in
    under the 'Frequency Response Experiment' section.
    τ\tauτ
    KKK
    τ\tauτ
    KKK
    τ\tauτ
    KKK
    τ\tauτ
    Table B.1
    Table B.1
    Table B.1
    Table B.1
    Results
    Table A.1
    Table A.2
    Table B.2
    Figure 12 Load shaft speed response to a constant input
    Figure 13 Load shaft speed sine wave response
    Figure 14
    Figure 15 Simulation done with default model parameters: K = 1 and = 0.1Save wl data and name it something like modeling_section#_Group#_K1tau01.
    20log⁡10(Gain)20\log_{10}(\text{Gain})20log10​(Gain)
    τ\tauτ
    Frequency Response
    Table B.1
    Table B.2