#381 How to work with a Real Time Operating System and is it any good? (FreeRTOS, ESP32)

#381 How to work with a Real Time Operating System and is it any good? (FreeRTOS, ESP32)

Andreas Spiess

3 года назад

235,559 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@Robotsreloaded
@Robotsreloaded - 06.09.2021 20:25

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 😁

Ответить
@meierthomas
@meierthomas - 27.09.2021 18:23

Conceptual question: Could I use freeRTOS to implement a HC-SR04 sensor which is fundamentally different to say a temp sensor given it implements a trigger/echo timing to return the distance? I think the answer should be yes as long as the allowed task time > than the timing required for the sensor to return the distance. With the default portTICK_PERIOD_MS of 1ms this should be more than enough as a the sensor requires a bit more than 10us to return the distance value, agree?

Ответить
@TOMTOM-nh3nl
@TOMTOM-nh3nl - 07.10.2021 15:06

Thank You

Ответить
@LemarinelNet
@LemarinelNet - 28.10.2021 13:10

I would add that you probably NEED RTOS as soon you start writing state machines to allow multiple parts of your sketch running parallel. That's what I was doing before knowing RTOS !

Ответить
@FF7824
@FF7824 - 28.10.2021 21:21

Beautiful explanation! (As always). I wish the real time features were as easily available on a Raspberry Pi. I know they are working on it (PREEMPT_RT merge into the standard Linux) but I don't think it has been perfected as yet. I would love having the usual Linux features available as low priority tasks while I safely handle real time tasks like driving motors or responding to sensors.

Ответить
@semihk09
@semihk09 - 29.10.2021 23:55

You are my inspiration. I admire your effort to make your work attractive and easy to make and at the same time professional.

I am at a critical threshold. And I'm here to ask you a question . I'm new to c and embedded systems. As you said, I don't want to use arduino ide. What I'm looking for is actually when I'm encoding stm32 I want to have options like . So, whether it's hal library, std library or drivers, it's like writing machine code by myself.

I am working on a project and my time to complete the project is a bit limited. Some tasks can take time to understand and put into practice as I think I am in the beginning phase. I think the difficulty coefficient is very high when freertos is also involved . Is it possible when coding in a std periph style encoding path (like in stm32) without using freertos? Or how right do you think it is to think this way.

I think about all these because my time is a bit limited. That's why I was very undecided. Yes, I think I am aware. If I want to continue on this path, I will have to learn freertos. I am not afraid of it . I'm just afraid that I will miss the end of the rope while learning freertos and not be able to complete the project on time. If you say, "No, son, don't do it, start freertos now. I'm ready to paint my face blue and fight for freedom :) What do you think I should do. How can this boy save the girl in the castle in this scenario? :) (I used exaggerated sentences. Wrong terminology unknowingly I apologize to everyone if I used it)

Ответить
@dennisp6337
@dennisp6337 - 01.11.2021 22:17

excellent video. Multitasking is finally a reality in my projects!

Ответить
@kjyhh
@kjyhh - 10.11.2021 02:55

Thank you so much. This is a great video. Your chanel is perfect for sharing this. Multi task MCUs is the future in like robot, iOTs. its useful!

Ответить
@Alex000113
@Alex000113 - 12.11.2021 00:55

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.

Ответить
@facundofarall7716
@facundofarall7716 - 22.11.2021 05:25

Very useful and well explained video, thank you so much!

Ответить
@tomaszwota1465
@tomaszwota1465 - 04.12.2021 22:24

"If you're good, you get more work"
That can be true outside of military too.

Ответить
@robustta5898
@robustta5898 - 16.12.2021 11:58

i hope cluster of esp32 can run windows 10

Ответить
@vks002
@vks002 - 26.12.2021 19:25

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 :)

Ответить
@DAVIDGREGORYKERR
@DAVIDGREGORYKERR - 02.01.2022 15:02

Can you use something like a message pump so that depending on the message a related routine is executed...

switch(Event.Type){
case 0: {
routine0(); break;
}
case 1:{
routine1(); break;
}
default:{
break;
}
}

Ответить
@fabianh.5848
@fabianh.5848 - 17.01.2022 10:15

"Guru Meditation Error" is a gag from the old Commodore Amiga. I like it.

Ответить
@patrickshaw8595
@patrickshaw8595 - 30.01.2022 07:46

Fun Fact you can't run a real time OS on any PC later than an 80386 because of System Management Mode.
Correction: You can - but if you need precision it is a fail.

Ответить
@jurjenbos228
@jurjenbos228 - 04.02.2022 09:52

Fact: The Apollo Guidance Computer (AGC) also was a RTOS, in every sense of the word.

Ответить
@fromgermany271
@fromgermany271 - 04.02.2022 22:45

„Real-time“ does not mean „fast“.
It means „always fast enough“.
For typical MC projects this time is measured in milliseconds (or less), but there are Real-time areas where multiple seconds are OK. As long as we never miss the deadline.

Ответить
@MauroMaccarone
@MauroMaccarone - 17.02.2022 21:59

Never die my hero! a lot of love from Argentina

Ответить
@alec73
@alec73 - 01.03.2022 19:24

Hi Andreas, I'm a newbee regarding the use of the ESP32 MCU and I'm experiencing some problems trying to upload sketches using the Arduino IDE. I believe I've followed all the steps required to be able to use the Arduino IDE for uploading sketches to the ESP32. However there's an issue that I'm not able to resolve and I hope you can guide me in the right direction.
The problem I'm having is that after uploading a sketch into the ESP32 (any example from an ESP32 specific library) the ESP32 keeps rebooting without any attempt to run the sketch. A message in the serial monitor states the following:

Running on single core chip, but application is built with dual core support.
Please enable CONFIG_FREERTOS_UNICORE option in menuconfig.

I opened the menuconfig and the only option I see is to enable the ESP32 to run on only one core... so I'm assuming that by default the ESP32 is already running on two cores. To be sure I tried both options, but neither seem to have any effect and the error message keeps popping up in the serial monitor.

The board that I'm using is the ESP32-DevKitM-1 v1.0 which has the ESP32-MINI-1. I don't if it's relevant but I also installed the VCP driver (windows 10) for the CP2102N.


My questions are:

First being obvious... What am I doing wrong here? ;-)
Second: Is there any way to run a sketch on the ESP32 without having to use the multiple task method as described in the numerous FreeRTOS tutorials? (while the examples in the ESP32 libraries do not contain multiple tasks)

Thanks in advance...

Alec

Ответить
@dguedel
@dguedel - 04.03.2022 10:23

Dear Andreas,
thank you very much for your instructive contributions to ESP32. Currently I am facing the challenge to play RTTTL ringtones under FreeRTOS. Do you have any experience with PWM outputs on buzzer using FreeRTOS? Every hint could help further ;-). Thanks a lot.
Kind regards,
Daniel

Ответить
@immortalsofar5314
@immortalsofar5314 - 18.03.2022 03:54

I'm kind of in two minds about this. I hate the spaghetti code in most Arduino libraries so I wrote a thin layer of firmware:Device:abstract layer for the hardware. Very thin, very lightweight, kind of a minimal OS, I suppose but with very little overhead.

Ответить
@joecox9958
@joecox9958 - 06.04.2022 19:45

too general, so nothing with FReeRTOS or ESP32, incomplete code makes little practice.

Ответить
@stevesfascinations1516
@stevesfascinations1516 - 09.04.2022 03:33

Really well explained, thank you very much! Thumbs up!

Ответить
@JerryEricsson
@JerryEricsson - 14.04.2022 23:10

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.

Ответить
@JerryEricsson
@JerryEricsson - 14.04.2022 23:15

Oh your info on this RTOS system reminds me of my college days back in the early 90's. Our computer labs were made up of 486 machines running DOS and WINDOWS 3.1 that nobody used much except to play with as a sort of DOS file system manager. Then we had Intro to UNIX! That was cool because using those old machines we could go into the network and sign onto the School's Mainframe machine in UNEX and do some real computing in an Operating system where all who were in the lab at one time 25 computers could sign into the Mainframe and tinker around with the Unix system. I still keep a Linux partition on my laptop and get into it when my anger at Windows exceeds my desire to get work done.

Ответить
@awesomedee5421
@awesomedee5421 - 07.06.2022 13:03

I sat in the front row, but I still didn't get it all.

Ответить
@ingridtorreslopes7838
@ingridtorreslopes7838 - 07.07.2022 13:49

Hi! I have been watching your videos about esp32 and find them very good! Do you have anything about sending data with MQTT from sensors reading on diferent cores? I am trying to use one core to read a LiDAR sensor and the other to read a GPS module, but now i can read the sensors well but have problems sending the data to the broker. I believe the client keeps disconecting but i dont know why.

Ответить
@AdaptivePhenix
@AdaptivePhenix - 05.08.2022 09:44

Those who are aware of the Parallax Propeller are rolling on the floor, laughing 🤣😂

Ответить
@pedrobravo6972
@pedrobravo6972 - 08.08.2022 12:22

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!!

Ответить
@andreameparishvili5468
@andreameparishvili5468 - 10.08.2022 00:53

the power of powerpoint

Ответить
@Brkge
@Brkge - 25.09.2022 10:46

Andreas: what do you think about ESP32's stability for industrial projects?

Ответить
@padimixu
@padimixu - 15.10.2022 09:37

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...)

Ответить
@jodeling35
@jodeling35 - 26.01.2023 16:28

As always: Great Work, Andreas! Thx!

Ответить
@michaelkaercher
@michaelkaercher - 10.02.2023 20:00

I used RTOS on the ESP32. It is a nice clean approach. But it is not easier compared to a standard sketch. Just much cleaner for software architecture. I like it.

Ответить
@zyroxiot9417
@zyroxiot9417 - 27.02.2023 00:42

Hi Andreas, thanks by the video.

Ответить
@rongarza9488
@rongarza9488 - 17.07.2023 18:16

Great video, Andreas, but this is multitasking, not parallel processing (correct me if I'm wrong). In true parallel processing, each core would not time slice at all. Each core could post to and read from global variables, if it needed to communicate with another core process. Otherwise, each core is in a world of its own.

Ответить
@TB-jl9fr
@TB-jl9fr - 20.07.2023 19:06

Thank you Andreas, i love the way how you explaining things :)
How can one start creating this kind of bubble diagram you showed ? With the tasks and queues... Is there some kind of systematic way or maybe even a graphical software?

Ответить
@fromgermany271
@fromgermany271 - 31.07.2023 22:09

Be cautious with the „only one writer“ idea. This does not work, if you have multiple cores and writer and reader are running in parallel. In such a case, only variables, that are atomic by design, e.g. a 32-bit value on a 32-bit machine, are save. Anything longer (and potentially also shorter, packed in structures) will create nasty errors.
Not likely here, but you even can get it if the scheduler switches tasks in between the „multi-atom“ update on a single core.
More cores and high use of the variable increases the likelihood of such a failure.
But especially such „happens rarely“ issues are a nightmare. ESP32 applications might not have an Alt-Ctrl-Del user available to fix the issue in a <add major brand> way. Or the application might just not want the watchdog to kick in.

Ответить
@quarteratom
@quarteratom - 07.10.2023 10:47

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.

Ответить
@user-mr3mf8lo7y
@user-mr3mf8lo7y - 02.05.2024 05:38

RTOS is most likely not too practical for most of Arduino community.
Your video, 22'04: RTOS is actually not designed to run processes in parallel. Other OSs, or, state-machines in Arduino can do way better job.
A misconception - Real-time OS does not necessarily mean running processes in real-time conccurrently, period.
Rather, running processes in a fixed and guarenteed length of time.
For instance, in a car assembly line a robot tightens a bolt in 2 seconds (fixed), then, moves onto next task and does something say in following 4 seconds. The motor controllor of belt is programmed as such, and, moves (or, stops) the belt in those fixed time-slots. Another example in heathcare. Say, a patient needs a medication for 15 minutes (fixed) after intitation, etc.. Thanks,.

Ответить
@PuretyLead-bg5wv
@PuretyLead-bg5wv - 04.05.2024 19:33

Many thanks for this privilege, taking tod take care of possible challenges and also return to answer issues @ commentNity.

Ответить
@vincentlin7240
@vincentlin7240 - 18.05.2024 07:53

One of the best RTOS video to start with, than you so much for making these! Also, love the jokes and the metaphors!

Ответить
@FullToki
@FullToki - 26.08.2024 07:09

Clark Eric Martinez Sharon Thomas Edward

Ответить
@AndreasSpiess
@AndreasSpiess - 25.04.2021 11:35

Correction: ISR is Interrupt Service Routine, not internet service routine

Ответить