Alarm Relay Sticking after motion detect

TonyR

IPCT Contributor
Joined
Jul 15, 2014
Messages
16,434
Reaction score
38,153
Location
Alabama
I am amazed how much forum traffic such a simple circuit has produced. There are several threads just in the last couple of months demonstrating similar circuits using 5 and 12VDC, opto-isolated relay boards from amazon and eBay that interface directly to camera outputs to operates strobes, lights and alarms. The boards are inexpensive, purpose-built, eliminate lots of wiring and components and perform beautifully.

Why re-invent the wheel? :idk:

Example 5VDC version:

5v_opto-relay_board.jpg
 
Last edited:

alastairstevenson

Staff member
Joined
Oct 28, 2014
Messages
15,930
Reaction score
6,778
Location
Scotland
Yes, agreed, some candidate posts on the same topic.
But I'd like to add even more if I may...

As evidenced by the fact that the 12v power needs to be removed when the alarm output is in the off state to open the relay suggests there is still current flow.
What might just have happened, due to the lack of a clamp diode/bypass diode/snubber circuit to absorb the inductive surge at switch off is that the output device has been damaged.
If so, there may be some leakage current in the off state.
The way to confirm that would be to check how near to zero the current is when in the off state and feeding the load when the 12v is on.
Normally this would be under a few microamps. If it's measured in milliamps it might be enough to keep the relay on.
 

J Sigmo

Known around here
Joined
Feb 5, 2018
Messages
997
Reaction score
1,333
As odd as it seems, I think everyone contributing here may be right in various ways. If any one of us could visit the OP's site, a few minutes with a voltmeter would probably answer all of our questions.

As I read the data sheet for the camera, I see that they never answer the question of what the alarm output really is!

But from the limited description, I am going to go out on a limb and say that what the camera may be doing is to SOURCE current when the alarm trips. In other words, it is a "high side" driver, and NOT an open collector to ground. It could be a small optocoupler or just a PNP transistor or P-Channel FET, but in any case, wired so that one side of the "switch" is tied to +12V, and the other side goes to the alarm output lead.

I'm lead to this by the manufacturer's wording in the datasheet, which sort of implies that the unit provides (sources) 12V at up to 300mA as its alarm output.

This possibility was suggested by @awsum140 early-on in the discussion, and as he recommended, measuring some voltages could clear this up.

What I recommend is to disconnect the relay and separate the two cameras' outputs. Then measure the voltage on one of the cameras' alarm output with respect to ground as you create motion and an alarm event.

If what we're suspecting is true, then you'll see the alarm lead go high (pull up to 12V) temporarily as the alarm output is active.

And if that is true, then the way it is currently wired up should not work. We're still left to speculate as to why the setup sort-of works, but latches on.

Assuming we prove that the cameras are pulling high on this output, and also understanding that we do not know what they use for their output driver circuit, one thing to consider is that the cameras may not "like" having their alarm outputs tied together this way. When one is in the alarm condition, the other one likely will not be. If the output driver can both source and sink, they'll be fighting each other. Again, we don't have any idea about the alarm output circuit design. But in any case, they may not like being "wire-ORed" this way.

You could be safe and install a diode in series with each of the outputs to "diode OR" them.

Tie the anode of one diode to each "alarm" wire, tie the two diode cathodes together and then tie this common cathode point to the "top" or "high" side of the relay. Finally, tie the other end of the relay's coil to ground. That would likely work fine if my assumption is correct. I would STILL install a protection diode around the relay coil, however (or use the SSR when it arrives).
 
Last edited:

wrybread

Pulling my weight
Joined
Sep 12, 2018
Messages
249
Reaction score
115
Location
San Francisco
Does the relay stay engaged even when no load is attached to it? In other words, when you remove your sirens etc or just make it so they don't actually power on?

Edited to add: agree with @TonyR's post above.
 

Kymadn

Young grasshopper
Joined
Feb 17, 2017
Messages
44
Reaction score
3
Thanks everyone for taking the time to share your thoughts. I am happy to say the problem has been resolved.

All i needed to do was swap the automotive mechanical relay with a Solid State Relay and all was working perfectly. I now have the cameras switching the 12v psu ground to the solid state relay. It turns on for the programmed 10 seconds and then switches off. The camera alarm outputs seem to work fine in parallel with each other.

In total this fix cost me $7 per SSR relay from my local electronics store.

In the near future i will be installing more cameras for this shopping center car park. Few more photos of my project attached:
 

Attachments

Last edited:

J Sigmo

Known around here
Joined
Feb 5, 2018
Messages
997
Reaction score
1,333
Yes. But we're still left not knowing why it was latching before! It could well have been the inductive kick from the relay's solenoid creating a temporary failure in one or both of the camera's outputs, latching them on. It's interesting that cycling power to the cameras would always unlatch things. That indicates that something in the camera was latching on, but without being permanently destroyed.

Do all or most of these cameras' alarm outputs sink to ground? Is that some kind of standard? If so, that explains why it works and allows for simply wiring several of the alarm outputs in parallel. But it still leaves a mystery. An annoying, unresolved mystery. ;)
 
Last edited:

Kymadn

Young grasshopper
Joined
Feb 17, 2017
Messages
44
Reaction score
3
Yes. But we're still left not knowing why it was latching before! It could well have been the inductive kick from the relay's solenoid creating a temporary failure in one or both of the camera's outputs, latching them on. It's interesting that cycling power to the cameras would always unlatch things. That indicates that something in the camera was latching on, but without being permanently destroyed.

This reminds me of a guy who worked where I worked years ago when I first got started in electronics work. We were both working in the department where we repaired commercial 2-Way radios. This guy drove all of us nuts, but he was right!

He had a lot of experience with the various radios, and when one came in with a particular symptom, he'd just go get the handful of parts required to "shotgun" the area of the circuit in question. He'd replace a few caps, diodes, trannies, etc., and then put the radio back together, test it, tune it up, and it was ready to go. But he NEVER knew what, exactly, had gone wrong because he'd replaced that batch of parts all at once and not actually tested any of them or made many, if any, measurements.

But the radio was fixed and out the door in a half hour or so, and the parts cost almost nothing compared to the labor cost the rest of us might have racked up finding the ONE actual problem! So the customer got his radio fixed for cheap and quickly. How can you argue with that? But for most of us, not actually knowing what was really wrong just drove us nuts! I really hate an unresolved mystery! It doesn't matter, but I just hate it anyhow. :)

Do all or most of these cameras' alarm outputs sink to ground? Is that some kind of standard? If so, that explains why it works and allows for simply wiring several of the alarm outputs in parallel. But it still leaves a mystery. An annoying, unresolved mystery. ;)
I feel ya mate. I too hate not knowing the reason why things happen. My background is actually 11 years in the radio communications industry. I studied electronics for 4 years and this had me a little baffled. I have been running my own business for the past 3 years. Point to point links and CCTV are my real bread and butter now. When i was commenting about removing the 12v power supply to unlatch the relay, that was only the 12v supply for the relay, siren and strobe. I was not resetting the camera. That means that the camera alarm output had actually done its job of closing contact on alarm and reverting back to an open contact. I know this because the relay did not re-energize after reconnecting the relay 12v power.

All i can theoretically conclude is that the camera I/O after closing contact in the alarm state, may have still provided a small amount of current to keep the relay coil energized after reverting back to open contact. This would make sense to me if the camera uses a FET or transistor to switch the output wires. The isolation between the coil on the mechanical relay was only 100 ohm. with the Solid State Relay i have 1.4M ohm isolation.

All of my cameras on this job i wired the +12v from the psu direct to the relay coil. The camera ground was commoned up with the psu ground. So when the camera alarm was active it sends the ground signal to activate the other side of the relay coil, suppling power to the siren/strobe for the cameras programmed latch duration.
 
Last edited:

Kymadn

Young grasshopper
Joined
Feb 17, 2017
Messages
44
Reaction score
3
What i learnt from this is not to use mechanical relays for I/O's.

I can say the best way to learn is to make mistakes :D
 

J Sigmo

Known around here
Joined
Feb 5, 2018
Messages
997
Reaction score
1,333
It still doesn't make sense. The "coil" in the solid state relay would have a much lower "drop out" current than the coil in the mechanical relay. So I'm not inclined to think it was leakage current through the transistor (or whatever it is that pulls to ground in the cameras). If it was, then you'd probably have more trouble with the SSR than you did with the mechanical relay.

The issue with off-state leakage current is something we only find with (ironically) the outputs of SSRs that use Triacs or back-to-back SCRs for the output. The problem with them is that they tend to have rather high leakage current, and thus, have a "minimum load" specification. Of course, that sort of SSR is only used for AC applications.

But I have not ever seen transistor outputs that leaked enough in their off-state to cause a relay to stick on, or even an SSR, for that matter. And the fact that your SSR is working tells us that there is not much leakage current in these output devices.

Plus, the leakage that you get with an SCR or TRIAC output in an SSR does not happen only after the device has been switched on. It's there all of the time. So you wouldn't observe the phenomenon of the siren latching on only after an actual alarm trip. It would be on all of the time, and would come back on immediately after you re-applied power to it.

So we were seeing some sort of latching of the alarm output devices in the cameras that was triggered only when the outputs actually activated (or, more likely, when they tried to DEactivate at the ends of their normal output intervals).

I think that you were seeing some kind of inadvertent creation of an SCR structure, triggered by the inductive spike from the mechanical relay's solenoid. Curiosity makes me want to install a protection diode, snubber, or MOV around the relay coil and try it again! :)

It seems that removing power to the alarm circuit clears this "latch" (just as removing the holding current through an SCR shuts it off).

The hold-in current for your mechanical relay is probably higher than the "must break" current for your SSR. So while the SSR "fixed" the problem, I think that's simply because it does not present an unprotected inductive load to the cameras' outputs.
 
Last edited:

Kymadn

Young grasshopper
Joined
Feb 17, 2017
Messages
44
Reaction score
3
interesting points. If i had a spare camera i would replicate this problem on the bench. Unfortunately i cant afford to spend to much time playing around with it on-site to solve this mystery. Maybe in the near future i can investigate further into it when i order more cameras for my client.

Here is some more information i found about camera I/O's:

Hikvision Alarm Input and Output (Alarm IO) : Wrightwood Surveillance Support

Interestingly enough they say "The relay should be low powered relay, not an automotive relay."
 

J Sigmo

Known around here
Joined
Feb 5, 2018
Messages
997
Reaction score
1,333
Still, the relay you used was low enough power if the coil resistance was 100 ohms. That would be well below the 300mA that the output is supposedly rated for. So I think your original choice was fine.

That article does show a protection diode placed around the relay coil, and that's good practice. And I do think that would have prevented the problem you were having.

I really wish we could get some good info from Dahua about the design of their alarm outputs.

If you keep doing what you just did, though, with that DC SSR, everything should be just dandy. So looking into this further is just a time-killer that you might do if you have some spare time to waste. I fully understand that!
 
Last edited:

Kymadn

Young grasshopper
Joined
Feb 17, 2017
Messages
44
Reaction score
3
The lack of documentation by Dahua would be my biggest criticism for their equipment. I found myself having to write some basic documents for my customers which i re-use now. Really the only way to become an expert is to buy the equipment and play with it. You really have to fiddle with it to nut it out.
 

J Sigmo

Known around here
Joined
Feb 5, 2018
Messages
997
Reaction score
1,333
Yes. Bad documentation is all too common these days. It wasn't always that way.
 
Last edited:

alastairstevenson

Staff member
Joined
Oct 28, 2014
Messages
15,930
Reaction score
6,778
Location
Scotland
Many years ago, many devices came with full schematics, and even descriptions of the design and how and why the gadget was designed that way and how to troubleshoot them down to the component level.
Yes, indeed.
I guess these were more necessary back then as electronics was much more component-oriented, and a lot less reliable, and there was a need to be able to fault-find and repair.

A couple of months back I bought a 'vintage' oscilloscope, a Hewlett-Packard 180A, still in good working order. A familiar item from the past ...
The 'Operating and Service Manual' has Principles of Operation, full schematics with waveforms and voltage annotation, circuit descriptions, components lists with reference designator maps, calibration and fault-finding instructions.
A real boon when it developed a fault, allowing easy analysis of the cause and fix.
Again the circuit detail has been essential in exploring another minor problem - the delayed timebase does not function.
It didn't take long to deduce that an n-channel Jfet in the sweep comparator appears to be faulty, so the delayed timebase never gets triggered.
I'm currently awaiting a 10-pack of hoped-for equivalents (the original HP part number is a 'special selection' with no info on specifications) of which you're totally spoiled for choice on eBay or Aliexpress.

All good fun when you've got a bit of time to tinker and the inclination to do so.
 

TonyR

IPCT Contributor
Joined
Jul 15, 2014
Messages
16,434
Reaction score
38,153
Location
Alabama
Ah, yes....a lot of familiar terms, technologies and equipment mentioned above by @J Sigmo . In many ways I miss what I did as a career, oftentimes I thought it amazing they actually paid ME to do something that I loved so much I would have done for free if I didn't have any bills.

And then I recall things that I don't miss....getting awakened 2-3 times a week by the cops at 2 AM because of a malfunctioning traffic signal or a pole laying in the road after getting knocked down, or being cursed, threatened by irate motorists, having soda and beer bottles thrown at me, being hit in the face with lit cigarettes....all of those happening more than just once or twice in almost 32 years.

Now my daily challenge is keeping my Pillminder filled, opening small boxes, and keeping appointments to the VA doctors, chiropractor, podiatrist and dentist. And working on the wife's 'Honey Do List'.

Wish I could get paid every time I peed.....I'd be rich! :facepalm:
 

Kymadn

Young grasshopper
Joined
Feb 17, 2017
Messages
44
Reaction score
3
So i was totally wrong about the camera i/o's commoned together. It definitely does not like it. First night tonight we ran the alarms in the scheduled time zone. Alerts and SMPT emails were sending out as a security guard was patrolling the area at midnight. The problem i had tonight was that when a camera detected motion and closed the contact, after checking the settings in the other linked cameras. I found the "video detect alarm enable" check box had changed from checked to unchecked. Some of the region highlighted areas slightly changed too. So for now i have disabled all relay contacts and reverted back to just using email notifications.

When i installed these camera it was tight for space in the conduit so i was trying to get away with a single 2 pair wire. Clearly another mistake. It looks as though i will need to pull a new wire through with more strands to separate the I/Os. Attached is my complete network diagram. Can anyone draw me up what they think would be the best way to wire these alarms? The 2 light poles are my main focus. The anaconda site i can disconnect one camera I/O's and run a single camera alarm off the 2 pair wire.

Trying to make this right but i only have my self to blame for not testing it thoroughly enough.
 

Attachments

Last edited:

alastairstevenson

Staff member
Joined
Oct 28, 2014
Messages
15,930
Reaction score
6,778
Location
Scotland
The problem i had tonight was that when a camera detected motion and closed the contact, after checking the settings in the other linked cameras. I found the "video detect alarm enable" check box had changed from checked to unchecked. Some of the region highlighted areas slightly changed too.
I don't see how you wire the alarm outputs would affect the alarm configuration settings in the camera.
Unless there is some disruption to the power supply that somehow bothers the configuration - which might happen if the outputs were fighting each other as they are actually push-pull as opposed to open collector / open drain / to close the circuit to GND.
 

awsum140

Known around here
Joined
Nov 14, 2017
Messages
1,254
Reaction score
1,128
Location
Southern NJ
I think you're seeing the effects of input impedance on the automotive relay being, relatively, very low while the input impedance of the solid state relay is relatively high. As Murphy says, unexpected results at the worst possible time.
 

J Sigmo

Known around here
Joined
Feb 5, 2018
Messages
997
Reaction score
1,333
I think @alastairstevenson is hitting the nail on the head.

Consider:

We've still not measured the output voltages from any single camera by itself.

The meager documentation states that the alarm output is "12V 300mA". That doesn't tell us what the outputs really do. But to me, the fact that they don't give a range, or upper limit for the positive voltage, implies that this is NOT an open collector output. If it was an open collector to ground, they'd give a maximum current and a maximum voltage that this output transistor could handle. Sort of like giving some of the specifications for an NPN transistor (max collector current and max collector voltage, since it would be the collector that would be tied to the "alarm" output lead for the camera).

I still don't think it was ever the relay that was causing the problem or else the solid state relay would either make no difference or would make the latching worse. The inductive kick from the mechanical relay is not present now with the solid state relays. So it must be paralleling the alarm leads that's causing problems at this point.

If I was there, I'd separate one camera's alarm output from everything else. Then I'd measure the voltage with respect to ground on its alarm lead both triggered and untriggered.

In the untriggered state, I'd want to find out if the output is trying to sink to ground versus just going "open circuit", and this will take a bit more effort (but not much, really). And this testing will pay off by letting us know if the output can pull both directions or only one.

Just to start, I'd get a 1000 ohm resistor and a clip lead. I'd cut the clip lead in half and solder the resistor in so that you've got a "1000 ohm clip lead". A simple test light would also work, but this will work with your voltmeter and tell us a bit about saturation voltages.

Now, connect one end of the clip lead to each of your volt meter's probes. You've now got a voltmeter with a low (1000 Ohm) input impedance instead of the usual 10 megohms.

With the alarm untriggered, using this rig, measure the voltage at this isolated (not tied to anything else) alarm lead from ground. Then measure that voltage with respect to your 12V supply's + output. (This assumes that your 12V supply still has its common tied to the camera's ground and is powered up).

Now make those same two measurements with the camera triggered.

You can make a chart showing the voltages for each of these measurements (four measurements total).

Alarm Lead Triggered with respect to ground with 1000 Ohms Load
Alarm Lead Untriggered with respect to ground with 1000 Ohms Load
Alarm Lead Triggered with respect to +12V with 1000 Ohms Load
Alarm Lead Untriggered with respect to +12 with 1000 Ohms Load

With this, we can see exactly what the camera's alarm output is trying to do. At least with about a 12mA load on it.

If the camera's output is meant to be a "logic" output, and pull both high and low (like a CMOS output or a TTL "totem-pole" output), then you cannot just wire the camera's alarm outputs in parallel.

Doing so will cause the cameras to "fight", with one trying to pull high while the other is pulling low. And we have no idea what mayhem this will create within the cameras.

If they are capable of pulling both high and low, then we also need to know when they pull high and when they pull low. Do they pull high when triggered, or do they pull low? Presumably, they pull low when triggered, but I'd want to check and know for sure.

I wouldn't worry about pulling any new wire or doing anything until we establish exactly what the cameras' outputs really do. We may never know what the actual circuitry is, but we can work around that as long as we understand what the outputs are trying to do.

Do those tests on one lone camera, establishing exactly what the outputs try to do, and then we'll know exactly how to wire things up. It might only require using the "diode OR" wiring I described earlier, or some variation on that. In any case, I think it will be simple and not require pulling any new wires.
 

Kymadn

Young grasshopper
Joined
Feb 17, 2017
Messages
44
Reaction score
3
Guys can we stay on topic please. I did not start this thread to chat about old oscilloscope, test equipment and CDC computers. I was hoping to put a few heads together and get some feedback from like minded techys on my project.

I think you're seeing the effects of input impedance on the automotive relay being, relatively, very low while the input impedance of the solid state relay is relatively high. As Murphy says, unexpected results at the worst possible time.
Forget the automotive relay. Its gone and replaced with a solid state relay. That problem is resolved and we are talking about a different issue now.

I don't see how you wire the alarm outputs would affect the alarm configuration settings in the camera.
Unless there is some disruption to the power supply that somehow bothers the configuration - which might happen if the outputs were fighting each other as they are actually push-pull as opposed to open collector / open drain / to close the circuit to GND.
Trust me mate i am 100% sure that the video detect alarm disabled itself on all my cameras. What happened was i started receiving emails alerts from 11PM when a security guard was doing his first patrol. He walked past all my cameras. I could see the siren/strobe set off. Then security did a second patrol and NO emails came through, No alarms at all. i logged in and i found all of the cameras had disabled the video detection alarm. So i re-enabled the alarm on all cameras but this time i disabled the "alarm relay". For the remainder of the night up to 4:30AM i received multiple emails as the security guards did several more patrols through the night.

Now.... Because i commoned the cameras camera ground on 1 wire and Alarm 1 Out on the other wire to switch the SSR on. Whats happening is the other cameras are sensing a close contact on the the alarm output when a different camera at the same location is motion detecting on the same 2-pair wire. I believe the camera is smart enough to detect that the alarm output has closed but there is no motion detect. It then switches off the motion detect alarm as protection.


The meager documentation states that the alarm output is "12V 300mA". That doesn't tell us what the outputs really do. But to me, the fact that they don't give a range, or upper limit for the positive voltage, implies that this is NOT an open collector output.
The document specification for the I/O stating 12V, 300mA is the Maximum voltage and current handling. What happens when the camera is motion detecting is i get a contact close between the camera ground wire and alarm out wire.
 
Top