what is needed to sense a simple closure switch

jspoon

Member
I now have my wc 2.2.2 up and running with a whopping one temperature sensor, so now want to play with input.  I have several alarm sensors that I want to monitor.  It basically just closes a switch inside, right?  So, can I just put 5 volts from the wc on one side and route the other to the input pin for TTL in?  There are no resistors or anything, just a switch.  Any advice would be appreciated.
 
Yes, alarm door and window sensor are reed relays that closed when magnet is near, and disconnected when magnet is far enough.
You can wire 5V with a 1K resistor through switch to the TTL input.  When you arm the alarm, simply watch the TTL input keeps to be logic 1.
When any door or window sensor triggered, it will change the TTL input level to zero.  You will need to save that state asap, then send out alarm.
 
Of course, you will need to check to make sure the TTL inputs connected to switches are all 1s, then arm the alarm.  You can add exit timer in your PLC logic if you need to.
 
jspoon said:
 Any advice would be appreciated.
 
 
Just remember that the inputs are fairly sensitive. Excessive input voltage can easily destroy the chip.
 
Long cable runs from door/window switches make great antennas. Switching transients from other electrical loads, lightning and other magnetic fields can (and will) induce voltages in these wires. Best case, they will be small enough to not cause you problems. Longer cables will likely see some intermittent change of the input (on reading as off, off reading as on) and worst case is damage to the input.
 
This can be mitigated to some extent with R/C filtering on the input, diode clamps etc.
It is "best" mitigated with optocouplers, let your sensor switches power the LED in the optocoupler, and let the isolated output from the opto drive the WC input.
 
Should have stuck with software, this hardware stuff hurts my head :)
 
Thank you for the responses.  It sounds like the optical isoloation is the safest route to go...
 
Ross, I believe you have some boards that have logic to help with analog levels (certainly not there yet, since I cannot handle simple on/off sensing!), but does that board help with the isolation on the TTL input lines or would that be something else?
 
Again, appreciate the help!
 
Actually, I see a lot of small cards that have relays on them that say they can be driven directly by a micrprocessor and are only like $9...
 
jspoon said:
It sounds like the optical isoloation is the safest route to go...
Optical isolation is the gold plated solution, I use it whenever I need to maintain metallic isolation but for a simple switch input IMHO it is overkill.
 
In my WC designs I simply buffer inputs with a TTL logic gate, typically a 74LS04. This puts an easy to change gate between the outside world and the WC. I'd much rather swap out a chip on my kludge interface board then replace the WC. I always seem to need some glue logic in my designs so buffering the input is not a big deal. There are buffers in the WC but they are surface mount, hard for these old eyeballs to solder.
 
For added protection I use a series resistor, pullup and diode clamps to Vcc and Gnd for any inputs the go outside the controller. Writing this I thought it sure sounds complicated but even with an opto probably need at least a series resistor to limit current depending on what voltage you are switching.
 
/tom
 
 
Tschmidt said:
In my WC designs I simply buffer inputs with a TTL logic gate, typically a 74LS04.
 
If you're going to use a TTL gate, please use an 74LS14 not LS04. The LS14 has schmidt input with hysteresis. The LS04 does not, and can oscillate and do all sorts of nasty things with low rise/fall signals etc.
 
 
Tschmidt said:
For added protection I use a series resistor, pullup and diode clamps to Vcc and Gnd for any inputs the go outside the controller.
 
By the time you add all those extra bits, surely an opto is simpler, smaller, about the same cost and far more robust? :)
 
(I got about a lifetimes worth of optos, picked up 500 for $5 incl shipping on ebay.... and they have AC inputs (two LEDs back-to-back). Yes, they still require a resistor)
 
jspoon said:
Ross, I believe you have some boards that have logic to help with analog levels (certainly not there yet, since I cannot handle simple on/off sensing!), but does that board help with the isolation on the TTL input lines or would that be something else?
 
My current WC8 I/O boards don't have optical isolation, although it's highly likely the next version will.
Yes, they have amplifiers for the analog inputs, and space to put some input conditioning (attenuators, filters, clamps).
Check http://webcontrol.rossw.net/
 
Ross
 
Agree 74LS14 is better then 74LS04 for slowly varying signals but a typical switch closure is pretty fast. Debounce is potentially a problem but that is another kettle of fish. I am of course a fan of schmitt triggers, no relationship.
 
I had never though about using an opto to condition inputs, unless I needed metallic isolation. My parts box is full of  TIL117 optos, but they are 8-pin DIPS and need  a base resistor. The ones you mentioned with back to back input LEDs look interesting, 4-pin end stack able DIP, no base resistor needed, still only 50% worst case CTR but I can live with that. I may have to invest the $15 for a 100 SFH620AA to have some on hand for future projects.
 
/tom
 
Tschmidt said:
Agree 74LS14 is better then 74LS04 for slowly varying signals but a typical switch closure is pretty fast.
 
Not really (not in terms of a schottky input that can change states in nanoseconds), especially with long cable runs.
Just us humans that are so slow :)
 
 
Tschmidt said:
I had never though about using an opto to condition inputs, unless I needed metallic isolation. My parts box is full of  TIL117 optos, but they are 8-pin DIPS and need  a base resistor. The ones you mentioned with back to back input LEDs look interesting, 4-pin end stack able DIP, no base resistor needed, still only 50% worst case CTR but I can live with that.
 
Not sure the CTR is that low. If you're driving it with DC, one (or the other) LED will be on 100% of the time.
With the (fairly) high input impedance of the WC, the CTR is largely irrelevant anyway.
Additionally, the few milliamps the LED takes helps with the reed (or other) switch contacts. Switches that pass almost no current are actually surprisingly difficult to make, you need a little bit to break down the (microscopic) corrosion or other muck that inevitably gets on the contacts surfaces.
 
When you look at the max/min current permissible on the LED, and the input requirement from the WC, your range of input resistors is quite wide.
 
I am new to this board and hardware, so I may be missing something...  It appears to me that the area of TTL input had kind of been ingored.  Since I had not thought about the protection aspect, I expected some very simple solution, but it seems ICs are involved.

For the analog input, we have Ross's board and for output we have a lot of very affordable relay boards.  But the TTL input seems to be ignored and I would think this would be a fairly significant use of boards like this...

Ross, have you considered a simple 4 or 8 input optocoupler board/kit/assembly that will inteface with your existing breakout board?

All this said, it I wanted to create a optocoupler interface, how should I approach it?  Do I find some piece of breadboard or something?  What would be the schematic if I wanted to use something like a set of SFH620AA's?
 
You're right about inputs being ignored for hobbyists -- I've googled and searched everywhere, and in whilst you will find countless output relay boards and motor drivers and such for hobbyist devices, you'll find next to nothing prebuilt and packaged for interfacing with the *real* world.
 
I use an 8 input / 8 relay board from www.hobby-boards.com for one of my devices (on a Raspberry PI system), but I don't think that will work on this board.
 
The latest project that uses the CAI board will be in a very, very electrically noisy environment (there's an arc welder rather close by) -- after looking at what it would take to build my own opto-isolators and all, I chose to go with surplus commercial gear.  Search for "Opto 22 IDC5" on ebay or whereever for examples of these devices -- the four of these i need are larger than the CAI board (!) but I'm hoping they'll do a good job of isolating things.
 
Note for Ross; if you do create an 8 input opto board, I'd be really interested, especially if it had a line of pads that would make it easy to solder on a header to match up to 8 of the data lines on a standard Arduino board pinout.  That would also broaden your market a bit, which never hurts, I think.
 
mwester, that I/O board is interesting, and of course expensive :)  However, they had a schematic of the board and if I am reading it correctly, they simply have an optocoupler and a 1.5K resistor on the input?    That seems pretty simple to put together...
 
Ross, how much extra room do I have on the plus version I ordered?  Guessing it is not enough to add 8 optocouplers and resistors...
 
Jay
 
Depends on what you want to do. Most alarm system door/windows sensor  inputs don't have opto-isolator chip. The reason is that the alarm system only arm with all switch connected, in another word, TTL input reads 5V. If thief cut the wire anywhere, it will make the TTL input drop. Any such 0 going spike will trigger alarm.  Normally, it is not easy to have noise spike making 5V connected TTL input falsely reaching to TTL 0.
 
Back
Top