What would a circuit look like that detects w/ analog pin if wire short/cut?  - Page 1
Forum section: electronics / beginners

author: NonaSuomy
author_rank: Newbie
timestamp: July 24, 2023, 05:20:01 am
content: Hi,I have a circuit that detects if a door contact is cut or shorted out which looks like this:I did a Falstad simulation of it here:https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l5YCsA2ATI8NV1QdlwMyQAcqyAnObiIpDTXYgKYC0YYAUAE4gEHLhkdPKkF06AFlxxuICXDG9+iumHizU8pQL47lk6ZA1bdITZIUGZANzNb2okeDCjxcugWgEoPmIg4A7ma4og7BoUJQgdp2HspgkUZB5uGxMUkxKaZOGaZ5yvLiHADOaYUx5W4AZgCGADbFTNEpYSnERUHl7WndRgAO7qqRXR6+0fl6AjklaSlzIb4gtQ1NyfYus1pGAB5mSGYEEmbIUwTUR2BHAMIArgAuADrFACpMxXccu+jEZuQeqBBUORvBcjgBlAAWAHsuI8Xm8Prt5ORBKIJMRqAkMKCQABBAB29ShAHMngBJfF9e6fOzUAgY3hA3h-OTgI4AEShMKeVyh+LuNQAxh9SvNRNkFqolvVGjSyBACIhzhIMPxJGyQJybgAjOpMJ4AUXxABMngB5KpPAAyAEt8frigAlN4294w4ocIAWhich is working if you open/close the door contact the voltage shows 1.65V if the contact is open or 1.1V if the contact is closed. If you hit the "Short Test Switch" you will short out the wires going to the contact and it will show 0V. If you hit the Cut Test Switch it will cut the wire and show 3.3V on the analog pin of the microcontroller which is represented by the voltage meter in the simulation.I would now like to have the same setup but for something turned on like a transistor and relay to test if the wires were cut or shorted as well. I can't wrap my mind around how I would accomplish this same process. ie when the transistor turns "on" show 1.65V to the analog pin. If the transistor turns "off" show 1.1V, if the line is shorted show 0V. If the line is cut show 3.3V.Here is another Falstad sim with just the transistor and relay. I'm not sure how to proceed with the same operation in it.http://falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWcMBMcUHYMGZIA4UA2ATmIxAUgpABZsKBTAWjDACgB3ETFEPK7ITx8qkNgDduGXv24oaIqEpoDo9UVGgI2AJxDZB+odzzDBwqmHhswGYSnncEhfWicuXEVJrAI82AjBsUlZCQj9NSCQreDhI3jcYSF9IqPA2ABd9BF5sHOzctwgvLWIaLBQyYjw6KzwS6SE8SgdIQkgcQmK4gBMGADMAQwBXABsMznBiGUtpowtJ81cBY1kxLgcFbDdN+ahJsDml3aX1-UMlvNzjM-kV+0dTiTkFFGcX7nwlKhV9NW-NNoNo40GZDKD9sCFLJDjNIR9tlRdihTPDEcsMSiFlwDC50fjErpMdJzi4eEoYmdcZ8wWSSWIAM4mMzGO57DRDUYMhiLfKXPn5MQ9DHok47EB9IZjCYAB1ocTANAUKioxDx3zYQAThank you.

author: EPAIII
author_rank: Super Contributor
timestamp: July 24, 2023, 07:57:12 am
content: If you are trying to fool proof an alarm circuit, it is easier to run a three wire cable. Then a source resistor on the alarm wire and an equal value termination resistor to ground at the end of the run, after the last "door" or "window" switch, sets the alarm wire to half of V+ when things are normal.Then bringing the Voltage from that end-line termination resistor back on the third, tamper detect wire will allow you to detect shorts and cut wires.With NO (normal open) "door" switch(es), a ground on the alarm wire indicates an open door or an attempt at tampering by shorting it to ground.If the alarm wire jumps to the full V+ Voltage, then the entire cable or at least one of the functional wires (alarm or ground) was cut.If you have multiple "door" or "window" switches, you can swap the wires used for the alarm, ground, and the third, tampering detection wire at each switch location. That way the wire colors are changed as the circuit goes around the building and someone trying to tamper will be confused. Ordinary shielded, twisted pair cable, used for things like audio, can serve as an inexpensive cable.By varying the resistor values you can change the normal Voltage present on the alarm wire. This can make it harder to jump with an external resistor. The only real place to tamper would be at the "door" switch itself.To sum it up:1/2 V+ on both the alarm and tamper wires = OKGnd on the alarm wire = Door Open Alarm or Tampering with shortOpen on tamper wire = tamper wire or entire cable cutV+ on alarm wire = alarm wire or ground wire or entire cable cutV+ on tamper wire = ground wire cut

author: NonaSuomy
author_rank: Newbie
timestamp: July 24, 2023, 01:31:41 pm
content: Thank you for your explanation. Can you show me further with a falstad simulation or similar and how this would work with an actively controlled device like a transistor/relay?As a magnetic contact is basically a straight-through wire that is easy to understand for me with the voltage divider / Double End Of Line resistors but turning a device on or off via a transistor and detecting the state of that on/off/Short/Cut wire is still confusing to me with no visualization.The transistor would be connected to things like piezo sirens and relays controlling other devices like a garage door etc.I basically want to know if all the control wires are in good condition. Nobody put a nail through them doing renovations or cut something by accident.My current code detects these values with an analog pin so I was trying to keep the 4 states (Open/Closed/Short/Cut) identical to the contact detection for the control devices.The wires are already in the walls and are a 4-conductor wire nontwisted pair.https://imgur.com/a/E59TS5SIgnore the parts I used here as I was just guessing what I would need to make it happen but something like this is what I was trying to do:

author: tooki
author_rank: Super Contributor
timestamp: July 24, 2023, 04:58:10 pm
content: Quote from: NonaSuomy on July 24, 2023, 01:31:41 pmIs that a soldered lap joint straight into a screw terminal?You mustn’t do that. Solder cold-flows under pressure, so over time thatwillloosen.You’d be better off twisting the wire and resistor lead and screwing that in, or crimping them together in a ferrule. Or strip your wire enough that you can solder the resistor to it, but still have enough bare wire to screw down on. (In which case I’d wind a few turns of resistor lead around the wire, like a tight coil, and solder that, rather than a long lap joint.)

author: NonaSuomy
author_rank: Newbie
timestamp: July 24, 2023, 10:58:43 pm
content: Thanks for the heads-up I'll see if I can invest in some ferrule gear.

author: tooki
author_rank: Super Contributor
timestamp: July 24, 2023, 11:58:44 pm
content: Quote from: NonaSuomy on July 24, 2023, 10:58:43 pmOne of the $15 ferrule crimpers from AliExpress will work well, something like this:https://www.aliexpress.com/item/1005005552837396.htmlhttps://www.aliexpress.com/item/1005005045473052.htmlThey come in both square and hexagonal crimp. I have hexagonal, but I might buy a square one, too, because square actually fits better into lots of terminal blocks, and the square crimpers cover a larger wire range within the same tool.

author: Terry Bites
author_rank: Super Contributor
timestamp: July 25, 2023, 06:47:35 pm
content: You've answered your own question.A loop with a defined resistance with detect a fail when open or short.

author: NonaSuomy
author_rank: Newbie
timestamp: July 25, 2023, 08:32:09 pm
content: Thank you for your statement. However, my question is this "Can you show me further with a falstad simulation or similar and how this would work with an actively controlled device like a transistor/relay?" I have not personally answered this for myself as I have no idea what it would look like. Every time I have tried it shorts out the transistor or limits the current to the relay which then won't allow it to open or close.I couldn't fit the full question in the post header.It says to post as much information about your question in pinned queues. I was trying to show what I did that was working with the door contact and what I was trying to do now which is get the same process working for a controlled output line which I can't seem to wrap my mind around.It may be trivial to you but this is why I posted this in the beginner section.

author: NonaSuomy
author_rank: Newbie
timestamp: August 14, 2023, 11:23:30 pm
content: Is anyone able to show me this?Thank you.

author: Terry Bites
author_rank: Super Contributor
timestamp: August 16, 2023, 08:39:31 am
content: I dont have time to play with Falstead but this is all you need.You can work out the coil resistance from the 150mW 5V rating: ~160RIt draws 30mA on a 5V supply, so you need a transistor with an current gain of at least 30 @30mA.A 2N2222 or a BC547 will do.1mA (5/4.7k) or so should turn the transistor fully on. Dissipating 10mW or so.If its not fully turned on it might melt!

author: ledtester
author_rank: Super Contributor
timestamp: August 17, 2023, 01:23:41 pm
content: Quote from: NonaSuomy on July 25, 2023, 08:32:09 pmYou can get a relay module like described in this post:https://randomnerdtutorials.com/micropython-relay-module-esp32-esp8266/You can use a 5V module if you have a 5V supply available otherwise go for the 3.3V module.

author: NonaSuomy
author_rank: Newbie
timestamp: August 18, 2023, 06:37:52 pm
content: Thank you for your replies the issue is not with the 3v3 relay or the transistor as those are the exact parts I am using.The issue is with my understanding of how to sense the wires going to those opto isolator/transistor/relay is in one of these 4 states (cut/short/on/off) with the correct voltages shown:When the transistor turns "on" show 1.65V to the analog pin. If the transistor turns "off" show 1.1V, if the line is shorted show 0V. If the line is cut show 3.3V etc.Doesn't have to be falstad, ascii art, paper napkin drawing anything.