Hi,
The code below shows the changes that I made to find not only the first but also the second correlation peak. Both the frequencies that belong to these periods are calculated (not in the code fragment).
case 2 :
if ((currentSum - previousSum) <= 0) {
float interpolationValue = 0.5 * (currentSum - twoPreviousSum) / (2 * previousSum - twoPreviousSum - currentSum);
if (firstPeriod == 0) {
firstPeriod = i - 1 + interpolationValue;
break;
}
else {
secondPeriod = i - 1 + interpolationValue;
pdState = 3;
}
}
break;
A question out of curiosity, would it be possible to get the same accuracy with FHT or FFT libraries on the Arduino (with interpolation added)?
Bart