jerryk
Posts: 30
Joined: Wed Nov 02, 2016 3:26 pm

Monitor old home security system zones with Pi

Thu Nov 03, 2016 7:57 am

I have an old home security system that I would like to monitor the status of the zones. It's an 8 zone system. The voltage at the zone terminal connection reads 6v dc for a secure zone and 13vdc for an unsecured zone. I have tried to use a LM324 as a comparator to give a low 0v for a secure zone and high 5v for an unsecured zone but the comparators output is limited to zero or the supply voltage of the comparator and the input voltage cannot exceed the supply voltage.

Here is the schematic for the system(last page) - http://scansecurity.net/Manuals/Napco/N ... %20850.pdf

I am not trying to control the inputs. I just need a simple status reading for the two voltages. Any ideas of how to get the 6 and 13 volt reading into a high or low reading that the raspberry pi can handle?

I'm new to electronics and the pi and appreciate any advice or direction to head for more research.

Thanks - Jerry

pcmanbob
Posts: 6619
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Monitor old home security system zones with Pi

Thu Nov 03, 2016 1:14 pm

Hi.

you may be able to do this with a simple voltage divider, like this :-
Image

Now I say may because adding resistances to alarm zone wiring can have unexpected results.
so I would suggest you try it using a meter before you connect your pi to it and you test the alarm to make sure it still works with this circuit connected to the zone terminals.
I chose high values in the hope that it would not affect the existing circuit, using these values you should find that 13v input will give you 2.1v on the gpio terminal and 6v input will give you 0.98v which should give you gpio high and low accordingly.
Edit. you will of course need one of these circuits for each zone you wish to monitor

Hope this helps and once again
PLEASE TEST THIS BEFORE CONNECTING PI
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

stevend
Posts: 211
Joined: Fri Oct 11, 2013 12:28 pm

Re: Monitor old home security system zones with Pi

Thu Nov 03, 2016 1:21 pm

Rather than an LM324 (which, IIRC, is an op amp) use an LM339 or LM393 comparator. These can be powered off the alarm supply, and have open collector outputs, so you can connect those directly to the Pi's inputs with pullups to 3.3V.
Depending on what else your Pi is connected to, it may be better to drive optoisolators from the comparator, rather than connecting directly to the Pi, to help with noise immunity.
You will also need a bit of noise filtering on the comparator outputs - maybe 10K in series followed by 10nF to 0V.

jerryk
Posts: 30
Joined: Wed Nov 02, 2016 3:26 pm

Re: Monitor old home security system zones with Pi

Fri Nov 04, 2016 1:12 am

Thank you for the help. I was able to find an LM339 in my parts pile and it seems to fit the bill so far as tested in my mock up on the breadboard with the following exception. If V- > V+ the output is high. I thought it should be the opposite.

As far as optoisolators go I have some 4n35's that I will try but I can't quite understand how they fit in the circuit yet.

Thanks - Jerry

stevend
Posts: 211
Joined: Fri Oct 11, 2013 12:28 pm

Re: Monitor old home security system zones with Pi

Fri Nov 04, 2016 1:37 pm

jerryk wrote:Thank you for the help. I was able to find an LM339 in my parts pile and it seems to fit the bill so far as tested in my mock up on the breadboard with the following exception. If V- > V+ the output is high. I thought it should be the opposite.
Thanks - Jerry
I hope you don't mean that - V+ and V- are the power supply pins! (+12V and 0V in your application).
From a quick look at the data sheet section 7.4, the output is 'high' when the '+' input is higher than the '-' input.

Note that you can simply swap the '+' and '-' inputs to get the output polarity as you wish.

For the optoisolator, you would drive its LED from the comparator output, with a series resistor to +12V (something like 2K2 should do). Then connect the emitter of the transistor to 0V of the Pi, and the collector to the input, with a pullup resistor (10-22K, say) to 3.3V. Ensure that there is no electrical connection between the comparator side of things and the Pi side - that's the point of optoisolators.

jerryk
Posts: 30
Joined: Wed Nov 02, 2016 3:26 pm

Re: Monitor old home security system zones with Pi

Fri Nov 04, 2016 9:47 pm

I was referring to the input pins and not the supply, however, I had some confusion going on and am back on track.

Your suggestions have worked perfectly with the 4n35 to isolate the pi from the security system voltage and the lm339 comparator is outputting correctly on my mock up. When I open a door in the house I get 3.3 volts and when I close it I get close to zero.

I'm going to order some more parts now that I can see the concept working. My ultimate goal is to have sms alerts sent to my delorme Inreach when there is some sort of security violation on the property. I'm in Alaska and spend a fair amount of time outside cell phone coverage.

Thank you for the help.

Jerry

jerryk
Posts: 30
Joined: Wed Nov 02, 2016 3:26 pm

Re: Monitor old home security system zones with Pi

Thu Nov 17, 2016 8:31 pm

I have the breadboard complete and it works great. I would like to include an LED on the emitter side of the octocoupler to give me a visual status light of each zone when it's triggered, in addition to feeding a high signal to the Pi input pin.

Without an LED in the circut when I open a door, window, etc. the emitter side of the octocoupler will go high at 3.3V as expected.

If I put an LED in the circuit on the emitter side it's forward voltage drops the emitter output from around 3.3V to 1.7V. When I look at the value of the Pi input pin receiving the 1.7V it reads high even with this low of an input voltage. My understanding is that an input pin on the Pi needs around a minimum of 2.2 volts to read high and as a good practice the voltage should be close to 3.3V.

So I'm wondering why it reads high with only 1.7V and if there is better way to incorporate the LED status light so that it does not produce this voltage drop on the emitter that is feeding the input pin to the Pi?

Jerry

stevend
Posts: 211
Joined: Fri Oct 11, 2013 12:28 pm

Re: Monitor old home security system zones with Pi

Thu Nov 17, 2016 10:56 pm

jerryk wrote: If I put an LED in the circuit on the emitter side it's forward voltage drops the emitter output from around 3.3V to 1.7V. When I look at the value of the Pi input pin receiving the 1.7V it reads high even with this low of an input voltage. My understanding is that an input pin on the Pi needs around a minimum of 2.2 volts to read high and as a good practice the voltage should be close to 3.3V.

So I'm wondering why it reads high with only 1.7V and if there is better way to incorporate the LED status light so that it does not produce this voltage drop on the emitter that is feeding the input pin to the Pi?

Jerry
The Pi is guaranteed to read high for an input voltage above a certain level (probably the 2.2 volts you quoted), and is guaranteed to read a low for an input voltage below a certain level (1 volt, maybe). If the input voltage is outside these ranges, there's no guarantee as to what the Pi will read - and the result may vary with which batch of chips you have, temperature, supply voltage and so on.

Also, power consumption is often minimised when the input voltage is close to one of the supply rails.

I suggest you go back to your original circuit, with the optoisolator emitter connected direct to the Pi's 0V, and the collector to an input. Then connect an LED in series with a resistor between +3.3V and the collector of the optoisolator. Choose the resistor to give the desired current through the LED (within the limits of the optoisolator) - something around 330-470 ohms may well suffice.

jerryk
Posts: 30
Joined: Wed Nov 02, 2016 3:26 pm

Re: Monitor old home security system zones with Pi

Fri Nov 18, 2016 8:03 am

Part of my problem was that I incorrectly copied my initial mock up board to my breadboard and that is why the LED and the GPIO pin was on the emitter side. It gave the illusion that it worked but with a voltage drop issue. Moving the GPIO input pin and LED to the collector works much better with the only caveat is that an alarm zone that is tripped or active will read low and when it is secure it reads high which has no consequence. I connected the LED per your post using a 470ohm resister and it worked perfectly.

I now get about .5V drop when I hook up the GPIO pin to an input which gives me around 2.75V on the high side and when it is tripped low it reads about .2V which is minimal and all within the limits.

I sure do appreciate your help and would be in a corner without it.

Here is the board with three of the eight zones in the house tripped. Now to write a program to allow me to get text alerts when the zones get tripped. FYI - the octocoupler I used was the ILQ615 which is a quad package. And the 9V reference voltage is from an LM7809.

Again - Thanks

Jerry

sc_alarm_interface2.jpg
sc_alarm_interface2.jpg (55.39 KiB) Viewed 2960 times
Attachments
sc_alarm_interface1.jpg
sc_alarm_interface1.jpg (60.15 KiB) Viewed 2960 times

jerryk
Posts: 30
Joined: Wed Nov 02, 2016 3:26 pm

Re: Monitor old home security system zones with Pi

Wed Nov 30, 2016 8:13 am

I am having some issues with erratic behavior that appears to be internal with my Raspberry Pi. I may be adding some sort of bug issue with the way I'm using edge detection in python. I'm not sure.

The symptoms are:

The board and the code produce the desired result of issuing a text to my phone any time a zone on the security system is open. It works fine for long periods of time, as in, 18-24 hours. Then all zones will trigger at the exact time and I will get a text per zone even when there have been no zones active.

I can also trigger all eight zones at once just by touching the ground lead of my Fluke 12 to the pi ground. If I reboot the pi and restart the program all goes back to normal for awhile and then the random triggered event will occur again.

Concerns are that there is a stability issue internal to the pi. I'm too new to electronics to have any real good hunches on this but if anyone has any thoughts I would appreciate your input.

I have included the schematic for the final board I'm using and a snippet of the relevant part of the code to see if there is anything that might be contributory in the way I put the circuit together.

Code: Select all

def alertchange8(zone8):
    timenow = dt.strftime(dt.now(), '%Y-%m-%d %H:%M:%S')
    body =('alert - zone8 changed ' + timenow)
    print body
    client = TwilioRestClient(account='ACe5dd34f0c6e275a4ecb5df40', token='350caa5f7b27d0cad52b6ef1b')
    client.messages.create(from_="+12019866496", to="(907) 956-6650", body=body)
    time.sleep(5)

    
def eventdetect():
     #GPIO.add_event_detect(zone6, GPIO.BOTH, callback=alertchange) # 
    GPIO.add_event_detect(11, GPIO.FALLING, callback=alertchange1, bouncetime=12000)  # add rising edge detection
    GPIO.add_event_detect(12, GPIO.FALLING, callback=alertchange2, bouncetime=12000)  # add rising 
    #GPIO.add_event_detect(13, GPIO.FALLING, callback=alertchange3, bouncetime=12000)  # add rising edge detection
    GPIO.add_event_detect(15, GPIO.FALLING, callback=alertchange4, bouncetime=12000)  # add rising 
    GPIO.add_event_detect(16, GPIO.FALLING, callback=alertchange5, bouncetime=12000)  # add rising edge detection
    GPIO.add_event_detect(18, GPIO.FALLING, callback=alertchange6, bouncetime=12000)  # add rising 
    GPIO.add_event_detect(31, GPIO.FALLING, callback=alertchange7, bouncetime=12000)  # add rising edge detection
    GPIO.add_event_detect(32, GPIO.FALLING, callback=alertchange8, bouncetime=12000)  # add rising
Final Breadboard layout per schematic.
breadboard_final.jpg
breadboard_final.jpg (62.91 KiB) Viewed 2755 times
Screen Shot 2016-11-29 at 10.50.05 PM.png
Screen Shot 2016-11-29 at 10.50.05 PM.png (59.63 KiB) Viewed 2778 times
Attachments
Screen Shot 2016-11-29 at 10.50.05 PM.png
Screen Shot 2016-11-29 at 10.50.05 PM.png (59.63 KiB) Viewed 2777 times

Return to “Automation, sensing and robotics”