4 Ways to Implement a Transfer Function in Code | Control Systems in Practice

  Рет қаралды 63,025

MATLAB

MATLAB

Күн бұрын

Check out the other videos in the series:
Part 1 - What Does a Controls Engineer Do? • What Control Systems E...
Part 2 - What Is Gain Scheduling? • What Is Gain Schedulin...
Part 3 - What Is Feedforward Control? • What Is Feedforward Co...
Part 4 - Why Time Delay Matters • Why Time Delay Matters...
Part 5 - A Better Way to Think About a Notch Filter • A Better Way to Think ...
Part 6 - What are Non-Minimum Phase Systems? • What Are Non-Minimum P...
In some situations, it is easier to design a controller or a filter using continuous, s-domain transfer functions. We have a lot of mathematical tools that make analyzing and manipulating them easier than, say, their equivalent time-domain differential equations. However, while we like to work with transfer functions for design and analysis, it’s often the case that we need to implement them in software that runs on some processor or microcontroller, and it might not be obvious how to go about doing this. So, in this video we’ll cover four simple ways to implement a transfer function in code.
Check out these other links:
- Download the code from the video, tfcodemethods.mlx: github.com/aerojunkie/control...
- A playlist on discrete control. It describes how we go from the s-domain to the z-domain and the 5th video specifically describes why the Tustin method is equivalent to trapezoidal integration: • Discrete Control
- Introduction to State Space: • Introduction to State-...
- Introduction to Embedded Coder: bit.ly/37KYGsh
--------------------------------------------------------------------------------------------------------
Get a free product trial: goo.gl/ZHFb5u
Learn more about MATLAB: goo.gl/8QV7ZZ
Learn more about Simulink: goo.gl/nqnbLe
See what's new in MATLAB and Simulink: goo.gl/pgGtod
© 2019 The MathWorks, Inc. MATLAB and Simulink are registered
trademarks of The MathWorks, Inc.
See www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders.

Пікірлер: 44
@varunmamtani2324
@varunmamtani2324 3 жыл бұрын
Easily the best tutorials I have found on the internet of anything really. Great work!
@user-qp4gs4ky8h
@user-qp4gs4ky8h 3 жыл бұрын
A wonderful explanation! Thank you very much!
@WolfixDwell
@WolfixDwell Жыл бұрын
Thank you for putting out nicely structured knowledge for everyone to grab and understand. Helped me with work-related thing.
@mnada72
@mnada72 3 жыл бұрын
I am a big fan of you Brian I come here after watching all the videos on your channel . I think your channel and followed by your videos here are a great reference for studying control What text book you recommend for studying control and a road map for how to be confident of control like you. My respect for your contribution to control engineering community.
@Debraj1978
@Debraj1978 2 жыл бұрын
Though state space implementation may seem better, since it uses just one integration per iteration, but while implementing the code on embedded controller "C" code, you will have to do matrix multiplication, which will take many cycles. In my opinion, converting to "z" transform is the best and most popular method.
@MrLeocars97
@MrLeocars97 Жыл бұрын
Indeed. However, matrix manipulation can be made easy if you are able to port Eigen (C matrix library) into your hardware ;)
@StefanBrock_PL
@StefanBrock_PL 4 жыл бұрын
Very clear presentation. Thanks. IMHO this are 3 metods and 1 trick.
@entropyz5242
@entropyz5242 4 жыл бұрын
Hello Brian, I just wanted to say that your videos have helped me so much in my control systems classes. I started watching your videos in my Linear Controls Systems I class at USC with Dr. Henryk Flashner; I just recently discovered that you attended this university as well. Watching your videos has given me a different perspective on control theory that has helped me comprehend it very well. You are truly and inspiration to me and to many of my classmates in the control systems field. Thank you so much for sharing your knowledge 🙏
@BrianBDouglas
@BrianBDouglas 4 жыл бұрын
Erick Zamora I took a few classes with Dr. Flashner! Thanks for the kind comment. Best of luck with everything!
@xursssulaxx
@xursssulaxx Жыл бұрын
thank you so much for these videos showing the matlab code. super helpful
@Amine-gz7gq
@Amine-gz7gq Ай бұрын
No one teaches control theory better than Brian Douglas
@kameelamareen
@kameelamareen 4 жыл бұрын
Cant thank you enough man !
@felixruiztorrez5192
@felixruiztorrez5192 3 жыл бұрын
Super video! Thank you!
@peter_jpw
@peter_jpw 2 жыл бұрын
I'd suggest as a default initializing previous-step signals to their current measured values. If someone is implementing a compensator or a filter, this would give the expected behavior, vs. initializing to zero which may give "spikes" or "jumps" upon startup.
@vihangpathak9759
@vihangpathak9759 4 жыл бұрын
Thank you so much Brian
@MrLeocars97
@MrLeocars97 4 жыл бұрын
Amazing! Thank you Brain!
@Tupiniviking_de_osasco
@Tupiniviking_de_osasco 4 жыл бұрын
Amazing as always! One question: what tools do you use to make your videos?
@vespulavulgaris8069
@vespulavulgaris8069 3 жыл бұрын
Thank you so much!
@babakkhaleghiborna7027
@babakkhaleghiborna7027 Жыл бұрын
You are brilliant, thanks a lot 🙏 🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏
@Supreme0084
@Supreme0084 4 жыл бұрын
Could you please make a video about the Nichols Chart and how to use it in designing phase lead/lag controllers.
@gastonmelo6473
@gastonmelo6473 4 жыл бұрын
Clear as cristal
@nitinkmaurya
@nitinkmaurya Жыл бұрын
Crystal*
@mehmetkilic9518
@mehmetkilic9518 4 жыл бұрын
Will you add also State-space discretization as an extra method?
@JKTCGMV13
@JKTCGMV13 4 жыл бұрын
Another episode! Writing the code is one thing that confused me the most.
@keithfife2355
@keithfife2355 10 ай бұрын
All of these methods essentially numerically solve the resulting ODE from the transfer function, what is the feasibility or other practical considerations for using a running convolution with a stored step response? Of course since a stored step response is necessarily finite in length it would only actually perform FIR filtering, but they can be made arbitrarily close to IIR filters.
@user-os7kc3gv3z
@user-os7kc3gv3z 9 ай бұрын
Hi Brian, quick question. How did coefficient in denominator of discretized function with z^-1 member switched from 1.99 to 1.9899 when code was written
@JamesTJoseph
@JamesTJoseph Жыл бұрын
I am trying it in Julia ☺️
@kebabsharif9627
@kebabsharif9627 2 жыл бұрын
What if the input signal in a Sawtooth form and the TF has and derivative componet i mean a zero in the origin ?
@blazepascal1878
@blazepascal1878 2 жыл бұрын
What would be the changes to this process if the system was MISO?
@gpcm
@gpcm 4 жыл бұрын
I wish I could like this video twice
@steeltitan8683
@steeltitan8683 2 жыл бұрын
You can do that actually! iykwim :D
@fernando.liozzi.41878
@fernando.liozzi.41878 4 жыл бұрын
Hi, thanks!, ydd=ud+2u-yd-(2)y. Is it possible that you forgot 2 in 5:39? Regards.
@BrianBDouglas
@BrianBDouglas 4 жыл бұрын
Fernando Liozzi yep, great catch. I can’t believe I left that off. Thanks for letting me know.
@saidburakguzel
@saidburakguzel 4 жыл бұрын
what if we have a higher than 2nd order transfer function? Also, how we can use the code that matlab generate, i couldn't find any input and output setion, its so complicated code, can you provide information or a link about this, thank you for your great video!!
@BrianBDouglas
@BrianBDouglas 4 жыл бұрын
The process is the same for higher than 2nd order transfer functions. You just will have to initialize more states at the beginning. For the state space method (easiest to explain), your state vector would have more elements in it but the code would still just have that single integrator. The auto code is complicated because there is a lot more going on than just the transfer function code. There is all of the stuff that runs the simulation and execution part of it as well (steps, timers, memory allocation, etc.). I don't have the code in front of me right now, but if you look through the file you should be able to find the portion where the transfer function is written out. Let me know if you can't figure it out in a bit and I'll try to help a bit more.
@saidburakguzel
@saidburakguzel 4 жыл бұрын
@@BrianBDouglas As a user, i would like to put the generated code directly into the microprocessor, but anyway MATLAB still doing well jop. I've reviewed the generated code in general and found some input, output, and useful definitions that you mentioned, but there are still lots of parts that need to be edited. i guess i rather use state-space arrays. I also watched a lot of your videos including state space, these are quite good and I would recommend it to anyone who working on it. Thank you for your help and interest :)
@steeltitan8683
@steeltitan8683 2 жыл бұрын
@@BrianBDouglas Sir, thank you for awesome lectures. I want to discritize a lead-lag controller for a microcontroller. I used the z-transform method you discussed, to get the time-domain coefficients and implemented the similar equations as you did (three delay terms in my case). The discrete controller's response is excellent when I plot using step(continuous, discrete) function. But it flies off to infinity when I do with difference equations as you did. Is it due to rounding error accumulating over time? I can't find a way around :(
@steeltitan8683
@steeltitan8683 2 жыл бұрын
Yes! Solved it! Using tfdata, I imported the coefficients of the discretized function. Then I used vpa to get the precise value of coefficients up to ten decimal places. It did the trick!
@mehmetkilic9518
@mehmetkilic9518 3 жыл бұрын
Hello Brian, I have used the third method for implementing a fourth-order transfer function without zeros [6810.43913975331 / (s^4 + 36.3373933727534s^3 + 495.152308922335s^2 + 2998.75737145633s + 6810.43913975331)]. I tested the resulting discrete method(Tustin, 0.005 s) and the corresponding continuous transfer function in simulation both results matched BUT I got little oscillatory behaviour response with a bias on the discrete transfer function response when I run them in real-time with ardunio support package. I couldn't find the reason. Can you give me a little help with that?
@mehmetkilic9518
@mehmetkilic9518 3 жыл бұрын
Be aware of the precision of transfer function coefficients. Do float or double can give you enough precision? Check it :)
@minghuiou9357
@minghuiou9357 11 ай бұрын
The discrete time system is nonminimum phase, need to consider how to make it minimum phase……
@mervynlarrier9424
@mervynlarrier9424 7 ай бұрын
Why does the first method accrue error over time?
@BrianBDouglas
@BrianBDouglas 6 ай бұрын
It comes from the numerical integration and differentiation. Instead of taking a continuous integral, we're using a first order method to sum the area under the curve and this isn't perfect. The faster the sample time the more accurate it is, but error will still accumulate. This is actually a problem with all of the methods. Better accuracy comes from solving fewer numerical integrations or increasing the order of the numerical integrator.
@alexandrpetrov1110
@alexandrpetrov1110 3 жыл бұрын
Thank you so much Brian
New Gadgets! Bycycle 4.0 🚲 #shorts
00:14
BongBee Family
Рет қаралды 19 МЛН
⬅️🤔➡️
00:31
Celine Dept
Рет қаралды 37 МЛН
PID Controller Implementation in Software - Phil's Lab #6
20:06
Phil’s Lab
Рет қаралды 203 М.
The Step Response | Control Systems in Practice
14:56
MATLAB
Рет қаралды 151 М.
A real control system - how to start designing
26:58
Brian Douglas
Рет қаралды 260 М.
Control Bootcamp:  Laplace Transforms and the Transfer Function
19:15
Everything You Need to Know About Control Theory
16:08
MATLAB
Рет қаралды 510 М.
PID vs. Other Control Methods: What's the Best Choice
10:33
RealPars
Рет қаралды 108 М.
What are Transfer Functions? | Control Systems in Practice
10:07
Understanding the Z-Transform
19:56
MATLAB
Рет қаралды 87 М.
Apple watch hidden camera
0:34
_vector_
Рет қаралды 64 МЛН
Секретный смартфон Apple без камеры для работы на АЭС
0:22
ВЫ ЧЕ СДЕЛАЛИ С iOS 18?
22:40
Overtake lab
Рет қаралды 129 М.
После ввода кода - протирайте панель
0:18