0
Offline
Newbie
Karma: 0
Posts: 9
Arduino rocks
|
 |
« on: December 27, 2009, 01:55:15 pm » |
Hi everybody: I'm new to Arduino and programming, but reasonably good in electronics. I' m interested in the frequency counter of MARNAW, so I downloaded the two source code Zip files in both , the sketchbook and into Arduino-0017,/hardware/libreries ( to be on the safe side). The I just copied the original Marnaw's Example Program into my sketchbook . But it didn't work: as soon as I try to compile it, I get the following message: “ Error: 'Void' does not name a type” on line 2. :o I'm think I'm doing something wrong, but what? Can someone help me?
Thank you
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #1 on: December 27, 2009, 04:49:41 pm » |
Downloaded from where?
Can you post you sketch now?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 9
Arduino rocks
|
 |
« Reply #2 on: December 28, 2009, 11:08:59 am » |
I Downloaded the libraries from: http://interface.khm.de/index.php/labor/experimente/arduino-frequency-counter-library/And this is the sketch I just downloaded from Marnaw as it is:
#include <FreqCounter.h>
void setup() { Serial.begin(57600); // connect to the serial port Serial.println("Frequency Counter"); }
long int frq; Void loop() {
FreqCounter::f_comp= 8; // Set compensation to 12 FreqCounter::start(100); // Start counting with gatetime of 100ms while (FreqCounter::f_ready == 0) // wait until counter ready frq=FreqCounter::f_freq; // read result Serial.println(frq); // print result delay(20); }
Anything wrong ? Thank you
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #3 on: December 28, 2009, 11:15:51 am » |
Yes, there is something wrong. [glow]V[/glow]oid and [glow]v[/glow]oid are not the same type. Change the return type for loop to void (with a lower case v).
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 9
Arduino rocks
|
 |
« Reply #4 on: December 28, 2009, 02:03:52 pm » |
Hey! You are magic! At least it compiles. But still no results: only the first “Frequency Counter” printout and nothing else. I connected a 4.5V square wave at pin 5 (protected by a 1.5KOhm). I modified the sketch adding some check point (A,B,C) to see where it stops. It just prints a fast serie of “C” as if the parameter “frq” doesn't exist (or empty). And b.t.w. where is declared that pin 5 is an input? What do you suggest? Is something I can do the get it running? Thanks for your patient support.  #include <FreqCounter.h>
void setup() { Serial.begin(57600); // connect to the serial port Serial.println("Frequency Counter"); }
long int frq; void loop() {
FreqCounter::f_comp= 8; // Set compensation to 12 Serial.println("A"); FreqCounter::start(1000); // Start counting with gatetime of 100ms Serial.println("B"); while (FreqCounter::f_ready == 0) // wait until counter ready Serial.println("C"); frq=FreqCounter::f_freq; // read result Serial.println(frq); // print result delay(20); }
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #5 on: December 28, 2009, 07:10:24 pm » |
What kind of Arduino are you using? The library seems to be defined for the Arduino with the 168 ship, not the 328. And b.t.w. where is declared that pin 5 is an input? The library is hard-coded to work with only that pin.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 9
Arduino rocks
|
 |
« Reply #6 on: December 29, 2009, 04:00:43 am » |
Yes: you are right: I'm using Arduino 328. So, should I forget abpou that sketch ?  Can you suggest me a good Frq. Counter library/sketch for 328? Thank you
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 3
Arduino rocks
|
 |
« Reply #7 on: January 14, 2010, 01:20:16 pm » |
I'm having the same problem, I got an Arduino with ATMega328, compiled the same software, fixed the capital V to make it compile, all that stuff and I have it connected straight to the PWM Timer1 output of another AVR (ATMega168 on my breadboard running a fan controller program I'm working on) and it isn't outputting any frequency. Is there any reason that the program only works on the 168 and not the 328 (last I checked they're identical chips except one has more memory)?
EDIT: Easy fix, whoever coded the frequency counter library threw in a check that only compiles the code if the target is an ATMega168, delete those two lines (the #if and #endif following it) in the FreqCounter.cpp file, save it, and then re-compile your Arduino code. it works great!
|
|
|
|
« Last Edit: January 14, 2010, 01:26:18 pm by CalcProgrammer1 »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 9
Arduino rocks
|
 |
« Reply #8 on: January 15, 2010, 04:58:58 pm » |
Great CalcProgrammer1. It works fine indeed !!!  You are a genius ! Next time I'll sweep an oil lamp I'll expect you to pop up 
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 2
Arduino rocks
|
 |
« Reply #9 on: February 16, 2010, 01:13:27 pm » |
hello everybody is there a way to measure TWO frequencies, one in each of two signals? Or, even better, two frequencies in the same signal? In other terms, can arduino perform some FFT? thanks!
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19003
I don't think you connected the grounds, Dave.
|
 |
« Reply #10 on: February 16, 2010, 01:34:39 pm » |
In other terms, can arduino perform some FFT? Yes, of course. Google, and ye shall find.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 2
Arduino rocks
|
 |
« Reply #11 on: February 20, 2010, 10:20:17 am » |
Thanks AWOL In fact it seems like this topic is already being discussed on the forum. Anyway I am still trying to acquire an audio signal; then I'll be able to think about how to treat it. paolo
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 22
Arduino rocks
|
 |
« Reply #12 on: February 28, 2010, 11:23:39 am » |
I have tried using this library (with modification for 328) and example sketch but I'm not getting results to the console. I'm using a Duemilanove with ATMega328. It compiles and this is the output I see: Frequency Counter 0 Freq: 0 1 Freq: 65536 2 Freq: 0 3 Freq: 0 4 Freq: 0 5 Freq: 0 6 Freq: 0
I've got a 250Hz square wave I'm trying to measure. Should I be feeding this into digital pin 5 or analog pin 5? I've tried every pin on the board with no luck. Here's the sketch:
// Frequency Counter Lib example // #include <FreqCounter.h>
// Switch on LED on pin 13 each second
void setup() { pinMode(13, OUTPUT); pinMode(11, OUTPUT); pinMode(7, OUTPUT); Serial.begin(57600); // connect to the serial port
Serial.println("Frequency Counter");
}
unsigned long frq; int cnt;
void loop() { // wait if any serial is going on FreqCounter::f_comp=106; FreqCounter::start(1000); while (FreqCounter::f_ready == 0) frq=FreqCounter::f_freq; Serial.print(cnt++); Serial.print(" Freq: "); Serial.println(frq); delay(200);
}
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 22
Arduino rocks
|
 |
« Reply #13 on: February 28, 2010, 11:10:51 pm » |
It seems the frequency counter does work on my Arduino, as verified by the faulty grounding on my macbook sending a small 60Hz signal through my wooden desk and picked up by the bare Arduino PCB!
Unplugging the laptop fixes that anomaly but still the counter won't read any intentional signals!
Is there a minimum threshold voltage the signal must be for proper detection? Will it read a sine wave? Is there a "trigger" level that's not being met? I would love to get this to work!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 22
Arduino rocks
|
 |
« Reply #14 on: March 04, 2010, 12:56:11 am » |
Solved. I was accidentally sending ± signal to arduino. Vertical shift up fixed the issue.
|
|
|
|
|
Logged
|
|
|
|
|
|