# Can I replace a relay with (e.g.) a transistor in this resistor ladder circuit?

I'm controlling a Sony car stereo from my car steering wheel remote via an ATMEGA328, based on this project.

It works by keeping the ATMEGA's digital pins in input mode while idle, and setting a single digital pin to output a 0 to activate a corresponding remote function via a resistance ladder. According to the original project, this

works because the Sony unit reads the remote control resistance using a voltage less than the [...] power supply

(I measured this at ~3.3v). My circuit works fine while powered from 5v, but when I turn off the car's ignition (which removes power from the circuit) and the stereo is still on, the controls on the stereo itself stop working, and sometimes the stereo receives erroneous commands.

To work around this, I put a relay between the ATMEGA circuit and the stereo remote input, powered by the same source that powers the circuit. So when the power is cut, the circuit is physically disconnected. This works fine.

simulate this circuit – Schematic created using CircuitLab

What I'm wondering is if I can remove the relay and replace it with something less bulky that will give me a similar high impedance (relative to 0v) when power is removed from the circuit, and when power is applied have a minimal impact on the voltage across the remote control input.

I have a mixed bag of transistors and other miscellaneous components lying around; is there a simple solid-state circuit that will achieve what I'm looking for? What sort of transistor is best suited to this application?

EDIT:

Some more information: Remote control input is at ~3.3v at open circuit. Depending on which output is selected, it will come down to between 0 and 2.3v.

I guess I'm picturing something like this:

• When power is off, Q1 won't be powered and so C-E will effectively be open-circuit, which is what I need.
• When powered and idle, I don't really care if Q1 is "on" or not.
• When powered and an output goes active, B will be pulled down towards 0V via the resistor ladder, $V_{BE}$ will be sufficient to turn on the transistor and $V_{CE}$ will therefore go to 0V, and the correct resistance/voltage will be presented at the remote control input.

What I don't know is if this setup will work in reality, will having the transistor in the circuit affect the resulting voltages to the input (or stop it working altogether), and if it will work, what characteristics I should be looking for in Q1 and R9 (assuming it's going to work the way I want, I guess the voltage across R9 and B-E will vary from 2.7v to 5v depending on which output is selected). Is there a minimum collector current required to get full saturation? Or am I just way off target altogether?

simulate this circuit

One way is to just replace the relay with a MOSFET or bipolar transistor.

Put the gate/base to +5v, source/emitter to the resistor chain and the drain/collector to stereo. For the BJT approach a base resistor of 100k-1meg will be needed

The choice of bias resistor for the BJT is a compromise between getting enough base current to pass the current from the resistor switches and causing an error in the interpretation of the resistor chain. As CupawnTae has found 200K seems to work correctly.

A MOSFET would not suffer from this problem as it does not require any gate current, however the challenge is getting device with a low enough threshold voltage so that it turns on acceptably for the larger value of the resistor chain - there will only be about 1.7V of gate bias then as the voltage at the receiver is ~3.3V and the gate voltage is 5V. Something with <1.5V gate threshold be needed.

Another way is something like this.

It relies on the output from your CPU being low when powered off.

The transistors in that case will not draw any current from the output.

Any general purpose NPN transistor should work ok. Multiple devices in one package such as UL2003 may not work as they are configured as darlington and will probably have a saturation voltage that is too high.

simulate this circuit – Schematic created using CircuitLab

• Argh! Sorry, this made me realize I messed up the schematic (sorry, newbie) - I've fixed it now, but I'm not sure how it affects your solution. Also, when you say it relies on the outputs being low, do they have to be actually at 0v? I would imagine I can't rely on that, but obviously they won't be actively high. And finally, I was hoping to replace the relay with a single circuit after the (now actually modeled) ladder - there are actually 7 outputs in the real circuit, and adding 7 transistors and 7 resistors would mean a complete rebuild, which would probably be worse than keeping the relay Sep 13, 2015 at 1:16
• You could put pull downs on the outputs of the MCU to ensure they are low when powered down. Sep 13, 2015 at 1:18
• Can you do a binary tree rather than a sequential selection? That would reduce the total to 3 or 4 transistors. Sep 13, 2015 at 1:23
• @CupawnTae - Kevin White's idea is good enough that you should consider re-building. But depending upon the range of voltage that the Sony uses, it may be totally possible not have to use discrete transistors for this. You can purchase a chip that has six "open drain" drivers in it to replace the various transistors. It would eliminate the series base resistors as well but you should still provide pull down resistors to the MCU pins where they connect to the logic chip inputs. The chip you want to look for would be a 74LV06 which you can find at Mouser or Digikey. (continued) Sep 13, 2015 at 4:29
• That's the effect I was commenting on. The bias current into the base will go into the collector in this situation. The base resistor needs to be high enough that it doesn't confuse the receiver. The resistor may need to be between 100k and 1meg. The MOSFET will not suffer from this. The main issue with a N-channel MOSFET is ensuring that the difference between the 3.3v max voltage on the receiver sense line and the 5V rail is enough to turn on the MOSFET. You will need a MOSFET with a threshold voltage of lower than 1.5V. Sep 13, 2015 at 20:49