Ensure accurate sampling frequency in FFT_03.ino

pull/21/head
Edgar Bonet 2018-09-19 12:32:05 +02:00
rodzic 92f4066a72
commit c564008306
1 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

@ -53,15 +53,15 @@ void setup()
void loop() void loop()
{ {
/*SAMPLING*/ /*SAMPLING*/
microseconds = micros();
for(int i=0; i<samples; i++) for(int i=0; i<samples; i++)
{ {
microseconds = micros(); //Overflows after around 70 minutes!
vReal[i] = analogRead(CHANNEL); vReal[i] = analogRead(CHANNEL);
vImag[i] = 0; vImag[i] = 0;
while(micros() - microseconds < sampling_period_us){ while(micros() - microseconds < sampling_period_us){
//empty loop //empty loop
} }
microseconds += sampling_period_us;
} }
/* Print the results of the sampling according to time */ /* Print the results of the sampling according to time */
Serial.println("Data:"); Serial.println("Data:");