Control Tutorials for MATLAB and Simulink (2024)

Related Tutorial Links

  • Simulink Control Intro
  • Simulink/MATLAB Interaction
  • Control Activity

Related External Links

Contents

  • Extracting a linear model into MATLAB
  • Implementing PI control
  • Closed-loop response

In the Cruise Control: Simulink Modeling page we created a Simulink model of the cruise control system. You can recreate the model or download it by right-clicking here and selecting Save link as. In this section, we will show how to implement a feedback controller in Simulink to meet the performance specifications for the system.

Extracting a linear model into MATLAB

A linear model of the system (in state space or transfer function form) can be extracted from a Simulink model into MATLAB. This is done through the use of In1 and Out1 blocks and the MATLAB function linmod.

  • Replace the Step Block and Scope Block with an In1 and an Out1 block, respectively (these blocks can be found in the Ports & Subsystems library). This defines the input and output of the system for the extraction process.

Control Tutorials for MATLAB and Simulink (1)

Save your file as "ccmodel.slx" (select Save As from the File menu). MATLAB will extract the linear model from the saved model file, not from the open model window. At the MATLAB prompt, enter the following commands:

m = 1000;b = 50;u = 500;[A,B,C,D] = linmod('ccmodel')cruise_ss = ss(A,B,C,D);
A = -0.0500B = 1.0000e-03C = 1D = 0

To verify the model extraction, we will generate an open-loop step response of the extracted transfer function in MATLAB. We will multiply the numerator by 500 to simulate a step input of 500 N. Enter the following command in MATLAB.

step(u*cruise_ss)

Control Tutorials for MATLAB and Simulink (2)

Implementing PI control

In the Cruise Control: PID Control page a PI controller was designed with Control Tutorials for MATLAB and Simulink (3) and Control Tutorials for MATLAB and Simulink (4) to give the desired response. We will implement this in Simulink by first containing the open-loop system from earlier in this page in a Subsystem block.

  • Create a new model window.
  • Drag a Subsystem block from the Ports & Subsystems library into your new model window.

Control Tutorials for MATLAB and Simulink (5)

  • Double-click on this block. You will see a blank window representing the contents of the subsystem (which is currently empty).
  • Open your previously saved model of the cruise control system, ccmodel.slx.
  • Select Select All from the Edit menu (or Ctrl-A), and select Copy from the Edit menu (or Ctrl-C).
  • Select the blank subsystem window from your new model and select Paste from the Edit menu (or Ctrl-V). You should see your original system in this new subsystem window. Close this window.
  • You should now see input and output terminals on the Subsystem block. Name this block "plant model".

Control Tutorials for MATLAB and Simulink (6)

Now, we will build a PI controller around the plant model. First, we will feed back the plant output.

  • Draw a line extending from the plant output.
  • Insert a Sum block and assign "+-" to it's inputs.
  • Tap a line of the output line and draw it to the negative input of the Sum block.

Control Tutorials for MATLAB and Simulink (7)

The output of the Sum block will provide the error signal. From this, we will generate proportional and integral components.

  • Insert an Integrator block after the Sum block and connect them with a line.
  • Insert and connect a Gain block after the Integrator block to provide the integral gain.
  • Label this Integrator "Ki" and assign it a value of "Ki".
  • Insert a new Gain block and connect it with a line tapped off the output of the Sum block.
  • Label this gain "Kp" and assign it a value of "Kp".

Control Tutorials for MATLAB and Simulink (8)

Now we will add the proportional and integral components and apply the sum to the plant.

  • Insert a Sum block between the Ki block and the plant model and connect the outputs of the two Gain blocks to the Sum block inputs.
  • Connect the Sum block output to the input of the plant block.

Control Tutorials for MATLAB and Simulink (9)

Finally, we will apply a step input and view the output with a Scope block.

  • Attach a Step block to the free input of the feedback Sum block.
  • Attach a Scope block to the plant output.
  • Double-click the Step block and set the Step Time to "0" and the Final Value to "u". This allows the input magnitude to be changed outside of Simulink.

Control Tutorials for MATLAB and Simulink (10)

You can download our version of the closed-loop system model by right-clicking here and selecting Save link as.

In this example, we constructed a PI controller from fundamental blocks. As an alternative, we could have used a Transfer Function block (from the Continuous library) to implement this in one step, as shown below.

Control Tutorials for MATLAB and Simulink (11)

You can download this model by right-clicking here and selecting Save link as.

Closed-loop response

To simulate this system, first, an appropriate simulation time must be set. Select Parameters from the Simulation menu and enter "10" in the Stop Time field. The design requirements included a rise time of less than 5 sec, so we simulate for 10 seconds to view the output. The physical parameters must now be set. Run the following commands at the MATLAB prompt:

m = 1000;b = 50;r = 10;Kp = 800;Ki = 40;

Run the simulation (hit Ctrl-T or select Run from the Simulation menu). When the simulation is finished, you should see the following output.

Control Tutorials for MATLAB and Simulink (12)


Published with MATLAB® 9.2

Control Tutorials for MATLAB and Simulink (2024)

References

Top Articles
Starfield: Komplettlösung & Guides mit Tipps
Amsterdam Food Favorites: 14 Must Eat Dishes
Varsity Competition Results 2022
Fiat 600e: Dolce Vita auf elektrisch
William G. Nolan - Baker Swan Funeral Home
Inside Watchland: The Franck Muller Watch Manufacturing Facilities | aBlogtoWatch
Tc-656 Utah
Double Helicath Clan Boss
Michigan Lottery Predictions For Today
Review: Chained Echoes (Switch) - One Of The Very Best RPGs Of The Year
Phun.celeb
Friscolawnmowing
Bg3 Fake Portrait Of A Noble Before His Death
Barber King Bargain Shop Tulsa Photos
Humidity Yesterday At My Location
Nsu Kpcom Student Handbook
Crystal Lust Wiki
Seattle Rub Rating
Juliewiththecake Wiki / Biography - Age, Boyfriend, Height, Net Worth - WikiBravo
Comcast Business Sign In
Smith And Wesson Nra Instructor Discount
Animal Eye Clinic Huntersville Nc
Interview With Marc Rheinard (Team ToniSport & Awesomatix) From Germany
Hdmovie 2
Genova Nail Spa Pearland Photos
Journal articles: 'Mark P. Herschede Trust' – Grafiati
That Is No Sword X Kakushi By Nez_R
2024-25 ITH Season Preview: USC Trojans
Noel Berry's Biography: Age, Height, Boyfriend, Family, Net Worth
ONE PAN BROCCOLI CASHEW CHICKEN
Kagtwt
Meet Kristine Saryan, Scott Patterson’s Wife
715 Henry Ave
Dimbleby Funeral Home
247 Transfer Portal Rankings Basketball
Savannah Schultz Leaked
Active Dispatch Calls Escambia County
Alloyed Trident Spear
Sound Of Freedom Showtimes Near Cinergy Midland
Busty Bruce Lee
https://www.hulu.com/series/amish-haunting-96e9c592-7006-47d6-bb8f-265e9ef174ec
Elaina Scotto Wedding
Clarksburg Wv Craigslist Personals
Traftarım 24
Press-Citizen Obituaries
Mere Hint Crossword
Ups First And Nees
Top 10 websites to play unblocked games
How To Evolve Nincada Into Shedinja
Realidades 2 Capitulo 2B Answers
I Got Hoes Might Just Be You N
O'reilly's Covington Tennessee
Latest Posts
Article information

Author: Virgilio Hermann JD

Last Updated:

Views: 5587

Rating: 4 / 5 (61 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Virgilio Hermann JD

Birthday: 1997-12-21

Address: 6946 Schoen Cove, Sipesshire, MO 55944

Phone: +3763365785260

Job: Accounting Engineer

Hobby: Web surfing, Rafting, Dowsing, Stand-up comedy, Ghost hunting, Swimming, Amateur radio

Introduction: My name is Virgilio Hermann JD, I am a fine, gifted, beautiful, encouraging, kind, talented, zealous person who loves writing and wants to share my knowledge and understanding with you.