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 Modelling 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.
Using Kirchoff’s Voltage Law, we can write the following equation:
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:
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
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.
The magnitude of the frequency response of the Rotary Servo Base Unit plant transfer function given in equation Eq 2.1 is defined as:
Then, the magnitude of it equals
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:
From this, the model time constant can be found as:
We obtained Eq (2.26) which described the dynamic behavior of the load shaft speed as a function of the motor input voltage. Starting from this equation, find the transfer function
The q_servo_modeling Simulink diagram shown in Figure 11 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.
Download the Modeling_files.zip and extract the files to desktop.
Open q_servo_modeling.m
SIMULINK file.
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.
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.
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 or f = 0Hz is applied.
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.
Result: Calculate the steady-state gain both in linear and decibel (dB) units 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 in Result.
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.
Result: Calculate the gain of the system (in both linear and dB units) and enter the results 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 modelling_section#_Group#_step.
Result: Plot the response in MATLAB. Recall that the maximum load speed is saved in the MATLAB workspace under the wl
variable.
Result: Find the steady-state gain using the measured step response and enter it in Table B.2.
Hint: Use the MATLAB ginput
command to measure points off the plot.
Find the time constant from the obtained response and enter the result in Table B.2.
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 adjust the model parameters you found in the previous experiments to tune the transfer function. Our goal is to match the simulated system response with the parameters you found as closely as possible to the response of the actual system. 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)
.
Save wl data and name it as modelling_section#_Group#_K1tau01.
Enter the command K = 1.25 in the MATLAB Command Window.
Update the parameters used by the Transfer Function block in the simulation by updating diagram in the q_servo_modeling SIMULINK diagram. To update the diagram, from the Modeling tab, click Update Model. Alternatively, press Ctrl+D. Connect and run the SIMULINK model and observe how the simulation response changes. Remember we have increased K from 1 to 1.25.
Save wl data and name it as modelling_section#_Group#_K125tau01.
Enter the command tau = 0.2
in the MATLAB Command Window.
Save wl data and name it as modelling_section#_Group#_K125tau02. Result: We have varied the gain and time constant model parameters. How do the gain and the time constant affect the system response?
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:
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
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:
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:
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). 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.
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:
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 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:
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
Express the steady-state gain () and the time constant () of the process model Eq (2.1) in terms of the , , and parameters.
Calculate the and model parameters using the system specifications given in Rotary Servo Base Unit User Manual. The parameters are to be calculated based on an the Rotary Servo Base Unit in the high-gear configuration.
The load attached to the motor shaft includes a 24-tooth gear, two 72-tooth gears, and a single 120-tooth gear along with any other external load that is attached to the load shaft. Thus, for the gear moment of inertia and the external load moment of inertia , the load inertia is . Using the specifications given in the Rotary Servo Base Unit User Manual find the total moment of inertia from the gears. Hint: Use the definition of moment of inertia for a disc .
Assuming that the disc load is attached to the load shaft, calculate the inertia of the disc load, , and the total load moment of inertia acting on the motor shaft from the disc and gears, .
Evaluate the equivalent moment of inertia . This is the total inertia from the motor, gears, and disc load. The moment of inertia of the DC motor can be found in the Rotary Servo Base Unit User Manual.
Calculate the steady-state model gain and time constant . These are the nominal model parameters and will be used to compare with parameters that are later found experimentally.
Referring to the Frequency Response, find the expression representing the time constant of the frequency response model given in Eq. (2.31). Begin by evaluating the magnitude of the transfer function at the cutoff frequency .
Referring to Bump Test, find the equation of steady-state gain of the step response and compare it with Eq 2.34. Hint: The the steady-state value of the load shaft speed can be defined as .
Evaluate the step response given in Eq. (2.40) at and compare it with Eq. (2.35).
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:
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 .
Click Connect button under Monitor & Tune and then run SIMULINK by clicking Start .
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.
Result: 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.
Result: Calculate the time constant using the obtained Bode plot by finding the cutoff frequency. Label the Bode plot with the -3 dB gain and the cutoff frequency. Enter the resulting time constant in Table B.2.
Hint: Use the Data Tips tool to obtain values from the MATLAB Figure.
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 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.
Update the simulation again by updating diagram. Connect and run the SIMULINK model and observe how the simulation response changes. Remember we have increased from 0.1 to 0.2.
Enter the nominal values, and , that were found in Pre-lab Q7 in the MATALB Command Window. Update the parameters and examine how well the simulated response matches the measured one.
Save wl data and name it as modelling_section#_Group#_K#tau#.
If the calculations were done properly, then the model should represent the actual system quite well. However, there are always some differences between each servo unit and, as a result, the model can always be tuned to match the system better. Try varying the model parameters until the simulated trace matches the measured response better. Enter these tuned values under the Model Validation section of Table B.2.
If you have tried with different and values save the data.
Result: Provide two reasons why the nominal model might not represent the Rotary Servo Base Unit with better accuracy.
Result: Create a MATLAB figure that shows the measured and simulated response of the model validation response using the tuned model parameters of and . This can be done by manually changing the Servo Model Transfer Function block parameters or changing the K
and tau
parameters in the MATLAB Command Window and going to Simulation | Update Diagram in the SIMULINK model.
Result: Explain how well the nominal model, the frequency response model, and the bump-test model represent the Rotary Servo Base Unit system.