Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

unstable arduino based frequency counter

Status
Not open for further replies.

marrc

Junior Member level 2
Joined
Mar 1, 2017
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
india
Activity points
219
hello,
am getting following out puts on serial monitor:

a) when no i/p applied : 50
b) when 555 connected to i/p: values changing continuously between hundreds,thousands, ten thousands for the same applied input

i have used following code:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const int pulsePin = 8; // Input signal connected to Pin 8 of Arduino
 
int pulseHigh; // Integer variable to capture High time of the incoming pulse
int pulseLow; // Integer variable to capture Low time of the incoming pulse
float pulseTotal; // Float variable to capture Total time of the incoming pulse
int frequency; // Calculated Frequency
 
void setup()
{
    Serial.begin(9600);
    pinMode(pulsePin,INPUT);
    
}
void loop()
{
   
     
    pulseHigh = pulseIn(pulsePin,HIGH);
    pulseLow = pulseIn(pulsePin,LOW);
    
    pulseTotal = pulseHigh + pulseLow; // Time period of the pulse in microseconds
    frequency=1000000/pulseTotal; // Frequency in Hertz (Hz)
    
    Serial.println(frequency);
    
}


plz help!
 
Last edited by a moderator:

Hi,

* What does this mean: "when no i/p applied"? --> don´t leave inputs floating.
I assume this means there is no inptu signal connected, but is there any pullup or pulldown?

* What does this mean? "when 555 connected to i/p"? Is this 555Hz?
Or is this any NE555 signal? Which signal, what levels, what frequency, what duty cycle?

Klaus
 

hi,
yes "when no i/p applied" means no i/p signal connected.
there is no pullup/pulldown the input is directly connected to the arduino(digital pin 8)

555 is NE555 timer in astable mode..not sure about the frequency though... i am using a mid sized cap and 2K resistor,if that helps

- - - Updated - - -

hi,
yes "when no i/p applied" means no i/p signal connected.
there is no pullup/pulldown the input is directly connected to the arduino(digital pin 8)

555 is NE555 timer in astable mode..not sure about the frequency though... i am using a mid sized cap and 2K resistor,if that helps
 

Hi,

there is no pullup/pulldown the input is directly connected to the arduino(digital pin 8)
When I say "don´t leave inputs floating" this means you should use either internal or external pullup or pulldown.
--> Do either of the four possible configurations, then tell us what happens.

not sure about the frequency though
This is no useful test .. if you don´t know the test condition.
--> Calculate, estimate, measure the vlaues or use any other signal source with known signal parameters.


i am using a mid sized cap and 2K resistor,if that helps
No. It doesn´t help. And btw. the color doesn´t help, too.
In electronics we need values with units.

***
What is the timeout for "pulsePin" function?

For debugging it makes more sense to output the raw values like pulseHigh or pulseLow...

Klaus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top