Go Down

Topic: Frequency Counter (Read 6 times) previous topic - next topic

5ala

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

PaulS

Downloaded from where?

Can you post you sketch now?

5ala

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:

Quote



#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

PaulS

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).

5ala

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. :)

Quote

#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);
}


Go Up