How to invert a pulsed signal with a raspberry pi? - Page 1
Forum section: electronics / beginners

author: jerryk
author_rank: Regular Contributor
timestamp: January 07, 2018, 02:08:55 am
content: I am working on two 1990's vintage Napco security systems. (Magnum Alert 850 and 825). The goal is to control the key pad with my cell phone so I can remotely set the alarm. I have succeeded with the model 825 since the key pad relied on simple hi/low logic. Each key press sends a high(+12v) or low(0v) voltage to the panel via four wires which translates to the binary equivalent of the pin number that the individual numeric push button corresponds to. The model 850 uses the same scheme but sends a pulsed signal out the four wires with the same binary scheme as the 825.The photo at the bottom shows the pulsed voltage I need to create. The bottom channel two is a reference pulse that I have to work with coming from the pannel. Channel one is the corresponding pulse that I need the pi to pass to the key pad inputs at the panel. My thoughts were to invert the reference pulse with either a nand gate like the cd4011 or an inverter ic of some sort. The ic needs to handle at least 13.5 V supply. Any suggestions on how to accomplish this task?Thanks - Jerry

author: danadak
author_rank: Super Contributor
timestamp: January 07, 2018, 11:59:14 am
content: A simple transistor inverter -This is shown with +5, works up to transistor breakdown voltage,but caution, you should scale up the collector R to set some designcriteria, say ~ 1 mA at the highest Vcc.R3 = ( Vccmax - Vcesat ) / 1 mA, Vcesat spec of transistor.Design the base R1 to drive .1 mA into transistor base when on,R1 = ( Vohmicroprocessor - Vbetransistor ) / .1 mANote I am ignoring the current, Vbe / R2, being robbed by R2, thatdecision probably OK. Or you can include that in calculation addingit to .1 mA.R2 is to keep transistor off when UP output is tristated, it absorbsleakage of ouput and transistor,R2 <= Vbe / Ileakage total, figure in tempco of Vbe of -2 mV / degree C,and use a margin on Vbe, say transistor Vbe x 1/2.Regards, Dana.

author: jerryk
author_rank: Regular Contributor
timestamp: January 07, 2018, 07:27:22 pm
content: Thanks Dana. I managed to get a 2n7000 to invert the signal fairly close to what I think I need. I'm not good on the math but playing around with the resistors that I have the closest I could come to a perfect signal inversion was per the schematic below.edit - I spoke to soon on my impression that I needed this circuit times four. I think I can just use the inverted signal from a single circuit for the four inputs on the raspberry pi. I think this is correct?Jerry

author: danadak
author_rank: Super Contributor
timestamp: January 07, 2018, 11:29:10 pm
content: If the 4 Pi inputs want to see the identical signal, no problem, just tiethe inputs together and feed them the output of the inverter circuit.Otherwise you need 4 inverter circuits. You could use a quad NPN arrayto do that with. May even be able to find one with internal base R's, trygoogle searches.The 2N7000 circuit looks OK, not sure why the source resistor needed,330 ohm. However, the worst case turn on V is 3V, and the Pi specs showa lower worst case VOH, so you need to look further into this, maybe staywith a bipolar.http://www.mosaic-industries.com/embedded-systems/microcontroller-projects/raspberry-pi/gpio-pin-electrical-specificationsRegards, Dana.

author: james_s
author_rank: Super Contributor
timestamp: January 08, 2018, 06:14:20 pm
content: Something like the 4066 analog switch IC could to the job for you and emulate any kind of keypad you want. I have an aftermarket computer interface in a couple of my old scanner radios that does exactly that to control the scanner.

author: sokoloff
author_rank: Super Contributor
timestamp: January 08, 2018, 06:23:37 pm
content: Why use an RPi? This seems a tailor-made application for a microcontroller (at least vs a Pi or other single board computer).Arduino (or the underlying Atmel) is cheap, easy, and plenty of IOs for something like this. Arduino has network cards available as well.Alternately, if you want wifi, ESP8266 platform has that as well as a smaller number of digital IOs.Maybe I misunderstand the reason to include a Pi, but it seems like massive overkill (and complexity) for what you need.

author: jerryk
author_rank: Regular Contributor
timestamp: January 08, 2018, 06:52:25 pm
content: I put the source resistor to balance the inverted signal since it's peak to peak voltage was 1V greater than the reference I was using. I have since removed it as unnecessary and am trying to resolve the next problem which is how to get that signal back to the panel through the 4n35 optocoupler with enough current to trigger a key press at the panel.The video clip shows the problem I'm having. The gist of it is that the inverted signal coming directly from the 2n7000 will simulate a key press but if I use an optocoupler to switch the inverted signal on and off it lacks the power to simulate a key press. I have attached a schematic that shows the connections in the video.As for the pi being overkill I agree but this is a very small part of the pi's over all interface with the board that I am making. The preliminary schematic of the main board is the second attachment but does not have this keyboard interface incorporated. Other aspects of pi's function is to be able to control the alarm system and other monitoring systems via a satellite communication device (Garmin Inreach) so it is all text based.Thanks for the other pointers and I will look in to the ESP8266 and the 4066 IC's to see how they fit. I think I have a few of the 4066 ic's around. Just another note is I am using the optocouplers to isolate the pi from the security panel since it is a 12V 1.5 A system.Jerryhttps://photos.app.goo.gl/gTlonE5ZwVNxDfq33*correction in video is the connection is to the third wire not the forth.

author: james_s
author_rank: Super Contributor
timestamp: January 08, 2018, 07:43:48 pm
content: My understanding of the situation is that the RPi is there to provide the online connectivity to access it from his mobile phone. While it's possible to interface a microcontroller to the internet my experience is that it results in a less than spectacular experience.