#149

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

Ralph S Bacon

Ralph S Bacon

Күн бұрын

Пікірлер: 383
@GeekMustHave
@GeekMustHave 5 жыл бұрын
Very nice video on running multiple threads on the two cores of the ESP32, I had no idea how but, now I do. Thanks. Keep broadcasting!!
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, GeekMustHave, noted and appreciated!
@george12121979
@george12121979 5 жыл бұрын
very usable. in a very simple way how exactly the two-core system works in esp32. It is a very interesting field for applications of esp32 and would like if you can continue on this field.
@RalphBacon
@RalphBacon 5 жыл бұрын
And continue I will, George! Stay tuned!
@peterheartfield8106
@peterheartfield8106 5 жыл бұрын
Thanks Ralph. Great video, yes please do more.
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, Peter Heartfield, noted and appreciated!
@neverendingrefit759
@neverendingrefit759 5 жыл бұрын
Great stuff, and yes please, more like this! Lots blogs etc about esp blink but not so much dipping your toe deeper into the ESP32
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, Boat data systems, noted and appreciated!
@bipolarchemist
@bipolarchemist 5 жыл бұрын
I've never (knowingly) tried this for processes running on different cores, but you might be able to use a variable of portMUX_TYPE to handle synchronization between the cores. Any variables you plan to change between cores might need to be declared volatile and then you add some wrappers around the variables to you want to modify to keep them from being modified by various processes at the same time. // Declared globally portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED; // In function to modify shared variables portENTER_CRITICAL(&mux); // modify/update variable here portEXIT_CRITICAL(&mux); This works great for interrupt handlers and might work with multiprocessor task as well.
@Thomas72B
@Thomas72B 5 жыл бұрын
Very interesting Video ! Please more videos about the ESP32 !
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, Thomas, noted and appreciated!
@ytbone9430
@ytbone9430 5 жыл бұрын
Thank you Ralph! o) I'm new to the microcontroller space and I really like your videos. The way you talk and present, it's very pleasant to watch and learn. I wouldn't mind more coding related videos. I am a software dev myself, but I have issues understanding on how to throw all the things together in loops/interrupts (say you want wifi, mqtt, config via webserver, read multiple sensors and drive a display with menu at the same time). Doing this on a microcontroller is quite different to desktop development, I surely have a lot to learn, thank you for getting me started. o)
@RalphBacon
@RalphBacon 5 жыл бұрын
And I'm glad to have you along, ytbone! If you're a dev then programming the Arduino and similar µControllers is not going to be difficult. In fact, the ESP32, with its operating system, feels like home to me! Keep tuned for further videos...
@libertywool
@libertywool 5 жыл бұрын
Instead of doing delay(1) in your main Arduino loop, you can use taskYIELD() to let the scheduler know to go do other more important work (Ready tasks with a priority equal to or greater than your task). Because, as you mentioned, in Arduino the main loop is just called repeated from an outer method, the scheduler does not stop running that task unless we allow it (unless we are running the preemptive scheduler). So that will work for core 0, but not core 1. Now since the Arduino loop is running on core 1 with priority 1, calling yield will not work if your task is on core 1 with priority 0, as that is less than the current priority. So to make the task run on core 1, change the priority to 1 or greater. Then calling taksYIELD() will run the task on core 1. And this also takes me back to why delay(1) works. Delay is going to pause the current task (Arduino loop) and yield control to the scheduler. This will put the Arduino loop task into a blocked state (ie not Ready), so the scheduler will then run lower priority tasks (ie your core 1 priority 0 task). Hope that helps explain what you were seeing...
@vonries
@vonries 5 жыл бұрын
I hate showing my stupidity so early in the game, but wtf? It sound very informative, but I have no idea what you're talking about.
@mikelopez9893
@mikelopez9893 5 жыл бұрын
+vonries A real time operating system splits work into several tasks which share cpu time. Tasks can be in one of several states (blocked, ready to run, running). The system has a timer and the scheduler gets control each timer tick. It suspends the current task and switches to the highest priority task in ready state. The esp32 has two cores: protocol (#0) and application (#1). It runs a modified version of free RTOS. Each core has its own scheduler and the two cores are NOT synchronised. For example disabling interrupts on one will NOT disable interrupts on the other and does NOT protect data from corruption. Communicating across cores needs expert knowledge - lots of traps for young players! There is some good info on all this at docs.espressif.com Ps: the 8266 also has RTOS not just the esp32
@vonries
@vonries 5 жыл бұрын
@@mikelopez9893 thanks, very cool.
@RalphBacon
@RalphBacon 5 жыл бұрын
Since doing this video, Toby, I've been looking into this a bit. Yes, a typical British understatement if ever you heard one! *taskYIELD()* doesn't give the expected results, I'm afraid, as neither does *vPortYield()* which is what taskYIELD() expands to. Whilst we're on the subject, *yield()* doesn't do it either as that just calls vPortYield(). What I've discovered is that if we _really_ don't want to use the standard loop() then just execute a *vTaskDelete(NULL)* to get rid of it once and for all. Everything else just keeps running as expected. However, I've begun to use loop() as a "master" controller in some of my sketches that can control things (eg suspend/resume tasks, very useful) and keep a watching brief on what is happening. Task orchestration, if you will, which reminds me strongly of an event listener framework I developed for work using JavaScript. What goes round comes around... More of this and other stuff in a future video! Thanks for your input, Toby, you have a lot of experience in this area and your continued feedback is greatly appreciated. Nice to hear from you.
@mikelopez9893
@mikelopez9893 5 жыл бұрын
Ralph S Bacon I think the issue is just priorities. TLDR - use priority 1. Here’s the espressif scheme: Priorities 10 to 14 are reserved for the system. For example, 14 is the watchdog timer, 10 is the TCP/IP stack. Priorities 1 to 9 are for general use. For example, WiFi events use priority 2. Priority 0 is the idle task. There are three ways a time slot can end. 1) it can voluntarily yield and the state goes to ready. 2) it can block waiting for something to happen - the state goes to blocked. 3) The time is used up - the state goes to ready. At the end of the time slot the scheduler takes the highest priority task in ready state and runs it. If several ready tasks have the same priority they are allocated “round robin” (but see caveat below) Caveat: the above is correct for the esp8266, but the esp32 does not have a complete multiprocessor implementation of free RTOS and can not guarantee equal round robin treatment across cores. I am concerned that you used priority zero which is reserved for idle. Essentially you are telling the system “nothing important to run here”. Hope this helps.
@John_Smith__
@John_Smith__ 5 жыл бұрын
Oh yes, ESP32 is a great great platform ! We would all love to see inter-task communication ... passing arguments and data.
@RalphBacon
@RalphBacon 5 жыл бұрын
Yes, that will be "interesting", John. Keep tuned. Thanks for posting.
@andymouse
@andymouse 5 жыл бұрын
Hi, speaking of ESP32's an Australian KZbinr who has a great channel called "The Unexpected Maker" has spent about a year designing a product called "TinyPico" Its as the name suggests a very small ESP32 development board, and I and many others have been watching the highs and lows of his design and thanks to crowd supply (and enormous effort on his part) is being shipped, I highly recommend that you have a look at his "TinyPico" as it really is feature packed, plenty of IO and he has a fully matched 3D antenna on there for outstanding WIFI performance. Take a look at his channel lots of interesting stuff....especially for ESP32's!
@RalphBacon
@RalphBacon 5 жыл бұрын
And look I did, Andy, very interesting. I shall read (and watch) some of his videos when time permits. For others, here's the link: unexpectedmaker.com/tinypico
@tomwatzek3500
@tomwatzek3500 5 жыл бұрын
Nice Video, thank you. I would be happy if you do another video an go more into detail. - like how to get variables from on core to the other.
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, Tom Watzek, noted and appreciated! Variables from one _task_ to another (the core is irrelevant) is the subject of my next video, Tom. Oh, perhaps I should not have said that.. spoiler alert! Too late!
@la6mp
@la6mp 5 жыл бұрын
Really good stuff, Ralph! It is nice to go a bit under the hood of devices we often use without knowing what they are really capable of.
@RalphBacon
@RalphBacon 5 жыл бұрын
You are most welcome John, I'm glad you like the video. Nice to hear from you.
@paulyorke1437
@paulyorke1437 5 жыл бұрын
I've been subscribing to your channel for a few weeks now Ralph. Excellent work and at a pace I can cope with. Brilliant. Just bought a couple of these ESP32s and started with your RTC sketch. Now can't wait for next episode re sharing variables between cores. Yes, more on the ESP32 please !!!
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, Paul, noted and appreciated!
@noweare1
@noweare1 5 жыл бұрын
Another worthwhile video. Count me in for more esp32 vids. As far as the speed difference ... that's just mind boggling.
@RalphBacon
@RalphBacon 5 жыл бұрын
Yes, Joey, it took me by surprise, actually. I wondered what I had done wrong! I even include some debugging statements in the code and it whizzed through so quickly it was amazing. Amazing chip.
@magic.marmot
@magic.marmot 5 жыл бұрын
Oh my, thank you so much! I work with FreeRTOS all the time on the professional side, and have some ESP-32 boards for experimenting and making new things at home. This gives me a whole 'nother level of being able to mix the two "under the hood", and has opened up a whole new bunch of ideas on how to meld the two.
@RalphBacon
@RalphBacon 5 жыл бұрын
With your RTOS experience you should be quite at home with the ESP32 then, Rob. The Arduino-style implementation doesn't expose all RTOS functions but if you read the Espressif web pages they tell you what to edit in their implementation header files to add functions. You might even prefer the ESP-IDF development environment. docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html Fun times ahead!
@robertnovak1602
@robertnovak1602 5 жыл бұрын
Hi Ralph, I really enjoy watching your videos, so thank you for sharing. The reason that putting nothing in loop() would result in your program doing nothing is because a "function" is just a location in memory which happens to contain instructions. Those instructions are generated by the compiler. If your function doesn't have any instructions, it would be effectively just a "jump" and "return", or possibly a "call" instruction (in fancier instruction sets). Basically, because the function doesn't have any content, when it generates the binary/executible, since it is optimizing for space, it most likely doesn't include that function, or won't provide an actual definition for it (different compilers and different optimization profiles will do different things, so I can't say precicely what it will do). Keep up the explorations, like I said, I really enjoy them.
@RalphBacon
@RalphBacon 5 жыл бұрын
Yes, it's unclear whether the compiler would optimise an empty loop away (you would hope it would) and if so the task handler could not start the expected (default) loop task. That might crash the chip I suppose. I've just deleted the task in other sketches if I don't want the default loop(). Thanks for posting, Robert, good to hear from you.
@robertnovak1602
@robertnovak1602 5 жыл бұрын
Depending on how obsessive you want to be, you can take a look at the ELF binary that gets generated, and see exactly what's getting created. It's not something I really enjoy doing, but it is usually enlightening. A very quick way to verify without looking at the binary itself would be to look at the size of the resulting binary with and without the delay added to loop(). If there's a massive size difference, you can be reasonably sure that the compiler is simply optimizing away most of the program. My thought would be that if loop() didn't contain any instructions, not only would the compiler remove the "call loop()" instruction, but it in theory should (being that it's C) optimize away most of even the basic wrapper program. Perhaps an example might illustrate: Suppose the "wrapper" program looks like: void main() { setup(); while(1) { loop(); } return; } if loop() is empty, that goes away, and the compiler is left with an additional empty while(1) loop. This also should get optimized away, and thus main() would become: void main() { setup() return; } resulting in the board not crashing per-se, it just essentially finishes the entirety of the task. anyway, I'm just some dude on the internet so feel absolutely free to take with a grain of salt.
@RalphBacon
@RalphBacon 5 жыл бұрын
I'm thinking that the ESP32 (RTOS) would start the task handler for specific tasks (one of them being loop) but if the loop did not exist it may do weird and wonderful things. Eventually we will find out, I'm sure.
@michaelhyde9971
@michaelhyde9971 5 жыл бұрын
Great video as usual. I was thinking about getting an esp32 now I will thanks :)
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, Michael Hyde, noted and appreciated!
@hmb2a
@hmb2a 3 жыл бұрын
Thank you, Ralph. Not only the contents but also the effects of your video are excellent. Please continue.
@RalphBacon
@RalphBacon 3 жыл бұрын
Thanks, will do! Well, once my house move has completed and I have a new workshop!
@wires4auto
@wires4auto 5 жыл бұрын
Fantastic! Ralph. I think this should be the second microcontroller board newbies get, the Delay fuction is so evil to beginners, and can hold them back. I would really like to see more of this board in the Arduino IDE, using Bluetooth fuction and passing information between the two cores. Thanks again.
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, gordon, noted and appreciated!
@ianstubbington2334
@ianstubbington2334 4 жыл бұрын
Great video for getting started with esp32. More please ;)
@RalphBacon
@RalphBacon 4 жыл бұрын
Thanks, will do!
@OsoPolarClone
@OsoPolarClone 5 жыл бұрын
Ralph another awesome video. I have seen other ESP32 videos but yours is the BEST! You did things I have never seen before. AWESOME!!!!!!
@RalphBacon
@RalphBacon 5 жыл бұрын
Wow! I'm glad you enjoyed the video, Bruce. It's a subject that is interesting for quite a few people. I shall have to do at least one further video.
@heyok
@heyok 5 жыл бұрын
Ralph, thank you for the time and effort you put into this as I really appreciate it. I always seem to learn something.
@RalphBacon
@RalphBacon 5 жыл бұрын
Thanks for that, heyok, nice to hear from you.
@marinehm
@marinehm 5 жыл бұрын
Ralph: Thank you so much for your videos! I bought my ESP32 when they 1st come out but at the time there was limited support. Now I feel confident I can load the board definitions into my IDE and press forward.
@RalphBacon
@RalphBacon 5 жыл бұрын
Quite right, Nick, when I did my first video on the ESP32, I remember them being a bit temperamental. And support was hit and miss. Now though, 55 videos later, I too feel that they have come of age. Keep tuned for further videos...
@robingiles399
@robingiles399 5 жыл бұрын
What a great video, looking forward to more ESP32 videos, area of interest are around maximising power saving capabilities, this unit is great, Perhaps looking at the ESP-PICO-D4 as well..
@RalphBacon
@RalphBacon 5 жыл бұрын
Thanks for that, ROBIN GILES, nice to hear from you.
@Trevor30926
@Trevor30926 5 жыл бұрын
HI Ralph, very interesting video. I have just ordered a couple of boards. Please keep this type of video coming, The more the merrier.
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, Trevor30926, noted and appreciated!
@TheZrpilot
@TheZrpilot 5 жыл бұрын
Very much enjoy this and ALL your videos Ralph... would like to see more!! Thanks!!!!
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, Max, noted and appreciated!
@prlombaard
@prlombaard 5 жыл бұрын
Hi Ralph, really enjoying your video on using freeRTOS with the ESP32. Although there is other videos out there this one explains it very well. Good introduction. Please create more such videos where you are using different mutexes and other such constructs. For exmaple like using a shared resource like SPI bus, this would give a good practical example of where such constructs are used. Even though the ESP32 have HSPI and VSPI if you for instance only connect all SPI devices on HSPI then you need some way of sharing this resource, and this is where mutexs work very well so that only one task can access the SPI bus at any one time.
@RalphBacon
@RalphBacon 5 жыл бұрын
Glad you liked it, Rudolph, and your comments on sharing the SPI bus very valid. Programming becomes much more tricky with threaded tasks - a simple mutex omission and the SPI bus is totally corrupted! It's something I will consider for a future video, thanks for the suggestion.
@deangreenhough3479
@deangreenhough3479 5 жыл бұрын
At work and yet to see. But boy, I’ve been waiting for this one. Well done Ralph😁🏴󠁧󠁢󠁥󠁮󠁧󠁿
@RalphBacon
@RalphBacon 5 жыл бұрын
I hope your expectations were met, Dean, and stay tuned for further videos.
@abboberg987
@abboberg987 5 жыл бұрын
Today i learned a lot; ESP32 has 2 cores and we can use it! Thanks Ralph
@RalphBacon
@RalphBacon 5 жыл бұрын
We can use two cores with care, André, as you will hear in my next video. Multitasking is a great liberator and at the same time a minefield. Keep watching!
@michaelbyron9688
@michaelbyron9688 5 жыл бұрын
Ralph, AWESOME video. The ESP32 is the processor to use today. how about a video on the sharing of variables between the two processors, going both ways.
@RalphBacon
@RalphBacon 5 жыл бұрын
Hmm, I wonder what could be the topic of my next-but-one video, Michael, I wonder... Nope, can't figure it out. We shall just have to wait and see.
@davidharms3562
@davidharms3562 Жыл бұрын
Still enjoying these videos Ralph! Keep up the great work, good sir! 👍🏻
@RalphBacon
@RalphBacon Жыл бұрын
Glad you like them!
@michaelbishton9439
@michaelbishton9439 5 жыл бұрын
I've programmed a bit in other languages pre-IoT and am transitioning to the world you reflect here. I really like your clear and thoughtful approach to explaining things. I know (perhaps) just enough to see that you are using functions with parameters that pass information. May I suggest that when you use a function (like xTaskCreatePinnedToCore), you include a link to it's library that lists all of the functions, parameters, and what they do? That way, advanced beginners like me can more quickly build on what you teach without trying to find the libraries you are already using. I've used Adafruit tutorials that show functions with links to (what looks to me to be) partial libraries or incomplete explanations, which limit their functionality. Many thanks!
@RalphBacon
@RalphBacon 5 жыл бұрын
Point taken, Michael, although in this case it's not so much a library as an entire operating system Free RTOS. It's been modified, somehow, by Espressif for this chip (not sure of the differences) but RTOS is well documented and there's a downloadable Reference Manual pdf too: www.freertos.org/Documentation/RTOS_book.html I hope this helps!
@michaelbishton9439
@michaelbishton9439 5 жыл бұрын
@@RalphBacon Thank you very much, it does. Please keep doing that so that people can look up the full list of functions.
@Ed19601
@Ed19601 5 жыл бұрын
Just got myself a few esp32's so I will be revisiting this
@RalphBacon
@RalphBacon 5 жыл бұрын
Yes, indeed, Ed, it's quite interesting what you can do with them.
@henrikjensen3278
@henrikjensen3278 5 жыл бұрын
Interesting video, I have played a bit with the ESP32, but have not studied it and did not know it had a RTOS. With a RTOS it means you could run both your task on the same processor, you do not need to distribute it on two processors to run them in parallel. One big advantage for ESP is 32 bit architecture, it means anything but byte variables will be faster on it by more than the clock speed. The speed increase in your test was insane, there must be many factors to get that much. One detail I did find out about the ESP32 is that programs are stored in a serial memory and it will use a serial protocol to read the program. This reading is fast, but much much slower than the processor, it uses a internal cache to prevent much delay while running the program.
@RalphBacon
@RalphBacon 5 жыл бұрын
Shh, don't spoil my next video on parallel task, Henrik! Yes, of course you can run multiple tasks on a single core, and as RTOS is running WiFi and BT tasks (among others) on Core 0 it's probably wise to treat core 0 with serious respect (memories of watchdog resets come to mind when I was coding my ESP8266 deice). You are correct about busses of any kind slowing down the processor - caching helps of course, but there's a limit and my first video #95 of the ESP32 driving a MAX7219 display was _very_ slow (caused by the stupidly slow I2C - or was it SPI? - bus setting). Anyway, great to hear from you, more in a future video!
@henrikjensen3278
@henrikjensen3278 5 жыл бұрын
I am looking forward to more videos about ESP32, a good youtube video is a fast way to learn stuff. It looks like the ESP32 has some limitations on real time response, due to the RTOS, what I mean is that you have to handle a lot of stuff with RTOS calls, not directly. This means lots of clock cycles slower. You can check my projects about "computer controlled ..." stuff to see what I mean: lygte-info.dk/project/indexProjects%20UK.html A RTOS calls will probably mean that the ESP32 will not be faster than a old style Arduino to setup the function (Bad description, what do you call programming multiple times simultaneous), but when running it will have better precision. When I get better acquainted with the ESP32 (or any ARM CPU) I may redo the above boxes, but for now they work very well.
@originuk
@originuk 2 жыл бұрын
Just quickly browsing through your tutorials - love what your're sharing! Multi-threaded stuff works fine when working with unique pins ... when using separate tasks to do stuff concurrently over the I2C or SPI bus, obviously needs resource locking... you may have mentioned this, already so apologies if you have. Great to see simple examples.
@RalphBacon
@RalphBacon Жыл бұрын
Yes, semaphores and mutexes can lock resources but that's no use if the GPIO pin you want to share is already in use with a peripheral! Imagine some part of your program interrupting an SPI packet!
@JerryEricsson
@JerryEricsson 5 жыл бұрын
Believe it or not, I actually have a wonderful use for your initial duel blink program, it will solve a problem I have been tinkering with for over a year now! You see I am a retired police officer, a few years back, my good wife of 50 years gave me one of those old model's of a 57 Chevy. Now back in 69, we drove a 57 Chevy out to Minnesota for our first year of married life, so it was that, I believe that she homed in on. That said, the model was painted the black and white of a police vehicle of that era, so I wanted to build and mount a small light bar that I could turn on to have the model be in pursuit whilst sitting atop my TV Stand. I have it working, but not right, I do have the wig-wag of the blue and red lights working right but the amber caution light in the rear window has to flash in conjunction with one of the overhead lights. This is not the way they really worked, in the old days when I began police work, the overhead lights ran by chain drive, the bulbs were aircraft landing lights, and the rear flasher ran off a simple flasher like a turn signal and the bulb was a simple stop light bulb from a car, I believe it was an 1157 if memory serves. So, you see, I can now have one core run the wig-wag overhead and the second do the caution amber, should work great once I replace the Nano with an ESP32! Sure in the future, I may try and program it so I can turn on the lights remotely from my laptop, that would really be cool, yes I think I will try and program it to do just that!
@RalphBacon
@RalphBacon 5 жыл бұрын
You can certainly do it like this, Jerry, but I would caution you against using Core 0 (too much). Just put all your tasks on Core 1 and it will work wonderfully well without upsetting WiFi and BT that runs (behind the scenes) on Core 0. I'll explain all this in a couple of weeks in a new video but given what you are describing is probably 2 or three "blink" programs this will do for now!
@michaelbyron9688
@michaelbyron9688 5 жыл бұрын
Consider using the Parallax 8 core "Prop" microcontroller. it is easy to use and ideal for concurrent programming. it can be programmed in C or in SPIN a very very easy to learn language.
@daviddoidge1252
@daviddoidge1252 5 жыл бұрын
Excellent again, looking forward to more ESP32 videos
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, David, noted and appreciated!
@anispinner
@anispinner 5 жыл бұрын
So many details. Thank you, Ralph! Subbed, looking to more content on MC's and FPGA's.
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, NLab, noted and appreciated!
@BiggsWorld
@BiggsWorld 5 жыл бұрын
I just found your channel, subscribed! Great video, I've been using esp32 for quite a while now and learned some new stuff. I like the teaching style too. I love these kinds of things that add to my knowledge! Bravo.
@RalphBacon
@RalphBacon 5 жыл бұрын
Thanks for that, BiggsWorld, nice to hear from you. Thanks for subscribing too!
@iHayri1
@iHayri1 3 жыл бұрын
Hi Ralph, just wanted to thank you for your incredible videos, they are extremely informative, very easy to understand and to learn from with no nonsense whatsoever like annoying background music which always seems too loud and makes understanding difficult. Of course I subscribed and hit the bell, to not miss a single video. Btw, the ESP32 is my new found love and I intent to learn every bit if information about it. Already designed and have manufactured a CNC milled aluminum case that will go with my version of a 3.5" IPS display with capacitive touch and the required PCB of course. Anyway, sorry about the long comment. Happy Holidays and a great New Year, stay safe.
@RalphBacon
@RalphBacon 3 жыл бұрын
Thanks so much for your kind words, Hayri. The ESP32 is indeed a wonderful device (not Revision 0 though!) and I am now reading up more on the freeRTOS and multitasking. Very powerful stuff which I will share in the New Year. Have a good one!
@iHayri1
@iHayri1 3 жыл бұрын
@@RalphBacon That is the least I can do, wish I could do more to support you than just subscribing but I do have my own struggles :-) Nevertheless if you are interested in my new upcoming PCB with the ESP32 WROVER on it, or anything esle I work on for that matter, I will be glad to send you one as a gift to show my appreciation for your excellent work. Looking forward to see freeRTOS and multitasking examples. Be well.
@JohnTinic
@JohnTinic 5 жыл бұрын
i love the esp. i avoided arduino wherever i could. just used it to flash my printer 😂 great video with onpoint informations thx👍
@RalphBacon
@RalphBacon 5 жыл бұрын
You are most welcome John, I'm glad you like the video. Nice to hear from you.
@mikelopez9893
@mikelopez9893 5 жыл бұрын
Nice video, but it might spread some misunderstanding about multi-core and RTOS. Note that RTOS can run multiple tasks on a SINGLE core. Pro tips: 1) Keep your tasks on core 1 and leave core 0 for Wifi etc 2) Use priority 1 or higher for tasks. Leave priority 0 for the “idle” task. 3) Use core affinity with caution! There is a good tutorial on free RTOS at www.freertos.org/tutorial. Keep up the good work. I always enjoy your videos.
@deangreenhough3479
@deangreenhough3479 5 жыл бұрын
Mike Lopez thank you Mike, that’s great additional Information and appreciated. 👍🏴󠁧󠁢󠁥󠁮󠁧󠁿
@RalphBacon
@RalphBacon 5 жыл бұрын
What you say, Mike, is of course 100% correct but I had to think of a way of presenting this clearly and using both cores was (I felt) a good way. I have other sketches that use the same core (or even switch cores) but that's for another day (if this video is received well). In general use, though, tasks should leave core 0 alone as much as possible to let WiFi and BT have their dedicated space to run. I'm a little disappointed that not all RTOS commands are available to the Arduino and the configuration files that control what is and isn't can be a veritable minefield. I'll keep it simple and in line with what my viewers will use most! It's an amazing device though, at an equally amazing price, and will probably convert me away from my current chip-of-choice, the ESP8266 but which doesn't have enough pins for me! I'll put your link in my GitHub if you don't mind, that's a good resource, thanks for the heads-up, appreciated.
@sortofsmarter
@sortofsmarter 5 жыл бұрын
This is soooooo cool....I have like 3 of these boards...late night aliexpress shopping..lol and needed lots of help to really understand what in the heck I got into and how to use them.....Andreas Spiess is good but a little to advanced for my newbie abilities....Thanks
@RalphBacon
@RalphBacon 5 жыл бұрын
Thanks for your post, Gene, good to hear from you.
@Ne555N
@Ne555N 4 жыл бұрын
This tutorial is excelent!! Thank you very much for the effort you put into the video
@RalphBacon
@RalphBacon 4 жыл бұрын
You're very welcome!
@willofirony
@willofirony 5 жыл бұрын
Yeah, I like this sort of stuff. Brilliant vid, Ralph.
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, Michael , noted and appreciated! Good to hear from you again!
@timcallinan
@timcallinan 2 жыл бұрын
Excellent Tutorial Ralph. Enjoying it
@RalphBacon
@RalphBacon 2 жыл бұрын
Glad you enjoyed it!
@williammiller7543
@williammiller7543 5 жыл бұрын
Another Great, Informative video. I'm starting to use the ESP32 and this background info is Very usefull.
@RalphBacon
@RalphBacon 5 жыл бұрын
Thanks for your post, William, good to hear from you.
@chetanyasaxena8082
@chetanyasaxena8082 5 жыл бұрын
Great Video, very informative. Keep up the good work sir BTW new sub. Please make more ESP32 Videos.
@RalphBacon
@RalphBacon 5 жыл бұрын
Thanks for your post, Chetanya Saxena, good to hear from you and thanks for the sub. You are most welcome.
@bhnienhuis
@bhnienhuis 5 жыл бұрын
Very interesting, please continue
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, Herman Nienhuis, noted and appreciated!
@tedmoga4797
@tedmoga4797 9 ай бұрын
I plan to use both cores in the ESP for a project I am working on. I want to use core 0 to read wav file data from an SD card and play it using I2S, and provide the audio frame that is being played to core 1. To keep a program running some code from the SD card to move some servos in syvn with the audio. So I have been looking on information how to get this all working. When I read your comments “To be honest, I would not use two cores to do this. Use two tasks instead, of equal priority (ie keep them at 1) on core 1. That way you won't upset either the BT, Wi-Fi or other system function running on Core 0. “ and “It is true - to an extent. Putting some simple tasks on Core 0 won't make it unstable as long as you "yield()" control back to the other tasks fairly frequently. That said, putting an intensive task on Core 0 is not a good idea - keep those for Core 1 (which is where your "loop()" runs) “ After reading some of your comments, I thought the ESP32 will not work for my project so I looked around and I found information that said if you do not enable the WIFI or the Bluetooth the code will not be running? esp32.com/viewtopic.php?t=31169 Some comments said if you do not include it in your code it will not run, “This is nuts. Don't initialise it. There's nothing to stop. “ I think this might be right, but I will have to look into it more. But it makes sense If you do not include WIFI in your sketch why would the code run?
@RalphBacon
@RalphBacon 9 ай бұрын
If you don't invoke Wi-Fi (on Core 0, as you say) then no Wi-Fi code will run. So your Core 0 can be used more like an App core (but there may be other stuff running on Core 0 that is sensitive to delays). If you get a PANIC on Core 0 you know you have crossed the line. Good practice would state that, usually, we should leave Core 0 to do all the Espressif things (including Wi-Fi, BT et al) and use Core 1 for our app. But, like all good rules, they are made to be broken now and again!
@oncledan282
@oncledan282 2 жыл бұрын
Hey! Ralph. I just looked at your video and I will try this tomorrow (it’s past 1AM for me, now). Thanks for this tutorial. 160 times faster ?? Really ?? It just might solve my flickering problem but I’ll try to get the TFT working first, then, the GPS. I’ll give you updates soon (via mail) Happy new year .. Talk to you soon !
@RalphBacon
@RalphBacon 2 жыл бұрын
Talk soon! Don't be a stranger!
@datho-cq1ez
@datho-cq1ez 10 ай бұрын
I am a student come from Viet Nam, this is a excellent video, thank you because share this topic.
@RalphBacon
@RalphBacon 9 ай бұрын
Glad you enjoyed it! Thanks for posting!
@GRPZ66
@GRPZ66 5 жыл бұрын
Excellent video. Keep them coming. Much appreciated.
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, Guido Zijlstra, noted and appreciated!
@rodneytapit5636
@rodneytapit5636 2 жыл бұрын
Thanks for this tutorial Ralph, it works for me. I would be very interested to know more about semaphores and mutex for the ESP32 - perhaps you have already made another video on the subject? Also, if I'm using wifi, async. server and client libraries what core would they be running on by default?
@RalphBacon
@RalphBacon 2 жыл бұрын
Wi-Fi runs on Core 0, along with BT and any other Espressif code. Your code should all run on Core 1. If you place any code on Core 0 you run the risk of it causing a PANIC on Core 0 as it is _very_ sensitive to any delays. I can't remember whether my video #151 (kzbin.info/www/bejne/r6jFomSnh5KZj5I ) dealt with semaphores / mutexes - I'll leave it for you to check!
@rodneytapit5636
@rodneytapit5636 2 жыл бұрын
@@RalphBacon Video #151 explains a lot of the finer detail, very good thank you. I wonder how 'sensitive' the single core ESP8266 is when it comes to WiFi operation and the user code delaying WiFi operations.
@ayganotomasyon1109
@ayganotomasyon1109 Жыл бұрын
Thats what i m looking for. Thank you.
@RalphBacon
@RalphBacon Жыл бұрын
Glad I could help!
@ElieWar
@ElieWar 5 жыл бұрын
Thank you, yes more, plz
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, Elie, noted and appreciated!
@magic.marmot
@magic.marmot 5 жыл бұрын
I've watched this again tonight, and have gained even more from it. I have to ask: does the Arduino IDE/library allow you to create multiple tasks on a single core?
@micultimy91
@micultimy91 5 жыл бұрын
It's called multi-threading. it's actually pseudo-multitasking because the mcu is a serial processor is going to perform a little bit of each task you gave it to, in order to give you the appearance of multi-tasking
@RalphBacon
@RalphBacon 5 жыл бұрын
My next video on the ESP32 shows this but you can try just by changing the core parameter on those tasks in this demo. Works as you would expect. If you don't specify a core to run on, then the task scheduler will allocate work to a core as it sees fit. there's much more detail here: www.freertos.org/implementation/a00005.html
@binhphuoc2971
@binhphuoc2971 3 жыл бұрын
Hello Ralph, thanks for your video. I learned quite few new things by watching it. I bet other videos of yours are no less excited. BTW: What is the IDE you're using at 16:29?
@RalphBacon
@RalphBacon 2 жыл бұрын
Glad it was helpful! I was using the Eclipse Sloeber IDE but as support for it has ceased I now use PlatformIO on Visual Studio.
@binhphuoc2971
@binhphuoc2971 2 жыл бұрын
@@RalphBacon Thanks. I'm using PlatformIO as well.
@mav29
@mav29 4 жыл бұрын
thanks mate, 2020 and still a great video
@RalphBacon
@RalphBacon 4 жыл бұрын
Glad you enjoyed it! I want to do another on Timer Tasks, more efficient. It's on the list...
@mav29
@mav29 4 жыл бұрын
@@RalphBacon we'll wait for it, And tonight I have decided to get me an esp32, thx haha BTW would it be possible to distribute load across 2 esp32 as processors while another is handling load distribution he he thx
@mav29
@mav29 4 жыл бұрын
@@RalphBacon im back sir, i just recieved my ESP32 today and im going to test it using your examples yaaayyyyyyy! cheers!
@billw2976
@billw2976 4 жыл бұрын
Ralph, thank you very much for you videos and especially for the time you have dedicated to the world of Arduino. May I ask, of you, what program did you use for programing? You said the name during the first part of the video but I was not able to get the name clear enough to do a search for it. It looks like a very interesting system for programing Arduino type processors. Thanks again, Bill in Oklahoma, USA.
@RalphBacon
@RalphBacon 4 жыл бұрын
I use the Eclipse (Sloeber) version but wait for the new Arduino IDE later this year, Bill. It's based on the same Eclipse setup so should be very good.
@jofie2302
@jofie2302 4 жыл бұрын
You should also consider using the "Visual Studio Code" IDE in combination with PlatformIO. It provides Intellisense/command completion, a nice outline, a header file per project remembering things like board type and details, etc.
@peut
@peut 5 жыл бұрын
Very nicely done. Thank you. Please continue.
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, Jose, noted and appreciated!
@stevehallam0850
@stevehallam0850 5 жыл бұрын
Really good stuff, thanks Ralph 👍
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, Steve Hallam, noted and appreciated!
@JohnnyG1956
@JohnnyG1956 4 жыл бұрын
I tried the code in the video and I didn't get the same results as you did. I copied the code from your GitHub, after changing the pins to the pins I am using (18 & 21), it worked perfectly. The difference is the semaphore = xSemaphoreCreateBinary(); line that was in your GitHub code. I didn't see that in the video. I have SOOOO much to learn.
@RalphBacon
@RalphBacon 4 жыл бұрын
We're all learning, John! Missing a line of code is no biggie. Glad you got it working in the end. ESP32 is such a powerful chip, don't you think?
@JohnnyG1956
@JohnnyG1956 4 жыл бұрын
@@RalphBacon Yes, it is an amazing chip. I probably need to focus a bit more. I started with the Arduino, then got the ESP32, Analog Discovery 2, and a few days ago, my NVidia Jeston Nano arrived. I know a little about all of them... I think it is time to stop buying toys and to start learning some stuff. If you want a suggestion for a video, I have one. My next project is to get an ESP32 to turn on/off and speed control a 4 pin cooling fan (I have an NF-A4X20 5V PWM). The speed would be based on the temperature that the temp sensor is sensing, in my case, between 26 and 37 degrees. The manufacturer told me that it will work with 3.2V so the ESP32 should drive it. Keep up the great content.
@oncledan282
@oncledan282 4 жыл бұрын
Hey, Ralph!I I thought, since that time I got my ESP32 from China, I might as well give it a go and see how to program this li'l wonder. 2 cores seems a nice things to have and I'm glad the use of these cores are very common to yours in my way of thinking .. and a bunch of GPIOs too, although not all of them ore broken out on my Board. I got the ESP32 Development board, from DOIT (or rather, a very nice clone, may I add). I downloaded the board specifics and driver from GitHub and I THINK it's working. I say « I THINK » because the IDE does not seem to see the board as far as the com port is concern. I'll seek other videos to see if I should connect this board via FTDI or if I can program it via the microUSB port, just like the Arduino boards. To be followed .. On that, a few days from the New Year, I wish you all the best for 2020. Talk to you soon, my Friend !
@RalphBacon
@RalphBacon 4 жыл бұрын
Happy New Year Daniel! The question is, does your PC see the COM port of the ESP32? You can use the USB socket just as on an Arduino to upload sketches etc and get back serial messages. Make sure you have selected the correct board from the long list.
@TheYephers
@TheYephers 5 жыл бұрын
I'm late to the party here but I read through a bunch of the comments below and did not see an answer to your question. So, I thought I would share why I believe you need the delay in the loop() function to make it work: It is as you say because the ESP-32 implementation is sitting on top of FreeRTOS, the RTOS is checking for tight loops and can result in the watchdog timeouts. Hence we need to have the vTaskDelay() calls if we are not writing code that makes use of the loop() method. The "delay" command internally tickle the watchdog to keep things happy. There was an issue created for this a couple of years ago that discusses it and it can be enlightening: github.com/espressif/arduino-esp32/issues/595
@RalphBacon
@RalphBacon 5 жыл бұрын
Yes, I'd come the same conclusion, Chris, that the sketch's loop was being called in a for(;;) loop - so if nothing was added to the loop() function then it would be considered a tight loop and starve other processes of CPU cycles. The solution I show in my next video (gosh! I'm ahead of the game this week) is to simply delete the task if it is not required. If we _are_ going to use the loop() as a sort of task supervisor then we don't delete it, obviously, nor does it need that delay(1) which worked so well but was just consuming CPU cycles for no benefit - hence the vTaskDelete. More in my next video, thanks for the confirmation!
@emmanuelsheshi1553
@emmanuelsheshi1553 2 жыл бұрын
i think the main loop has the highest priority, you need the delay(1) so put a hold on it so the other loops can run
@RalphBacon
@RalphBacon 2 жыл бұрын
The main loop runs at a priority of 1, the same as others unless you put them higher or lower. Ideally, all tasks should run at priority 1 so the scheduler can do its time-slicing work, unless you're doing some advanced stuff.
@lmamakos
@lmamakos 5 жыл бұрын
Is the Arduino runtime environment for the ESP32 thread-safe and reentrant? In the past, casual inspection of some Arduino libraries show that some/many are not thread-safe because they use statically allocated memory without any locking or protection. This is the tricky part of multi-threaded programming and usually results in intermittent and hard to diagnose bugs because the cause is so timing dependent. Like is the Serial.print method not using any static buffers while its formatting, e.g., Integer values into text? What happens if both threads are simultaneously running the same method? In other examples of adapting the Arduino environment into an RTOS with multiple threads, the practice usually is to only have one execution thread be allowed to use the Arduino environment because its unsafe, and the other threads do "other" processing in known-to-be-thread-safe ways.
@RalphBacon
@RalphBacon 5 жыл бұрын
Excellent point you make, Louis. I shall investigate. Given that most libraries were never written to be thread safe I suspect the safest way to use them is to ensure that only one task ever uses them at a time - which, given the logic of a program could be quite straightforward. For example, if you are writing to a TFT display ensure that only one task (at a time) can access it. I'll investigate what Espressif say, too, on this subject. Thanks for posting, good to hear from you.
@jonathanr4242
@jonathanr4242 3 жыл бұрын
Thanks for another excellent video. I don't mean to be pedantic, but shouldn't we write assembler to do a proper speed comparison because the compiler might be more optimal for one processor or the other?
@RalphBacon
@RalphBacon 3 жыл бұрын
Well, my understanding and belief, Jonathan, is that the compiler writes far better assembler than we can; taking into account the optimisation levels we can invoke too. Anyway, what's a few nanoseconds amongst μControllers? In this case. the difference in clock speed between the Arduino and the ESP32 makes this such a one-horse race anyway... 🤷‍♂️
@jonathanr4242
@jonathanr4242 3 жыл бұрын
@@RalphBacon Hi Ralph, yes 62ms is quite an amazing speed. It's really a cool how this technology filters down to us hobbyists.
@kennmossman8701
@kennmossman8701 5 жыл бұрын
MORE please sir!
@RalphBacon
@RalphBacon 5 жыл бұрын
Ooh, that's enthusiastic, Kenn! I was just thinking (always dangerous) the other day about multitasking on this chip. We will have to see whether all that Deep Thought comes up with new videos.
@kennmossman8701
@kennmossman8701 5 жыл бұрын
@@RalphBacon Use one core per task? Or virtual multi-tasking?
@robinvanleeuwen1911
@robinvanleeuwen1911 2 жыл бұрын
Yeah I like to see that sort of stuff (multicore programming on ESP32)
@RalphBacon
@RalphBacon 2 жыл бұрын
Yes, multicore vs multitasking is quite different though, so keep tuned.
@vonries
@vonries 5 жыл бұрын
Great video as always Ralph! I see a lot of yes please do more esp32 videos and not a single one that says no thank you go back to only doing the arduino. I'll add my vote for doing more esp32 videos please. I wonder if you turned off the bluetooth and wifi if it would run your test program even faster. If they were needed, I would think they could be turned back on to publish the results. Like publishing the numbers to a webpage etc.
@RalphBacon
@RalphBacon 5 жыл бұрын
I don't think you would see a speed increase if WiFi and BT were switched off, Steven, because they run on Core 0 (behind the scenes) and we were running that Prime Number nonsense purely on Core 1 - and the two are completely independent. In fact, running a duplicate task on Core 0 could have caused a processor reset if the WiFi or BT tasks were starved of CPU cycles - you have to tread very carefully when using Core 0. OK, more videos on ESP32 is what I hear. Keep tuned!
@vonries
@vonries 5 жыл бұрын
@@RalphBacon oh I thought you had it doing multicore processing.
@mksmurff
@mksmurff 3 жыл бұрын
Just found this. Brilliant. Earned a sub
@RalphBacon
@RalphBacon 3 жыл бұрын
Thanks, DannyK, welcome aboard.
@jeffbluejets2626
@jeffbluejets2626 5 жыл бұрын
As usual, great stuff. More thankyou.
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, Jeff Bluejets, noted and appreciated!
@patrickmaartense7772
@patrickmaartense7772 5 жыл бұрын
yes please more of this !
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, patrick maartense, noted and appreciated!
@skipdaniels5875
@skipdaniels5875 5 жыл бұрын
Ralph, If you are looking for projects to do, what about ESP-NOW Thanks Skip
@RalphBacon
@RalphBacon 5 жыл бұрын
Thanks, Skip, I'll add it to my list of things to look at!
@rzinindiana8029
@rzinindiana8029 3 жыл бұрын
As usual... clear and important info... TX
@RalphBacon
@RalphBacon 3 жыл бұрын
Glad it was helpful!
@pepethefrog7193
@pepethefrog7193 5 жыл бұрын
Running the primenumber code bound to a core gives 135ms. Seems rtos uses both cores for the "unbound" state. Why is one esp32 core 7 times faster than a 8266? Love your way of explaining things plus the examples on git. How is that with passing variables between cores?
@RalphBacon
@RalphBacon 5 жыл бұрын
I don't think it's anything to do which core it's bound to (or allowed to 'float') it's down to the task _priority_ and if you increase yours from 0 to 2 (with 24 the maximum allowed) it will indeed run again in about 64mS. See examples: xTaskCreatePinnedToCore( loop0, /* Function to implement the task */ "Task0", /* Name of the task */ 1000, /* Stack size in words */ NULL, /* Task input parameter */ 2, /* Priority of the task */ &Task0, /* Task handle. */ 1); /* Core where the task should run */ OR: xTaskCreate( loop0, /* Function to implement the task */ "Task0", /* Name of the task */ 1000, /* Stack size in words */ NULL, /* Task input parameter */ 24, /* Priority of the task */ &Task0 /* Task handle. */ );
@vincenttang9059
@vincenttang9059 4 жыл бұрын
Very Useful for me, thank you for your sharing :)
@RalphBacon
@RalphBacon 4 жыл бұрын
Glad it was helpful!
@science4allworld587
@science4allworld587 5 жыл бұрын
Study on power consumption variations when one cpu is off? Thanks.
@RalphBacon
@RalphBacon 5 жыл бұрын
No, I haven't even gone there (but I bet others have). I'm not sure that I would choose an ESP32 for battery usage but I guess 'needs must'. I might do something in a future video, but nothing is planned right now.
@ChaplainDaveSparks
@ChaplainDaveSparks 5 жыл бұрын
Ditto for setting the different clock frequencies and measuring power.
@niekbeijloos8355
@niekbeijloos8355 4 жыл бұрын
Did you figure out why the delay(1) is needed within the loop ? I can not find a proper explanation for that. Thank you in advanced!
@RalphBacon
@RalphBacon 4 жыл бұрын
Yes, Niek, I found out the reason. A _delay()_ has an inbuilt _yield()_ which, as you know, allows other processes to take their time slot from the processor. Without the _delay()_ the loop never relinquishes MCU time to other tasks. I tried the following options: //delay(1); //taskYIELD(); //vPortYield(); //yield(); vTaskDelete(NULL); The latter is the best option as it removes the _loop()_ task permanently, never to be called again. Some of the other _yield_ options didn't do what I expected.
@niekbeijloos8355
@niekbeijloos8355 4 жыл бұрын
@@RalphBacon Thank you Ralph, really helpful. Keep it up! Your explanations are very clear.
@EmbSysDev
@EmbSysDev 4 жыл бұрын
Very , very nice into to ESP32 !
@RalphBacon
@RalphBacon 4 жыл бұрын
Thanks!
@abpccpba
@abpccpba 5 жыл бұрын
Thanks yes more on ESP32 👍
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, Paul C Johnson, noted and appreciated!
@therealblujuice
@therealblujuice 5 жыл бұрын
Yes!!! Please!!! Esp32
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, Justin, noted and appreciated!
@jenniferw8963
@jenniferw8963 2 жыл бұрын
Hah, I hadn't yet finished the video yet and was going to ask if this supported "semaphores".. which I learned about in Operating Systems class back in 1995. Anyways, cool to see they use the same terminology and that this processor can do this :) Semaphores are great for whben accessing shared global variables.
@RalphBacon
@RalphBacon 2 жыл бұрын
Indeed. Trying to "share" global variables without using them is a recipe for disaster! Glad you like the video 👍
@yvesinformel221
@yvesinformel221 4 жыл бұрын
Can we make an analogy with token ring where station had to wait for the token to talk ?
@RalphBacon
@RalphBacon 4 жыл бұрын
Sort of. Certainly if you initiate a task but have to wait in the future for the result it can be like that. Multitasking can be complex (and the devil to debug) so it's best to keep tasks atomic (or at least independent), so they start and complete a task without a caller waiting on the result.
@GilchristMcGill
@GilchristMcGill 2 жыл бұрын
Thank you.
@RalphBacon
@RalphBacon 2 жыл бұрын
Most welcome, Gil
@AbdullahMohsin
@AbdullahMohsin 4 жыл бұрын
please do more esp32 vids!!
@RalphBacon
@RalphBacon 4 жыл бұрын
I might do more in the future, it's a very good chip that ESP32.
@AbdullahMohsin
@AbdullahMohsin 4 жыл бұрын
@@RalphBacon I'll definitely be waiting to watch!!
@flemmingchristiansen2462
@flemmingchristiansen2462 5 жыл бұрын
Seems the speed will make you pale, What happened to your colors? Great video, like to see more ESP32 stuff
@RalphBacon
@RalphBacon 5 жыл бұрын
Certainly the speed test did make me pale with wonder! But in reality, it's all down to the green screen (ChromaKey) that sometimes just doesn't want to play ball and this is how I fix it!
@nullptr.
@nullptr. Жыл бұрын
Could you make a video showing how to pass parameters to those tasks? or maybe just point me to a resource, been struggling with it
@RalphBacon
@RalphBacon Жыл бұрын
You cannot pass "parameters" - plural! You can only pass ONE parameter at the time of the task being instantiated. Thereafter you can read variables from within the task code just as you might normally, as long as you take care that another part of your code (or another task) is not updating those same variables (in which case use a semaphore or similar). To pass the single parameter in at the time of task instantiation, cast as a (void *), that is, an unknown type pointer. Look at my example code to see the exact syntax.
@RalphBacon
@RalphBacon Жыл бұрын
That said, you can pass in a struct which contains more than one variable!
@georgestewart5879
@georgestewart5879 5 жыл бұрын
Yes some more please.
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, George, noted and appreciated!
@RobertoColi
@RobertoColi 5 жыл бұрын
Ralph, you did not test the prime number code with an Arduino MEGA. That is the core al almost all the 3D printer boards. It would be interesting then having a 3D printer board based on ESP32: speed, dual core, more memory, wireless !!
@RalphBacon
@RalphBacon 5 жыл бұрын
I can't remember the last time I used a Mega2560, Roberto! The Mega is not normally considered any faster than an UNO (sometimes it can be slower) so that might help you realise what the ESP32 can bring you. See: arduino.stackexchange.com/questions/36545/will-an-atmega2560-board-be-faster-than-a-uno-for-hard-real-time-data-logging
@Graham1904
@Graham1904 5 жыл бұрын
Well presented esp (pun) ially for a newbie like myself
@RalphBacon
@RalphBacon 5 жыл бұрын
Groan. Almost a pun, anyway, Graham! Glad you liked the video!
@dekipet
@dekipet 5 жыл бұрын
Neat one. Thank you.
@RalphBacon
@RalphBacon 5 жыл бұрын
You are most welcome Dejan, I'm glad you like the video. Nice to hear from you.
@dekipet
@dekipet 5 жыл бұрын
@@RalphBacon ESP32 has so much to unveil. Just to mention chips ID, touch sensor, temperature sensor, etc. It would be nice to someone take all of that, all of connectivity and make a nice video, or blog article. I am planning to put it on a magazine article i write for. Time is all i don't have. Damn...
@RalphBacon
@RalphBacon 5 жыл бұрын
I'm starting a petition for the UK government to create a 30-hour day to give me more time to do the stuff I need to. Sounds like you will be the first signatory! Yes, I'll get round to the ESP32 features, I hope, in due course, if only I had more time. Oh, I have a feeling of deja vu...
@DrexProjects
@DrexProjects 5 жыл бұрын
I have yet to try the 32. I have many 328s, 168s, 88s and shit tons of 8266s. So I guess I will have to spring for the 32.
@RalphBacon
@RalphBacon 5 жыл бұрын
The ESP8266 is a great chip (when moving up fro the Uno/Nano crowd) but this is in a different league altogether. Do try one. At worst it will act like a very, very fast Arduino Uno!
@DrGreenGiant
@DrGreenGiant 5 жыл бұрын
Why do you use for (;;) rather than while (true)? Great video btw, thank you
@DrGreenGiant
@DrGreenGiant 5 жыл бұрын
... Also may you explain .mutex? Best explanation of semaphores I've heard, cheers!
@DrGreenGiant
@DrGreenGiant 5 жыл бұрын
@Thomas Samoht ah ok so they are identical really but just personnel preference which one you use
@RalphBacon
@RalphBacon 5 жыл бұрын
Strictly speaking, not personal preference either, Simon. For the reason Thomas has explained for(;;) was used first and is now a _de facto_ way of expressing _do forever_ . You would be swimming against the current if you coded _while (true)_ even though the compiler creates the same underlying code! A bit like *c = c+1* vs *c++* , which one would _you_ choose? (Hint, if you chose the first one, you're swimming against the current!).
@DrGreenGiant
@DrGreenGiant 5 жыл бұрын
@@RalphBacon Understood, ish. I guess if "true" didn't used to exist, while (1) would have worked? (just curious). So it is personal preference since it doesn't make any difference to the underlying code but the trend is to use for (;;), personal preference in that you either go with the trend or not. It's an interesting discussion though, so thanks for bearing with me! I personally think while (true) looks nicer but that's just me being young and always had that option available I guess! Also, disagree with the last point as I believe x++ and x=x+1 don't compile to the same ASM?
@RalphBacon
@RalphBacon 5 жыл бұрын
Don't worry, Simon, no Arduino police are going to come knocking on your door if you dare to use while(true) instead of for(;;)! It's just convention. Do it your way. It may well become the new way to do it - and while(true) is more understandable than for(;;), let's face it! (Others have asked this too, look here: stackoverflow.com/questions/3807606/whiletrue-versus-for )
@charesealbow5357
@charesealbow5357 Жыл бұрын
Ralph, what happens if you add a xSemaphoreGive statement after the xSemaphoreTake statement in loop2?
@RalphBacon
@RalphBacon Жыл бұрын
You've released the semaphore immediately it's been taken.
@foxabilo
@foxabilo 5 жыл бұрын
Yea, I like this sort of stuff
@RalphBacon
@RalphBacon 5 жыл бұрын
Thank you for your feedback, foxabilo, noted and appreciated!
@foxabilo
@foxabilo 5 жыл бұрын
@@RalphBacon Just been chatting with Andreas Spiess on the platform.io JTAG debug feature western digital has just given everyone for free, about to test the ST-Link V2 with the ESP32 and the Atom editor to see if the maker space can get dirt cheap jtag debugging. Seems the ESP32 is making a resurgence in popularity for all things IOT and a whole bunch of new cool things and toys, really exciting time to be getting to know this cheap abundant powerful hardware. Hope you have a great time with it all and I hope the channel grows well, solid walkthrows of interesting stuff are always a great resource to link to when explaining something to someone just starting out.
@RalphBacon
@RalphBacon 5 жыл бұрын
So, just to clarify, will JTAG debugging allow single stepping of code, or how does it work? I've used MS Visual Studio for years and was spoiled by this feature (impossible to debug enterprise level code otherwise). If the ESP32 allows it... well, I'll await your response first.
@foxabilo
@foxabilo 5 жыл бұрын
@@RalphBacon I am in the breadboard and rats nest phase of finding out, platformio says it supports multi threaded debugging, I'll let you know how that works once i put all this magic smoke back in ;)
@foxabilo
@foxabilo 5 жыл бұрын
So first update, this is specifically regarding the STLink32 V2 and clones, if you set the debug_tool = stlink then you get a compile time error of "DebugInvalidOptions: Unknown debug tool `stlink`. Please use one of `esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa` or `custom`:" I am going to have a scout round the net to see if it is possible to use the "custom" option to set up for use with the STLink if not I will have to order one of the ESP-Prog boards or look at the JLINK clone project as I doubt anyone has £600 floating about to debug a blink led project ;)
@berkanab4260
@berkanab4260 Жыл бұрын
Hello, quick question, do you meanwhile know why you have to include the delay from (1)?
@RalphBacon
@RalphBacon Жыл бұрын
If you are talking about the one in the loop( ) it is to stop it being optimised away by the compiler. You can remove it, and the loop ( ) function disappears too which _might_ give you an error because the outer shell is calling it.
@yurkshirelad
@yurkshirelad 3 жыл бұрын
An RTOS task isn't a loop, it's simply a task. You need a loop within the task to keep it alive, otherwise it ends. Just like a task you would do, like drinking a cup of tea. When you've finished your tea, you finish that task. If you don't want that task to end, you need a loop to drink tea forever. I'm sure someone else beat me to answering this, given how old the video is. But I thought I would post anyway. The Arduino IDE dictates the use of a loop, and its application code invokes it as fast as it can.
@RalphBacon
@RalphBacon 3 жыл бұрын
Well, OK, Mike, let's call it a looping task. I don't know about the RTOS code but there's probably a while(1) or for(; ;) somewhere in that task scheduler!
@maxpenfold8699
@maxpenfold8699 3 жыл бұрын
What a great Video, thanks!
@RalphBacon
@RalphBacon 3 жыл бұрын
Glad you liked it!
@GoodAllDay
@GoodAllDay 5 жыл бұрын
Can i use hardware interrupts and dual core mode at the same time? When i tried it, i got a lot of errors in runtime. For example, structure in my project: 0 core for attach Interrupts, and some of algorithms. 1 core for Wi-fi communication and updates tft display using i2c. Is it possible?
@RalphBacon
@RalphBacon 5 жыл бұрын
You must be careful in using Core 0. Try and keep all your tasks on Core 1 initially. Passing semaphores between tasks is fine, but *not* from an ISR, you need a different function. Core 0 is used by RTOS for the WiFi and BlueTooth; if you starve them of CPU cycles they will crash.
#148 TCA9548A I2C MULTIPLEXER (& Voltage Shifter)
38:00
Ralph S Bacon
Рет қаралды 27 М.
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 22 МЛН
風船をキャッチしろ!🎈 Balloon catch Challenges
00:57
はじめしゃちょー(hajime)
Рет қаралды 88 МЛН
Twin Telepathy Challenge!
00:23
Stokes Twins
Рет қаралды 80 МЛН
#257 Wireless Serial Comms⚡for your Arduino (or other μController)
29:40
Every Softlock in Portal
43:08
Marblr
Рет қаралды 638 М.
#BB9 Organising your code🧹for easier debugging and maintenance✅
18:45
3 engineers race to design a PCB in 2 hours | Design Battle
11:50
Predictable Designs
Рет қаралды 414 М.
#328 ESP32 Secrets: Interrupts, and Deep-Sleep under the Hood
18:57
Andreas Spiess
Рет қаралды 178 М.
PlatformIO: All you need to know in 10 Minutes!
10:56
J's e-shack
Рет қаралды 332 М.
M5Stack Cardputer: ESP32-S3 Pocket Computer
17:06
ExplainingComputers
Рет қаралды 103 М.
Hacking a weird TV censoring device
20:59
Ben Eater
Рет қаралды 3,2 МЛН
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 22 МЛН