Hello,
I'm trying to measure the impedance of a loudspeaker. The resonant frequency where the impedance has its maximum should be at about 60Hz.
So I programmed a sine sweep from 20 to 120Hz and send it through a resistor in series to the loudspeaker. Between them I am trying to measure the av voltage with analogread() but it doesn't work. Is there an other way to measure it? I Think the problem is, that a measure at a very short time the DC voltage....
I'm trying to measure the impedance of a loudspeaker. The resonant frequency where the impedance has its maximum should be at about 60Hz.
So I programmed a sine sweep from 20 to 120Hz and send it through a resistor in series to the loudspeaker. Between them I am trying to measure the av voltage with analogread() but it doesn't work. Is there an other way to measure it? I Think the problem is, that a measure at a very short time the DC voltage....
Code:
#include <Audio.h> // Bibliotheken
#include <Wire.h> //
#include <SPI.h> //
#include <SD.h> //
#include <SerialFlash.h> //
///////////////////////////////////////////////////////////////////////////// Audio Library
AudioSynthWaveformSine sine; // Sinus
AudioOutputI2S LineOut; // Output = LineOut
AudioConnection patchCord1(sine,0, LineOut,1); // Sinus -> LineOut + Headphone(r)
AudioConnection patchCord2(sine,0, LineOut,0); // Sinus -> LineOut + Headphone(l)
AudioControlSGTL5000 sgtl5000_1; // Audioshield
///////////////////////////////////////////////////////////////////////////// Variablen
int f_i; // Laufindex der Frequenz
int f_start = 20; // Startfrequenz
int f_end = 120; // Endfrequenz
int dt; // Delaytime
int voltage; // Spannung am 1K Widerstand
///////////////////////////////////////////////////////////////////////////// Setup für den Sweep
void setup()
{
AudioMemory(20); // 20*128Bit reserviert
sgtl5000_1.enable(); // Audio Shield aktivieren
sgtl5000_1.volume(1); // Lautstärke zwischen 0-1
sine.amplitude(0.1); // Amplitude des Sinus
}
///////////////////////////////////////////////////////////////////////////// Loop
void loop()
{
for(f_i=f_start;f_i<=f_end;f_i++) // Schleife von Start- bis Endfrequenz
{
sine.frequency(f_i); // Frequenz des Sweeps
voltage= analogRead(14);
Serial.print(f_i);
Serial.print("\t");
Serial.println(voltage);
delay(1000/f_i); // Jede Frequenz wird genau eine Periodenlänge gespielt
}
}