# Experiment 2: Mathematical modelling

(1)        Verify that your motor position blocks are correct.

Run the model "Experiment 1 Part 1" from the previous laboratory by applying a square wave input that switches between positive and negative 180 degrees.  The motor should turn 360 degrees back and forth and the scope should show the output follows the square wave  if the block output is in degrees.

(2)  Purpose of the dithering signal

Run the model "Experiment 1 Part 1" from the previous laboratory and observe the output signal. Set the amplitude of the dithering signal to 0 and repeat the process. Comment on the differences on the output.

(3)  Observe the effects of changing the time constant on the noise filter.

Apply a sinusoidal wave to the motor block (speed output). Change the time constant on the output filter  a number of times and for each case comment on the bandwidth, which is the frequency at which the gain is -3dB in this case. Also, for each different time constant used, apply a constant voltage and comment on the amount of noise in the output.

(4)  Plot voltage vs motor speed
Apply a constant voltage to the motor block (speed output) and record the speed of the motor. Repeat this process for a number of input voltages ranging from -8 V to 8 V. Plot the results and from the graph determine the static gain of the motor.

(5) Find the dominant pole of the motor

Plot the step response of the motor block (speed output). Assuming the system is first order and find the dominant pole of the motor using the equation

where TC is the time constant or the time for a step response to rise to 63.2% of its final value.

(6)
Motor transfer function

Find the motor transfer function from your experiment results and compare the step response of the model and the physical motor.

We begin by making sure the motor is connected to Hilink control board as shown below.

Note: P0_A could also be red+black and P0_B could also be purple under our new colour code.

Once the motor is correctly connected to the Hilink control board and the control board is correctly connected to the PC, switch on the power of the Hilink board and start MATLAB.

(If the progarm keeps crashing open windows task manager and set the number of cores that the MATLAB process operates on to only 1)

In the MATLAB command window set S = inf and T = 1/2048.

Open the model "Experiment 1 part 1" downloaded in the previous laboratory. If you no longer have this model download it now.  Clicking on the signal generator.  In the pop up window choose square wave for wave form, 180 for amplitude and 1 hertz for frequency. Close the pup up window.  Build the model (by pressing ctrl + B).  Connect it and run it by clicking appropriate buttons on the simulink program tool bar.   The motor should turn 360 degrees back and forth and the scope should show the output follows the square wave  if the block output is in degrees.

Repeat this process for the MPradians block by applying a square wave of positive and negative p in order to check if the output is in radians.

If not repeat the 3rd task of experiment 1.

Once this task is completed set the signal generator back to a sine wave with unit amplitude.

Open the model "Experiment 1 part 1" downloaded in the previous laboratory. Build, connect and run the model and observe the waveform. In the model you should notice a sinusoidal block that adds to the signal after the "PID" block. Adjust the amplitude of this wave to zero and repeat the process. Do you notice any differences in the output signals?

Is the system without this dithering signal linear or nonlinear? If it is nonlinear, what may cause this nonlinearity and how may this dithering signal reduce the nonlinearity?  Try different values of the amplitude and comment on their effects on the output.  Summarize your results in a table or graph in order to support your comment.

Using the blank template found here construct the following Simulink model.  The sine wave block can be found in the source section of the Simulink library or using search.

Double click on the "MSradians" block to open up the subsystem. Adjust the time constant of the output filter (coefficient of 's' in the denominator) to zero. Build, connect and run the model. Adjust the frequency of the sine wave until the peak-to-peak value of the output is the same as the peak-to-peak value of the input. This is known as the gain crossover frequency and gives a good indication of the bandwidth.  The bandwidth is the frequency at which the gain is 0.707 or -3dB in this case.

Note: This will happen at a high frequency in the range of (200-1000 rad/sec). For a time constant of 0 you may find the signal to noise ratio is too low to accurately find the gain crossover frequency.

Repeat this process for different values of the filter time constant. If you get an error when trying to run the model try building it again. Complete the following table:

Comment on the effect of the filter time constant on the bandwidth of the system.

Replace the sine wave block using a "constant" block with a value of 3. Run the model with each filter time constant used in the previous part. Qualitatively discuss the amount of noise present as the filter time constant is decreased.

What are the benefits of using the output filter?
What are the disadvantages of using the output filter?
Can the use of such a filter be justified assuming there is some trade off?
What issues does the use of the filter bring into the system? (e.g. does it increase the order of the system/add a new pole?)

Adjust the time constant of the filter back to its original value.

Run the model and wait for the motor to reach steady state. Once the motor has reached steady state record the velocity of the output shaft. Repeat this process for a number of input voltages ranging from -8 V  to 8 V. Take a few extra measurements between the range of -2 to 2 V. Record your results in the following table.

.
.
.

Once this table is complete plot your results using MATLAB or excel.

Is the graph linear? If not the plot is not linear.  Is there any regions where the plot is linear? If there are regions where the plot is linear find the gradient. This is known as the static gain of the motor.

Note: Line fitting and equation generation can be done using the MATLAB function 'polyfit'.

If the plot is nonlinear provide a reason as to why it is nonlinear. If you need a hint go back and read over the preparation. Can this nonlinearity be overcome or is it something that must be recognised but not modelled?

Have the final value of the step block to be 6. Build and run the model. Measure the rise time of step response (0-63.2%).

Assuming the system is first order find the pole position of the system using the equation:

where Tc=rise time (0-63.2%).  It is the time constant or the time for a step response to rise to 63.2% of its final value.

You can add a DC component  to the step input using a constant block and a sum block in order to avoid  the nonlinearity at zero speed.

Using the generic motor transfer function given in the preparation, develop the motor transfer function for both speed and position output.

Compare the speed output step response of the motor with that of the model you built using the model shown below:

Summarize the overshoots, rise times, delay times and  settling times of the motor and the estimated transfer function using a table.

Are the results as expected in terms of rise time and steady state value?
If not what may have caused these inaccuracies in the model?
Does the nonlinearity of the motor play a factor?
Does the first order system assumption play a factor?
Suggest ways the effect of nonlinearities may be reduced.