I am interfacing with an existing product. This product uses a PIC16F54 uC and is ultimately driving a solenoid. This device is a black box to me and I have no input into the software running on the device or the design of it. I have identified the pins on the UC which receive the input and control the output of the solenoid.

Without going into all the specifics, my device is going to "piggy back" onto the existing device and give an alternative method of control to the device while reading its output and input.

my uC will need to be able read the same inputs and also control the output. I don't imagine connecting the inputs together so both uCs can see the input will be a problem. However, the outputs will be a problem. One might be driving the pin low, while another is driving the pin high.

What are my options to overcome this? Ideally, I'd like to tap just two or three points and not get into cutting traces to add additional circuitry.

I am thinking my best bet might just be a "man-in-the-middle" type scenario where I cut the output trace from the device uC and wire that as an input into my uC and then make my uC control the output itself.

My uC will be a rasberry PI w/ TE291 3V/5V shifters to get me to the 5V the PIC is using.

  • \$\begingroup\$ your "man-in-the-middle" certainly does avoid conflict, and gives you absolute control over the solenoid. Beware that the original output could be open collector, in which case you might need a pull-up resistor for logic level. \$\endgroup\$
    – Marla
    Commented Jul 1, 2016 at 15:27
  • 1
    \$\begingroup\$ On the other hand, if the existing circuit is open collector, it would be safe to simply connect the two uC outputs together. You would have a "wired-AND" connection where the combined output would only be high if both uC's set their outputs high. \$\endgroup\$
    – The Photon
    Commented Jul 1, 2016 at 15:33
  • \$\begingroup\$ We user PICs here and you are out of luck - if you can't control the black box firmware you must cut the trace. They are unhappy when they try to drive outputs. \$\endgroup\$ Commented Jul 1, 2016 at 16:26
  • \$\begingroup\$ Thanks. The application requires wired-or. I am thinking the man in the middle solution is going to be the only plausible one. The downside to this is that if my device fails the other device will fail as well. Cutting the trace and adding an OR gate might be the best solution at the cost of added complexity and component count. \$\endgroup\$
    – jr.
    Commented Jul 1, 2016 at 17:05

1 Answer 1


It depends on the output circuit of the device you are trying to hack. The solenoid is probably wired (like a relay) on one end to the positive supply and to ground through a transistor on the other (or a driver chip like ULN2003).

I would put a second transistor in parallel with the existing one and control it from my device.

The solenoid would be driven whenever any of the devices would like it on, however it would not turn off unless both devices want it off.

If your "add-on" must have the ultimate authority, than you can cut the output trace and just wire the existing output to any input of your device.

  • \$\begingroup\$ The solenoid is ultimately driven by a relay. I'm sure there is some transistors between the uC output and the relay coil. I haven't dug that far into the output circuitry. My device doesn't need authority. The solenoid should be OR controlled by either uC. The device has a 15V and 5V regulator. The 15V is used for relay coil. Perhaps I should look to interface a few devices beyond the uC output. \$\endgroup\$
    – jr.
    Commented Jul 1, 2016 at 17:18
  • \$\begingroup\$ Then hack the circuit that controls that relay :) \$\endgroup\$
    – filo
    Commented Jul 1, 2016 at 17:19
  • \$\begingroup\$ Agree. I need to map out what that circuit looks like and see what might be the best place to interface with that. Could likely just switch 15V to the coil from my uC via a transistor and that would end up being logical OR. \$\endgroup\$
    – jr.
    Commented Jul 1, 2016 at 17:24
  • \$\begingroup\$ You can also add just a second relay in parallel with the original one. \$\endgroup\$
    – filo
    Commented Jul 1, 2016 at 17:25
  • \$\begingroup\$ Yes. It appears I have some options. Need to map out the circuit beyond the uC and determine best way. I'll be back with more info once I trace it out. Thx for talking it through. \$\endgroup\$
    – jr.
    Commented Jul 1, 2016 at 17:28

Your Answer

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

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