Тёмный

#381 

Andreas Spiess
Подписаться 477 тыс.
Просмотров 233 тыс.
50% 1

Using a real operating system to simplify programming with the Arduino IDE. Is this possible and how? Let’s have a closer look!
Operating systems were invented to simplify our lives. But, because they need a lot of resources, they only run on reasonable computers like the Raspberry Pi or a PC. Right? Wrong. Nowadays, we also get operating systems running on our small MCUs. Particularly interesting in this respect is the ESP32 because it has enough power and memory to accommodate such an additional burden. And the best: It already runs a version of FreeRTOS with all our Arduino sketches, and it is easier than you think. Is this useful?
I am a proud Patreon of @GreatScott!, @ElectroBOOM , @Electronoobs , @EEVblog , and others. No Docker, No Microsoft Teams, Zoom
Links:
FreeRTOS deep dive: • Introduction to RTOS P...
Parallel tasks without RTOS: • ✔ Multitask Arduino wi...
Code (for reference only): github.com/SensorsIot/Morse-T...
ESP32 Dev. Board used for Prototyping: s.click.aliexpress.com/e/_ANHrBc
ESP32 Prog: s.click.aliexpress.com/e/_AougSs or amzn.to/3tjrsL4
Logic Analyzer 16ch (clone) : s.click.aliexpress.com/e/_9R3ZMZ
Logic Analyzer 8ch (clone) : s.click.aliexpress.com/e/_APm5bP
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

Наука

Опубликовано:

 

5 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 599   
@AndreasSpiess
@AndreasSpiess 3 года назад
Correction: ISR is Interrupt Service Routine, not internet service routine
@varunkoganti9067
@varunkoganti9067 3 года назад
This must be an April fools joke.
@AndreasSpiess
@AndreasSpiess 3 года назад
I already posted a pinned correction comment ;-)
@markmaker2488
@markmaker2488 3 года назад
Another great tutorial and reason to love the esp32 even more, thanks!
@sunuk1915
@sunuk1915 3 года назад
ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-LaYXrdASR8M.html
@PuretyLead-bg5wv
@PuretyLead-bg5wv 3 месяца назад
Correct, great teacher
@TheDefpom
@TheDefpom 3 года назад
Shawn did a really good series on freertos, I’m glad you reference it.
@AndreasSpiess
@AndreasSpiess 3 года назад
Agreed. Probably a little "oversophisticated" versus the end...
@tonyfremont
@tonyfremont 3 года назад
He has put out a bunch of good STM32 CubeMX videos too.
@iSuperMC
@iSuperMC 3 года назад
Who’s Shawn ? Could you send a link please
@marcdraco2189
@marcdraco2189 2 года назад
@@iSuperMC Shawn Hymell (Digi-Key). He does a lot of instructional videos but he's a bit of an egg-head for most of us.
@shiftyjesusfish
@shiftyjesusfish 3 года назад
I can't even begin to tell you how much I value the work you (and other educational youtubers who are truly educated and articulate) do for the comunity and myself..... Tryin to jump in with arduino and programming to make my dream projects come true would have overwhelmed me and I would have definitely given up without the resources you provide. Sometimes when your teaching yourself things the hardest part is not knowing what you don't know, and not knowing how to ask the right questions, so when you go out of your way to provide context and redundant examples along the way without delight too deep into those other topics it really elevates the content from infotainment to genuinely valuable educational material.
@AndreasSpiess
@AndreasSpiess 3 года назад
Thank you for the nice words! I became a RU-vidr because I learned a lot when I started with the Arduino myself...
@francescoreale
@francescoreale 3 года назад
Thank you very much! I can't even imagine all the work behind this video! Great job.
@AndreasSpiess
@AndreasSpiess 3 года назад
You are welcome! You are right, this one was not easy. Also because I had to concentrate very much on the important things. The script took many iterations...
@rfrisbee1
@rfrisbee1 3 года назад
One aspect of RTOS development you somewhat glossed over is the amount of memory to assign for each task's stack. FreeRTOS has features to determine stack usage / detect stack overflow, so that the stack size for each task can be set appropriately. For development it's useful to use a processor with plenty of RAM so that task stacks can be set much larger than needed and then reduced so the application can run on a part with less RAM. Another important FreeRTOS specific detail is enabling the RTOS features you want in the FreeRTOS config header file. Finally, for those using STM32 processors, avoid using both STMCube HAL and FreeRTOS together. They do not play nice!
@AndreasSpiess
@AndreasSpiess 3 года назад
Thank you for your additional info. Indeed, I did not know how much stack is enough. Fortunately, the ESP32 has enough RAM for my application. So I did not need to answer the question...
@yagizhanugur
@yagizhanugur 3 года назад
Hello what problems did you observ with rtos and HAL library. Please Share your experiences.
@maxstripeGaming
@maxstripeGaming 2 года назад
@@yagizhanugur cant be used together as they both try to play the OS part and do scheduling and shit like that they are flat out incompatible
@tahunus3148
@tahunus3148 2 года назад
@@AndreasSpiess I found this on the ESP-IDF docs that might produce an answer: - At runtime, call the function uxTaskGetStackHighWaterMark() with the handle of any task where you think there is unused stack memory. This function returns the minimum lifetime free stack memory in bytes. The easiest time to call this is from the task itself: call uxTaskGetStackHighWaterMark(NULL) to get the current task’s high water mark after the time that the task has achieved its peak stack usage (i.e. if there is a main loop, execute the main loop a number of times with all possible states and then call uxTaskGetStackHighWaterMark()). Often, it’s possible to subtract almost the entire value returned here from the total stack size of a task, but allow some safety margin to account for unexpected small increases in stack usage at runtime. - Call uxTaskGetSystemState() at runtime to get a summary of all tasks in the system. This includes their individual stack “high watermark” values. It's in the RAM Usage section: docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/performance/ram-usage.html Thanks for your wonderfully informative and well made videos!
@TheNormalUniverse
@TheNormalUniverse 3 года назад
Thanks for referencing my vid Andreas! I’m self taught so I didn’t know there are more elegant ways to do multitasking. I haven’t watched all of this video yet but I will definitely come back to it. I’m getting back into coding to make a synthesizer so this is just what I need.
@AndreasSpiess
@AndreasSpiess 3 года назад
You are welcome. You will see, RTOS is a different world because most things are "under the hood" and your code is easy to read.
@ShawnHymel
@ShawnHymel 3 года назад
Great explanation, and thanks for the shout out!
@AndreasSpiess
@AndreasSpiess 3 года назад
You are welcome!
@carltone
@carltone 3 года назад
Andreas, excellent instructional video. Your explanation of time slicing, task creation by breaking down the requirements of the program, communication queues was well explained. The analysis aspect of programming is a crucial skill that is required when incorporating the additional control of a multitasking environment into a program solution. Your big picture overview to small detail approach, embedded humour (pun) ensure your technical videos are a great learning tool and a joy to watch. Well done!
@AndreasSpiess
@AndreasSpiess 3 года назад
Thank you for your nice words!
@useyourbrain2022
@useyourbrain2022 3 года назад
incredibly explained, as always, thanks!, I wish I had a teacher like you when I was studying at the university
@AndreasSpiess
@AndreasSpiess 3 года назад
Happy to help! And thank you for your nice words.
@vks002
@vks002 2 года назад
Excellent tutorial Andreas! I wanted to start off with RTOS and I remembered that you had a video on this. So I went straight into it as I know you would do the best job is getting me started. Thank you so much. Now I can go through the rest of documentation and other tutorials :)
@AndreasSpiess
@AndreasSpiess 2 года назад
Glad to read that. A good start is all I wanted to provide ;-)
@PemboPemberton
@PemboPemberton 3 года назад
A great intro to RTOS. I find it good practice to use it all of the time with the ESP32 and just have the OTA in the "loop" function. It's a good way to learn how to program many micro controllers in the big industry and not just hobbyist style coding. As I've also been use RTOS on many other microcontrollers like ARM and PIC for many years in industry. This makes porting code from other microcontrollers to the ESP range very easy. ...Keep up the great work. - Enjoying watching from the UK. 😉👌
@AndreasSpiess
@AndreasSpiess 3 года назад
Thank you for your feedback. For sure it makes a lot simpler...
@BlueyMcPhluey
@BlueyMcPhluey 2 года назад
lately every time I have an interest in a topic and search youtube you've made a video on it already. Thanks once again :)
@AndreasSpiess
@AndreasSpiess 2 года назад
Happy to hear that!
@n-elia
@n-elia 3 года назад
Thank you for taking time to recurd such an instructive video. Keep up your wonderful work!
@AndreasSpiess
@AndreasSpiess 3 года назад
My pleasure! And thank you for your nice words!
@sarahjanegray
@sarahjanegray 3 года назад
Excellent video, as always, Andreas. I found myself working through and learning how RTOS worked when working through and debugging the code for the ESP32 Internet radio project that you discussed previously. However this cleared up a few things I was not able to get my head around from the Free RTOS documentation. Thanks again.
@AndreasSpiess
@AndreasSpiess 3 года назад
You are welcome! I forgot that the internet radio also used RTOS. I am getting old...
@xboxgamer9216
@xboxgamer9216 3 года назад
Was waiting for something like this . Thank you
@AndreasSpiess
@AndreasSpiess 3 года назад
:-)
@Alex000113
@Alex000113 2 года назад
Theres a lot of really informative material in this video THANKS ! I didnt realize it was so straightforward to run freeRTOS on an ESP32. My first freeRTOS app was running within 15mins of completing this video. Really encouraged now to delve deeper.
@AndreasSpiess
@AndreasSpiess 2 года назад
I think a deep dive will be rewarding. Enjoy!
@williamwatson1532
@williamwatson1532 3 года назад
Another great video Andreas.! I liked your history lesson at the beginning. In the late '80s I worked with Forth which was perfectly capable of multitasking with 8bit microprocessors like the 1802, Z80, 6809 & 8051. It used a cooperative round robin model which meant the program designer could allocate as much cpu time as was needed for each part of a task. With no interrupt and time slicing the task switching overhead was tiny. One benefit was the ability to test and alter code from the keyboard with existing tasks running in the background.
@AndreasSpiess
@AndreasSpiess 3 года назад
You are right. We currently re-discover things we had in the 80s like inline debugging. But of course, today it is much easier because of the resources an ESP32 offers. It has nearly no limitations for an average project. Which makes things much easier. No optimization needed, just straight programming...
@aeljandro2
@aeljandro2 3 года назад
Thanks for taking the time on making these videos. You are a great great teacher! I've learned a lot from you. Thanks for all!
@AndreasSpiess
@AndreasSpiess 3 года назад
You're welcome!
@kwinzman
@kwinzman 3 года назад
Thank you for this amazing video! I like to believe that me commenting about FreeRTOS in your "The All-New Arduino IDE 2.0: Introduction and Test " video had a small role it its creation. 😊
@AndreasSpiess
@AndreasSpiess 3 года назад
:-)
@klassichd10
@klassichd10 3 года назад
Thanks a lot for this compact introduction in such an important topic as FreeRTos on ESP32!
@AndreasSpiess
@AndreasSpiess 3 года назад
You are welcome! Like hardware debugging, this is game changing for me...
@wm6h
@wm6h 3 года назад
Thank you Andreas. I learn something from every video of yours. Today, I learned QLF 😀. Also, that debugging hook up @ 12:35 caught my interest and maybe suggests a future video. See you next Sunday.
@AndreasSpiess
@AndreasSpiess 3 года назад
When I listen to the bands I hear a lot of QLF... I already made a video about hardware debugging with PlatformIO.
@avejst
@avejst 3 года назад
Impressive video as always 👍 Thanks for sharing your experience with all of us 👍😀
@AndreasSpiess
@AndreasSpiess 3 года назад
Thank you! This one was not too simple to understand, I think...
@kroojohn
@kroojohn 3 года назад
Once again a very detailed and useful video, including a wealth of information and tips ... Thank you :)
@AndreasSpiess
@AndreasSpiess 3 года назад
My pleasure!
@guntherjordan7177
@guntherjordan7177 3 года назад
Ein Video an meinem Geburtstag über eines meiner aktuellen Lieblings-Bauelemente. Das ist ein extrem interessantes Thema, -werde mich da demnächst mehr mit beschäftigen. Danke für's zeigen!
@AndreasSpiess
@AndreasSpiess 3 года назад
Bitte, gern geschehen, Und herzliche Glückwünsche!
@large65
@large65 3 года назад
At first! Thank you for your great explanations on all the different topics. They are fabulous! Just a minor remark: I think that RTOS is not about "fast" responses to an event, but about guaranteed (!) response (in a specified time). How fast the RTOS has to react depends on the physical properties of the system under control.
@AndreasSpiess
@AndreasSpiess 3 года назад
Good point!
@DougCooperTech
@DougCooperTech 3 года назад
That was a great introduction. It would be great to see other FreeRTOS videos. Thanks
@AndreasSpiess
@AndreasSpiess 3 года назад
We will see. Maybe as a part of a project.
@robertobrenes5283
@robertobrenes5283 3 года назад
nice video! today i saw a little Tensorflow on an ESP32cam and then this video! So much to learn!
@AndreasSpiess
@AndreasSpiess 3 года назад
True. But a lot of opportunities!
@DannyBackx
@DannyBackx 3 года назад
Nice and sufficiently accurate description of a difficult subject. Note that shared resources also include your display.
@AndreasSpiess
@AndreasSpiess 3 года назад
You are right. I thought, the display was on the list of shared resources...
@AlexGoris
@AlexGoris 3 года назад
Thanks for another great video, Andreas! I have a project which is sitting around for over a year now, which is built on ESP32 and needs to perform several tasks separate from eachother. I got some great ideas on how to accomplish this in a better when than it is managed now.
@AndreasSpiess
@AndreasSpiess 3 года назад
You will see that, if you get the design of the different modules right, things get much simpler than with standard programming.
@alastorgdl
@alastorgdl 2 года назад
@@AndreasSpiess Is VERY surprising the level of resistance people have against using a RTOS, specially in camps like CubeIDE. It's like they prefer DOS than Windows
@vincentlin7240
@vincentlin7240 2 месяца назад
One of the best RTOS video to start with, than you so much for making these! Also, love the jokes and the metaphors!
@AndreasSpiess
@AndreasSpiess 2 месяца назад
You are welcome! Thank you for your kind words.
@ThomasDwyer187
@ThomasDwyer187 3 года назад
Great stuff, Andreas! I appreciate your high-quality information~
@AndreasSpiess
@AndreasSpiess 3 года назад
My pleasure!
@mysomervda
@mysomervda 3 года назад
Thanks. Great as usual, that was a nice introduction and overview of RTOS for me.
@AndreasSpiess
@AndreasSpiess 3 года назад
Glad it was helpful!
@peut
@peut 3 года назад
Thanks Andreas. Great summary of the extra power and features FreeRTOS provides! Further: In principle, mutexes should be used for all shared resources, no exceptions. However, if the resource is simple, e.g. a boolean variable, chances of corruption due to concurrent access are negligable or maybe even non-existent, depending on the code and the compiler. The same applies for a mutex with only one writer and one or more readers. However, taking the risk of corruption should be a conscious one and taken with a lot of care. Small tip: Taking and giving mutexes is "expensive" in terms of performance. In a time critical loop it may be help to use xSemaphoreGetMutexHolder( nameOfSemaphore ) to check if a Mutex has been taken. Apparently, this generates less overhead than the xSemaphoreTake function. An example would be a mutex set by a task to stop a tight loop in another task.
@AndreasSpiess
@AndreasSpiess 3 года назад
Thank you for the additional info! You are right with the Mutex because we do not know when the millisecond is over (maybe in the middle of an update statement). However, the ESP32 is mindboggling fast. I checked how long my tasks run. Even the longest one (searching for the next letter) only needed a fraction of the 1ms slot. So I always know when I pass the control to the scheduler. I think, with such a fast processor we can avoid many situations a slower CPU could generate. I also proposed to only use one priority based on this fact. Also here we reduce the chance for problematic situations without any harm.
@Robotsreloaded
@Robotsreloaded 2 года назад
Love your videos! I've heard the word RTOS many times and thought it's something very complicated. Your explanation gives a very good intro to it. Now there is so many use cases coming in my mind 😁
@AndreasSpiess
@AndreasSpiess 2 года назад
Glad it was helpful!
@alastorgdl
@alastorgdl 2 года назад
@RobotsReloaded You don't even think on using a PC as baremetal. An embedded system is basically the same case even if the level of complexity is lower
@peter.stimpel
@peter.stimpel 3 года назад
great stuff Andreas, thanks a lot. But at 20:41 there was a blocked resource in the spellchecker, it seems ;) Thanks a lot for diving into such not obvious topics!
@AndreasSpiess
@AndreasSpiess 3 года назад
:-)) You are right. Unfortunately here the problem was between my ears...
@nickp3837
@nickp3837 3 года назад
Great video, much to learn as always. After you last video on ESP32 using two cores I have built several multi tasking systems but I wasn't aware of this level of detail. After this I switched from std:: mutex to xSemaphoreCreateMutex() which saves some memory. FYI If you are porting existing code there is no need to go back and change the calls to delay(); In the framework delay(ms) simply calls vTaskDelay(ms / portTICK_PERIOD_MS);
@AndreasSpiess
@AndreasSpiess 3 года назад
Thank you for the tip about delay(). I was not sure.
@tonysfun
@tonysfun 3 года назад
Amazing! Thank you so much Andreas! And you have great humor also!
@AndreasSpiess
@AndreasSpiess 3 года назад
I try my best to keep the humor in those times ;-)
@TonoNamnum
@TonoNamnum 3 года назад
I believe this video should be fundamental for every maker! Thanks Andreas!
@AndreasSpiess
@AndreasSpiess 3 года назад
Glad you think so!
@Chris-ib8lw
@Chris-ib8lw 3 года назад
"If you are good, you get more work!" Not going to lie, that line gave me flash backs to my Air Force days. haha As always, love the videos and I always learn a lot from you!
@AndreasSpiess
@AndreasSpiess 3 года назад
:-))
@MaqsoodAlamShafiq
@MaqsoodAlamShafiq 2 года назад
Excellent video. The secret of arduino setup() & loop() being RTOS task is very helpful. Learning such tips earlier help a lot. @12:27 the schema and explanation gave a great deal of insight on project design and state machine concept. 👍 There is another saying "He won't get a break if he learns his lesson". I think it is a universal fact that good people are kept busy 🤣
@AndreasSpiess
@AndreasSpiess 2 года назад
Thank you. Glad it was helpful!
@becauseican2607
@becauseican2607 3 года назад
Grüezi Andreas 🇨🇭 I have to give this a try. Thanks for sharing ✌️
@AndreasSpiess
@AndreasSpiess 3 года назад
Hope you enjoy
@johnwest7993
@johnwest7993 2 года назад
I almost never critique RU-vid videos simply because they are what they are, a freely given effort to inform people of something. But your videos are exceptionally good due to your intellect, consummate skills, and your meticulous presentation. So because of that, and at the risk of being perceived as overly critical I will point out that you said 'seconds' instead of 'milliseconds' at 23:07 into the video. I do so because I think that to you, it matters. You actually want to be clear, concise and correct about everything you tell us, and you work at it throughout your videos. That is the reason why I watch ALL of your videos, even on subjects in which I have little interest, because they all exhibit what few other RU-vid videos do - genuine quality. I appreciate the quality, and I can guess how much mental and physical effort is involved in creating and maintaining it, video after video. Thank you Andreas.
@AndreasSpiess
@AndreasSpiess 2 года назад
Thank you for the info about my slip of the tongue . And thank you for your nice words. Glad you like the content of the channel.
@fgaviator
@fgaviator 3 года назад
Great video! Never knew the ESP32 already hat an RTOS. This will be really useful. Minor correction: do the spinlock functions at 21:14 really expect a parameter - the documentation in your next shot suggests they are "void void" functions.
@AndreasSpiess
@AndreasSpiess 3 года назад
In the ESP32 implementation they expect (or allow?) a parameter. But I am no specialist.
@caseykoons
@caseykoons 3 года назад
Very nicely made video of the project. Good scope. I like the design of the deck too.
@AndreasSpiess
@AndreasSpiess 3 года назад
Thank you!
@marlb64
@marlb64 3 года назад
Thanks Andreas, for yet another great educational video !!
@AndreasSpiess
@AndreasSpiess 3 года назад
Glad you liked it!
@Uncle-Duncan-Shack
@Uncle-Duncan-Shack 3 года назад
Very nice Andreas, greetings to you and the laboratory manager fur (Feline) from South Africa. We are also concerned with speed, and is why we have parallax flip boards in our possession, 8 cogs to do multi tasking. And then I noticed the Teensy 4 boards, faaaaast. And the the 4.1 can store data to a sd card for recording. This is more industrial type applications for us, so we are not bothered about the 100mA of current to run these mcu's. So much nice stuff, a solution looking for a problem. I enjoyed the video, something to look forward to on a Sunday. See you next week, Kind regards, Duncan
@AndreasSpiess
@AndreasSpiess 3 года назад
Greetings back to SA. Yes, those boards are very fast. For my applications often much too fast. For this one, I checked and found that none of the tasks needed more than a few percent of one time slot. BTW: Next week there is no video from me. Only 3 per 4 weeks...
@MauroMaccarone
@MauroMaccarone 2 года назад
Never die my hero! a lot of love from Argentina
@AndreasSpiess
@AndreasSpiess 2 года назад
:-)
@jodeling35
@jodeling35 Год назад
As always: Great Work, Andreas! Thx!
@AndreasSpiess
@AndreasSpiess Год назад
You are welcome!
@BillXT11
@BillXT11 3 года назад
Thanks for starting with RTOS, always wanted to learn it!
@AndreasSpiess
@AndreasSpiess 3 года назад
Go for it. It is worthwhile.
@chaniapellet
@chaniapellet 3 года назад
Very nice! Thank you for this video.
@AndreasSpiess
@AndreasSpiess 3 года назад
Glad you liked it!
@dariuszruminski8549
@dariuszruminski8549 3 года назад
Thank you for the lesson!
@AndreasSpiess
@AndreasSpiess 3 года назад
You are welcome!
@ChristopherHeald
@ChristopherHeald 3 года назад
This is so much more elegant than the mess of millis(). Thank you for the clear explanations, as always.
@AndreasSpiess
@AndreasSpiess 3 года назад
Indeed! Much easier to read.
@facundofarall7716
@facundofarall7716 2 года назад
Very useful and well explained video, thank you so much!
@AndreasSpiess
@AndreasSpiess 2 года назад
Glad it was helpful!
@bm830810
@bm830810 3 года назад
20:25 I think the mutex is used when you can have concurrent access and not just multiple writes, assume one task is reading a struct, and in the middle of reading, the other task modifies the struct.
@arnodej9590
@arnodej9590 3 года назад
If the processor can read/write 32 bit variables atomically you don't need to protect them (if you have only one writer). If your processor cannot access the data in one instruction, you indeed need protect read and write.
@haves_
@haves_ 3 года назад
yes, when the display task needs to print the variable onto the screen, the writing task should not change it until the display task finished printing.
@vatterger
@vatterger 3 года назад
Exactly, you may have single-writer-multi-reader-configs when the shared resource can be written atomically, like 32-bit words on a 32-bit processor, but most other things require some protection even when only one thread is writing. Atomic operations (Compare and Swap etc) are also a useful thing to look into. They can help avoid mutexes and therefore overhead when building queues or counters.
@AndreasSpiess
@AndreasSpiess 3 года назад
Thank you for the discussion. I would like to add another aspect: Because the ESP32 is so fast, none of my tasks needed more than a fraction of 1ms and I was always able to actively pass the control back to the scheduler. Is a mutex still needed?
@bm830810
@bm830810 3 года назад
​@@AndreasSpiess and thanks again to you dear Andreas for your great contents. Hadnt thought about it this way, your assuming since there is no preemption in your case, the mutex is not needed, which I think is right. although I would always add them as good practice since you don't know what future holds...
@antoniojesusarquillosalvar4342
@antoniojesusarquillosalvar4342 3 года назад
Really impressive! The best channel on this subject in Internet.
@insanemainstream3633
@insanemainstream3633 3 года назад
I wish my brain could multitask his knowledge without all the deadlocks! Great content as usual Andreas liked vid.
@AndreasSpiess
@AndreasSpiess 3 года назад
Wow, thanks!
@MrKelaher
@MrKelaher 3 года назад
Great presentation ! I love RTOS, by first was VxWorks, they really make embedded coding easier in most cases. Your single writer, multiple readers comment about mutex not being needed is only true for simple variables - if you need to update many parts of a struct, for example the x and y parts of coordinate, then either both reads and writes always need a mutex (if writes are common relative to reads) or a spin lock on write is needed (faster if writes are much less common than reads), or some odd stuff might be seen ! General rule is mutex unless performance is an issue then selectively remove them with massive comments in code - better safe than sorry . Defensive coding is always the RTOS coders friend !
@AndreasSpiess
@AndreasSpiess 3 года назад
Thank you for the addition about mutexes. I did not think about those cases because all my tasks only use a fraction of a slot and I always actively pass control back to the scheduler. But I agree: Better safe than sorry...
@christiancarassai9540
@christiancarassai9540 3 года назад
Right? Wrong!!! hahahaha. Andreas, your videos are excellent, and a great source of information. Congratulations, one of the best channels on microcontrollers and iot!!!
@AndreasSpiess
@AndreasSpiess 3 года назад
Thank you for your nice words!
@eduardo9626
@eduardo9626 3 года назад
I want more videos like this! Thanks for this video
@AndreasSpiess
@AndreasSpiess 3 года назад
You are welcome! We will see...
@stevesfascinations1516
@stevesfascinations1516 2 года назад
Really well explained, thank you very much! Thumbs up!
@AndreasSpiess
@AndreasSpiess 2 года назад
Glad you enjoyed it!
@quarteratom
@quarteratom 10 месяцев назад
Never knew the ESP32 had a full FreeRTOS running in the background always. It is well hidden, not showing when we write simple serial Arduino programs. And not only it manages the WiFi on one core, but it gives us a really easy way to write parallel code with tasks and queues and locks. Brilliant.
@AndreasSpiess
@AndreasSpiess 10 месяцев назад
I agree!
@hypnotourist
@hypnotourist 3 года назад
Wow ! That was really an eye opener for me. I had no idea we could use that. Thank you weird accent guy !
@AndreasSpiess
@AndreasSpiess 3 года назад
Glad you liked it!
@dennisp6337
@dennisp6337 2 года назад
excellent video. Multitasking is finally a reality in my projects!
@AndreasSpiess
@AndreasSpiess 2 года назад
Fantastic!
@CraigHollabaugh
@CraigHollabaugh 3 года назад
Excellent comprehensive example with code examination. I've used FreeRTOS on 10 or so projects. What you've covered here is probably 90% of FreeRTOS projects. If users can get through your example understanding these concepts, their spaghetti code will become readable, understandable and maintainable. One last thing, do NOT use arduino delay. It affects the scheduler and your code will stop working. Search your code and change delay to vTaskDelay. Thanks from Colorado.
@AndreasSpiess
@AndreasSpiess 3 года назад
Thanks for sharing your experience! One question: What does the Arduino delay() harm? I thought, it just takes up all the time in the task's slot (which is, of course, not ideal).
@CraigHollabaugh
@CraigHollabaugh 3 года назад
​@@AndreasSpiess I looked at the ESP32 FreeRTOS delay code. It implements Arduino delay with vTaskDelay, so on the ESP32 using delay should work fine. I believe my comment above deals the smaller Atmel parts, 328P, with limited timers. Seems like I remember using Arduino delay changes TIMER2 (may be incorrect here), that's the same timer used by FreeRTOS's scheduler. It may be different now, but back then Arduino's delay affected the scheduler. If this is incorrect or has changed, please comment below. I've switched to using STM32's for my designs which runs FreeRTOS just fine. Thanks again for the video, I'm always interested in what your doing (keeps me from having to figure things out), you do a wonderful and complete exploration.
@CraigHollabaugh
@CraigHollabaugh 3 года назад
On Linux Arduino 1.8.13, ESP32 delay implementation is here. ~/.arduino15/packages/esp32/hardware/esp32/1.0.6/cores/esp32/esp32-hal-misc.c void delay(uint32_t ms) { vTaskDelay(ms / portTICK_PERIOD_MS); }
@NextLevelCode
@NextLevelCode 3 года назад
You sir are a gentleman and a scholar. Well done as usual.
@AndreasSpiess
@AndreasSpiess 3 года назад
Thank you!
@Giblet535
@Giblet535 3 года назад
Great presentation, as usual Mr. S! Interesting trivia: Back in the 80's, there were multiuser OSes like MPM (a multi-user version of CPM) that didn't time slice. It's true! Each user had a dedicated CPU/RAM card, and the OS managed authentication, physical board allocation, and the shared permanent storage (SMD disks, mag tapes, and even 12-inch laserdiscs). Their 15MB disks were tiny miracles of miniaturization: usually 16 inches wide, 20 inches long, and 10 inches high.
@AndreasSpiess
@AndreasSpiess 3 года назад
You are right. We even had RTOS systems for one CPU back then. I never heard of such a concept where you had different CPUs managed by one operating system. For me this came later with the VAX/VMS multi-processor systems.
@d.hughredelmeier1960
@d.hughredelmeier1960 3 года назад
MP/m really did use time slicing on a single CPU. At least in most configurations. MP/m 8-16 seems to have supported multiple processors (typically one 8-bit and one 16-bit). I'd guess it also supported premption and time slicing. Multi-user without premption and time slicing is not really workable in general, but if you really dedicated one core per user it could work. What was the name of the computer system that you used.
@d.hughredelmeier1960
@d.hughredelmeier1960 3 года назад
@@AndreasSpiess commercial mainframes multiprocessors were available by the early 1960s. For example, the Burroughs D825. As far as I remember, the first multiprocessor VAXes were home-made at Purdue University and ran UNIX.
@waltsteinchen
@waltsteinchen 3 года назад
Amazing interesting video! Thanks a lot Andreas!
@AndreasSpiess
@AndreasSpiess 3 года назад
Glad you liked it! So it was worth the effort.
@santiagovelezflorez1634
@santiagovelezflorez1634 3 года назад
Thank you very much Professor Andreas super interesting the RTOS, I imagine many examples in which I can simplify the code design.
@AndreasSpiess
@AndreasSpiess 3 года назад
Very good. You will love it, I am sure.
@StarkRG
@StarkRG 3 года назад
The first time I heard about the concept of an RTOS was from someone I used to hang out with online who was part of the development team for the RTOS on some fighter jet (the F22, I think), then seeing RTOS as an option when compiling the Linux kernel, and, finally, FreeRTOS on the ESP32.
@AndreasSpiess
@AndreasSpiess 3 года назад
The concept is old (I used one in the 80s). But now with the abundance resources it is very easy to use...
@henrybecker2842
@henrybecker2842 3 года назад
This is a great session. Thank you very much :-)
@AndreasSpiess
@AndreasSpiess 3 года назад
Glad you enjoyed it!
@davidstonier-gibson5852
@davidstonier-gibson5852 3 года назад
Danke schön, noch einmal. I managed to get through a whole career in embedded controls without ever using a true RTOS. I started with bare-metal assembler in the early 70s, and retired the same way. I did during that time make many very simple superloop systems, and never wrote blocking code. As I have just transitioned from Arduino to ESP32, and in retirement started learning C++, I found this very interesting. One day I may just have to give it a spin.
@AndreasSpiess
@AndreasSpiess 3 года назад
As you write, you can do without it. But it is much easier to do it with one. We already used RTOS in the 80s for räsonable complex products. I am curious what your verdict would be after trying it...
@noweare1
@noweare1 3 года назад
I feel the same i.e. Is it worth the time to learn it and how much time to be fully understood? I think if you are into robotics where there are a lot of things going on it could be helpful. Most of my projects are pretty simple though.
@anthonvanderneut
@anthonvanderneut 3 года назад
Another video with a swiss accent, it must be Sunday! Thanks for providing a regular time reference in COVID induced "days without much distinction" otherwise.
@AndreasSpiess
@AndreasSpiess 3 года назад
You are welcome! Indeed it sometimes in not easy to distinguish weekends and weekdays with all this Home Office...
@dickesf8525
@dickesf8525 3 года назад
This video is super usefull! Thanks a lot!
@AndreasSpiess
@AndreasSpiess 3 года назад
Glad it was helpful!
@santopino2546
@santopino2546 3 года назад
Interesting as usual. Thanks Pity I don't have time now to test this out.
@AndreasSpiess
@AndreasSpiess 3 года назад
It takes some time to get acquainted... At least for me.
@ericwebster6911
@ericwebster6911 3 года назад
Great information. Thanks for the video.
@AndreasSpiess
@AndreasSpiess 3 года назад
You are welcome!
@ozzymandius666
@ozzymandius666 3 года назад
Excellent video. I'm a noob at this stuff, and I feel using RTOS is an excellent way to learn about the relationships between hardware and software, as well...
@AndreasSpiess
@AndreasSpiess 3 года назад
True. And it forces you to work on the problem before programming...
@padimixu
@padimixu Год назад
Another great presentation!... RTOS in a nutshell 🙂 --> BTW Anderas when you use Visual Studio there is an easy way to move the heavy .vs forder out of your Solution root: Tools > Options > Text Editor > C/C++ > Advanced In the section "Browsing database backup..." change the option "Use backup folder" to "True" and indicate a temporary forlder on your PC as "Backup folder" (the section names may be a bit different, my VS is in French...)
@AndreasSpiess
@AndreasSpiess Год назад
Thanks for the tip!
@Richardincancale
@Richardincancale 3 года назад
I used to do real-time programming 40 years ago using RSX-11 on PDP-11s. I can confirm that debugging can be challenging! One case I remember well - a multithreaded spooler sending output across a network to line printers all over the place. Once in a while a line for one would show up in the middle of output for another! Had to sit and watch for hours until spotting it happening - and send a message across the network to freeze the program so I could arrive in time to get a memory dump! Got it in the end!
@AndreasSpiess
@AndreasSpiess 3 года назад
Thank you for telling us the nice story! It shows exactly what I wanted to say.
@noweare1
@noweare1 3 года назад
I am not a big fan of interrupts and when writing more involved programs I am always trying to keep the loop time a low as possible. I need to do this project and just play around with the few commands that you used. Thanks for trimming down a very large amount of info into something we can use.
@AndreasSpiess
@AndreasSpiess 3 года назад
I also did not need interrupts (with the exception of the PS/2 library. 1ms was fast enough.
@kozlovskyi
@kozlovskyi 3 года назад
Cool! Appreciate that you trying to push asynchronous programing into embedded DIY areas.
@AndreasSpiess
@AndreasSpiess 3 года назад
Thank you! Maybe after this video a "pull" will result ;-)
@fhisg
@fhisg 3 года назад
To be fair, the NodeMCU (Lua) firmware has already been offering an async model on the ESP8266/ESP32 since 2015. Not based on FreeRTOS but on the Espressif NonOS SDK.
@warperone
@warperone 3 года назад
Well explained as usual Andreas.
@AndreasSpiess
@AndreasSpiess 3 года назад
Thank you!
@ed.puckett
@ed.puckett 3 года назад
Thank you, you are very inspiring!
@AndreasSpiess
@AndreasSpiess 3 года назад
You are welcome!
@Bianchi77
@Bianchi77 3 года назад
Cool video, thanks for the info :)
@AndreasSpiess
@AndreasSpiess 3 года назад
You are welcome!
@pedrobravo6972
@pedrobravo6972 2 года назад
Hello Andreas, here is the guy from Chile from ESP32 sitting in the first row of your class. I love the tests done with leds and semaphores. However, those of us who develop IoT systems need to have a template for REAL applications that separates slow tasks from fast ones through two threads. Example of slow tasks: - Establish a bluetooth connection - Connect and reconnect to WiFi and MQTT - Validate if there is MQTT connection - In case of alert, send an e-mail - Reception of orders or parameters from MQTT Example of quick tasks: - Sensor reading - Calculations with information from the sensors - Preparation of information that needs to be sent Do you have an example in which in Core 0, you handle the WiFi connection and the rest is handled in Core 1 (or vice versa)? The sketch is booted for me when I try to separate the WiFi connection and put it in the slow core. I have tried putting it in core 0 and core 1. Can you give us a solution that connects WiFi on a separate thread? It would be magnificent!!
@AndreasSpiess
@AndreasSpiess 2 года назад
I do not think that slow or fast is a good classification. I see all tasks as what they are: A task has prerequisites to run and leads to results. This is the first thing to design. Second is to find out whether some of the tasks are so time-critical that they have to be able to interrupt others. These get a higher priority. Third is "load balancing" where you distribute and assign tasks to cores. Often this is not needed and can be left to the RTOS. With the ESP32 we have to consider that some tasks already exist (like Wi-Fi) and run on a core with a high priority. They can influence your decisions. I would only go to step 2 and even 3 if you foresee or encounter problems. So your "slow" tasks all are low priority tasks and "quick" tasks have a higher priority. Keep in mind that no task runs for long because it is always interrupted by RTOS.
@seamusdemora5598
@seamusdemora5598 3 года назад
I loved the Einstein quote re resource allocation to problem vs. solution. And of course your observation about how the typical engineer allocates time is 100% "on target" in my experience. But you missed an opportunity I think - to remind engineers that the quality of their solution often improves when they allocate resources more like Einstein. :) Great video, BTW.
@AndreasSpiess
@AndreasSpiess 3 года назад
You are right. But I do not like to tell people what to do. I hope some learned from Einstein ;-)
@baconsledge
@baconsledge 3 года назад
Excellent...thank you!
@AndreasSpiess
@AndreasSpiess 3 года назад
You are welcome!
@RP6conrad
@RP6conrad 3 года назад
I use RTOS on the ESP32 for a gps-logger with a e-paper screen (GPS-speedsurfing). As the display routine was blocking (>0.5s), I was stucked... Then I discovered RTOS, and this was a fantastic tool to fix this problem ! Now the esp32 can receive, parse and store the gps data @ 10 Hz on a sd-card ! The display gives me the actual speed and distance. I still work with a lot of global variables, works fine for me !
@AndreasSpiess
@AndreasSpiess 3 года назад
A good application for an RTOS, indeed!
@ailijic
@ailijic 3 года назад
Thank you for making this video.
@AndreasSpiess
@AndreasSpiess 3 года назад
You are welcome!
@joska9744
@joska9744 3 года назад
Very, very interesting! Thansks!!
@AndreasSpiess
@AndreasSpiess 3 года назад
Glad you liked it!
@dd0356
@dd0356 3 года назад
Interesting topic. i will have to watch it again when i am more fit.. Just came out of covid fever, feeling weak..
@adilcoelho
@adilcoelho 3 года назад
been there a month ago.. take care and get an oxymeter to check on your saturation. If it goes lower than 90% please go to a doctor.. Even if you dont feel bad breathing, trust me
@AndreasSpiess
@AndreasSpiess 3 года назад
Glad to read that both of you survived! So far I had no problems and now, I go my first shot and some hope that I can avoid your experiences.
@haroldfinz4863
@haroldfinz4863 3 года назад
Good to know you're coming out of it, and to have enough strength to post about it.
@adilcoelho
@adilcoelho 3 года назад
@@AndreasSpiess the shot will surely help.. Glad youre getting it! Your videos are awesome
@dd0356
@dd0356 3 года назад
@@adilcoelho thanks for your tips. luckily my oxygen level was within safe limits. but i had fever for a very long time and consequently weakness..Here in India, this thing has taken worst direction, almost every fourth person is affected and hospitals are unable to cope up due to sudden increase especially in the last 2 weeks. Last year situation was better.
@JerryEricsson
@JerryEricsson 2 года назад
Greetings from snow covered South Dakota. We have just finished a 3 day blizzard here, lots of snow banks and blocked roads. No mail for 3 days as movement was impossiable even for our mail men. The snow plow just passed my house now at 1400! At last we can get out and shovel snow! Well the folks who can still shovel will get out. I am pretty much stationary any more. I am back among the living once more after having sunken down to the bottom of a well of depression when my lovely wife of 51 years died of cancer. I never knew one could fall so deeply so quickly! Thankfully I have a strong family and good doctors who dug me out of the well and have me again playing with arduinos and ESP units. I have been building my WIFI radios again, and have some nice looking products around my home built in old watch boxes as well as rebuilt old IPOD amplifiers where I built the wifi units and pulled power from their amp power supplies giving me some wonderfully deep sounding systems. I have them programed with music and programs from the 40's through the 80's limiting my station load to around 50 discrete channels. I wanted to thank you for the prayers and caring when I was caring for my wife, it helped.
@AndreasSpiess
@AndreasSpiess 2 года назад
I am glad to see you here again! Bad luck with the snow in your area. Here we had a very mild winter and now spring is here with nice temperatures. So I am pretty sure that the snow also will go away soon where you live. And I am sure it will help you if you see the flowers and can go outside again. And of course, good music is a very important ingredient!
@-highvoltage4685
@-highvoltage4685 3 года назад
thank you for talking about the hidden esp32 secrets and wonders :)
@AndreasSpiess
@AndreasSpiess 3 года назад
You are welcome!
@rinokentie8653
@rinokentie8653 3 года назад
Great stuff!
@AndreasSpiess
@AndreasSpiess 3 года назад
Glad you think so!
@zyghom
@zyghom 3 года назад
not only I was in the army but also I learned there Morse code as it was still a time to send all the communication over it - what a time it was!!! ;-)
@AndreasSpiess
@AndreasSpiess 3 года назад
I learned Morse in military, too!
@John_Smith__
@John_Smith__ 3 года назад
Very good Video no doubt Andreas!
@AndreasSpiess
@AndreasSpiess 3 года назад
Thank you!
@alexanderm6862
@alexanderm6862 3 года назад
Great content, thanks
@AndreasSpiess
@AndreasSpiess 3 года назад
Glad you liked it!
@Adrzah
@Adrzah 3 года назад
Awesome stuff
@AndreasSpiess
@AndreasSpiess 3 года назад
Thank you!
@niraami
@niraami 3 года назад
As a fulltime ESP32 programmer (for 3 years now), I've found that if you want to save yourself a lot of headaches and constantly hitting limitations then either use Arduino as a component under ESP-IDF, or just don't use it at all and use ESP-IDF functions directly. Also utilizing the ESP-IDF & FreeRTOS documentation is quite important, as you learn a lot of crucial things like that a delay of 65ms (15:40 :)) is not actually a thing, it will probably block for 70ms :) you can find out how on your own edit: my last point may be inaccurate, as after a bit of research it seems that arduino might have changed the default value (100) to 1000hz, making 1ms tick resolution possible.
@AndreasSpiess
@AndreasSpiess 3 года назад
You can be sure I checked the timing of my Morse signals ;-) You also saw it on the logic analyzer. Anyway, using manufacturer's IDE is for sure a better decision if you only work with one architecture. I use at least three architectures. So , the Arduino IDE is ok for me. And I also do not create sellable products.
@niraami
@niraami 3 года назад
@@AndreasSpiess Good points indeed, I guess my situation is more of an exception. Also yeah, I edited the comment when I saw the 1ms resolution on the scope ;)
@fabianh.5848
@fabianh.5848 2 года назад
"Guru Meditation Error" is a gag from the old Commodore Amiga. I like it.
@AndreasSpiess
@AndreasSpiess 2 года назад
I did not know that. Thanks!
@fabianh.5848
@fabianh.5848 2 года назад
@@AndreasSpiess whenever the diskette didn't work or a program crashed. That was a gimmick by the programmers.
@berndeckenfels
@berndeckenfels 3 года назад
Great summary.
@AndreasSpiess
@AndreasSpiess 3 года назад
Thank you!
@maxdido6226
@maxdido6226 3 года назад
Great video, thanks for sharing this - I was used to C parallel programming on high performance computing, finding the similar concepts here makes me feel younger 😊
@AndreasSpiess
@AndreasSpiess 3 года назад
Glad you feel young! Here it is spring. A perfect time for that. These concepts are not new. We had RTOS in the 1980s already. But now they are much easier to use because we do not encounter limitations on the ESP32.
Далее
#425 GitHub Tutorial without using the Command Line
16:04
Это iPhone 16
00:52
Просмотров 620 тыс.
ТЫ С ДРУГОМ В ДЕТСТВЕ😂#shorts
01:00
#363 Which ESP32 pins are safe to use?
11:53
Просмотров 128 тыс.
Hacking a weird TV censoring device
20:59
Просмотров 3 млн
Cracking Enigma in 2021 - Computerphile
21:20
Просмотров 2,4 млн
The Micro Mechanisms in Your Phone
19:31
Просмотров 1,2 млн
Лучший браузер!
0:27
Просмотров 1,1 млн