I'm wondering about the status of this post from 2016, concerning using an ADC to read a MAX4466 mic input, which is what I'm attempting.
https://forum.pjrc.com/threads/40468-Help-with-Basic-Audio-Lib-results
It mentions doing soldering to get the bias voltage down to 1.2V. However, in the ADC.h file, it looks like it (now?) defaults to 3.3V. Anyways, I'm not touching it, and the MAX4466 seems to work fine.
The problem that I'm seeing is fairly high static noise. When I send the output to a speaker, the noise is higher than what the mic should pick up. The min and max levels below show ~31xxx min to ~33xxx.
The speaker doesn't appear to have any noise. When I send it a sine wave, it sounds perfect (although an FFT might spot a warble.)
When I connect the ADC input to ground (GND), I get values fairly consistently between 6 and ~120. Does this mean that the reference voltage is flaky, or could there be an issue in the ADC ? Or is this expected?
Also, I have no idea what conversion or sampling speed should be for this application. I'm using a Teensy 3.6.
#include <ADC.h>
int ADC1 = 16;
ADC* adc;
void setup()
{
Serial.begin(38400);
pinMode(LEDpin, OUTPUT);
adc = new ADC();
// Doesn't seem to make much difference.
adc->setConversionSpeed(ADC_LOW_SPEED, 0);
// Setting this to 10 generates a range centered at 512.
// Setting this to 16 generates a range centered at 32k.
adc->setResolution(16, 0);
SIM_SCGC2 |= SIM_SCGC2_DAC0 | SIM_SCGC2_DAC1;
DAC0_C0 = DAC_C0_DACEN | DAC_C0_DACRFS;
DAC1_C0 = DAC_C0_DACEN | DAC_C0_DACRFS;
}
int led;
int level = 0; // -1;
int max_level, min_level;
void loop()
{
digitalWrite(LEDpin, led);
led = 1 - led;
min_level = 100000;
max_level = -100000;
for (int i = 0; i < 30000; ++i)
{
// 3.3V will produce results around 32k (for 16 bit samples.)
int level = adc->analogRead(ADC1);
if (level > max_level)
max_level = level;
if (level < min_level)
min_level = level;
// Convert from 16 bit (centered at 32k) to 12 bit (centered at 2k)
level = ((level - 32768) >> 4) + 2048;
// A+
// Endian nuetral write
DAC0_DAT0L = level % 256;
DAC0_DATH = level >> 8;
// A-
DAC1_DAT0L = (4096 - level) % 256;
DAC1_DATH = (4096 - level) >> 8;
}
Serial.print(min_level);
Serial.print(" min ");
Serial.print(max_level);
Serial.println(" max");
}
https://forum.pjrc.com/threads/40468-Help-with-Basic-Audio-Lib-results
It mentions doing soldering to get the bias voltage down to 1.2V. However, in the ADC.h file, it looks like it (now?) defaults to 3.3V. Anyways, I'm not touching it, and the MAX4466 seems to work fine.
The problem that I'm seeing is fairly high static noise. When I send the output to a speaker, the noise is higher than what the mic should pick up. The min and max levels below show ~31xxx min to ~33xxx.
The speaker doesn't appear to have any noise. When I send it a sine wave, it sounds perfect (although an FFT might spot a warble.)
When I connect the ADC input to ground (GND), I get values fairly consistently between 6 and ~120. Does this mean that the reference voltage is flaky, or could there be an issue in the ADC ? Or is this expected?
Also, I have no idea what conversion or sampling speed should be for this application. I'm using a Teensy 3.6.
#include <ADC.h>
int ADC1 = 16;
ADC* adc;
void setup()
{
Serial.begin(38400);
pinMode(LEDpin, OUTPUT);
adc = new ADC();
// Doesn't seem to make much difference.
adc->setConversionSpeed(ADC_LOW_SPEED, 0);
// Setting this to 10 generates a range centered at 512.
// Setting this to 16 generates a range centered at 32k.
adc->setResolution(16, 0);
SIM_SCGC2 |= SIM_SCGC2_DAC0 | SIM_SCGC2_DAC1;
DAC0_C0 = DAC_C0_DACEN | DAC_C0_DACRFS;
DAC1_C0 = DAC_C0_DACEN | DAC_C0_DACRFS;
}
int led;
int level = 0; // -1;
int max_level, min_level;
void loop()
{
digitalWrite(LEDpin, led);
led = 1 - led;
min_level = 100000;
max_level = -100000;
for (int i = 0; i < 30000; ++i)
{
// 3.3V will produce results around 32k (for 16 bit samples.)
int level = adc->analogRead(ADC1);
if (level > max_level)
max_level = level;
if (level < min_level)
min_level = level;
// Convert from 16 bit (centered at 32k) to 12 bit (centered at 2k)
level = ((level - 32768) >> 4) + 2048;
// A+
// Endian nuetral write
DAC0_DAT0L = level % 256;
DAC0_DATH = level >> 8;
// A-
DAC1_DAT0L = (4096 - level) % 256;
DAC1_DATH = (4096 - level) >> 8;
}
Serial.print(min_level);
Serial.print(" min ");
Serial.print(max_level);
Serial.println(" max");
}