ee 460 advanced control and sys integration an introduction to simulink wed, october 7 ee 460...
TRANSCRIPT
EE 460 Advanced Control and Sys IntegrationAn Introduction to Simulink
Wed, October 7 EE 460 Advanced Control and System Integration Slide 1 of 10
An Intro. to SimulinkModeling the QUANSER QUBE-Servo
Wed, October 7 EE 460 Advanced Control and System Integration
• Let’s Develop a model of a DC servomotor in Simulink Motor with load
x
y
z
Symbol Value (units) Description
Rm 8.4 (Ohm) Armature resistance
Lm 0.85x10-3 (H) Armature inductance
Km 0.042 (V/(rad/s)) Back-EMF constant
Kt 0.042 (Nm/A) Torque constant
Jh (kg.m2) Load Hub Inertia (=0.0106, =0.0111)
Jd (kg.m2) Disk Inertia (=0.053, =0.0248)
Jm 4.0x10-6 (kg.m2) Rotor Inertia
Slide 2 of 10
An Intro. to SimulinkModeling the QUANSER QUBE-Servo
Wed, October 7 EE 460 Advanced Control and System Integration
• Build the Simulink Model Start MATLAB (run as admin) Open Simulink
o >> Simulink Create a Blank model
o New -> Simulink Model Select the Blocks from the
Library Browsero Continuous -> Transfer Fn
– Enter Numerator and Denominator coefficients» Lm and Rm
– Change name of block» Voltage to Currrent
o Add remaining blocks
+
-
( )aE s
( )mE s
( )aI s1
m mL s R
( )T s ( )s s
mK
K1
s
( )s1
J s B
Slide 3 of 10
An Intro. to SimulinkModeling the QUANSER QUBE-Servo
Wed, October 7 EE 460 Advanced Control and System Integration
• Define the values of the parameters in MATLAB Can use a *.m file Run the simulation
o Change modelsim params
You MUST run the *.m file first as it will define the model params used in the Simulink design!!
Slide 4 of 10
An Intro. to SimulinkComparing the Simulation with Real Hardware
Wed, October 7 EE 460 Advanced Control and System Integration
• Now let’s compare simulation with real hardware!! Change the input and output to ports
o Name the input port “Vin (V)”o Name the output port “w (rad/s)”
Create a subsystem from the model Add a “step” input
o Set the step time to 1 sec Set the simulation duration to “2” – i.e., two seconds
o Add a scope and check if it all works!!
Slide 5 of 10
%% Students MUST run these two lines code>> C:\Program Files\Quanser\QUARC\quarc\quarc_setup>> mex -setup:'C:\Program Files\MATLAB\2014B\bin\win64\mexopts\winsdk-7.1_c.xml' C
An Intro. to SimulinkComparing the Simulation with Real Hardware
Wed, October 7 EE 460 Advanced Control and System Integration
• Now add the QUARC blocks to communicate with the real-time hardware From the Simulink Library Browser Add:
1. QUARC Targets -> Data Acquisition -> Generic -> configuration– HIL Initialize» Double click on the icon and set Board Type: to qube_servo_usb
2. QUARC Targets -> Data Acquisition -> Generic -> Intermediate I/O– HIL Write Analog» Double click on the icon and select Board Name -> HIL-1
3. Set the Simulation Mode -> External
Slide 6 of 10
Wed, October 7 EE 460 Advanced Control and System Integration
• Now Build ( ), Connect to Target ( ), and Run ( )
The disc should now spin
Slide 7 of 10
An Intro. to SimulinkComparing the Simulation with Real Hardware
Wed, October 7 EE 460 Advanced Control and System Integration
• Now add blocks to read the motor’s speed and compare with simulation1. Add QUARC Targets -> Data Acquisition -> Generic ->
Timebaseso HIL Read Encoder Timebase
2. Add QUARC Targets -> Discontinuitieso Inverse Modulus
– Double click and enter Modulus: 2^16
3. Add a Gain block with Gain: 2*pi/512/44. Add a low-freq differentiator
o Transfer function: 200s/(s+200)
5. Add a 2:1 mux and then connect to a scope
(G
Slide 8 of 10
An Intro. to SimulinkComparing the Simulation with Real Hardware
Wed, October 7 EE 460 Advanced Control and System Integration
• As before: Now Build, Connect to Target, and Run
Slide 9 of 10
An Intro. to SimulinkComparing the Simulation with Real Hardware
Wed, October 7 EE 460 Advanced Control and System Integration
• Final Result
Slide 10 of 10