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
Best Dribble Moves In NBA 2K21 [Complete Guide]
Best Pizza In Massena
Maxtrack Live
Truist Park Section 135
Costco The Dalles Or
Kristine Leahy Spouse
Weapons Storehouse Nyt Crossword
Xrarse
Minn Kota Paws
Snarky Tea Net Worth 2022
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Myql Loan Login
10 Great Things You Might Know Troy McClure From | Topless Robot
Signs Of a Troubled TIPM
C Spire Express Pay
Ivegore Machete Mutolation
10 Best Places to Go and Things to Know for a Trip to the Hickory M...
Summer Rae Boyfriend Love Island – Just Speak News
Who called you from 6466062860 (+16466062860) ?
Straight Talk Phones With 7 Inch Screen
Check From Po Box 1111 Charlotte Nc 28201
Sport-News heute – Schweiz & International | aktuell im Ticker
Commodore Beach Club Live Cam
Rondom Ajax: ME grijpt in tijdens protest Ajax-fans bij hoofdbureau politie
Www.publicsurplus.com Motor Pool
Pjs Obits
All Obituaries | Verkuilen-Van Deurzen Family Funeral Home | Little Chute WI funeral home and cremation
Kabob-House-Spokane Photos
Lacey Costco Gas Price
UCLA Study Abroad | International Education Office
Buhl Park Summer Concert Series 2023 Schedule
Motor Mounts
Broken Gphone X Tarkov
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Chapaeva Age
Leland Nc Craigslist
Consume Oakbrook Terrace Menu
#1 | Rottweiler Puppies For Sale In New York | Uptown
Go Upstate Mugshots Gaffney Sc
Laff Tv Passport
Craigslist Florida Trucks
Lucyave Boutique Reviews
Sour OG is a chill recreational strain -- just have healthy snacks nearby (cannabis review)
Stitch And Angel Tattoo Black And White
The Average Amount of Calories in a Poke Bowl | Grubby's Poke
Displacer Cub – 5th Edition SRD
Abigail Cordova Murder
Heat Wave and Summer Temperature Data for Oklahoma City, Oklahoma
BYU Football: Instant Observations From Blowout Win At Wyoming
Download Twitter Video (X), Photo, GIF - Twitter Downloader
Invitation Quinceanera Espanol
Guidance | GreenStar™ 3 2630 Display
Latest Posts
Article information

Author: Moshe Kshlerin

Last Updated:

Views: 5342

Rating: 4.7 / 5 (57 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Moshe Kshlerin

Birthday: 1994-01-25

Address: Suite 609 315 Lupita Unions, Ronnieburgh, MI 62697

Phone: +2424755286529

Job: District Education Designer

Hobby: Yoga, Gunsmithing, Singing, 3D printing, Nordic skating, Soapmaking, Juggling

Introduction: My name is Moshe Kshlerin, I am a gleaming, attractive, outstanding, pleasant, delightful, outstanding, famous person who loves writing and wants to share my knowledge and understanding with you.