Hi
How to fix compiling error
#define SAMPLES 128
#define SAMPLING_FREQUENCY 1000
int valuePin = PA7;
int Value ;
void setup()
{
pinMode(PA7, INPUT);
Serial.begin(250000);
}
void loop() {
Value = analogRead(valuePin);
//FFT(data, 64, 100); //to get top five value of frequencies of X having 64 sample at 100Hz sampling
FFT(Value, 128, 1000);
/*Serial.print(f_peaks[0]);
Serial.print(" ");
Serial.println(f_peaks[1]);
//delay(99999);
*/
delay(99);
}
//-----------------------------FFT Function----------------------------------------------//
float FFT(int in[], byte N, float Frequency)
{
unsigned int data[13] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048};
int a, c1, f, o, x;
a = N;
for (int i = 0; i < 12; i++) //calculating the levels
{
if (data[i] <= a) {
o = i;
}
}
int in_ps[data[o]] = {}; //input for sequencing
float out_r[data[o]] = {}; //real part of transform
float out_im[data[o]] = {}; //imaginory part of transform
x = 0;
for (int b = 0; b < o; b++) // bit reversal
{
c1 = data[b];
f = data[o] / (c1 + c1);
for (int j = 0; j < c1; j++)
{
x = x + 1;
in_ps[x] = in_ps[j] + f;
}
}
for (int i = 0; i < data[o]; i++) // update input array as per bit reverse order
{
if (in_ps[i] < a)
{
out_r[i] = in[in_ps[i]];
}
if (in_ps[i] > a)
{
out_r[i] = in[in_ps[i] - a];
}
}
int i10, i11, n1;
float e, c, s, tr, ti;
for (int i = 0; i < data[o]; i++)
/*
/////////////////////////////////////////////
{
Serial.print(out_r[i]);
Serial.print("\t"); // un comment to print RAW o/p
Serial.println(out_im[i]);
//Serial.println("i");
}
///////////////////////////////////////////////
*/
//---> here onward out_r contains amplitude and our_in conntains frequency (Hz)
for (int i = 0; i < data[o - 1]; i++) // getting amplitude from compex number
{
out_r[i] = sqrt(out_r[i] * out_r[i] + out_im[i] * out_im[i]); // to increase the speed delete sqrt
out_im[i] = i * Frequency / N;
Serial.print(out_im[i]);
//Serial.print("Hz");
Serial.print("\t"); // un comment to print freuency bin
Serial.println(out_r[i]);
}
x = 0; // peak detection
for (int i = 1; i < data[o - 1] - 1; i++)
{
if (out_r[i] > out_r[i - 1] && out_r[i] > out_r[i + 1])
{ in_ps[x] = i; //in_ps array used for storage of peak number
x = x + 1;
}
}
s = 0;
c = 0;
for (int i = 0; i < x; i++) // re arraange as per magnitude
{
for (int j = c; j < x; j++)
{
if (out_r[in_ps[i]] < out_r[in_ps[j]])
{ s = in_ps[i];
in_ps[i] = in_ps[j];
in_ps[j] = s;
}
}
c = c + 1;
}
}
error
Arduino: 1.8.9 (Mac OS X), Board: “Generic STM32F103C series, STM32F103C8 (20k RAM. 64k Flash), STLink, 72Mhz (Normal), Smallest (default)”
/Users/Documents/Arduino/quadrature_detector_3/quadrature_detector_3.ino: In function ‘void loop()’:
quadrature_detector_3:17:23: error: invalid conversion from ‘int’ to ‘int*’ [-fpermissive]
FFT(Value, 128, 1000);
^
/Users/Documents/Arduino/quadrature_detector_3/quadrature_detector_3.ino:30:7: note: initializing argument 1 of ‘float FFT(int*, byte, float)’
float FFT(int in, byte N, float Frequency)
^~~
exit status 1
invalid conversion from ‘int’ to ‘int*’ [-fpermissive]