#392

  Переглядів 32,155

Andreas Spiess

Andreas Spiess

2 роки тому

Attention: This is a re-published video. During my Summer Break, I decided to re-publish interesting older videos
I show how to program a PID controller to be used to stabilize the speed of a motor.
To show the effects of the different factors on the result I test it in reality with the fan of my wind tunnel.
I am a proud Patreon of @GreatScott!, @ElectroBOOM , @Electronoobs , @EEVblog , and others. No Docker, No Microsoft Teams, Zoom
The PID principle can be used for many other applications where unstable systems have to be stabilized.
Links:
Data logging from an Arduino to Excel: • #9 Arduino Data Logger...
Arduino Pro Micro: s.click.aliexpress.com/e/_9JABMh or amzn.to/3wa8g3r
ADS1115: s.click.aliexpress.com/e/_98a6It or amzn.to/3Anqfa7
Self-balancing Robot: • #35 Inside an Autonomo...
PID library: github.com/GyverLibs/GyverPID
The links above usually are affiliate links that support the channel (no additional cost for you).
Supporting Material and Blog Page: www.sensorsiot.org
Github: www.github.com/sensorsiot
My Patreon Page: / andreasspiess
Discord: / discord
If you want to support the channel, please use the links below to start your shopping. No additional charges for you, but I get a commission of your purchases to buy new stuff for the channel
My Amazon.com shop: www.amazon.com/shop/andreassp...
For Banggood bit.ly/2jAQEf4
For AliExpress: bit.ly/2B0yTLL
For Amazon.de: amzn.to/2r0ZCYI
For Amazon UK: amzn.to/2mxBaJf
For ebay.com: ebay.to/2DuYXBp
profile.php?...
/ spiessa
www.instructables.com/member/...
Please do not try to email me. This communication channel is reserved for my primary job
As an Amazon Associate, I earn from qualifying purchases
#no#midroll#ads

КОМЕНТАРІ: 110
@Palominostudio
@Palominostudio 2 роки тому
Many people battle with PID theory, that's why they are also known as Pain Inflicting Devices.
@AndreasSpiess
@AndreasSpiess 2 роки тому
:-)) Indeed, it is not a simple thing. Especially if you start with theory...
@btkramer
@btkramer 2 роки тому
I started setting up PID loops years ago for work with very little knowledge and had very little trouble. The more I learn about PIDs, the harder it gets to set them up.
@AndreasSpiess
@AndreasSpiess 2 роки тому
Interesting fact. I think, this can also happen in other areas. I also fear more things as I get older :-(
@edwardvanhazendonk
@edwardvanhazendonk 2 роки тому
Thanks, a great understandable explanation! Enjoy your holidays!
@AndreasSpiess
@AndreasSpiess 2 роки тому
You are welcome!
@PhG1961
@PhG1961 2 роки тому
Nice to see this video again. I often recap older videos and tech doc's. If not, I start to forget... so I want to stay sharp !
@AndreasSpiess
@AndreasSpiess 2 роки тому
A good behavior! I thought I do a pre-selection for my viewers. And it was not easy to shorten the list to 8 videos...
@zyghom
@zyghom 2 роки тому
quadryllion years ago, my final exam in the school: "PID controllers" - amazing, I was learning this for 5 years I think.
@AndreasSpiess
@AndreasSpiess 2 роки тому
I also had it in school but learned more with these projects, I think...
@zyghom
@zyghom 2 роки тому
@@AndreasSpiess YOU TOUCHED THE POINT Andreas ;-)
@nopparuj
@nopparuj 2 роки тому
Finally PID, i was looking for a tutorial.
@AndreasSpiess
@AndreasSpiess 2 роки тому
Glad the video was helpful!
@oscargr_
@oscargr_ 2 роки тому
@@AndreasSpiess Good idea to republish. It seems people don't look back at older videos much. 😁
@DrJALAGHARI
@DrJALAGHARI 2 роки тому
That's the explanation i was looking for PID controller.
@AndreasSpiess
@AndreasSpiess 2 роки тому
Glad the video was helpful!
@philip6382
@philip6382 2 роки тому
Never thought this video would be so good! Well done 👌🏼😍
@AndreasSpiess
@AndreasSpiess 2 роки тому
Thank you!
@inlywang8157
@inlywang8157 2 роки тому
well ilustrated👏
@AndreasSpiess
@AndreasSpiess 2 роки тому
Thank you!
@pedroset7972
@pedroset7972 2 роки тому
This is the most well ilustrated thing i've ever seen about PID. Great!
@AndreasSpiess
@AndreasSpiess 2 роки тому
Thank you for your nice words!
@KommaAchtKommaEins
@KommaAchtKommaEins 2 роки тому
Very nice. I used to work as a student programmer at a university researching about airplanes. Those guys always talked about PID which I hadn't heard of but were unable to tell me how to actually make a program of it. In the end I wrote a PID controller on a real-time PCI card in a PC which worked very nicely. Your video however shows the effect of P, I and D perfectly. Thanks.
@AndreasSpiess
@AndreasSpiess 2 роки тому
It is always good to do a project if you want to learn how things work. Only then I usually find the important questions.
@federicopacini9083
@federicopacini9083 2 роки тому
Very very nice explanation! Thank you!
@AndreasSpiess
@AndreasSpiess 2 роки тому
You are welcome!
@risingedgeelectronics5358
@risingedgeelectronics5358 2 роки тому
I have done loads of theory on PID controllers for control theory… this video explained the theory better than all the text books I have used.
@AndreasSpiess
@AndreasSpiess 2 роки тому
The theory is quite hard, I think. It is much more rewarding to just try and see what happens.
@BerndSchmitt-Martinique
@BerndSchmitt-Martinique 2 роки тому
Ihr Drehbuch-Autor hat wieder mal seine Klasse bewiesen. Happy sunday morning.
@AndreasSpiess
@AndreasSpiess 2 роки тому
Danke!
@garethsmith7628
@garethsmith7628 2 роки тому
and a half or one percent deadband around the setpoint makes things somewhat more stable in many cases.
@temyraverdana6421
@temyraverdana6421 2 роки тому
Very useful video. Thanks
@AndreasSpiess
@AndreasSpiess 2 роки тому
You are welcome!
@PHamster
@PHamster 2 роки тому
Omg that’s a bloweymatron. Aka Delta fan!
@AndreasSpiess
@AndreasSpiess 2 роки тому
And very strong!
@Ayce47
@Ayce47 2 роки тому
So glad you uploaded this! Was about to start learning some things about PID for a self regulating Badezuber which runs on wood.
@AndreasSpiess
@AndreasSpiess 2 роки тому
Glad the video was helpful for your project!
@pd8559
@pd8559 2 роки тому
Such a useful concept. First you use one to control the heat in your barbecue outside so you can have some tasty meat things to eat. Then you use one to control the temperature in your beer brewing container so you have something tasty to drink with your tasty meat things. Life is good with PID!
@AndreasSpiess
@AndreasSpiess 2 роки тому
Definitively! A very important concept for all areas of life.
@gfcwfzkm
@gfcwfzkm 2 роки тому
I would love to see a more in-depth video of PID controllers, a follow-up video. Specially at the end where you teased your roboter there, maybe demonstrating how to use multiple PID controllers within the same device / system to balance a roboter yet make it move
@AndreasSpiess
@AndreasSpiess 2 роки тому
You find a link to the robot videos in the video description.
@kcmichaelm
@kcmichaelm 2 роки тому
I took three semesters of control system classes for EE undergrad. I truly wish that this type of video would have been shown at the very beginning - just to get a high-level concept of what you were intended to learn by the end of the class. We never saw any type of practical application in any way - it was 100% math and bode/NyQuist plots. Even the “labs” were just making such plots in MATLAB and simulating the outputs in SimuLink. Luckily there is a lot of great control system content on UKposts.
@AndreasSpiess
@AndreasSpiess 2 роки тому
I agree that good professors not always are good teachers (I also had a few of them). I usually try to start with the simple and go in the direction of the complex stuff. I find it easier that way. I also think that many PID controllers cannot easily be calculated because you do not have a good model of the reality. For example the self-balancing robot is very complex if you want to model the stepper motors including drivers. It was easier to just try with different parameters.
@DougHanchard
@DougHanchard 2 роки тому
@@AndreasSpiess The Achilles of advanced theories without practical examples is why many engineering schools have a significant dropout and failure percentile. This is particularly true across North America and some parts of Europe.
@Fjyclydjgu
@Fjyclydjgu 2 роки тому
Use GyverPID library for arduino. Seek at github.
@AndreasSpiess
@AndreasSpiess 2 роки тому
Unfortunately its documentation seems to be in Russian.
@alifqastalani2430
@alifqastalani2430 2 роки тому
great
@AndreasSpiess
@AndreasSpiess 2 роки тому
Thank you!
@electronic7979
@electronic7979 2 роки тому
👏👏👏
@AndreasSpiess
@AndreasSpiess 2 роки тому
:-)
@benyounesoukarfifstm8782
@benyounesoukarfifstm8782 2 роки тому
Thank u sir for this great job, can u please precise which type of sensor you used ?
@BaumInventions
@BaumInventions 2 роки тому
It looks like a 4 wire fan with integrated fanspeed output. + / - / PWM in / rpm out
@AndreasSpiess
@AndreasSpiess 2 роки тому
Indeed, I used a 4 wire fan with a built-in RPM sensor.
@benyounesoukarfifstm8782
@benyounesoukarfifstm8782 2 роки тому
@@AndreasSpiess Thank you sir
@muctop17
@muctop17 2 роки тому
Very nice, Andreas! Again! But how do I do. if there is no fixed set value? I want to cool down my server box with the least possible rpm rate to the lowest temperature, to avoid noise. Temperature of the surroundings is allways changing, of cause and I don´t know what the low temperature I can reach inside. All I know is, perhaps what is the lowest (or maximum ?)difference I can (or want to) reach between inside and outside temperature....
@martinmckee5333
@martinmckee5333 2 роки тому
Generally, in a case like that, you want to set the maximum safe temperature as the setpoint. The most important thing is to protect the server, but if the temperature is below the setpoint, the fans will simply stop. If you have readings of ambient temperature as well as internal you could calculate the difference and use that as the setpoint. There is no advantage to do that, however. If the ambient temperature is low, then the fan is likely to be running when it doesn't need to, and if ambient temperature is high, the internal temperature may go too high.
@AndreasSpiess
@AndreasSpiess 2 роки тому
@muctop: You have to define the goal. The controller only executes what you want. As martin wrote you have different possibilities (constant inside temperature, constant difference, maximum inside temperature)
@DuneKraftwerk
@DuneKraftwerk 2 роки тому
Next step feed forward loop
@AndreasSpiess
@AndreasSpiess 2 роки тому
I do not understand :-(
@garethsmith7628
@garethsmith7628 2 роки тому
Often for fans you are better off looking at current or power as your PV, instead of speed, current is a very good proxy for flow.
@AndreasSpiess
@AndreasSpiess 2 роки тому
I agree if you plan to block the flow. I wanted to calibrate different flow meters and therefore needed a constant wind speed at various levels. So I thought the speed would be ok.
@ms2649
@ms2649 2 роки тому
You should make a video "PID controllers - adding D to the system" and explain how the derivative can be important in certain situations. Thanks to your original video i was able to make a basic one (at first still with i trem windup in it) in less than an hour in lua as a mod for a game and after some help i have a "PID module" that's used in way more places now then i had expected. Thanks for the video 👍
@AndreasSpiess
@AndreasSpiess 2 роки тому
So far I did not find a lot of applications for the "D part". It is mostly used to increase initial reaction time.
@ms2649
@ms2649 2 роки тому
@@AndreasSpiess i had to implement Derivative when i was writing code for a targeting system for a missile (in a game) that uses a semi checkpoint based flight path. Without the Derivative it would either turn too late/wide, or i had it turn too aggressive and had basically do a 90° turn on the spot to compensate for the start of the turn. EDIT: What about drones? They use derivative for the abrupt turns to keep it stable while vibrating.
@hesspet
@hesspet 2 роки тому
@@AndreasSpiess Rule of thumb. P-> Present Errors, I -> Past Errors, D-> The "look" into the future :-) Not for your application here. But often working with "D" helps to reduce Jitter or smoothes the reaction if you need fast speed changes . Eg. on a RC Plane or Multicopters. The D Value is the magic portion. :-) I found somewhere the description: "the cushion" of the PID system: smoothes the movement from one postion to an other.
@DEtchells
@DEtchells 2 роки тому
This was very helpful(!) It left out the D part (maybe I just missed it?), but the examples showing the results of playing with P and I were very informative! (And just understanding why the I coefficient should be much much lower than the P one was worth the entire video :-)
@AndreasSpiess
@AndreasSpiess 2 роки тому
I thought I mentioned that the D part usually is not needed and complicates things a lot. It is only for special cases to speed-up reaction time.
@imagingresourcereviews
@imagingresourcereviews 2 роки тому
@@AndreasSpiess Ah, so you did. I'm wondering how much I should use if I *do* want to speed up the response though. I have a toaster oven that I'm trying to drive with a PID controller. It has a very slow response time that I've been hoping to speed up, but maybe my trying to use the D parameter explains why it always wants to oscillate :-) Given how long a time constant it has, I suspect I'm going to be best served by using only P and I as you suggested. Thanks again for the extremely useful video! (And for re-publishing it; I wouldn't have known to look that far back in your prior videos :-)
@AndreasSpiess
@AndreasSpiess 2 роки тому
@imagingresource: A controller only can speed up the reaction of a fast system. It cannot change physical laws. As you write: A toaster is by definition a very slow system.
@imagingresourcereviews
@imagingresourcereviews 2 роки тому
@@AndreasSpiess Thanks, that's an important, fundamental realization for me. If the PID loop is commanding full power output from the oven, cranking up the D component isn't going to make it warm up any faster! (Obvious once you think about it or someone points it out to you, but DOH... :-0) Thanks again! (This video is also going to be a great help to me in tuning the PID loops on my 3D printers. I feel like I finally understand PID for the first time!)
@seamusdemora5598
@seamusdemora5598 2 роки тому
@@AndreasSpiess When I studied PID controllers (years ago), my prof spent much time on stability and finding the "critical" response: not too slow (overdamped), not too fast (underdamped), but just right (critically damped). Without this sort of analysis, you are driving blind we were told. When I began to apply these lessons to "real-world" problems a few years later, I learned that the transfer function of "the plant" is never as simple as the ones in the textbook. Still - it is useful.
@DAVIDGREGORYKERR
@DAVIDGREGORYKERR 2 роки тому
What about using a Raspberry Pi IV + an ADC/DAC Hat for the Raspberry Pi and some simple C++ code that could be run in a loop until no longer needed at which it exits the loop.
@AndreasSpiess
@AndreasSpiess 2 роки тому
A Pi could be used, of course. But it probably would be an overkill for such a simple application.
@hesspet
@hesspet 2 роки тому
A linux controller ist not the best way to do PID controllers, it must have a real-time kernel to get perfect results. The first multicopter were build on a arduino system. They controlled 4 motors around 500-1000 loops per second. So everything bigger ist waste of money for a simple motor control.
@fritschalterheijden318
@fritschalterheijden318 2 роки тому
Great video. PID-controller should be explained with easy examples so people should not be afraid of using them. I would suggest 2 corrections though: (1) the speed of the fan rises when you block the flow. Less mass needs to be transported, so the fan needs less energy. (2) the difference = setSpeed - speed. Not the other way around. In your case the speed would rise if it was to high. You need negative feedback. Best regards and enjoy your vacation.
@AndreasSpiess
@AndreasSpiess 2 роки тому
You are right if you expect to block the tunnel. In my case I wanted to calibrate my flow sensor and therefore wanted to have stable wind speeds at different levels..
@nazareth978
@nazareth978 2 роки тому
One more small remark. Although this video is very good for beginners, there is much to know beyound this video, and there is a big amount of literature for PID regulations from different sources available. Therefore I suggest to align to the standards even when laying down the basics to avoid further confusions. "setSpeed" should be "setpoint", "difference" should be "error signal", as these are their official names used everywhere else. The "i factor" in this example is a multiplier, but should be a divider, as officially it is "integration time", which slows down the I-term, if increases... But anyway, this is also a great video, as usual :)
@TheRainHarvester
@TheRainHarvester 2 роки тому
Hi Andreas, Do you know how many encoder interrupts per second can be realistically tracked with a 16MHz micro? I can't get anywhere near theoretical because I guess some interrupts come quickly close together and I miss a few. I'm using an ink jet shuttle with dc encoder and can't go faster than 500 mm/min without losing steps. (29 steps/mm) on my channel At 750mm I lose 0.5mm after running for a minute. My interrupt is quick: bit wise if-check and increment/decrement. Oscilloscope shows little time in interrupts.
@TheRainHarvester
@TheRainHarvester 2 роки тому
Ps In my video using a PID to control a 3d printer. But for testing, I also disconnected the motor and just moved by hand to verify motor noise was not an electrical issue.
@martinmckee5333
@martinmckee5333 2 роки тому
Your mention of 16MHz makes me wonder if you are using an Atmel-based Arduino of some description (ATMega328, ATMega2560, etc.). If so, the milliseconds clock has a constantly running timer interrupt that would have higher priority than a pin interrupt. That might be your problem. Having say that, if my math was right, your current limit is about 250 interrupts per second. It should be possible to handle more than that on the processor. Using Arduino code I've handled >1kHz, and even more by bypassing the Arduino libraries and runtime.
@TheRainHarvester
@TheRainHarvester 2 роки тому
@@martinmckee5333 Yes, I can handle 40000*29 IRQs per second (that seems suspiciously high.I used grbl with f40000 and 29 step/mm, but maybe grbl had an upper limit, or acceleration limited the max freq) from GRBL. But from the encoder, I miss steps. I thought maybe the pulses sometimes come in back-to-back since the shuttle movement isn't perfect. So was wondering what real-world results were like.
@TheRainHarvester
@TheRainHarvester 2 роки тому
@@martinmckee5333 oh, I'm using msp430g2553, so I don't know about the millisecond timer, but since I can get so many IRQ per sec directly from GRBL (instead of the encoder), I don't think that is the problem.
@martinmckee5333
@martinmckee5333 2 роки тому
@@TheRainHarvester yes, that absolutely sounds like a hardware issue.
@benjamilindqvist912
@benjamilindqvist912 2 роки тому
I still dont get how to properly get started with the P and I values. Should I start with adjusting the P or the I and what value should I select? I once did a project in school about PID controllers, but never really knew how to begin adjusting it. I just always found myself rising the P and then rising the I, but I could do this infinitely, and did not notice anything happening.
@oscargr_
@oscargr_ 2 роки тому
How did you evaluate the performance? Do you make a graph of the process variable over time? e.g. speed/time or temperature/time? Find a way to reliably measure and graph the process. Then, as you say.. increase P until process becomes unstable... Dial it back 10 or 20% Then slowly increase I. As Andreas says, for most home style project the D gain does almost nothing and it makes tuning much more difficult.
@AndreasSpiess
@AndreasSpiess 2 роки тому
@Benjami: I wonder that nothing happened when you changed the parameters. Usually the systems react very strong to changes of the parameters...
@keithr0
@keithr0 2 роки тому
It's really just servo theory, I had to learn it at college back in the 60s. That was, of course, all analog and involved a lot of calculus. Digital servos with PID are much simpler.
@AndreasSpiess
@AndreasSpiess 2 роки тому
As you say: Both have to solve the same problems. And proportional amplifiers or integrators can easily be done with op-amps. The calculus is still difficult, I think...
@MPElectronique
@MPElectronique 2 роки тому
Batman is coming :-)
@AndreasSpiess
@AndreasSpiess 2 роки тому
Unfortunately, I do not understand :-(
@MPElectronique
@MPElectronique 2 роки тому
@@AndreasSpiess with your truck batcave :)
@JamesFraley
@JamesFraley 2 роки тому
I appreciate the effort, but this video was not nearly as clear as most of your videos.
@AndreasSpiess
@AndreasSpiess 2 роки тому
Sorry for that
@Thomas72B
@Thomas72B 2 роки тому
Unfortunately there is a small mistake in the video because PID stands for: P = proportional, I = integral and D = differential
@geoffd8127
@geoffd8127 2 роки тому
I have only seen D called the Derivative term...never Differential. Maybe that term is used more in scientific descriptions of the process, rather than an actual device.
@Thomas72B
@Thomas72B 2 роки тому
@@geoffd8127 Yes you are right it stands for: P = proportional I = integral D = derivative not differntial
@AndreasSpiess
@AndreasSpiess 2 роки тому
Thank you for the correction!
@peter.stimpel
@peter.stimpel 2 роки тому
Peter, you do not build such a robot! Finish the other projects, first! PETER!
@AndreasSpiess
@AndreasSpiess 2 роки тому
You are right, Peter! But it is a very rewarding and interesting project. You can do the other projects later ;-)
@peter.stimpel
@peter.stimpel 2 роки тому
@@AndreasSpiess "You can do it afterwards" resulted in me buying some boxes to store projects "not finished yet". Quite a nice pile of boxes...
@hesspet
@hesspet 2 роки тому
To late. Peter has finished such a robot :-) and our cat doesn't like this thing....
@peter.stimpel
@peter.stimpel 2 роки тому
@@hesspet :D
How the Most Expensive Swords in the World Are Made
25:27
Veritasium
Переглядів 5 млн
The Scientist Who Discovered the World's Most Beautiful Equation
14:58
ІГОР ГОЛОВАНЬ подав до суду на ЗЕЛЕНСЬКОГО
18:56
Спецпроекти Сергія Мамаєва
Переглядів 127 тис.
MICHIEL VS JUVENTUS WOMEN 🙈📏
00:26
Celine Dept
Переглядів 52 млн
The Race For AI Robots Just Got Real (OpenAI, NVIDIA and more)
21:26
ColdFusion
Переглядів 844 тис.
Boost Your PCB Design Productivity | 7 Best Plugins for KiCad
10:58
Terminal Curiosity
Переглядів 16 тис.
This Lego Vacuum Generator Sucks!
15:04
Jamie's Brick Jams
Переглядів 61 тис.
Dare I say "Cinematic"? Ricoh GR III HDF Model
19:51
Samuel Streetlife
Переглядів 22 тис.
Опыты с САМОЙ ДОРОГОЙ Жидкостью!
20:17
Старый и новый Redmi Book Pro #xiaomi #redmibookpro
0:53
Не шарю!
Переглядів 152 тис.
Samsung Pay всё
0:34
Romancev768
Переглядів 246 тис.
1$ Handmade Filter for Camera 😱 #photography
1:00
Jean Black
Переглядів 16 млн
¡ Soldando Con Transistor STR y Desoldando LEDs Hack !
0:12
EcoRob Tech
Переглядів 2,5 млн