Lab 2 Manual

pdf

School

University of Calgary *

*We aren’t endorsed by this school

Course

561

Subject

Electrical Engineering

Date

Dec 6, 2023

Type

pdf

Pages

8

Uploaded by ProfessorHawk2150

Report
QUBE-SERVO2Workbook-Student Hardware Interfacing, Filtering, Block Diagram Modeling, And State-Space Modeling Lab adapted from Quanser labs Hardware Interfacing, Filtering, Block Diagram Modeling, and Stat-space Modeling. 1 Background 1.1 DC Motor Direct-current (DC) motors are used in a variety of applications. As discussed in the QUBE-Servo 2 User Manual, the QUBE-Servo 2 has a brushed DC motor that is connected to a PWM amplifier. See the QUBE-Servo 2 User Manual for details. 1.2 Encoders An encoder is a measurement device that is used to find the position of a spinning shaft. There are many types of encoders but one of the most common is the rotary incremental optical encoder, shown in Figure 1.1. Unlike potentiometers, encoders come in two different types, absolute or relative. Incremental encoders are relative. The angle they measure depends on the last position and when it was last powered. Figure 1.1: US Digital incremental rotary optical shaft encoder Attached to the shaft is a set of bands that change if light can be seen by a photo sensor which combined with a decoding algorithm result in a count-based output giving the rotational position of the shaft. This count can then be converted into either radians or degrees based on how many counts there are in a revolution of the shaft. 1.3 Filtering A low-pass filter can be used to block out the high-frequency components of a signal. A first-order low-pass filter transfer function has the form , (1.1) QUBE-SERVO 2 Workbook - Student 2
QUBE-SERVO2Workbook-Student v1.2 where ω f is the cut-off frequency of the filter in radians per second (rad/s). All higher frequency components of the signal will be attenuated by at least −3 dB ≈ 50 %. 1.4 Motor Modeling The Quanser QUBE-Servo 2 is a DC rotary servo system. Its motor armature circuit schematic is shown in Figure 1.2 and the electrical and mechanical parameters are given in Table 1.1. The DC motor shaft is connected to the load hub. The hub is a metal disk used to mount the disk or rotary pendulum and has a moment of inertia of J h . A disk load is attached to the output shaft with a moment of inertia of J d . Figure 1.2: QUBE-Servo 2 DC motor and load The back-emf (electromotive) voltage e b ( t ) depends on the speed of the motor shaft, ω m , and the back-emf constant of the motor, k m . It opposes the current flow. The back emf voltage is given by: e b ( t ) = k m ω m ( t ). (1.1) Symbol Description Value DC Motor R m Terminal resistance 8 . 4Ω k t Torque constant 0 . 042 N . m / A km Motor back-emf constant 0 . 042 V /( rad / s ) Jm Rotor inertia 4 . 0 × 10 −6 kg . m 2 Lm Rotor inductance 1 . 16 mH m h Load hub mass 0 . 0106 kg rh Load hub radius 0 . 0111 m J h Load hub inertia 0 . 6 × 10 −6 kg . m 2 Load Disk m d Mass of disk load 0 . 053 kg r d Radius of disk load 0 . 0248 m Table 1.1: QUBE-Servo 2 system parameters
QUBE-SERVO2Workbook-Student Using Kirchoff’s Voltage Law, we can write the following equation: . (1.2) Since the motor inductance L m is much less than its resistance, it can be ignored. Then, the equation becomes v m ( t ) − R m i m ( t ) − k m ω m ( t ) = 0 . (1.3) Solving for i m ( t ) , the motor current can be found as: . (1.4) The motor shaft equation is expressed as J eq ω ˙ m ( t ) = τ m ( t ) , (1.5) where J eq is the total moment of inertia acting on the motor shaft and τ m is the applied torque from the DC motor. Based on the current applied, the torque is τ m = k t i m ( t ). (1.6) The moment of inertia of a disk about its pivot, with mass m and radius r , is . 1.5 Linear State-Space Representation The standard state-space representation of a multi-input multi-output (MIMO) continuous linear-time invariant (LTI) system with n state variables, r input variables, and m output variables is x ˙( t ) = Ax(t) + Bu(t), (1.7) y ( t ) = Cx ( t ) + Du ( t ), (1.8) where x is the vector of state variables ( n ×1) , u is the control input vector ( r ×1) , y is the output vector ( m ×1) , A is the system matrix ( n × n ) , B is the input matrix ( n × r ) , C is the output matrix ( m × n ) , and D is the feed-forward matrix ( m × r ) . The block diagram representation of the state-space Equation 1.7 and Equation 1.8 is shown in Figure 1.3. Figure 1.3: State-Space Block Diagram QUBE-SERVO 2 Workbook - Student 2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
QUBE-SERVO2Workbook-Student v1.2 2 In-Lab Exercises In this lab, we will be investigating how to connect to the QUBE-servo 2 system, how to filter the output to remove noise and look at a couple of different ways to model the system and how they compare with the real system. 2.1 Configuring a Simulink Model for the QUBE-Servo 2 Follow these steps to build a SIMULINK model that will interface to the QUBE-Servo 2 using QUARC : 1. Load the MATLAB software. 2. Create a new SIMULINK diagram by going to File | New | Model item in the menu bar. 3. Open the SIMULINK Library Browser window by clicking on the View | Library Browser item in the SIMULINK menu bar or clicking on the SIMULINK icon. 4. Expand the QUARC Targets item and go to the Data Acquisition | Generic | Configuration folder, as shown in Figure 2.2. 5. Click-and-drag the HIL Initialize block from the library window into the blank SIMULINK model. This block is used to configure your data acquisition device. 6. Double-click on the HIL Initialize block. 7. Make sure the QUBE-Servo 2 is connected to your PC USB port and the USB Power LED is lit green. 8. In the Board type field, select qube_servo2_usb . Figure 2.2: QUARC Targets in SIMULINK Library Browser
QUBE-SERVO2Workbook-Student v1.2 9. Under the QUARC tab select quarc_win64.tlc as the QUARC Target, after this you should have a new tab called Hardware, in this tab click Monitor & Tune. If your system has been successfully connected the status LED on the Qube Servo will turn green. Add a screen shot of your working model into your report. (1 point) 10. Clicking the Stop button in the Hardware tab will now stop the program running on the system. 2.2 Reading the Encoder 1. Using the SIMULINK model you configured for the QUBE-Servo 2 in the previous section, add the HIL Read Encoder block from the QUARC Targets | Data Acquisition | Generic | Immediate I/O category in the Library Browser. 2. Connect the HIL Read Encoder to a Gain and Display block (without the HIL Write Analog block). In the Library Browser, you can find the Display block from the Simulink | Sinks and the Gain block from Simulink | Math Operations . Add a screen shot of this model when it is working to your report. (1 point) 3. Run the system on the servo and rotate the disc back and forth. The Display block shows the number of counts measured by the encoder. The encoder counts are proportional to the angle of disc. 4. What happens to the encoder reading every time the QUARC controller is started? Stop the controller, move around the disc, and re-start the controller. What do you notice about the encoder measurement when the controller is re-started? (1 point) 5. Measure how many counts the encoder outputs for a full rotation. Briefly explain your procedure to determine this and validate that this matches the specifications given in the QUBE-Servo 2 User Manual.(2 points) 6. Ultimately, we want to display the disc angle in degrees, not counts. Modify your model to convert counts to degrees. Run the QUARC controller and confirm that the Display block shows the angle of the disc correctly. (2 points) 7. If instead you wanted to measure your angle in radians how would your model have to be changed? Make this modification to your system and confirm the display block is showing the expected result. (2 points) 2.3 Driving the DC Motor 1. Add the HIL Write Analog block from the Data Acquisition | Generic | Immediate I/O category into your SIMULINK diagram. This block is used to output a signal from analog output channel #0 on the data acquisition device. This is connected to the on-board PWM amplifier which drives the DC motor. 2. Add the Constant block found in the Simulink | Sources folder to your Simulink model. Connect the Constant and HIL Write Analog blocks together. 3. Connect the Stall detection block found on D2L to your system, with input from one of the subsystem connected directly before the HIL write block so it is reading the voltage you are sending to the motor. Input two should be connected right after the HIL Read Encoder block. This subsystem will stop the model if it is not moving for more than 10 seconds and more than 5 volts are applied, the details of this subsystem are shown in Figure 2.4. The Control input for this sub system should be connected to the signal
QUBE-SERVO2Workbook-Student that you are sending to the HIL Write Block and the Position (Counts) should receive the signal from the encoder in counts. Figure 2.4: Stall Detection Subsystem 4. Build and run the QUARC controller. 5. Set the Constant block to 0 . 5 . This applies 0 . 5 V to the DC motor in the QUBE-Servo 2. Confirm that we are obtaining a positive measurement when a positive signal is applied . This convention is important, especially in control systems when the design assumes the measurement goes up positively when a positive input is applied. Finally, in what direction does the disc rotate (clockwise or counter-clockwise) when a positive input is applied? (2 points) 6. Stop the QUARC controller. 2.4 Filtering 1. Now modify your model so that you can measure the speed that the motor is running at, and then output that information to a Scope. Additionally change the input from a constant value to a square wave going from 1V to 3V at 0.4 Hz. (1 points) 2. Build and run the QUARC controller. Examine the encoder speed response. How do the input and output signals compare? (2 points) 3. Explain why the encoder- based measurement is noisy. Hint: Measure the encoder position measurement using a new Scope. Zoom up on the position response and remember that this later enters a derivative block. Is the signal continuous? (2 points) 4. One way to remove some of the high- frequency components is adding a low-pass filter (LPF) to the derivative output. From the Simulink | Continuous Simulink library, add a Transfer Fcn block after the Derivative output and connect LPF to the Scope . Set the Transfer Fcn block to act as the following transfer function 50/( s +50) . 5. Build and run the QUARC controller. Show the filtered encoder-based speed response and the motor voltage. Has it improved? (2 points) 6. What is the cutoff frequency of the low-pass filter 50/( s +50) ? Give you answer in both rad/s and Hz. (2 points) 7. Vary the cutoff frequency, ω f , between 10 to 200 rad / s (or 1 . 6 to 32 Hz). What effect does it have on the filtered response? Try 4 different cutoff frequencies spread over this range other than 50. Consider the benefit and the trade-off of lowering and increasing this parameter.(4 points) QUBE-SERVO 2 Workbook - Student 4
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
QUBE-SERVO2Workbook-Student v1.2 8. Stop the QUARC controller. 2.5 Block Diagram Modeling 1. The motor shaft of the QUBE-Servo 2 is attached to a load hub and a disk load. Based on the parameters given in Table 1.1, calculate the equivalent moment of inertia that is acting on the motor shaft. (1 point) 2. Find the set of differential equations that can be used to model this system and design a MATLAB script to solve them numerically (eg with Euler’s method) over 10 seconds with a step input of 5V at 1 second. Explain your code and show the outputs of it. (5 points) 3. Build a block diagram model of the QUBE-Servo 2 and connect it in parallel with the model from the previous section for running the motor and explain how you made this block model of the differential equations. (1 point) 4. Build and run the QUARC controller with your QUBE-Servo 2 model. Attach a screen capture of your scopes. Does your model represent the QUBE-Servo 2 reasonably well? (2 points) 5. You may notice that the model does not match the measured system exactly. What could cause this difference? Given one possible source and explain how it would affect the model. (2 points) 6. Take the Laplace Transform and find the voltage to speed transfer function, Ω( s )/ V m ( s ) , of the system. Evaluate the transfer function by filling in the numerical values for the variables. (2 points) 7. Stop the QUARC controller. 2.6 State Space Modeling 1. Derive the state-space model of the DC motor from the differential equation you obtained previously for the following state variables: x 1 = θ m ( t ) and x 2 = θ ˙ m ( t ) , y 1 = θ m ( t ) and y 2 = θ ˙ m ( t ) (i.e. measuring motor position and speed), and the input variable u = v m ( t ) . (2 points) 2. Based on the state space model derived in Step 2 create the MATLAB script that constructs a MATLAB state-space model, generate its step response and plots its result on a figure. Explain your code in your report. (2 points) 3. Modify your model from the previous section to also contain the state space model so it can be compared with the real system. Note : there is a state space block in Simulink which can be used for this. 4. Build and run the model. Attach a screen capture of your scopes. Does your model represent the actual DC motor well? (2 points) 5. Compare the two models and do they give similar results? (1 point) 6. Stop the QUARC controller. Submit your report, MATLAB Code and Simulink files to the drop box on D2L (2 marks)
QUBE-SERVO2Workbook-Student v1.2 © 2021 Quanser Inc., All rights reserved. Quanser Inc. 119 Spy Court Markham, Ontario L3R 5H6 Canada info@quanser.com Phone: 1-905-940-3575 Fax: 1-905-940-3576 Printed in Markham, Ontario. For more information on the solutions Quanser Inc. offers, please visit the web site at: http://www.quanser.com This document and the software described in it are provided subject to a license agreement. Neither the software nor this document may be used or copied except as specified under the terms of that license agreement. Quanser Inc. grants the following rights: a) The right to reproduce the work, to incorporate the work into one or more collections, and to reproduce the work as incorporated in the collections, b) to create and reproduce adaptations provided reasonable steps are taken to clearly identify the changes that were made to the original work, c) to distribute and publically perform the work including as incorporated in collections, and d) to distribute and publicly perform adaptations. The above rights may be exercised in all media and formats whether now known or hereafter devised. These rights are granted subject to and limited by the following restrictions: a) You may not exercise any of the rights granted to You in above in any manner that is primarily intended for or directed toward commercial advantage or private monetary compensation, and b) You must keep intact all copyright notices for the Work and provide the name Quanser Inc. for attribution. These restrictions may not be waved without express prior written permission of Quanser Inc.