phoneDTMF icon indicating copy to clipboard operation
phoneDTMF copied to clipboard

maxFrequence returned by nano 2890

Open hayden-t opened this issue 3 years ago • 9 comments
trafficstars

this is the same 328 chip as uno ? readme says i need 6000. what gives ?? (thanks)

hayden-t avatar Aug 05 '22 11:08 hayden-t

My project uses an ESP with 240MHz. The ATMega328 (Uno and Nano) have a 16MHz oscillator. The clock speed should be enough to read it. It is just important that you read the analog input 6000 times on each second.

Adrianotiger avatar Aug 05 '22 12:08 Adrianotiger

even if i have this most basic script, the analog center reported varies alot, sometimes correct, sometimes volts off.


#include <PhoneDTMF.h>
PhoneDTMF dtmf = PhoneDTMF();


int dtmfPin = A0;

float* pMagnitudes;

void setup()
{
  
  Serial.begin(9600);
  Serial.println("Ready");
  
  delay(1000);
  dtmf.begin(dtmfPin);


  Serial.println(dtmf.getAnalogCenter() * (5.0 / 1023.0));
  Serial.println(dtmf.getSampleFrequence());

hayden-t avatar Aug 05 '22 14:08 hayden-t

you should not measure it when a signal is present.

When you call dtmf.begin(), the center is measured. If you already have a signal, this value can be higher or lower.

The center is regulated automatically on each measurement.

Adrianotiger avatar Aug 05 '22 14:08 Adrianotiger

no, this is happening with no signal, just 2.5v flatline

hayden-t avatar Aug 05 '22 14:08 hayden-t

doing some research i found this library which when i use its analogfastread function my maxfrequence is nearly 4000 https://github.com/avandalen/avdweb_AnalogReadFast

hayden-t avatar Aug 05 '22 16:08 hayden-t

looking further at your code it seems the limiting factor for me is not so much the adc sample rate, but the additional code in ProcessSample that is called everytime an analogue read is done. maybe nano is not fast enough

hayden-t avatar Aug 05 '22 16:08 hayden-t

i reverted back to standard analog read and commented out the process sample code, it now reports maxfreq at 8929, so would have t optimize that code if possible, i may just buy the decoder board.

hayden-t avatar Aug 05 '22 16:08 hayden-t

But 8930 is ok to measure the tone

Adrianotiger avatar Aug 05 '22 16:08 Adrianotiger

except thats with no processing:

/* Call this routine for every sample. */
//El_Supremo - change to int (WHY was it byte??)
  /// <summary>
void PhoneDTMF::ProcessSample(int16_t sample)
{
/*
  float Q0;
  //EL_Supremo subtract adc_centre to offset the sample correctly
  for (uint8_t i = 0; i < TONES; i++)
  {
    Q0 = _afToneCoeff[i] * _afQ1[i] - _afQ2[i] + _fAmplifier * (sample - _iAdcCentre);
    _afQ2[i] = _afQ1[i];
    _afQ1[i] = Q0;
  }
  _fAdcCentre += (float)sample / (float)_iSamplesCount;
*/
#ifdef DTMF_DEBUG
  if (_iDataIndex < 128)
  {
    _aiAnalogData[_iDataIndex++] = sample;
  }
#endif
}

hayden-t avatar Aug 05 '22 17:08 hayden-t