Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

analog read time 10 times slower #17

Open
silderan opened this issue Feb 9, 2024 · 12 comments
Open

analog read time 10 times slower #17

silderan opened this issue Feb 9, 2024 · 12 comments

Comments

@silderan
Copy link

silderan commented Feb 9, 2024

Hello.

I'm trying to make an audio spectrum analizer displayed on LCD.
Using 1024 samples seems better for more than 10 bars, but fps goes down dramatically.
Reading your code, says each analog reading takes 9,8uS, but my tests says it's arround 84uS.
84uS * 1024 aprox. 100mS. It's 10 readings per second.

Looking your video and another one that uses your code, LEDs seems displaying fine, with good FPS.

Is there some change in new ESP32 versions?

@whatever2010
Copy link

HI there i'm having the same issue! any luck yet?

@silderan
Copy link
Author

Well, not by solving this issue.
I went other way using I2S-DMA-ADC reading.
Take a look to my repository. I'm about to upload an API/modular version easier to use.

But, anyway, I'm curious to know why this issue. In some days, I will have ESP32 boards from another vendor. I'll tell something.

@whatever2010
Copy link

Sure mate! Thanks 👍

@s-marley
Copy link
Owner

Hi all, apolgies for not responding here quickly - I haven't looked at this in quite some time. Unfortunately I have no idea why my tests resulted in times so much different to other peoples. As @silderan said, there are better ways to do this so if I were to do this again I would have a look at his method instead. Sorry I cannot be of help!

@whatever2010
Copy link

Hi, thanks for responding. I actually did try that method.

@Cowh3adDK
Copy link

from my own testing i get these awful ADC conversion times from esp32 modules not manufactured by Espressif

@I-hate-2FA
Copy link

my esp is the cheapest esp lolin 32 lite with no shielding, the performance is
42us
23.81khz
it is still more then 20khz, so good enough, if you want more fps, why not update the display with 512 old sample and 512 new sample, that way the data is most recent and not as taxing on the hardware, like a rolling buffer, i think you can understand me

@silderan
Copy link
Author

silderan commented Jan 3, 2025 via email

@whatever2010
Copy link

Hi guys, I overcome this problem by using an I2s mic on the same fake esp32, and then I found the Wled with sound reactive capability, but in my idea nothing can beat the SP107e, It has a lot of wonderful effects, a dedicated app and lote of controls. But if you want to make your own spectrum analyser, try using an I2s mic. Cheers.

@I-hate-2FA
Copy link

Yes, I think I understand you. But this doesn't solve the 84us DAC sample time. By configuring the DAC to do samples so the CPU is free for Fourier transformation and display bars, is the way to go. Anyway, I was unable to do it properly and some "quick beats", like drums, sometimes don't show on display. Furthermore, I had some issues like viewing two peaks in some sounds. Using a phone for creating a "pure" tone, I saw the same issue. Maybe the problem is the microphone that creates some kind of harmonics. So, I give up :P El jue, 2 ene 2025 a las 21:32, AILIFE @.>) escribió:

my esp is the cheapest esp lolin 32 lite with no shielding, the performance is 42us 23.81khz it is still more then 20khz, so good enough, if you want more fps, why not update the display with 512 old sample and 512 new sample, that way the data is most recent and not as taxing on the hardware, like a rolling buffer, i think you can understand me — Reply to this email directly, view it on GitHub <#17 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQI7LWKCVSKKLEGTDDA3WD2IWO7JAVCNFSM6AAAAABUQSETGCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRYGM2DGMJYG4 . You are receiving this because you were mentioned.Message ID: @.
>

with most micro you can use adc dma ring buffer and cpu just do FFT and drive the neopixel constantly but again this is arduino ide so it wont happen
but ill be using 1602 LCD insted of neopixel cuz i dont have space this is just a extra feature cuz i already need that display why not make it do more and refresh rate of a LCD is terrible it cant really do more then 15fps so for me its not an issue and btw the i2c lcd is even worse cant even do 10fps

@I-hate-2FA
Copy link

Hi guys, I overcome this problem by using an I2s mic on the same fake esp32, and then I found the Wled with sound reactive capability, but in my idea nothing can beat the SP107e, It has a lot of wonderful effects, a dedicated app and lote of controls. But if you want to make your own spectrum analyser, try using an I2s mic. Cheers.

well yes wled is the best with app to configure but my project i want to use a screen i need display battery percentage of 12v which you will need to write usermod thats poorly documented and also i need it to self hold with a relay and power button again its using wled for unintended thing really not any good, i did use wled connect to digital mic and that control all rgb light in my house over DDP to light that run esphome (because home assistant and wled hate each other this is the only logical solution) it work quite well but not for this project i have in mind

@I-hate-2FA
Copy link

i tried to sample adc in the core 0 while loop run in core 1, but the adc conversion time just go to over double, so that was no good
i implemented the 1024 sample but only use 100 new reading before doing fft once and refresh the display, the frame rate is very good, way better then the LCD display i modified the code to work on can handle, downside is although it looked very responsive, the reading is lagging behind a bit, 100-200ms, which for LCD is not a bug deal because the refresh rate is bad anyways, but if you are using VFD display or led matrix it can be noticeable, but ive not found the true problem of ADC yet, since the cheap ESP just performed the same in all my previous project i dont have any other genuine one to compare to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants