# Can I detect the absence of square wave?

Can I build a circuit to set the output high if there is a square wave at the input and set it low when missing the square wave (the input become low)?

Edit: The signal is 2 kHz, +5/0 V.

It's not homework. No restriction but now I don't have any retriggable monostable IC like 74123 or 4538 and getting one may take time.

In case I get one of them how can choose the value of C and R?

• (1) Your question gives no clue about what the squarewave frequency is. Is it 1 MHz, 1 kHz, 1 Hz, 1 mHz or what? (2) Since the squarewave is "missing" every cycle how long to you want to wait before giving a low output? (3) Also missing is the voltage, +5/0, +5/-5, etc. Please edit your question (not the comments) with all the relevant information. Jun 3, 2018 at 21:22
• My search turned up a question with some common info. - electronics.stackexchange.com/questions/69586/… Jun 3, 2018 at 21:36
• Retriggerable monostable. 74121.
– jonk
Jun 3, 2018 at 21:50
• @jonk - Oh, please. Go for something decent, like a 74HC4538. Jun 3, 2018 at 22:22
• @armma 555 timer configured as one?
– jonk
Jun 3, 2018 at 22:53

If you are looking for a solution with components in your junk box then this might work.

simulate this circuit – Schematic created using CircuitLab

Figure 1. An RC pulse extender.

How it works:

• When IN goes high C1 charges quickly through R1 and D1 in parallel with R2. The input to NOT1 goes high as does OUT.
• When IN goes low C1 discharges through R2 only. When the voltage on C1 drops below the low threshold of NOT1 it will switch and OUT will switch low.
• R1 is intended to limit the current drawn from the previous stage. You haven't specified what is providing this so you'll have to work out the safe current that device can provide and set R1 accordingly. Then set R2 to at least ten times R1 value. With R2 so much higher in value than R1 we can leave it out of the parallel calculation in the first point.
• Having established R1 and R2 you can calculate $C_1 = \frac {\tau}{R_2}$ where $\tau$ is the time delay required for pulse absence - 10 ms in your case.
• Check the R1C1 time constant ($\tau = R_1 C_1$) to ensure that this is acceptable.

Ideally NOT1 and NOT2 would be Schmitt trigger type to give clean switching.

Update:

It turns out that the source signal is a TSOP1738. The block diagram is shown in Figure 2.

Figure 2. The device has an open-collector output with a weak pull-up resistor.

simulate this circuit

Figure 3. Modified schematic.

• At 2 kHz the pulse width will be 0.25 ms.
• The charge time will be $\tau = R_1 C = 80k \times C$.
• The discharge time will be $\tau = R_2 C$.

Update 2:

I tried to understand how this circuit set the output low when the input high (no signal) and set it high when there is a signal but something missing.

This is what @DaveTweed suspected you really wanted but I missed.

simulate this circuit

Figure 4. Sensor is high when there is no received signal.

How this one works:

• With no signal C1 charges up and NOT1 goes low.
• Every time a pulse is received Q1 turns on, discharges the capacitor and NOT1 output goes high.

Calculate C using the formulas above.

• thank you for your appreciated effort. if the signal received from TSOP1738 ir receiver for example . how can i choose R1? regards Jun 4, 2018 at 8:52
• Link to datasheet please but read it to figure out what the maximum output current is first. Jun 4, 2018 at 8:53
• pdf.datasheetcatalog.com/datasheets/208/301092_DS.pdf output current 5mA Jun 4, 2018 at 9:22
• Two problems: (1) That's not a direct link to the datasheet. I don't know if I can trust that site. (2) Now that you've provided information that should be in the question I have to change the answer because that device is open collector. You must put all the relevant information into the question otherwise you waste everyone's time. Jun 4, 2018 at 10:18
• Too complicated. Eliminate the diode, R2 and one of the inverters. Now you're keeping C1 from charging, rather than trying to keep it charged. Jun 4, 2018 at 13:34

It really depends on how accurately you've defined what you want in the question.

Start here and understand the components that make up a square wave.

If you absolutely have to know it's a square wave input (and its missing) then you could run an FFT with just 4-8 bins. While understanding an FFT is complex, you can do this very easily with existing libraries on almost any small MCU with an A/D.

If you want a cheap single 'chip' solution you could use an Arduino Nano, Mini or Pro Mini. A Pro mini or Nano will cost less than \$3 on Ebay.
All of these will accept an FFT library of which there are an endless supply. This might be a good starting point for an Arduino library. It provides about 7ms per bin update so might meet your need for speed if you hold the number of bins low.

To try and ascertain that you actually have a square wave input in any other way is going to be a multichip solution and quite challenging I'd posit. Using an MCU as a component will be much easier.

If you just want a logic level that changes with the absence of edges at approximately that frequency, you can use a 74LVC1G123 retriggerable monostable multivibrator. This would be for an application like a missing clock detector.

As long as the edges keep arriving before it times out, the output Q stays high.

• In comments, the OP appears to have said that they want a solution without using a retriggable monostable IC. No explanation for that restriction has been given. I've asked them to update the question with explanations for all of their restrictions. :-( Jun 4, 2018 at 2:13
• @SamGibson So I see. Then I guess it's a homework thing. Of course something monostable-ish could be implemented with synchronous logic and a clock, if that is permitted. Jun 4, 2018 at 2:19
• i have modified the post Jun 4, 2018 at 7:49