# Square wave detector

Discussion in 'Electronic Design' started by pinku, Nov 3, 2007.

1. ### pinkuGuest

Hi,
I need to detect a presence of square wave. If square wave is there I
need to generate a logic 0 and this square wave is not present I need
to generate logic 1 or vise versa. Can you suggest me a circuit for
this functionality.

Regards
Pinku

2. ### John PopelishGuest

First, you have to do a lot better than that at defining
"square wave". You might be surprised at the variety of
signals that have been called square waves.

3. ### Greg NeillGuest

Does your signal line have only a square wave on it,
or are there other things present when the square
wave isn't?

Is the squarewave centered on zero (so it goes positive
and negative) or does it have zero as its floor? What
is the magnitude (volts) of the signal?

What's the period (or frequency) of the square wave?

4. ### Paul Hovnanian P.E.Guest

And, for what period can the square wave be present (absent) before the
output must correctly signal its status?

If you've got enough time, you could use a technician, an oscilloscope
and a toggle switch. Technician examines the 'scope periodically and, if
the wave status changes, flips the switch to the correct position.

;-)

5. ### John LarkinGuest

I bet a PhD in physical chemistry would work almost as well.

John

6. ### Jerry AvinsGuest

How square is it really? I.E. what's the bandwidth?
Are there other signals at the same time?

Jerry

7. ### Jerry AvinsGuest

Is the duty cycle 50%? If yes, with what tolerance?

Jerry

8. ### D from BCGuest

I smell a differentiator somewhere in that circuit.

D from BC

9. ### robert bristow-johnsonGuest

the question i would have is: detect the presence of the square wave
against what other alternative? silence or noise?
we probably won't know that; no common timebase...
that's an issue of setting a threshold.
but we should know that. if we do, i would say to cross-correlate
with, say, two different square waves of the known (or trial)
frequency that have fundamental 90 degrees apart.

if we *did* have a common timebase and could do synchronous detection,
it would be just a single square wave to cross-correlate with.
hmmm... maybe a matched filter implemented as an FIR with a stretch
of square wave as its impulse response. that might work for either
synchronous or async.

r b-j

10. ### msgGuest

FWIW, many, many years ago I built an intrusion alarm with a superregen
quieted in the presence of the carrier, noise power dropped and the
superregeneration frequency spectrum narrowed; filtering as per your
suggestion above worked well and the system was quite robust.

Regards,

Michael

11. ### Paul Hovnanian P.E.Guest

Art history major?

12. ### Jeff LiebermannGuest

Close. The local multiversity, UCSC, has a "History of Consciousness"
major, which should provide an endless supply of graduates capeable of
detecting a square wave:
<http://humwww.ucsc.edu/HistCon/>
<http://en.wikipedia.org/wiki/History_of_Consciousness>

I hate to admit it, but there was a time in the early 1960's when I
worked on a job that resembled a "square wave detector". In this
case, I was sentenced to stare at a Tek 520A vector display, for what
seemed like endless hours, and yell of help if anything changed.
Unfortunately, things did change so I really did need to pay
attention. After about 10 consecutive days of this nonsense, I
simulated a mental breakdown, and was assigned a more creative task.
That was sweeping the floor from all the crud that was falling from
the ceiling during construction.

B.F. Skinner trained pigeons to peck at a CRT to run a guided missile.
<http://en.wikipedia.org/wiki/Project_Pigeon>
<http://www.spring.org.uk/2007/06/pigeon-guided-missiles-superstitious.php>
I guess a graduate student can be trained to do the same.

13. ### John FieldsGuest

---
Assuming you mean a square wave looks like this:

__________ _____
___| |__________|

|<---t1--->|<---t2--->|
| |
|<--------2t1-------->|

You could use a couple of counters, a clock, a magnitude comparator
and some glue logic to do it in hardware and determine whether
clocks accumulated during time t1 were equal to the number
accumulated during t2. If they are, then a square wave is present.

Use one counter to accumulate clocks during t1, the other to
accumulate clocks during t2, the edges to do the comparisons and
then to clear the counters on the fly. That way your worst latency
will be 1/2 cycle. You'll also need to do a zero detect so you
won't detect 0 counts = 0 counts as a square wave.

14. ### John LarkinGuest

Or an HC123?

Or just reset a counter every input edge, and clock it from something
else. When it reaches some terminal count, it hangs, and that's the
timeout. We do that in FPGAs as signal-loss detectors.

John

15. ### pinkuGuest

Thanks in tones ..for all the idea.
The signal is not 50% duty cycle. This signal is coming from other
card. I need to glow a LED if square wave is present. Voltage level is
digital i.e 0V and +5V. Basically if there is toggle in the line I
need to drive low and if no toggling drive high.
If this detection can be done using simply digital circuit along with
capacitor and Diode will be great.

Regards
Pinku

16. ### Jerry AvinsGuest

As long as the major interest isn't abstract expressionism.

Jerry

17. ### Ken S. TuckerGuest

The basic TTL spec defines a LO by <1/3 Vcc,
and the HI by >2/3 Vcc, every gate works to
that standard, (approximately), so a TTL spec
gate becomes a detector.
Take that TTL spec'd O/P threw a series cap,
and the power transferred should lite-up your
LED.
Ken

18. ### John FieldsGuest

---
I took: "I need to detect a presence of square wave." to mean that
he wanted to determine whether the signal was 50% duty cycle (a
square wave) or not; not something one can easily detect with a
123.

As it turns out all he wants to know is, "Is the signal there?" so
sure, a 123 would work, but why waste 1/2 a chip?

19. ### JamieGuest

30 years ago?, that puts you up in the old duffer category!

And here, I thought you were a young gentleman. At least you
still have your mind fully intact which is more than I can
say for a couple of others here!

It'll be aprox 29 years for me employed in the field
while doing school mean while at the start which was rough on
me. There were few weekends we got to enjoy our self.

20. ### John LarkinGuest

Saw it in half, and save a few cents?

John