This program is working fine with arduino uno, for blue pill there is compiling error. I looked at Goertzel.h but I didn't find something special which can cause the problem.
Here are, program, error, Goertzel.h file.
Code: Select all
// Set things up
//http://play.fallows.ca/wp/radio/ham-radio/signal-analysis-morse-decoder/
#include <Goertzel.h>
int sensorPin =PA6;
//int sensorPin =A0;
int led = PC13;
//int led = 13;
//const float TARGET_FREQUENCY = 500;
const float TARGET_FREQUENCY = 5000;
const int N = 100;
const float THRESHOLD = 4000;
const float SAMPLING_FREQUENCY = 8900;
// Create the filter
//Goertzel goertzel = Goertzel(TARGET_FREQUENCY, N, SAMPLING_FREQUENCY);
Goertzel goertzel = Goertzel(TARGET_FREQUENCY, N, SAMPLING_FREQUENCY);
void setup(){
pinMode(led, OUTPUT);
Serial.begin(115200);
}
void loop()
{
goertzel.sample(sensorPin);
// Check samples for tone at target
float magnitude = goertzel.detect();
// if the tone is present, light LED
if(magnitude>THRESHOLD)
digitalWrite(led, HIGH);
else
digitalWrite(led, LOW);
// Serial.println(magnitude);
Serial.println(magnitude);
}
///////////////////////////////////////////////////////////////
Arduino: 1.8.8 (Windows 10), Board: "Generic STM32F1 series, BluePill F103C6 (32K), STLink, Enabled (generic 'Serial'), None, Low/Full Speed, Smallest (-Os default), Newlib Nano (default)"
A subdirectory or file sketch already exists.
In file included from c:\users\galinka\appdata\local\arduino15\packages\stm32\tools\arm-none-eabi-gcc\6-2017-q2-update\arm-none-eabi\include\c++\6.3.1\cctype:42:0,
from c:\users\galinka\appdata\local\arduino15\packages\stm32\tools\arm-none-eabi-gcc\6-2017-q2-update\arm-none-eabi\include\c++\6.3.1\bits\localefwd.h:42,
from c:\users\galinka\appdata\local\arduino15\packages\stm32\tools\arm-none-eabi-gcc\6-2017-q2-update\arm-none-eabi\include\c++\6.3.1\string:43,
from c:\users\galinka\appdata\local\arduino15\packages\stm32\tools\arm-none-eabi-gcc\6-2017-q2-update\arm-none-eabi\include\c++\6.3.1\stdexcept:39,
from c:\users\galinka\appdata\local\arduino15\packages\stm32\tools\arm-none-eabi-gcc\6-2017-q2-update\arm-none-eabi\include\c++\6.3.1\array:39,
from c:\users\galinka\appdata\local\arduino15\packages\stm32\tools\arm-none-eabi-gcc\6-2017-q2-update\arm-none-eabi\include\c++\6.3.1\tuple:39,
from c:\users\galinka\appdata\local\arduino15\packages\stm32\tools\arm-none-eabi-gcc\6-2017-q2-update\arm-none-eabi\include\c++\6.3.1\functional:55,
from C:\Users\Galinka\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.5.0\cores\arduino/WInterrupts.h:25,
from C:\Users\Galinka\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.5.0\cores\arduino/wiring.h:39,
from C:\Users\Galinka\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.5.0\cores\arduino/Arduino.h:32,
from C:\Users\Galinka\Documents\Arduino\libraries\Goertzel-master\Goertzel.cpp:19:
C:\Users\Galinka\Documents\Arduino\libraries\Goertzel-master\Goertzel.cpp:26:5: error: expected unqualified-id before numeric constant
int _N;
^
In file included from C:\Users\Galinka\Documents\Arduino\libraries\Goertzel-master\Goertzel.cpp:22:0:
C:\Users\Galinka\Documents\Arduino\libraries\Goertzel-master\Goertzel.cpp: In constructor 'Goertzel::Goertzel(float, float, float)':
C:\Users\Galinka\Documents\Arduino\libraries\Goertzel-master\Goertzel.h:26:14: error: lvalue required as left operand of assignment
#define MAXN 200
^
C:\Users\Galinka\Documents\Arduino\libraries\Goertzel-master\Goertzel.cpp:48:9: note: in expansion of macro 'MAXN'
_N=MAXN;
^~~~
C:\Users\Galinka\Documents\Arduino\libraries\Goertzel-master\Goertzel.cpp:50:8: error: lvalue required as left operand of assignment
_N=N;
^
exit status 1
Error compiling for board Generic STM32F1 series.
Goertzel.h
Code: Select all
/*
The Goertzel algorithm is long standing so see
http://en.wikipedia.org/wiki/Goertzel_algorithm for a full description.
It is often used in DTMF tone detection as an alternative to the Fast
Fourier Transform because it is quick with low overheard because it
is only searching for a single frequency rather than showing the
occurrence of all frequencies.
This work is entirely based on the Kevin Banks code found at
http://www.eetimes.com/design/embedded/4024443/The-Goertzel-Algorithm
so full credit to him for his generic implementation and breakdown. I've
simply massaged it into an Arduino library. I recommend reading his article
for a full description of whats going on behind the scenes.
See Contributors.md and add yourself for pull requests
Released into the public domain.
*/
// ensure this library description is only included once
#ifndef Goertzel_h
#define Goertzel_h
// include types & constants of Wiring core API
#include "Arduino.h"
#define MAXN 200
#define ADCCENTER 512
// library interface description
class Goertzel
{
// user-accessible "public" interface
public:
Goertzel(float,float,float);
Goertzel(float,float);
void sample(int);
float detect();
// library-accessible "private" interface
private:
void GetRealImag(float*,float*);
void ProcessSample(int);
void ResetGoertzel(void);
};
#endif