Converting a switch into a click/double-click pulse emitter

Thread Starter

Ted Benson

Joined Sep 11, 2017
3
Hi all,

I'm trying to convert a magnetic switch (like the things you nail to a window) into something that emits either clicks/double-clicks or clicks/long-clicks on close/open. Here's a diagram of the input/output signals I'm looking for: there are a few variations that would work (below).

The back story is that I'm trying to figure out how to combine a magnetic window sensor with one of those Amazon IoT buttons so that I can register one event when the window opens and a separate event when the window closes.

Thanks for any help!!

 

crutschow

Joined Mar 14, 2008
34,280
The magnetic sensor is typically closed when the window is closed and open when the window is open.
So why do you need the pulsee?
 

Thread Starter

Ted Benson

Joined Sep 11, 2017
3
Hi @crutschow,

My plan is to solder it in place of the button on one of Amazon's IoT Buttons. These buttons let you send CLICK, DOUBLE_CLICK, and LONG_CLICK events to an API over a WiFi connection. So if I can map the window opening to CLICK event and map the window closing to the DOUBLE_CLICK event, then I can basically use the device as a way to send window open/close notifications to a home security API I'm building.
 

crutschow

Joined Mar 14, 2008
34,280
Note that you will likely have to add a debounce circuit to the magnetic switch output to avoid false triggering of the one-shots.
 

AnalogKid

Joined Aug 1, 2013
10,986
Should be a pretty simple circuit, maybe one hex inverter and some Rs and Cs.
What power is available for the pulse circuit?
What are the periods of the long and short output pulses?

ak
 

philba

Joined Aug 17, 2017
959
I'm sure it's doable with some amount of logic but you might also look at a low end micro. Arduino Nano, Trinket or similar. The advantage of that is you can experiment with delays without changing the hardware. I suspect you will spend some time figuring out what the iot button needs to see.
 

crutschow

Joined Mar 14, 2008
34,280
Below is the LTspice simulation of a circuit using a single 555 timer and a CD4077 XNOR gate pulse-doubler circuit (U3) to trigger the 555 on both the leading and trailing edge of the window switch operation.
This gives your "Desired Output".
The top XNOR (U2) generates the signal to change the time-constant and give a different output pulse-width for the leading and trailing edge pulses.
The short pulse is determined by the R2C1 time-constant and the long pulse is determined by the (R2+R3)C1 time-constant.
The circuit is also insensitive to any input switch bounce.

upload_2017-9-12_0-33-36.png
 
Last edited:

AnalogKid

Joined Aug 1, 2013
10,986
First pass at the "Desired Output". R1-C1 set the narrow output pulse on the input leading edge. R2-C2 set the wide output pulse on the input trailing edge.

EDIT: See post #16 for an updated schematic that includes switch debouncing.

ak
DualPulser-5-c.gif
 

Attachments

Last edited:

crutschow

Joined Mar 14, 2008
34,280
First pass at the "Desired Output". R1-C1 set the narrow output pulse on the input leading edge. R2-C2 set the wide output pulse on the input trailing edge.
I like that. It's a nice simple circuit.
The only possible problem I see is that any input switch bounce will appear on the output (which may or may not be a problem to the Amazon IoT input).
You may want to use the spare gate in a debounce circuit.
 

AnalogKid

Joined Aug 1, 2013
10,986
Agree about debouncing. Scrambling for time, I left off the input and output connections.

Magnetic reed switches don't bounce very much. Since the input is a dry contact and there has to be a pull down resistor anyway, a 1.0 uF and 22 K in parallel from the input to GND should do it.

ak
 

crutschow

Joined Mar 14, 2008
34,280
Since the input is a dry contact and there has to be a pull down resistor anyway, a 1.0 uF and 22 K in parallel from the input to GND should do it.
Might the capacitive surge current not weld the contacts?
Since you have a spare gate, just connect that to the switch and use an RC delay at its output to the next Schmidt input.
Something like this:
upload_2017-9-12_17-53-36.png

From a nice, simple guy.
But of course. :D
 

AnalogKid

Joined Aug 1, 2013
10,986
Might the capacitive surge current not weld the contacts?
Since you have a spare gate, just connect that to the switch and use an RC delay at its output to the next Schmidt input.
I had that thought about 5 minutes after I posted, but by then I was gone from the keyboard.
I've never encountered a problem with sealed reed switch contacts welding. Bit if contact welding is a concern, you can increase the resistance and decrease the capacitance, both by 10x. Still, since there is that extra gate, the series R-C is the better solution. If you do that, swap R1 and R2 to maintain the logic polarity.

ak
 
Top