Control Tutorials for MATLAB and Simulink (2024)

Control Tutorials for MATLAB and Simulink (1)

Key Topics: Frequency Response Analysis, System Identification, Nonlinear Systems, Pulse-Width Modulation, Bode Plots

Contents

  • Equipment needed
  • Purpose
  • Frequency response experiment
  • Extensions

Equipment needed

  • Arduino microprocessor (e.g. Uno, Mega, etc.)
  • Breadboard
  • Battery (AA for example)
  • Electronic components (inductor, resistor, capacitor)
  • Diode
  • Transistor (MOSFET)
  • Jumper wires

The system we will be employing in this activity is a type of DC/DC converter called a Boost (Step-Up) Converter. The purpose of a boost converter is to take the voltage supplied by a constant voltage source (e.g. a battery) and output an (approximately) constant higher output voltage. Details regarding the principle of operation of a boost converter can be found in Part (a) of this activity. We will implement a couple of very simple (not optimized) versions of a boost converter in order to illustrate how to experimentally determine the frequency response of a system. In this part of the activity, the Arduino board will be used for measuring the output of the circuit via one of the board's Analog Inputs and for controlling the level of the output voltage via one of the board's Digital Outputs. The Arduino board will also communicate the recorded data to Simulink for visualization and analysis.

A schematic of the boost circuit we will analyze in this section is shown below including a list of the variables we will employ.

(Rload) resistance of the load resistor
(Req) equivalent series resistance (ESR) of the inductor
(L) inductance of the inductor
(C) capacitance of capacitor
(ei) input voltage (from the battery)
(eo) output voltage

Control Tutorials for MATLAB and Simulink (2)

Purpose

The purpose of this activity is to build further intuition regarding the operation of a boost converter circuit. Specifically, in this part of the activity we will model the circuit based on experimentally obtained frequency response data. This technique provides intuition regarding frequency response analysis and demonstrates a blackbox approach for generating an approximate (local) model of a nonlinear system.

Frequency response experiment

Referring to the analysis of Part (a) of this activity, we demonstrated that the output voltage of the boost circuit chatters up and down as the transistor (MOSFET) is switched on and off as shown in the following. The output, however, can approximate a constant (DC) voltage by employing a very high switching frequency and by including a capacitor to "filter" the ripple.

Control Tutorials for MATLAB and Simulink (3)

One of the challenges of designing a controller for a DC/DC converter is that the plant model is inherently nonlinear due to the switching between the two discrete states of the circuit. One solution to this challenge is to generate a linear model that averages the ON and OFF states of the boost converter in order to approximate the true nonlinear behavior of the circuit. This approach is appropriate when the switching frequency is sufficiently high such that the chatter in the output voltage is small and can be well approximated by a single continuous model. In practice, the averaged model removes the switch and employs an equivalent inductance in place of the true inductance. Often the equivalent inductance is modeled in terms of the duty cycle Control Tutorials for MATLAB and Simulink (4) as Control Tutorials for MATLAB and Simulink (5). If the converter operates in a small range of duty cycles, then employing a constant Control Tutorials for MATLAB and Simulink (6) in the model is appropriate.

Below is shown a depiction of an averaged boost converter model. Here we have neglected the equivalent series resistance for the inductor since in practice it is often negligible in comparison to other effects. Often a resistance Control Tutorials for MATLAB and Simulink (7) is included in series with the capacitor to better model the impedance of the capacitor for high frequency switching inputs, though we have not done so here.

Control Tutorials for MATLAB and Simulink (8)

So far we have analyzed the boost converter for an input of Control Tutorials for MATLAB and Simulink (9) and an output of Control Tutorials for MATLAB and Simulink (10). In practice, our control input to the converter is actually the duty cycle, that is, the percent of time the converter switch is on. With this in mind, we can generate the following linearized model of the averaged boost converter shown above. This transfer function has for its input the deviation Control Tutorials for MATLAB and Simulink (11) of the current duty cycle Control Tutorials for MATLAB and Simulink (12) from some nominal duty cycle Control Tutorials for MATLAB and Simulink (13), that is, Control Tutorials for MATLAB and Simulink (14). Similarly, the output is the deviation Control Tutorials for MATLAB and Simulink (15) of the output voltage Control Tutorials for MATLAB and Simulink (16) from the nominal output voltage Control Tutorials for MATLAB and Simulink (17) that corresponds to the nominal duty cycle Control Tutorials for MATLAB and Simulink (18), that is, Control Tutorials for MATLAB and Simulink (19).

(1)Control Tutorials for MATLAB and Simulink (20)

The above model is helpful in providing some insight into the behavior of the boost converter. Specifically, we can see the system has two poles due to the LC filter inherent in the circuit. Also interesting is that the model has a non-minimum phase zero. The behavior of a non-minimum phase system such as this is characterized by the fact that its response to a step input initially moves in a direction opposite of the commanded direction. In this case, this means that an increase in duty cycle will initially cause the output voltage to drop before beginning to increase toward its ultimate steady-state value. The intuition behind this behavior is as follows. An increase in duty cycle means that the circuit is in its ON state for a longer period of time. In the ON state, the current from the battery will flow through the switch and the load is in essence disconnected from the battery for a longer period of time. Therefore, the output voltage will initially drop. This increased ON time also, however, causes the current through the inductor to rise. This increase in current through the inductor eventually leads to an increase in output voltage.

Despite the intuition provided by the model given above, its accuracy may be limited. For example, inaccuracies in the model could be due to failing to capture the non-ideal nature of the circuit components, as well as failing to capture the dynamics of the channels of the Arduino board which are inherently part of our closed-loop system. One solution is to generate a blackbox model of the boost converter based on empirical data. Specifically, a common industrial practice is to experimentally generate a frequency response model of the boost converter. We will do that here by experimentally generating a Bode plot of the boost converter's frequency response.

Hardware setup

Our hardware setup will be exactly the same as that employed in Part (a) of this activity, except we will use different value components for the capacitor and the load in order to make the boost circuit respond faster. Specifically, we will employ a 1200 Control Tutorials for MATLAB and Simulink (21) capacitor and a 1000 Control Tutorials for MATLAB and Simulink (22) resistor for the load. Furthermore, we will still use a Digital Output of the Arduino board to switch our transistor, but in this case we will use a hardware-generated PWM signal. Only those Digital Outputs marked by the ~ symbol can generate such a PWM signal. The frequency of the hardware-generated PWM is constant and much faster than what we can achieve in software with Simulink. Most pins generate a PWM signal with an approximate frequency of 490 Hz. On the Arduino Uno and some similar boards, pins 5 and 6 generate a PWM signal with a higher frequency of 980 Hz.

Control Tutorials for MATLAB and Simulink (23)

Looking at the theoretical linear averaged boost converter model given above with denominator Control Tutorials for MATLAB and Simulink (24), we expect the system to have a natural frequency of Control Tutorials for MATLAB and Simulink (25). For our circuit components and a 1.5-Volt battery with nominal duty cycle of 0.39, we expect that the natural frequency of the boost converter to be around 17.6 rad/sec (Control Tutorials for MATLAB and Simulink (26) 2.80 Hz). Since we expect the magnitude of the boost converter to begin to roll off around this frequency (it will begin to attenuate inputs with frequencies above this threshold), the hardware-generated PWM signal should be sufficiently fast. In other words, since 490 Hz is more than two decades larger than 2.80 Hz, the boost circuit should in essence filter the square wave input resulting in a relatively smooth output voltage.

Software setup

Our Simulink model for performing this frequency response experiment will be similar to our model from Part (a) of this activity. In order to trigger the hardware generated output, we will replace the Digital Write block with the Analog Write block from the IO package. For details on how to use the IO package, refer to the following link. The name of the Analog Write block is a bit of a misnomer since the output is still digital, but the block does generate the PWM signal we desire. The desired duty cycle is specified as an 8-bit number. Since Control Tutorials for MATLAB and Simulink (27), the block accepts inputs between 0 and 255 where 0 corresponds to a Control Tutorials for MATLAB and Simulink (28) duty cycle and 255 corresponds to a Control Tutorials for MATLAB and Simulink (29) duty cycle. We will continue to use Pin 9 for our digital output. We will also replace the Pulse Generator block with a Sine Wave block from the Sources library since frequency response data is generated from the system's response to sinusoidal inputs over a range of frequencies. For the Sine Wave block, we will continue to employ a Sample time of Ts that has been set to 0.01 seconds. Furthermore, we will set the Bias to "100" and the Amplitude to "40". Therefore, the Sine Wave block will generate a sinusoid that varies between 60 and 140, which corresponds to the duty cycle varying between approximately Control Tutorials for MATLAB and Simulink (30) and Control Tutorials for MATLAB and Simulink (31). The frequency of the Sine Wave will be varied throughout the experiment. A depiction of the modified Simulink model is shown below and can be downloaded here.

Control Tutorials for MATLAB and Simulink (32)

It can be a little difficult to envision the physical input to our system. The following figure may help by illustrating how the duty cycle is changing sinusoidally. The input signal is still the digital PWM signal, but the percent of time the PWM signal is "ON" is changing smoothly.

Control Tutorials for MATLAB and Simulink (33)

Bode plot generation

With frequency response analysis we are interested in examining how a system responds to different frequency sinusoidal inputs. For linear (or locally linear) systems, we know that in steady state a sinusoidal input will generate a sinusoidal output of the same frequency, but with possibly different amplitude and phase. It is this scaling of the amplitude and time shifting that we are interested in. We will experimentally determine this scaling (magnitude) and phase information, then we will represent the information in the form of a Bode plot.

Setting the frequency of the Sine Wave in our Simulink model to Control Tutorials for MATLAB and Simulink (34) rad/sec (1 Hz) and running the model, we generate the following output voltage response demonstrating how our 1.6-Volt battery input can be stepped to a higher voltage depending on the control of the transistor switching.

Control Tutorials for MATLAB and Simulink (35)

Examining the above, we can see that there is an initial transient due to the natural response of the circuit, but once that dies out, the steady-state response exhibits the sinusoidal response we expected. Assuming that the To Workspace blocks in our Simulink model are set to have Array outputs, the following MATLAB commands will plot the steady-state voltage output (starting at 3 seconds) on the same set of axes as the duty cycle input, thereby demonstrating the resultant scaling and shifting of the output.

 [AX,H1,H2] = plotyy(3:0.01:10,eo(301:1001),3:0.01:10,dc(301:1001),'plot'); xlabel('time (sec)') set(get(AX(1),'Ylabel'),'String','output voltage (Volts)') set(get(AX(2),'Ylabel'),'String','duty cycle') title('Boost Circuit Frequency Response (freq = 1 Hz)') 

Control Tutorials for MATLAB and Simulink (36)

From the recorded data shown above, we can calculate the magnitude and phase response of our boost converter at this frequency, Control Tutorials for MATLAB and Simulink (37) rad/sec. First we will estimate the magnitude. We know that the input duty cycle sinusoid has an amplitude of 40/255 Control Tutorials for MATLAB and Simulink (38) 0.16. From inspection of the output voltage data, the difference between a peak and the valley that immediately succeeds it is on average approximately 0.66 Volts which corresponds to an amplitude of 0.66/2 = 0.33 Volts. We use only successive peaks and valleys for determining amplitude because the bias in the output can drift. Based on these two observations, the magnitude of the boost converter at this frequency is 0.33/0.16 Control Tutorials for MATLAB and Simulink (39) 2.06. When converted to decibels, the magnitude at this frequency is 20 Control Tutorials for MATLAB and Simulink (40) 2.06 Control Tutorials for MATLAB and Simulink (41) 6.28 dB. Next we will estimate the phase. From inspection of the above, we can see that the output lags behind the input (as expected). Comparing a peak of our input duty cycle signal to the peak of the output voltage signal that immediately follows it, we can see that the output signal is shifted by on average 0.16 seconds (note that the frequencies of the input and the output are equal (1 Hz)). Since the period of our signals are 1 second, that means our output lags behind the input by about Control Tutorials for MATLAB and Simulink (42) of a cycle, where one cycle corresponds to 360 degrees (Control Tutorials for MATLAB and Simulink (43) of 360 degrees Control Tutorials for MATLAB and Simulink (44) 58 degrees). Also, we use the convention that the phase is negative when the output lags behind the input. Calculating the phase in a different manner, we can multiply the time lag by the frequency. Therefore, the phase lag is -0.16 seconds Control Tutorials for MATLAB and Simulink (45) radians/second, which is approximately -1.0 radians. Converting to degrees, we again have that the phase is approximately -58 degrees.

These calculations provide the frequency response of our boost converter at one frequency. If we repeat this process over a range of frequencies, we can experimentally create a Bode plot for our boost converter (for this set of conditions). Below is given a table of calculated magnitude and phase values for our boost circuit. This data is generated for a slightly different set-up than we have used so far, but the results are very similar to what would be generated for the original set-up. Specifically, the load resistor, capacitor, and inductor are unchanged, but we employed a different transistor and diode, and used a pin with the 980 Hz PWM signal. The transistor employed was an IRFZ44N Power MOSFET and the diode was an NTE585 Schottky diode. These components provide higher performance, but aren't really necessary for the level of power and PWM frequencies we are employing.

Frequency (Hz)0.010.050.10.20.250.512.55
Frequency (rad/sec)0.06280.3140.6281.261.573.146.2815.731.4
Magnitude (dB)9.529.359.069.168.967.446.15-0.28-9.83
Phase (degree)-0.36-0.00-0.36-5.76-9.0-28.8-75.6-90.0-162

This data can then be compiled in the form of a Bode plot by executing the following commands at the MATLAB command line.

freq = [0.0628 0.314 0.628 1.26 1.57 3.14 6.28 15.7 31.4];mag = [9.52 9.35 9.06 9.16 8.96 7.44 6.16 -0.28 -9.83];phase = [-0.36 0 -0.36 -5.76 -9 -28.8 -75.6 -90.0 -162];subplot(2,1,1);semilogx(freq,mag,'*')grid onxlabel('frequency (rad/sec)')ylabel('magnitude (dB)')title('Boost Converter Empirical Bode Diagram')subplot(2,1,2);semilogx(freq,phase,'*')grid onxlabel('frequency (rad/sec)')ylabel('phase (deg)')

Control Tutorials for MATLAB and Simulink (46)

Examining the above Bode diagram, the frequency response of the circuit doesn't exactly agree with the theoretical linear averaged model given at the beginning of this section, but it does exhibit the same character. Specifically, the empirically-derived Bode diagram reflects a type 0 system with two poles, though the DC gain and the location of the poles are somewhat different than predicted by the theoretical linear averaged model. The system is type 0 because the magnitude plot is flat at low frequencies and the phase approaches 0 degrees at low frequencies. The presence of the two poles is indicated by the magnitude plot rolling off at a slope of approximately -40 dB/decade (and the phase appears headed towards -180 degrees). The contribution of the non-minimum phase zero cannot be seen because it is thought that its break frequency (around 160 rad/sec) is beyond the frequency band in which we can clearly identify the boost converter's response. This non-minimum phase zero would in theory add another 90 degrees of phase lag at high frequencies.

It is typical that the high-frequency behavior of a system is difficult to identify experimentally. This arises due to a couple of issues that can be illustrated by our physical experiment. One issue is that for physical systems the output tends to get attenuated at high frequencies. The following figure shows the 5 Hz data from our experiment which was the highest frequency we attempted to identify. At this frequency, we can already see that the amplitude of the output is getting quite small. As the amplitude becomes small, the various sources of error can become quite large as a percentage of the signal amplitude. For example, you can see that the quantization due to our analog-to-digital conversion is already significant and will become more so at even higher frequencies. The other issue is that at high frequencies the period of one cycle becomes quite small. Therefore, any errors in timing become a larger percentage of a single cycle. Again examining the following figure, one can see that the number of samples we are able to take per cycle is getting smaller (at 5 Hz, can sample about 20 times per cycle at most).

Control Tutorials for MATLAB and Simulink (47)

Even though the accuracy of our model is lacking at higher frequencies, it is often okay because we wouldn't wish to operate our boost converter in that frequency band anyway. It is, however, imperative that we understand what range of frequencies of input commands we can achieve for our given system.

Extensions

Some extensions to this activity would be to experiment with different circuit components to see what kind of performance can be achieved. It could also be interesting to examine other types of DC/DC converters, such as the buck converter and the buck-boost converter. In Part (c) of this activity, we will design and implement a controller for maintaining the output voltage of the boost converter we examined here.


Published with MATLAB® 8.2

Control Tutorials for MATLAB and Simulink (2024)

FAQs

How do I find answers in MATLAB? ›

To view all of your solutions, go to a Problem page and click View my solutions. You can view your solutions in a list or in the Solution Map. If using the list view, you can review the display by selecting a Sort by option.

Is MATLAB Simulink hard to learn? ›

MATLAB is designed for the way you think and the work you do, so learning is accessible whether you are a novice or an expert. The Help Center is always available to guide you with robust documentation, community answers, and how-to videos. Additionally, online interactive training is a great way to get started.

How much time is required to learn MATLAB? ›

If you're a novice programmer, you can expect it to take a little longer than if you were a more seasoned programmer. Someone who can afford to devote all their time to MATLAB can finish learning the language in two weeks. If you have a lot of other responsibilities, however, it will take you longer to complete.

How to pass structure to Simulink? ›

To connect the structure input or output in a MATLAB function with Simulink, you must define a Simulink. Bus object in the base workspace. Then use this bus object as signal datra type for the signals which are to be connected to Matlab function.

How do you get a long answer in MATLAB? ›

To format the way numbers display, do one of the following:
  1. On the Home tab, in the Environment section, click Preferences. Select MATLAB > Command Window, and then choose a Numeric format option.
  2. Use the format function, for example: format short format short e format long.

How do I find Solver in MATLAB? ›

Description. S = solve( eqn , var ) solves the equation eqn for the variable var . If you do not specify var , the symvar function determines the variable to solve for. For example, solve(x + 1 == 2, x) solves the equation x + 1 = 2 for x.

Is MATLAB harder than Python? ›

The Difference in Technical Computing:

They are both used for the same type of work, such as numerical analysis, data visualization, and scientific computation. When it comes to syntax and readability, Python is often easier to read and understand than MATLAB.

What is the salary of MATLAB Simulink? ›

Average Annual Salary by Experience

Matlab Developer salary in India with less than 1 year of experience to 5 years ranges from ₹ 2.0 Lakhs to ₹ 9.4 Lakhs with an average annual salary of ₹ 5.6 Lakhs based on 342 latest salaries.

Is MATLAB enough for a job? ›

Conclusion. The industry has some familiar buzz that learning MATLAB will not be a good opportunity for a better career. But this is not fully true. Yes, it is an acceptable reason that salary or company structure will never be able to touch available popular jobs on other programming technologies.

Is MATLAB in high demand? ›

Matlab careers are actually on the rise today. It's a very popular programming language. It can be used by a developer, engineer, programmer, scientist, etc. to collect and sort out data, and develop apps, software, and sites.

Can I learn MATLAB in 1 month? ›

If you want to become an expert in Matlab then you need to mention which part of madlab you want to learn and want expertise. If I generalize my answer highly, It may take at least 3 months to learn matlab and may take maximum 3 years to become an expert.

How to run Simulink step by step? ›

In the Simulink Toolstrip, on the Simulation tab, click Step Forward to start a simulation of the model vdp . The simulation starts and pauses just after calculating the output values for the first simulation time and before stepping to the next simulation time.

How to generate code from Simulink? ›

To generate code, you must make the following changes: In the Modeling tab of the model toolstrip, click Model Settings. The Configuration Parameters dialog opens. Navigate to the Code Generation tab, select the Generate code only parameter, and click Apply.

How to check results in MATLAB? ›

View Results in Command Window

The Summary Report link provides access to the Model Advisor Command-Line Summary report. You can review additional results in the Command Window by calling the DisplayResults parameter when you run the Model Advisor.

How do you find the step response in MATLAB? ›

[ y , tOut ] = step( sys , tFinal ) computes the step response from t = 0 to the end time t = tFinal . [ y , tOut ] = step( sys , t ) returns the step response of a dynamic system model sys at the times specified in the vector t .

How do I find something in MATLAB code? ›

Search Using Find Dialog Box

The Find dialog box opens. The search begins at the current cursor position. MATLAB finds the text you specified and highlights it. MATLAB beeps when a search for Find Next reaches the end of the Command Window, or when a search for Find Previous reaches the top of the Command Window.

What is the ANS command in MATLAB? ›

ans is the variable created when an output is returned without a specified output argument. MATLAB® creates the ans variable and stores the output there. Changing or using the value of ans in a script or function is not recommended, as the value can change frequently. ans is specific to the current workspace.

Top Articles
Lake-Nyos-Katastrophe
How did Lake Nyos suddenly kill 1,700 people?
FPL tips and team of the week: Eze, Fernandes and Mateta should shine this week
Best Pre Med Schools U.s. News
Goodall Brazier hiring Vice President in Arizona, United States | LinkedIn
The Ultimate Guide To Jelly Bean Brain Leaks: Causes, Symptoms, And Solutions
Keck Healthstream
Craigsist Houston
An Honest Review of Accor Live Limitless (ALL) Loyalty Program
Amc Theatres Website
Who is Ariana Grande? Everything You Need to Know
Plan the Ultimate Trip to Lexington, Kentucky
Wsisd Calendar
Huniepop Jessie Questions And Answers
Does the MLB allow gambling? Here's what to know about League Rule 21
Food Universe Near Me Circular
Demystifying the C-Suite: A Close Look at the Top Executive Roles - 33rd Square
Fingerfang Rock Conan
Jennette Mccurdy Cameltoe
Lehigh Valley Ironpigs Score
Post Crescent Obituary
Alvin Isd Ixl
Thermal Pants Mens Walmart
Bfri Forum
Aldine Isd Pay Scale 23-24
Appraisalport Com Dashboard /# Orders
Check Subdomains Of A Domain
That Is No Sword X Kakushi By Nez_R
Usc Human Biology
Hingham Police Scanner Wicked Local
Bolly2Tolly Sale
Lux Nails Columbia Mo
O'reilly's Los Banos
Dr Yakubu Riverview
Nikki Porsche Girl Head
Managementassistent directie Wonen
JetBlue, Spirit end $3.8 billion merger agreement after losing antitrust suit
Finastra Gfx
Tires Shop Santoyo
Ella And David Steve Strange
Make An Appointment Att
Sirius Satellite Radio Sports Schedule
Hypebeast Muckrack
Tamu Registration Worksheet
Under One Shining Stone Another Lies
Jane Powell, Spirited Star of Movie Musicals ‘Royal Wedding,’ ‘Seven Brides,’ Dies at 92
Wyoming Roads Cameras
Commissary Exchange Benefits What You Need To Know Aafes To Offer Service To Former Military
4215 Tapper Rd Norton Oh 44203
Sharon Sagona Obituary
Cloud Cannabis Grand Rapids Downtown Dispensary Reviews
Chase Bank Time Hours
Latest Posts
Article information

Author: Domingo Moore

Last Updated:

Views: 5291

Rating: 4.2 / 5 (73 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Domingo Moore

Birthday: 1997-05-20

Address: 6485 Kohler Route, Antonioton, VT 77375-0299

Phone: +3213869077934

Job: Sales Analyst

Hobby: Kayaking, Roller skating, Cabaret, Rugby, Homebrewing, Creative writing, amateur radio

Introduction: My name is Domingo Moore, I am a attractive, gorgeous, funny, jolly, spotless, nice, fantastic person who loves writing and wants to share my knowledge and understanding with you.