#328

  Переглядів 171,289

Andreas Spiess

Andreas Spiess

День тому

Do you need speedy reactions and simple coding? Then, interrupts are a good thing to use. And, because interrupts have things in common with deep-sleep, we will also dig into that topic. And we will find some “Secrets of the ESP32”. For sure, we will look “under its hood.”
I am a proud Patreon of GreatScott!, Electroboom, Electronoobs, EEVblog, and others.
Links:
Sketches: github.com/SensorsIot/ESP32-I...
ESP32 board: s.click.aliexpress.com/e/_dTP...
ESP32 shield: ESP32 shield: s.click.aliexpress.com/e/_d66...
The links above usually are affiliate links which 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 the next 24 hours) 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 or invite me on LinkedIn. These communication channels are reserved for my primary job
As an Amazon Associate, I earn from qualifying purchases

КОМЕНТАРІ: 602
@AndreasSpiess
@AndreasSpiess 4 роки тому
At 15:20 I mixed micro with milliseconds. As you can see on the oscilloscope it is milliseconds
@noweare1
@noweare1 4 роки тому
No big deal. It takes me an even longer time to wake up : )
@Build_the_Future
@Build_the_Future 4 роки тому
Can you do a video on CAN bus? Also check out my channel if you want to see me build a two-legged walking robot. Enjoy
@techfuture9846
@techfuture9846 4 роки тому
This inconsistency and delays you are showing is not a problem of ESP32, it's a problem of Arduino porting for ESP32. Just use ESP-IDF directly and redo the experiments - results will be completely different ;)
@movax20h
@movax20h 4 роки тому
@@techfuture9846 The 150ms of delay after wakeup to actual code running is probably issue with bootloader.
@techfuture9846
@techfuture9846 4 роки тому
@@movax20h, I'm talking about the pure interrupt response time, jitter, etc. The wakeup time is different beer.
@jackm416
@jackm416 4 роки тому
How lucky we all are that these super well-produced, interesting and informative videos are available to view at our leisure. What a world we all live in! Thank You Andress!
@AndreasSpiess
@AndreasSpiess 4 роки тому
Thank you for your nice words!
@Andyinater
@Andyinater 4 роки тому
Truly. I am able to pursue a life passion project through stitching together knowledge from a collection of great youtubers, with Andreas a shining example. You make the world a better place :)
@azreal629
@azreal629 3 роки тому
Agreed, great video!
@SuperMrHolland
@SuperMrHolland 4 роки тому
As always a pleasure to watch. I like that you are not only focusing on hardware, but also explains how to utilize software to make project simple and easy to make
@AndreasSpiess
@AndreasSpiess 4 роки тому
My pleasure!
@KarmaDonyo
@KarmaDonyo 3 роки тому
This is the second video I've watched by Andreas, and I subscribed after watching the first few minutes of this. With so much bad information out there, this channel is a breath of fresh air. So much to unpack in this video. I'll be watching it again and again, thank you Andreas.
@AndreasSpiess
@AndreasSpiess 3 роки тому
Welcome aboard the channel!
@KarmaDonyo
@KarmaDonyo 3 роки тому
@@AndreasSpiess thanks Andreas, I have my seat in the front row
@santorcuato
@santorcuato 4 роки тому
Thanks Andreas, you ever find the way to make it clear and easy to understand. The two channel osciloscope trick is really interesting, but this is part of your very high end workshop...
@ximonx
@ximonx 4 роки тому
You could use a logic analyser, you can pick them up for cheap these days 👍
@AndreasSpiess
@AndreasSpiess 4 роки тому
And 2 channel oscilloscopes are also quite cheap these days. No need for the one I have...
@difegam3
@difegam3 4 роки тому
Thank you for the explanation... You are really making a valuable content. I'm already sitting in the first row waiting a next video.
@AndreasSpiess
@AndreasSpiess 4 роки тому
Than) you!
@arthurdescamps564
@arthurdescamps564 4 роки тому
Thank you ! Perfect timing ! We were just running into random crashes yesterday with our encoders running off ESP 8266. Cleaning up the interrupt functions based on your advises solved our issue ! For the little story, We are building a 4DOF motion platform using salvaged standing desk electric pistons and ESPs. Such a great content every time ! Thanks again !
@AndreasSpiess
@AndreasSpiess 4 роки тому
Glad the video helped! Enjoy your project!
@HariWiguna
@HariWiguna 4 роки тому
Advanced topic explained with just enough info for practical use. Great job Andreas!
@AndreasSpiess
@AndreasSpiess 4 роки тому
Thank you!, Hari.
@aspuzling
@aspuzling 4 роки тому
It would be interesting to see a video on using the ULP core for running code without waking up the ESP32. Would be nice to explore the possibilities and limitations of the ULP core.
@aspuzling
@aspuzling 4 роки тому
Silly me, of course you have already made such a video! ukposts.info/have/v-deo/ZYF6l4uLeXhouKs.html
@christopherguy1217
@christopherguy1217 4 роки тому
Great video, very informative. Thank you for all the work you put in to producing this.
@AndreasSpiess
@AndreasSpiess 4 роки тому
My pleasure! Glad you liked it.
@TheModelmaker123
@TheModelmaker123 4 роки тому
Great Topic, The ESP32 has so many new features, performance advantages and value over the Arduino. For the hobbyist, one platform can serve many projects . Your post make the transition worth attempting. Keep them coming!
@AndreasSpiess
@AndreasSpiess 4 роки тому
And it has Wi-Fi, which the most important difference for me.
@yayser
@yayser Рік тому
Greetings from Turkey Andreas, I just wanted to thank you for all the great videos you have put out here on the channel. I can't imagine what I would do without you. Loved the cat btw :)
@AndreasSpiess
@AndreasSpiess Рік тому
Thank you for your kind words!
@leadeddeveloper9575
@leadeddeveloper9575 4 роки тому
Thank you for sharing your knowledge with community!
@AndreasSpiess
@AndreasSpiess 4 роки тому
My pleasure!
@PhG1961
@PhG1961 4 роки тому
Well done ! Indeed interesting, again I've learned something new.
@AndreasSpiess
@AndreasSpiess 4 роки тому
That is my hope for every video. I also learned something unexpected about the ESP32
@PatrickZeiler
@PatrickZeiler 4 роки тому
Great overview of IRQ usage on esp32, thank you!
@AndreasSpiess
@AndreasSpiess 4 роки тому
You are welcome!
@myksmith
@myksmith 3 роки тому
Brilliant video. Exactly what I wanted. And excellent overview for the beginner or even the experienced. I worked on embedded systems 15 years ago - we used microcontrollers, GPS, cellular comms, and used this to create telematics devices installed on John Deere and Liebherr equipment (and others). We read the CAN bus, and used interrupts for things like movement, engines turning on and other interrupts. Since then I've been doing product management, and now I'm getting back into this level of coding... and was depressed that Arduinos don't have good interrupts and sleep. Your video has brought me back up to speed SUPER quickly, helping me restore my memory from tape, and quickly jumpstarting me with a new microcontroller board.
@AndreasSpiess
@AndreasSpiess 3 роки тому
So have fun with your future projects!
@noweare1
@noweare1 4 роки тому
Geat work Andeas, just purchased my first esp32 and I have a lot of catching up to do : )
@AndreasSpiess
@AndreasSpiess 4 роки тому
Indeed. Enjoy!
@ddavid2
@ddavid2 2 роки тому
I did a great discovery when I found your channel with such professional analysis!
@AndreasSpiess
@AndreasSpiess 2 роки тому
Welcome aboard the channel!
@RobBarter
@RobBarter 3 роки тому
Thank you for pointing me towards the Otii. Now have one and it is becoming an essential piece of kit. Especially now I’m investigating why my new custom board is using 1mA more than it should be
@AndreasSpiess
@AndreasSpiess 3 роки тому
Glad I was helpful!
@MrAtom631
@MrAtom631 4 роки тому
Very informative, thanks!! I will need this in near future, so it is just on time :)
@AndreasSpiess
@AndreasSpiess 4 роки тому
Glad it was helpful!
@adaminsanoff
@adaminsanoff 4 роки тому
Amazing, Herr Spiess! We can not thank you enough!
@AndreasSpiess
@AndreasSpiess 4 роки тому
Glad you like it!
@PileofKyle
@PileofKyle 4 роки тому
Amazingly presented, Just as I received my first ESP32 in the mail!
@AndreasSpiess
@AndreasSpiess 4 роки тому
Enjoy!
@bgable7707
@bgable7707 3 роки тому
Great job of using the KISS principle, Keep It Simple S.... Silly. This is the most straight for explanation of ISRs, aka, AST as we know them on our beloved VAX-32s. Thanks for showing us all your amazing "scope" work! I'm REALLY enjoying your 2020 video's along with all the others, VERY HELPFUL!!!
@AndreasSpiess
@AndreasSpiess 3 роки тому
Glad you like my stuff! I only sold VAX computers, I never programmed them :-( At least the biggest I sold was a VAX9000 for 10 million Swiss Francs. At that time maybe 25 million dollars...
@stephensimmons1537
@stephensimmons1537 4 роки тому
Just got my adafruit esp32 feather in the mail today first video I find is this and what a great video!
@AndreasSpiess
@AndreasSpiess 4 роки тому
Enjoy your journey. You find a lot of ESP32 videos on this channel...
@DuongTrongHue
@DuongTrongHue 4 роки тому
Your video is both useful and interesting. Great job!
@AndreasSpiess
@AndreasSpiess 4 роки тому
Glad you think so!
@thepanda666
@thepanda666 4 роки тому
Great info! thank you. I'll def use this next time.
@AndreasSpiess
@AndreasSpiess 4 роки тому
Glad it was helpful!
@RCWalletVacuum
@RCWalletVacuum 5 місяців тому
Informative videos AND kitties!? What a combo!
@AndreasSpiess
@AndreasSpiess 5 місяців тому
Thank you! 😊
@stevew9945
@stevew9945 3 роки тому
Another outstanding video, many thanks for your efforts
@AndreasSpiess
@AndreasSpiess 3 роки тому
My pleasure!
@BenMitro
@BenMitro 4 роки тому
Very good summary Andreas, thanks.
@AndreasSpiess
@AndreasSpiess 4 роки тому
Glad you liked it!
@czarekcz1097
@czarekcz1097 4 роки тому
Mr Spiess, I enjoy your presentations and like this one too. Thank you for all your effort and shared knowledge. There are several reasons why CPU like this one may have long interrupt latency. One of them (and it is a Real Time limitations of large processors like multicore Intel and ARM) is cache coherency. Simple, interrupt code maybe not present in cache and other current content of the cache need to be saved before reloading new one to/from RAM. For vary fast approach, user need to instruct compiler (I dont know how to do it at ESP32 yet) to keep interrupt service routine (if short) permanently in cache. This is typical approach for RT Linux for example.
@AndreasSpiess
@AndreasSpiess 4 роки тому
You are right. There are a few other comments pointing in your direction,. too
@tonysfun
@tonysfun 4 роки тому
You are right again! But the main think is that the rest is perfect! My friend Hari is gonna love this - I love this sample also! Thank you Andreas!
@AndreasSpiess
@AndreasSpiess 4 роки тому
You are welcome! I hope your lockdown also will end soon...
@tonysfun
@tonysfun 4 роки тому
@@AndreasSpiess In god old NEBRASKA, we had a minimal closedown and even the mall open last Friday! I hope governments get smart and reopen everything ASAP! People will not go, if they are in the risk group, like me and my wife, since we don't want to get sick! People are much smarter than government thinks! I think we OVERDID this, but now is time to reopen everything and let business control everything they know how! I hope your finger gets well soon and you are also being able to do whatever you did before this crappy virus! Good luck and stay safe!
@Hessijames79
@Hessijames79 4 роки тому
Nice idea with the output pin debugging.
@AndreasSpiess
@AndreasSpiess 4 роки тому
Thanks!
@fredbcarneiro
@fredbcarneiro 4 роки тому
Ok, one thing: thank you for identing your code in a proper way!
@AndreasSpiess
@AndreasSpiess 4 роки тому
I use ctrl-T ;-)
@traditionrider
@traditionrider 3 роки тому
Love how you used Tishka in the video to illustrate the deep sleep example.
@AndreasSpiess
@AndreasSpiess 3 роки тому
It was not hard to convince her to help in this project ;-)
@avejst
@avejst 4 роки тому
Great walkthrough as always Simple and easy guide, fantastic Thanks for sharing 👍😀
@AndreasSpiess
@AndreasSpiess 4 роки тому
Glad you enjoyed it
@willy.verbiest
@willy.verbiest 4 роки тому
Very well explained in detail
@AndreasSpiess
@AndreasSpiess 4 роки тому
Glad it was helpful!
@cleberam
@cleberam 4 роки тому
@Andreas, I detach the interrupt at the beginning of the ISR on my Dimmer control, it's only 60Hz and an ESP8266 (today) but it did resolve the flickering I was facing at the edges turning on the off the light completely (and smoothly). Wifi has to be on and there is intense MQTT to keep dashboard as real time as possible, so if I miss a trigger at the edges I just complete the cycle one way or another. With this I could literally get the entire 1% to 99% (in a logarithm scale for real light scale) without bugs. Another great video from you. Cheers.
@AndreasSpiess
@AndreasSpiess 4 роки тому
Interesting. I thought 60 Hz would be possible, especially on the non-Wi-Fi core.
@phillipneal8194
@phillipneal8194 4 роки тому
Bravo ! Another wonderful video.
@AndreasSpiess
@AndreasSpiess 4 роки тому
Many thanks!
@klassichd10
@klassichd10 4 роки тому
Thanks a lot for your effort, your experiments, the video and the explanations. And we are now back to the same question we discussed when the ESP32 became availabe: How to use the different cores for different tasks in Arduino IDE , e.g. to decouple WiFi. Up to now I did not find a solution. This is why my counter at the water meter still uses 2 pcs ESP8266. One just for counting and tranferring data via HW-serial without any WiFi output and the second for analyzing the data and communication with my home automation system. Not very elegant, but runs very stable, uptime 657 days since the last blackout caused by road construction works.
@AndreasSpiess
@AndreasSpiess 4 роки тому
I think this is a good concept. Or use a little HW for time critical tasks.
@ingusestons6480
@ingusestons6480 4 роки тому
TNX for your work!
@AndreasSpiess
@AndreasSpiess 4 роки тому
My pleasure!
@TYGAMatt
@TYGAMatt 3 роки тому
Hi. What a great video. I think you may have just solved my esp32 interrupt crashing issues. I will test your code tomorrow. FYI I'll be using it for a speedometer.
@TYGAMatt
@TYGAMatt 3 роки тому
Update: the Frequency_Counter_with_Interrupt.ino seems to run fine. A little inaccurate at really low rpm (60rpm for example) but good at high rpm. Maybe some smoothing required. Now trying to use time between pulses so work out rpm. Not going to plan yet ;)
@JanJeronimus
@JanJeronimus 4 роки тому
To experiment with measuring a higher frequency a (simple) hardware frequency divider could be added.
@AndreasSpiess
@AndreasSpiess 4 роки тому
The frequency counter was just my example to demonstrate the two interrupts in one example.It was not meant to be useful...
@thomasdiebel1221
@thomasdiebel1221 9 місяців тому
Always a pleasure to watch your videos. Thanks for this on. I ran into some trubble appling the irq approach to a 100Hz signal with not as perfect steep flanks as in your given example. The isr gets triggered multiple times during rising and falling flanks. The RISING statemend seems to have no effect in the allocation of the irq. The esp32 seems to have problems with shallow flanked and slow signals. In such cases additional HW and Code is needed...
@AndreasSpiess
@AndreasSpiess 9 місяців тому
It is always good to have a Schmitt trigger in front of the interrupt input. Maybe you can disable the interrupt for a few ms in the ISR as a work around.
@StefanoBettega
@StefanoBettega 4 роки тому
I agree with your idea of being the RTOS influencing the interrupt latency. The RTOS itself (which seems to mee FreeRTOS reading the definitions you wrote to allow ISRs to be safely called) has surely some routines to schedule our loop() function with its own tasks, which can be in turn the communications module handlers (Wifi and/or Bluetooth). Even though you disable them, they could be still working for some reason. In addition the scheduler itself can use an interrupt to switch internal tasks, and this can be another jitter cause.
@AndreasSpiess
@AndreasSpiess 4 роки тому
Many other commenters support this theory.
@pes003
@pes003 4 роки тому
Hello, your videos help me a lot, as I´m working with ESP32 for my Bachelor's thesis and there is not a lot of documentation out there. So thank you. :)
@noweare1
@noweare1 4 роки тому
Are you using IDF or Arduino for developement ?
@AndreasSpiess
@AndreasSpiess 4 роки тому
You are welcome!
@niklas4401
@niklas4401 4 роки тому
Interesting as Always!
@AndreasSpiess
@AndreasSpiess 4 роки тому
Glad you think so!
@electronic7979
@electronic7979 4 роки тому
Very helpful video. I liked it
@AndreasSpiess
@AndreasSpiess 4 роки тому
Glad to hear that
@jamesgoacher1606
@jamesgoacher1606 4 роки тому
Very interesting and I believe this will be useful to me.
@AndreasSpiess
@AndreasSpiess 4 роки тому
Glad to hear that!
@bobpaydar3210
@bobpaydar3210 3 роки тому
perfect video thanks 😊
@AndreasSpiess
@AndreasSpiess 3 роки тому
You're welcome 😊
@alexandern8671
@alexandern8671 4 роки тому
Thank you for another interesting and instructive video Andreas. >edit: went through the comments and found this was already reported, sorry I just wanted to add that RTOS seems indeed to be a culprit for the interrupt response latency and jitter. I think that attachInterrupt actually hooks up not to the interrupt controller but to an RTOS callback function. This function is entered the queue of RTOS tasks, and get executed after the completion of all the previous tasks only. Apparently it is possible to get a fast interrupt response when programming using noOS SDK from Espressif but I did not try this yet.
@noweare1
@noweare1 4 роки тому
That's a mistake then. It's an interrupt and should have a higher priority than a normal task.
@AndreasSpiess
@AndreasSpiess 4 роки тому
@Alexander: Maybe I will have once a closer look into RTOS...
@Quemedices684
@Quemedices684 2 роки тому
I don’t get it… Arduino is by no means RTOS, and it has no callbacks or other real time capabilities
@alexandern8671
@alexandern8671 2 роки тому
@@Quemedices684 ESP32 Arduino calls various functions that are built around Espresif's SDK that in turn uses RTOS for WiFi operations. If one does not need WiFi or software timers then no RTOS is involved indeed.
@hanli4977
@hanli4977 4 роки тому
Very helpful video. I like the cute pointer 👈
@AndreasSpiess
@AndreasSpiess 3 роки тому
Thank you so much 😊
@benricok
@benricok 4 роки тому
Awesome video😎
@AndreasSpiess
@AndreasSpiess 4 роки тому
Thanks 😁
@nosafetyswitch9378
@nosafetyswitch9378 4 роки тому
This video helped a lot! I wanted to monitor my PV panel energy harvesting using an ESP8266 and an arduino DUE (i know, not ebergy efficient but thats what I had lying around). Before th is video they were consuming 210mA and up to 250mA when publishing the measurements. Now i modified the sketch so that the DUE is always asleep (by pull down resistor on reset) and only wakes up for 3 sec (by the ESP) to measure and transmit the data to the ESP then go to sleep again. The ESP then (after connecting) publishes the data and goes to sleep for 20 sec or so. The result is that during sleep they both consume on 38mA and only 100mA when the ESP is awake. Only 3 seconds of 200mA now which easily runs this 24/7 on a single 18650 cell and for several days! Thanks for the insight!
@AndreasSpiess
@AndreasSpiess 3 роки тому
Nice project!
@critica1mass
@critica1mass 2 роки тому
Great video. One question: Do you have a schematic of how you hooked up the input signal and LCD display to the ESP32 as demonstrated in your video?
@AndreasSpiess
@AndreasSpiess 2 роки тому
I do no more remember. But I am sure Google knows...
@Brian_Of_Melbourne
@Brian_Of_Melbourne 4 роки тому
Andreas, perhaps a followup comparing the interrupt coding and latency on other 'Arduinos' like STM32, SAMD21, ATMega, ATTiny, ESP8266, MK20DX (Teensy), SiFive E31 (HiFive1), etc.
@AndreasSpiess
@AndreasSpiess 4 роки тому
This is a very special topic. So blogs are probably a better place for such comparisons.
@ripper121
@ripper121 4 роки тому
Take a look into there datasheet and you can compare by your own.
@leocurious9919
@leocurious9919 4 роки тому
@@ripper121 Ah yes, datasheets to find out about interrupts and how they affect everything... let me just quickly read for dozens of hours to compare a few µC... Just seeing that a ESP32 is pretty much useless if you go into deep sleep is enough information.
@dieSpinnt
@dieSpinnt 4 роки тому
@@leocurious9919 Really, that's a very specialized problem and different for each individual case, as Andreas said. Think about changing just one clock cycle in your application code changing the complete timing that is at issue here. It is best to simulate this for each individual case, better to test it as an experimental setup. If something is important for a preliminary decision, it is the limiting/rating values and the clock behavior that can be found in the data sheet. So @Ripper121's remark is far more helpful than displaying one's own laziness. Stay healthy:)
@leocurious9919
@leocurious9919 4 роки тому
@@dieSpinnt It would be a perfect followup to this video. And for which videos does this not apply? "displaying one's own laziness"
@timdurham9091
@timdurham9091 4 роки тому
Very nice work! You should be quarantined more often.
@AndreasSpiess
@AndreasSpiess 4 роки тому
Not a lot of change here. I am anyway living in my lab ;-)
@aressto
@aressto 3 роки тому
Superb video with tons of help! Ty! What microcontroller do u recommend for RT systems with wifi inside? Do u meet such?
@AndreasSpiess
@AndreasSpiess 3 роки тому
If you need fast responses, you probably are better with separating Wi-Fi from the MCU (using a ESP-01 for example)
@kostashellas
@kostashellas 3 роки тому
Great video once again Andreas, very educating! ; just a comment pcnt (optimized assembly code on esp32 for pulse counting) can do better than standard isr when it comes to frequency counting?
@AndreasSpiess
@AndreasSpiess 3 роки тому
Assembly usually is faster. But nearly nobody can use it.
@kerron_
@kerron_ 4 роки тому
I didnt know they had external interrupts. Good video
@AndreasSpiess
@AndreasSpiess 4 роки тому
Thank you!
@s16e559
@s16e559 3 роки тому
hey there! thanks for the amazin videos! One question does every core has it's own set of timers, or are timers/interrupts etc. all global and both cores share the same of them?
@AndreasSpiess
@AndreasSpiess 3 роки тому
You can have a look at the block diagram in the datasheet. There you find all peripherals.
@marcobassini3576
@marcobassini3576 Рік тому
Timers are global (there are 4), interrupts are per core. With the ESP IDF framework you can exploit all the features.
@EvileDik
@EvileDik 4 роки тому
Great stuff Andreas, I thought I was competent with ESP interrupts, you showed me 2 new things! I am interested, is it not possible to use the ULP processor to collect small amounts of data then only wake up and upload to the main processor one every 10 readings or so? I am imagining some kind of slow process like a weather station application.
@AndreasSpiess
@AndreasSpiess 4 роки тому
I think I mentioned this fact in thee video.
@timmtub
@timmtub 4 роки тому
Andreas, nice video! Regarding start-up time: the ESP32 supports deep sleep wake stubs that are executed before any normal initialization. It can send the ESP back to sleep if for example the voltage of a connected battery is too low. I use this feature for undervoltage detection of a connected lipo battery (saving on an additional hardware component). Best
@AndreasSpiess
@AndreasSpiess 4 роки тому
I mention that in the summary. Do you have an example for the Arduino IDE?
@timmtub
@timmtub 4 роки тому
@@AndreasSpiess Sorry, missed that part! It is easy to implement in Arduino, as the default wake up stub function is weakly coupled and can be overwritten directly: RTC_DATA_ATTR int bootCount = 0; void RTC_IRAM_ATTR esp_wake_deep_sleep(void) { esp_default_wake_deep_sleep(); bootCount++; } This increments the counter before the bootloader starts. Greetings from Germany
@666aron
@666aron 4 роки тому
Very interesting and informative video as always. I don't know how to disable interrupts in arduino mode, but in bare-bone C/C++ or w/o rtos it is possible. I think that it would be quite interesting to compare the behavior / timing in bare-bone / arduino program.
@AndreasSpiess
@AndreasSpiess 4 роки тому
For the moment I have no project with the need of those fast interrupts. So I will not follow up.
@QUIX2468
@QUIX2468 3 роки тому
Nice video! I have just one question: What is the divice called that you used to measure the power consumption of the esp32? (I once saw it at the eevblog mailbag, but it seems that I can't find itanymore.) Thank you very much in advance for your answer!
@AndreasSpiess
@AndreasSpiess 3 роки тому
I use several devices: The ucurrent gold, the current ranger (both shown in one of my videos), the Joulescope, and the OTII
@DimitarManovski
@DimitarManovski 4 роки тому
Great video, thanks you :)
@AndreasSpiess
@AndreasSpiess 4 роки тому
Glad you liked it!
@mikelopez9893
@mikelopez9893 4 роки тому
Your videos are always excellent. By the way, If you want a low latency ISR on the ESP32, consider placing it in IRAM. (There is a flag you can put on the ISR definition to do this).
@movax20h
@movax20h 4 роки тому
He already did that. I think the issue with ISR is due to arduino code, not ESP32. Also I don't think you really need the mutexes in ISR unless you manipulate more complex data structures from ISR. doing read-modify-write (like count++) from ISR, while rest of the code only do reads (so you might need to have two variables to track how much count you already processed, not reset it back to zero), is safe and doesn't require a mutex.
@SpinStar1956
@SpinStar1956 2 роки тому
Great video! Question 🙋‍♂️ could you count frequency with an internal hardware counter? Are they cascadable so that you could at least use them for HF? Thanks 😊 73…
@AndreasSpiess
@AndreasSpiess 2 роки тому
You are right. You can use the internal counters either to count or to divide the frequency of the input signal. Here I did not want to build a fast counter, I only used it as a simple to understand example for interrupts.
@SpinStar1956
@SpinStar1956 2 роки тому
@@AndreasSpiess Thanks for your replies; much appreciated 😃
@prathambumb5593
@prathambumb5593 4 роки тому
Thank You
@AndreasSpiess
@AndreasSpiess 4 роки тому
You're welcome
@bernhardgabler5381
@bernhardgabler5381 4 роки тому
A great part of the inaccuracy in the interrupt code (at 7:13 in video) is caused by your own loop code: { frequency = count; display(0, "frequency=", frequency); lastEntry=millis(); count=0 } You use count but reset it only after displaying on the pretty slow LCD. That means, all events that occur during the LCD operation are not counted, but lost. Also, if the duration of LCD output varies, it worsens the count precision. You could improve it if you first completed the job of count handling: { frequency = count; count=0; display(0, "frequency=", frequency); lastEntry=millis(); } BTW, your polling loop (at 3:54 in video) would be more elegant if you replaced lastentry= millis(); while (millis() < lastEntry + 1000) {...} with endTime=millis()+1000; while (millis() < endTime) {...} This way the addition would be done only once. However a good compiler might catch this and produce the same binary code.
@movax20h
@movax20h 4 роки тому
The compiler will figure out the optimization you mentioned at the end automatically. There will be no difference in performance. However, your hint about doing count=0; just after reading frequency is a valid one. In fact if you have mutexes used, you can wrap read and reset of the count, into critical block and be even safer. There are other approaches (like not resetting count at all, and remembering the last count, and subtracting it from current count to get new frequency (might require a special handling of overflows tho; but it will not need mutexes).
@heinrich..
@heinrich.. 6 місяців тому
it is perfectly fine how he did it. even if the displaying took multiple seconds it wouldnt change anything since the lastEntry variable is changed just before resetting the counter. so it doesnt matter how many counts there were while communicating with the lcd. correct me if i miss something though
@lernenmitrobin
@lernenmitrobin 4 роки тому
I'm currently using the ESP32 for a fft application on net voltage and load current signals (2 analogue channels, 50Hz), where I trigger a timer interrupt up to 1024 times per period, so ~ 100k samples/s on RTOS using both cores. In my case I'm working with hardware interrupt each ~20ms which calculates a timer value for the real period time divided by 1024. This timer or counter calls another ISR every ~ 20µs. In my opinion the ESP32 is fast enough for similar applications. But I'm totally agree with your point of the delay of hardware interrupts. Thanks for your research!
@AndreasSpiess
@AndreasSpiess 4 роки тому
Quite a sophisticated application ;-) I use now a second RTOS task with a delay for my morsetrainer. Works fine (ms)
@andymouse
@andymouse 4 роки тому
Very useful...cheers.
@AndreasSpiess
@AndreasSpiess 4 роки тому
Glad you think so!
@zyghom
@zyghom 2 роки тому
super nice Andreas, as usual: idea stolen for my next project: rpm of my noctua fan counted using your example ;-)
@AndreasSpiess
@AndreasSpiess 2 роки тому
Sounds great!
@theScottishAlien
@theScottishAlien 4 роки тому
Very interesting! I've been trying to combine wake up timer and wake up interrupt on my current project but have run into a bug with the ESP32 that is problematic for multiple wake up methods. Have you ever tried both a timer and interrupt for deep sleep? For example, counter on interrupt and then sending the count total every 5min?
@AndreasSpiess
@AndreasSpiess 4 роки тому
I wold not mix deep sleep and interrupts. As shown, in one case the CPU sleeps and in the other it runs
@theScottishAlien
@theScottishAlien 4 роки тому
@@AndreasSpiess I mean waking up on an interrupt pin (esp_sleep_enable_ext0_wakeup(GPIO_NUM_33,1)) I've found that when including ext0 and timer wakeup that there one of the two sometimes doesn't work
@shadow7037932
@shadow7037932 4 роки тому
@8:00 In regards to a real time MCU, have you looked at the Ti CC3220/MSP430 and Ti RTOS?
@AndreasSpiess
@AndreasSpiess 3 роки тому
No. I stick with my few MCUs because it is a lot of effort to add another one.
@JS7457
@JS7457 2 роки тому
Hey there! I have an application similar to your example with the counter and I had the same problem as you, the esp32 crashing. You said in the video that the ESP32 is not for fast real-time applications, but what about using FreeRTOS? or is it completely different? Also could you give some examples of fast real time mcu's out there so your counter could work? Thanks!
@AndreasSpiess
@AndreasSpiess 2 роки тому
I made a video about freeRTOS. Maybe you watch it. But I doubt it would help in this situation.
@indranilkarmakar8490
@indranilkarmakar8490 4 роки тому
Hello sir , i am very helpful by your videos in my projects and i want to thank you . i have a question , in nodemcu the maximum deep sleep time is around 71 minutes , so if i want to sleep nodemcu whole time until an external interrupt occurs then what should be changes in the code?
@AndreasSpiess
@AndreasSpiess 4 роки тому
Nothing. Timer interrupts are different from external interrupts
@indranilkarmakar8490
@indranilkarmakar8490 4 роки тому
@@AndreasSpiess thank you sir
@TristanGrimaux
@TristanGrimaux 3 роки тому
It would be lovely to have chapters in your videos!
@AndreasSpiess
@AndreasSpiess 3 роки тому
They are probably too short and are made to be watched till the end (except mailbags which have chapters)
@TristanGrimaux
@TristanGrimaux 3 роки тому
@@AndreasSpiess Andreas, for me your videos turn very quickly into references, and the chapters are excelent to go and check something again
@andreitisanu2788
@andreitisanu2788 3 роки тому
Nice video you have! I have a question for you if you can to help me. Can I make a wake up event with a touch sensor and in the same time I have timer wake up? I want to use this method to send the data through Wi-Fi(at every one hour) and touch sensor to wake up to see the values via Bluetooth? Or it's too much?
@AndreasSpiess
@AndreasSpiess 3 роки тому
Here you find some info: randomnerdtutorials.com/esp32-touch-wake-up-deep-sleep/randomnerdtutorials.com/esp32-touch-wake-up-deep-sleep/
@meinsda5983
@meinsda5983 4 роки тому
Great video! Most of the programmers don't know that they should use more interrupts! It seems that you can't block the interrupts inside the isr.
@AndreasSpiess
@AndreasSpiess 4 роки тому
There are some discussions going in other comments around "disable interrrupt" ;-)
@meinsda5983
@meinsda5983 4 роки тому
@@AndreasSpiess yes i have read. Normaly if you learn interrupt programming, the first command in the ISR is that you mask the interrupts, that no other can block you. Only die NMI is allowed
@tomasallegrini2503
@tomasallegrini2503 3 роки тому
Hi Andreas, i've been following for a while, you help me a lot with your videos about lora and esp32, which help me to write firmware for a local startup. Latelly i've seen some problems with the esp32 (we have in production more or less 300 boards based on esp32 wrover), sometimes the uc freezes (hangs), i am not sure if this happens after the deepsleep (the device samples data for 3 minutes, and enters in deepsleep for 12 minutes) because of a fail in the RTC to generate the interrup to wake up the board. (the board cannot be accesed once that is deploy, we are using in farms). Have you ever encounter a problem like this? Do you have any recommendation or knowledge about this problem? Thanks in advance, hope you are well!
@AndreasSpiess
@AndreasSpiess 3 роки тому
These are bad problems which mainly occur if you deploy many devices. Here I restart my boards without thinking if they do not work anymore. So I cannot answer your question. The only possibility is to start logging and try to provoke the error in a test setup.
@muharremboyraz2813
@muharremboyraz2813 4 роки тому
Hi, thank you for best videos about esp32. I trying to input capture mod for reading receiver signal but i can't find. Can you help about this.
@AndreasSpiess
@AndreasSpiess 4 роки тому
I share my knowledge in my videos.
@sounavailable
@sounavailable 3 роки тому
What tool did you use to accurately measure the milliamp current consuption at 15:30? it does not appear in you link with the equipment you are using...
@AndreasSpiess
@AndreasSpiess 3 роки тому
I made a few videos about current measurement and deep sleep. This is an OTII and sometimes I use a current ranger or microcurrent gold or Joulescope.
@navadeep.ganesh
@navadeep.ganesh 4 роки тому
Excellent......found something thinkstriking.
@AndreasSpiess
@AndreasSpiess 4 роки тому
Glad you liked it!
@turkerbayraktarlar2640
@turkerbayraktarlar2640 4 роки тому
Fantastic
@AndreasSpiess
@AndreasSpiess 4 роки тому
Thank you so much 😀
@andresceballos4128
@andresceballos4128 2 роки тому
hello good video thank you very much it helped me a lot but I have a question I have a set of multiple gpio as an interrupt pointing to the same ISR function, the question is how can I know which GPIO was activated by interrupt? Or are there special methods to do this type of query?
@AndreasSpiess
@AndreasSpiess 2 роки тому
I would add different ISRs for each interrupt and call a common function inside each one. Maybe there is also a register to find out which interrupt was triggered. But I do not know it.
@gerdkah6064
@gerdkah6064 4 роки тому
very well explained! who is responsible for the english subtitels? (want to know why some english-words are translated in other words - e.g. _heap_ -> _cluster_ )
@AndreasSpiess
@AndreasSpiess 4 роки тому
Google does add an auto-translation.
@gerdkah6064
@gerdkah6064 4 роки тому
@@AndreasSpiess astonishing ^v^
@juancarlosnarvaez3875
@juancarlosnarvaez3875 4 роки тому
Good Andreas!!
@AndreasSpiess
@AndreasSpiess 4 роки тому
Thank you!
@SteveWrightNZ
@SteveWrightNZ 4 роки тому
cool! thankx!
@AndreasSpiess
@AndreasSpiess 4 роки тому
You are welcome!
@AndriesdeBeer
@AndriesdeBeer 4 роки тому
Much appreciated by this guy with the Afrikaans accent!
@AndreasSpiess
@AndreasSpiess 4 роки тому
You are welcome!
@zaidinh
@zaidinh 3 роки тому
Hi Andreas, I am experiencing the same interrupt latency issues with my design. Have you come across any there any good alternatives of ESP32 like MCU boards at fast realtime operations low interrupt latency; that can provide wifi and ADC?
@AndreasSpiess
@AndreasSpiess 3 роки тому
I heard that STM finally jumped on the Wi-Fi bandwagon. But I do not know if we can program it with the Arduino IDE.
@fredericbenzaquine3510
@fredericbenzaquine3510 4 роки тому
Hi , love your videos so much. By the way, do you know the boards from Kevin Darrah ´trigbaords’ they consume almost nothing and they are based on ESP32. I’d love to have a review from you, be safe.
@AndreasSpiess
@AndreasSpiess 4 роки тому
I had one of them in one of my past mailbags.
@fredericbenzaquine3510
@fredericbenzaquine3510 4 роки тому
@@AndreasSpiess Hi, it is very unlikely as they just got announced a few weeks ago but I'll check, maybe you are referring to the 8266 model.
@bm830810
@bm830810 4 роки тому
Is it possible to handle the interrupts with the second core? maybe this fixes the high jitter on EXTI
@AndreasSpiess
@AndreasSpiess 4 роки тому
It is possible, but I do not know why it would change. Maybe somebody tries?
@bm830810
@bm830810 4 роки тому
@@AndreasSpiess The main core is running many background tasks, I believe the second core is completely idle, If RTOS is handling the interrupts (which it shouldn't) that's another story
@devrim-oguz
@devrim-oguz 4 роки тому
@@AndreasSpiess I think the delay is due to other FreeRTOS tasks taking over. Running it on another code could help. You need to create a very high priority task on that core and disable the watchdog timer.
@jrgalyen
@jrgalyen 4 роки тому
Ali Devrim OGUZ FreeRTOS seems to have a make menuconfig option to lock it to only the first core? would this assist after your interrupt suggestion? also interested in other versions. wroom, wrover, (solo can’t be real-time), S2. Would love to have time to test them. Probably goes for all of us. Also need to invest in oscilloscope / dsi.
@devrim-oguz
@devrim-oguz 4 роки тому
@@jrgalyen yeah that'll probably work too, however it may not let you run your program on the other core. I haven't tried that. I only saw the menu option to "not run the freertos on a single core"
@fingerprint8479
@fingerprint8479 4 роки тому
Mr Andreas, thanks for the video. I have a project that extensively uses interrupts. It uses 8 water flow meters to measure water consumption. I have always used portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED; in my code without actually understanding its function. I saw you are using portMUX_TYPE sync = portMUX_INITIALIZER_UNLOCKED; Tried to search for the differences but failed to find relevant explanations. Why MUX or SYNC and when to use one or the other? Thanks in advance.
@inclinedplane0192
@inclinedplane0192 4 роки тому
That is just a variable name, you could use portMUX_TYPE potato = portMUX_INITIALIZER_UNLOCKED; just refer to the same variable name in your ISR's portENTER_CRITICAL(&potato) and portEXIT_CRITICAL(&potato) calls.
@craigcooper2497
@craigcooper2497 3 роки тому
A little off topic but... When using the ext1 deep sleep wake, is it possible to use an IF statement to perform tasks based on which of the buttons woke the esp?
@AndreasSpiess
@AndreasSpiess 3 роки тому
It should be possible to read the pins with digital read as one of the first actions after wake-up
@craigcooper2497
@craigcooper2497 3 роки тому
@@AndreasSpiess thank you for the quick response, definitely an option, but I was only using a single pulse as not to cause multiple wake ups. As the esp prints the GPIO I thought it may be an option to do something like below: IF(GPIO_WAKE_REASON==GPIO2){ TASK ONE } ELSE IF(GPIO_WAKE_REASON==GPIO15){ TASK TWO } ELSE{ esp sleep enable ext1 Esp deep sleep start }
@ifzq0
@ifzq0 Рік тому
GREAT VIDEO!!!! Yes, it´s a penny that ESP32 is not good for Real Time applications. I´ve noticed the high Jitter on interrupts (Varying from 2 to 45us). It would be good if someone finds how to program the interrupt with *high Priority* even on assembler.
@AndreasSpiess
@AndreasSpiess Рік тому
So far I do not know of such a project :-(
@sammflynn6751
@sammflynn6751 3 роки тому
Sir, hope you are doing well and enjoying holiday. Could you please repeat the interrupt frequency test for other popular microcontrollers like arduino mega,due or nano. I have six quadrature encoder for motor control using PID and was wondering what might be the best solution for this kind of project.
@AndreasSpiess
@AndreasSpiess 3 роки тому
I have no such plans for the moment. The Arduinos are much faster, and fastest are probably the STM32s
@akj7
@akj7 4 роки тому
Thank you Mr. Spiess for the interesting video. Having started programming Microcontrollers with Arduinos and ESPs, and now programming Controllers on a professional level, the DIY embedded system community is filled with lack of skills: poor code because no real programming knowledge, lack of understanding of what is actually going on under the hood, ... . For example, one thing i noticed in professionally, is that i had to always master the controllers' documentations, i had to work on. This lead to the fact that most issues that you mentioned in the video simply can't happen (like polling the digitalread and delaying). I therefore really appreciate deep videos like yours, that aren't simply about repeating examples found online, but analyse and go behind the curtains.
@noweare1
@noweare1 4 роки тому
He didn't delay, he used millis(). Take another look.
@AndreasSpiess
@AndreasSpiess 4 роки тому
@Jules: Glad you like them.
@fehereger
@fehereger 4 роки тому
at smt32 controllers existing interrupt priorities(interrupt in interrupts), maybe that helps with counting edges, when the EXTI is the most highest.
@AndreasSpiess
@AndreasSpiess 4 роки тому
That is what most other CPUs have.
@TheEmbeddedHobbyist
@TheEmbeddedHobbyist 4 роки тому
If your running an RTOS then there will always be issues with when you get to see the interrupt. so i can see why the latency is changing, it depends where you interrupt arrives in the the background processes. Not sure if the ESP32 RTOS has variable time slots or fixed time slots so there could be issues there. In the embedded world there is a lot of effort to get an RTOS working correctly. Spent many a happy week on embedded RTOS courses, just to decide that if you don't need all that an RTOS offers then it best not to use one. Also interrupts are a pain for proving the code is safe, as how do you check all the possible places in your main code where it can get interrupted, don't get issues when interrupted at the point. Nice thought provoking video as usual, thanks
@movax20h
@movax20h 4 роки тому
You can process interrupts at higher priority (i.e. level 5, just before NMI level). By default ISR will be lowest priority (level 1), so it will be preempted and/or delayed by other routines like a task scheduler. It is possible to have stable latency and minimal jitter using FreeRTOS.
@BillXT11
@BillXT11 4 роки тому
Can you do a video comparing interrupts, timers and tasks? how to use them, in which situation and speed limitation?
@AndreasSpiess
@AndreasSpiess 4 роки тому
I do not know. I am not into video.
@BillXT11
@BillXT11 4 роки тому
Andreas Spiess hehehe sorry I meant an episode ;)
Use the very attractive new ATTINY chips for your projects
14:34
Andreas Spiess
Переглядів 187 тис.
Radar Sensors from $3 to over $100: Which one is Best?
14:31
Andreas Spiess
Переглядів 145 тис.
ТІНА КАРОЛЬ & SHUMEI - СТЕРВА ( ПРЕМ'ЄРА 2024)
03:20
Rutgers University Confirmed: Meshtastic and LoRa are dangerous
13:27
Andreas Spiess
Переглядів 703 тис.
USB-C Tutorial for Everybody (Connector, Cable, PD, Data Transfer, Devices)
26:08
451 Which Processor can kill the ESP32?
11:24
Andreas Spiess
Переглядів 329 тис.
#339 The new ESP32-S2: How relevant is it for the Makers? First tests
11:32
Andreas Spiess
Переглядів 256 тис.
ESP32 Deep Sleep: Ultra-Low Power Coprocessor
15:27
atomic14
Переглядів 28 тис.
ESP32 Guide 2024 | Choosing and Using an ESP32 Board
41:06
DroneBot Workshop
Переглядів 192 тис.
Don't Throw Your Old Sim Card
19:16
TEST COMPARE
Переглядів 1,5 млн
Какой MacBook выбрать в 2024 - М1, М2 или М3?
24:56
iphone X Convert To Iphone 11Pro #iphonex #iphone11pro #shorts
0:13
Technical Mobile
Переглядів 4,9 млн
GOOGLE СДЕЛАЛИ НЕВОЗМОЖНОЕ! Это круче любого Samsung, Apple и Xiaomi…
13:16
Thebox - о технике и гаджетах
Переглядів 59 тис.
Самая редкая видеокарта от SONY
13:51
Nitroxsenys
Переглядів 48 тис.
Почему iPhone ярче? #apple #iphone
0:46
Не шарю!
Переглядів 399 тис.