-->
Page 1 of 2

Reliable Audio ADC Timer-ing

PostPosted: Thu Mar 26, 2015 3:25 pm
by cnlohr
So, I've looked this over time and time again for a few months now, and it's good to see people in various threads have been making headway with this. I've seen references to people being able to execute various versions of adc_read at pretty high speeds (20kHz, etc.) along with a few versions that talk to the read_sar_dout, function itself. I profiled this one to be ~25kHz https://github.com/mattcallow/esp8266-s ... tch/driver

This is fine and all, but I was wondering if anyone has yet figured out how to have a particularly low-latency high speed interrupt. Say I want to record at 11025 (or close to it). I can't seem to find any way of hooking an interrupt to execute at that period. Any ideas on how one would go about doing this? I would need it to override the Wifi RX interrupt and be able to interrupt the idle loop, etc.

I am actually trying to make an embedded version of my ColorChord system. The ESP8266 is a wonderful choice from my perspective... Just not sure how to get the whole get-audio-into-the-chip thing.

Also, I am trying as absolutely as hard as I can to avoid having to use an external ADC.

Re: Reliable Audio ADC Timer-ing

PostPosted: Sat Mar 28, 2015 10:06 am
by cnlohr
So, I am now sampling using the regular ADC code from the traditional timer.

Code: Select all   os_timer_arm_us(&hs_timer, 40, 1); //25,000


I split the ADC into two parts, one that starts sampling one that finishes... And I profiled it to get around 45kHz.

BUT! There is still a problem. My sampling does not happen on the 1/25,000th of a second. Any idea how I would be able to set the priority of my events to overtake the wifi interrupts, or whatever could be interfering with my code? Any idea how I can set up a interrupt to make it happen?

Code: Select all
//Timer event.
static void ICACHE_FLASH_ATTR
 hsTimer(void *arg)
{
   ets_intr_lock();
   uint16_t r = hs_adc_read();
   hs_adc_start();
   ets_intr_unlock();
   if( r == 0x400 ) r = 0x3ff;
   sounddata[soundhead] = r>>2;
   soundhead = (soundhead+1)&(BUFFSIZE-1);
}


Image
Image

Re: Reliable Audio ADC Timer-ing

PostPosted: Tue Jan 19, 2016 1:44 am
by RichardH
I was pleased to find your post here about the ADC. Other reports claimed that it was limited to 200Hz and that it was mutually exclusive to some WiFi operation.

How has your experimenting progressed? Are you able to get a reliable sampling rate on the ADC? Using an 07 or 12?

Like you, I have a project where I'd like to sample at 8KHz (44KHz would be amazing) without an external ADC chip.

Cheers,
Richard

Re: Reliable Audio ADC Timer-ing

PostPosted: Mon Jan 25, 2016 4:37 am
by esp03madness
External ADC is not very fast either. I'm currently looking at MCP3021 (10bit, i2c). On esp8266 i2c is bit banged and with the MCP3021 gives a maximum of 11111 samples/sec at 100% cpu. Also, sooner or later you will be interrupted for a wifi task or such, and during this period all ADC sampling will stop.

I am currently at a loss of what to do. I'll try to find a different external module first, but it's not looking good right now.