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.

Square wave detection

Status
Not open for further replies.

Murugesh_89

Full Member level 5
Full Member level 5
Joined
Nov 23, 2012
Messages
266
Helped
7
Reputation
12
Reaction score
6
Trophy points
1,298
Location
India
Visit site
Activity points
3,267
Hi,
I am getting a square wave input as shown below which i need to be counted.
Wave.JPG

I am giving this to external interrupt of microcontroller. Since in the negative cycle i am getting noises as shown in red color, i am getting multiple interrupt WHICH IS NOT FIXED VALUE.

The frequency of wave is 0 - 500 Hz.

What should i do in HARDWARE so that i can get single pulse and hence single interrupt?

Thanks,
Murugesh
 

maybe some kind of rc filter?

what is the cause of the noice at the end of the wave? is it present at the beginning of the wave too?

of course it's easier to modify the software to filter this kind of things but...
 

Hi,
What should i do in HARDWARE so that i can get single pulse and hence single interrupt?
As suggested Kurenai_ryu add RC filter. or
To make sure the interrupts are valid and not only products of spikes on the pin, add a filter in the interrupt routine. The filter samples the level on the interrupt
line three/five times and compares the values to see if the value is stable. If the value is not the same for all the samples, discard.
Interrupt Filter.PNG

For detail see
http://www.atmel.com/images/doc2508.pdf
 

Hello!

Don't add an RC filter, there is a simpler way to do this.
When you get an interrupt:
- Disable the port interrupts;
- Fire a timer with a duration greater than your instability period;
- Once this timer is over, re-enable interrupts.

Well, this assumes that the period of instability has a fixed duration, but
that's usually the case, right? I suspect the squarewave comes from some
mechanical switch, therefore you have multiple interrupts.

Dora.
 

Hi doraemon,
I have done like this only. I want to do in hardware itself instead running a separate timer for this. Because i am going to handle three interrupts at a same time. It will be better if single pulse is coming and counting it.
 

Hello!

But there is no problem at all doing it with a timer. At least if you have a remaining
timer that you could use for it.
A small correction to what I said:

- Disable the port interrupts; (only the port pin where the square wave comes)
- Fire a timer with a duration greater than your instability period;
- Once this timer is over, re-enable port interrupts. (only the port pin where the square wave comes)

This way it will be absolutely transparent and the program would behave exactly as if you
had input a clean square wave to it.

Dora.
 

**broken link removed**I suppose your fall time(Red duration) remains same from 0-500Hz and here is hardware solution in my opinion.
use an RC filter having time constant slightly greater then the then fall time...
example:
Red-Duration=1nSec
Let R=100R
C=1nSec/100R= 10uF

hope it helped..
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top