Go Down

Topic: Can't use FHT library (Read 6549 times) previous topic - next topic

sebautistam

Hi there!
I'm new on Arduino, and I'm trying to use the FHT library. I installed the library and when I open the fhb_adc example and verify it, it says this:

fht_adc.pde: In function 'void loop()':
fht_adc:35: error: 'fht_input' was not declared in this scope
fht_adc:37: error: 'fht_window' was not declared in this scope
fht_adc:38: error: 'fht_reorder' was not declared in this scope
fht_adc:39: error: 'fht_run' was not declared in this scope
fht_adc:40: error: 'fht_mag_log' was not declared in this scope
fht_adc:43: error: 'fht_log_out' was not declared in this scope

The library appears in the IDE, but I guess something is wrong! Please help me :)

robtillaart

after installing a library you need to restart all occurrences of the IDE.
might help.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

sebautistam

I already restart the IDE and even the computer, and still doesn't works  :~

robtillaart

time to post your whole sketch and a link to the library?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

g_u_e_s_t

did you unzip the library files and place them in your library folder manually?  if not, give that a try.  there have been some problems with the library import.  it sounds like its finding the library, but none of the files in the library.

sebautistam

#5
May 02, 2014, 03:53 am Last Edit: May 02, 2014, 03:57 am by Coding Badly Reason: 1
Hey! I manually unzip the folders and still doesn't works :c Both appears on the library menu, but I get the same error. Here is the example:

Code: [Select]
/*
fht_adc.pde
guest openmusiclabs.com 9.5.12
example sketch for testing the fht library.
it takes in data on ADC0 (Analog0) and processes them
with the fht. the data is sent out over the serial
port at 115.2kb.  there is a pure data patch for
visualizing the data.
*/

#define LOG_OUT 1 // use the log output function
#define FHT_N 256 // set to 256 point fht

#include <FHT.h> // include the library

void setup() {
 Serial.begin(115200); // use the serial port
 TIMSK0 = 0; // turn off timer0 for lower jitter
 ADCSRA = 0xe5; // set the adc to free running mode
 ADMUX = 0x40; // use adc0
 DIDR0 = 0x01; // turn off the digital input for adc0
}

void loop() {
 while(1) { // reduces jitter
   cli();  // UDRE interrupt slows this way down on arduino1.0
   for (int i = 0 ; i < FHT_N ; i++) { // save 256 samples
     while(!(ADCSRA & 0x10)); // wait for adc to be ready
     ADCSRA = 0xf5; // restart adc
     byte m = ADCL; // fetch adc data
     byte j = ADCH;
     int k = (j << 8) | m; // form into an int
     k -= 0x0200; // form into a signed int
     k <<= 6; // form into a 16b signed int
     fht_input[i] = k; // put real data into bins
   }
   fht_window(); // window the data for better frequency response
   fht_reorder(); // reorder the data before doing the fht
   fht_run(); // process the data in the fht
   fht_mag_log(); // take the output of the fht
   sei();
   Serial.write(255); // send a start byte
   Serial.write(fht_log_out, FHT_N/2); // send out the data
 }
}


This is on the Example menu of the IDE when I install these new libraries, and is the same in the next link; and here is where i get the libraries:
http://wiki.openmusiclabs.com/wiki/ArduinoFHT?action=AttachFile&do=view&target=ArduinoFHT.zip

I really appreciate your help (:


Moderator edit: [code] [/code] tags added.

sandrews

I was having the same problem as sebautistam, but I put reorder_table_creator and arduinofft_display.pd in the FHT folder and put that right in my Arduino/libraries directory.  I'm still working out what the data I'm getting in my Serial Monitor...  It looks a little scary and it keeps freezing the whole program...  
Maybe try something this?

g_u_e_s_t

there have a been a lot of people unable to properly install the FHT library lately, and i dont know what is causing it.  so any input from more experienced people would be very helpful.

the reason for the wiered output data is because the code is optimized for use with PD, so the output is a serial.write, rather than a serial.println (the latter does ascii readable text, the other is just raw data).

sebautistam


I was having the same problem as sebautistam, but I put reorder_table_creator and arduinofft_display.pd in the FHT folder and put that right in my Arduino/libraries directory.  I'm still working out what the data I'm getting in my Serial Monitor...  It looks a little scary and it keeps freezing the whole program...  
Maybe try something this?


I don't really understand what did you do, so may you explain it to me, please? :) 
Did you took reorder_table_creator and arduinofft_display.pd files from where, and put them where? :D

THANKS!! :D

sebautistam

As I said, I'm really new usiong Arduino, but I noticed that when I clicked on "Import librarie> ArduinoFHT" no code is added to the project :( I guess that is not okay haha

Inajar

I found this library usable after I moved from the direct avr programming and changing it to the arduino language. Try using something like this:
Code: [Select]

#define LOG_OUT 1 // use the log output function
#define FHT_N 128  // set to 128 point fht
#include <FHT.h> // include the library

void setup() {
Serial.begin(9600); // use the serial port
}
void loop() {
   for (int i = 0 ; i < FHT_N ; i++) { // save 128 samples
     fht_input[i] = analogRead(adcPin); // put real data into bins
   }
   fht_window(); // window the data for better frequency response
   fht_reorder(); // reorder the data before doing the fht
   fht_run(); // process the data in the fht
   fht_mag_log(); // take the output of the fht
   for (byte i = 0 ; i < FHT_N/2 ; i++) {
      Serial.print(fht_log_out[i]);
      Serial.print(" ");
   }
   Serial.println();
}

gruberator

Hello,

This error appears when you include FHT library first and then define output type.
Solution to the problem is to first define output type then include the library.

This is also true for all defined parameters for FHT library like FHT_N.
Try for example defining size greater than 256 eg 512.
If FHT_N define is before FHT include, then you will receive following error

#error FHT_N value not defined

if you put #define FHT_N after FHT include, this error will be gone, and
FHT_N will have default 256 size.

Code: [Select]


#define LOG_OUT 1 // use the log output function, define before including FHT library!
#define FHT_N 256 // set fht size

#include <FHT.h> // include the library


Cheers  :smiley-evil:

zniv

I really need to bump this!

I am getting the exact same error as OP...
Did anybody find a fix yet?

jremington

#13
Nov 27, 2016, 08:56 pm Last Edit: Nov 27, 2016, 08:57 pm by jremington
If you mean the first post of this old series, that was a user error. It works fine for me.

Go Up