1
\$\begingroup\$

I have a DSC 1864 House Alarm and I want to connect up my Raspberry Pi's GPIO to the Keybus (a serial data communication protocol used by the alarm).

I would say my knowledge of electronics is novice to intermediate.

Info:

The Keybus is a 4 wire serial data bus - +12V, Ground, DATA and CLK.

The clock runs at 1khz from what I've heard.

The Logic is 0-12V I believe (I tested with a multimeter since I dont have a scope and got 12.84v on the +12v and a continually changing 6-8V on both Data and Clk lines as to be expected.)

The Raspberry Pi has a 0 - 3.3V logic level, With anything above 2.8V being HIGH.

Quesiton:

My question is how best to connect these two, with the Pi purely just eavesdropping on the keybus - I dont need to write to it, just read from it.

I'm concerned that if I dont have a high impedance circuit, that the Raspberry Pi will act as a drain on the circuit and disrupt communications between the alarm panels (bad!).

Possible Solutions:

  1. Use an Optocoupler - Not a good solution as I've heard they are slow and draw a lot of current on the transmitting side.

  2. Use a logic shifter chip - Possibly, but I dont know how to find the right one for my needs, and it has to have high impedance so as to not disrupt the keybus circuit.

  3. Use resistors as a voltage divider - This is the route I was planning on going. I calculated that the following:

schematic

simulate this circuit – Schematic created using CircuitLab

Will give 3v at the Pi when DATA goes to 12v, but will fry the GPIO pin if the voltage goes above 13.5v.

It should provide 1.05mA to the Pi - I'm not sure if this is enough for input purposes.

Further Reading:

Resources I've found while researching this:

Any help / suggestions here would be greatly appreciated.

\$\endgroup\$

4 Answers 4

2
\$\begingroup\$

An opto-coupler (or two) could easily do the job, and will provide some welcome isolation between the two devices if the power supplies should float apart. If you don't know why this is a good idea, you really should read up about it.

We have run opto-couplers at MHz, even passed PAL video through them, so a low-speed data bus will be fine.

Without looking too closely, I'd guess that a popular part such as 4n25 would be entirely adequate.

\$\endgroup\$
6
  • \$\begingroup\$ Okay, it sounds like an optocoupler is the best solution - but how well will it eavesdrop on the data signal without interfering with it? Remember there are other devices connected on the bus which are mission critical. I dont know enough about electronics to read this off it's datasheet. I see values of 10mA but I'm not sure if that is a lot when dealing with logic signals? \$\endgroup\$
    – Mikepote
    Jul 31, 2013 at 7:43
  • \$\begingroup\$ Depends on the exact operation of this bus, but if you find you need to buffer the signal into the opto you can do that easily enough on the alarm-side whilst maintaining the isolation across the opto. \$\endgroup\$
    – John U
    Jul 31, 2013 at 8:00
  • \$\begingroup\$ <cough> If it's the best solution, accepting it as the answer would be dandy ;) \$\endgroup\$
    – John U
    Jul 31, 2013 at 16:41
  • \$\begingroup\$ Sure. I just had to understand the datasheet a bit better, but the 4N25 can be made to work with 10mA no problem, so I'm going to go with that. \$\endgroup\$
    – Mikepote
    Jul 31, 2013 at 20:26
  • 1
    \$\begingroup\$ Update: the opto-couplers worked like a charm! \$\endgroup\$
    – Mikepote
    Aug 26, 2013 at 13:34
2
\$\begingroup\$

I used a much more simpler design

My design

I use it with my keybusdev for Linux on Raspberry Pi at https://github.com/hvesalai/keybus

\$\endgroup\$
1
\$\begingroup\$

The resistive divider will work, as long as the voltage is within safe limits.

If you want some more protection, you could put a 12 V Zener diode across the signal line to ground, parallel with both your resistors. This will put some load (capacitive and current) on the signalling line, though.

You could also put a 3.3V Zener across the input directly, but then you have to lower the 10 kOhm resistor to 2 kOhm or so, because a Zener needs 5 mA of current to properly develop its stand-off voltage (else it will be lower.)

Another option would be to use a resistive divider with some kind of re-buffering before going to the RPi. This may be a rail-to-rail cheap op-amp like the MCP601, or a tri-state buffer like the 74HC125, or something else. Op-amps aren't great buffers for digital signals when the frequencies go high, but at 1 kHz, I think you have nothing to fear.

And because there is a clock and a signal, you need this set-up times two. There are both opamps and buffers that have more than one circuit inside the same IC package, which should make it reasonably simple/cheap to accomplish, if you go for the more complex version.

schematic

simulate this circuit – Schematic created using CircuitLab

Another way to do it would be to use a N-channel MOSFET transistor and a pull-up to 3.3V. This will invert the signal, though -- perhaps you can convert in software.

schematic

simulate this circuit

\$\endgroup\$
1
\$\begingroup\$

A common "4050" non-inverting High to Low Buffer ic will do what you want. It's outputs are tied to it's VCC (In this case, the R-Pi's 3.3v), while it's inputs can be up to 15v. This will work for read only, as the 4050 has 6 one way buffers.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
1
  • \$\begingroup\$ What concerns me here is that the Raspberry Pi will be powered off a wall-wart in one room and the alarm system has it's own PSU upstairs in the bedroom. Wont this make a large ground loop? I suppose I could power the Pi from the 12+V from the alarm but it's a tiny little wire, not sure if it can handle any large current draw... \$\endgroup\$
    – Mikepote
    Jul 31, 2013 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.