Electronic – Using a transistor for interfacing different voltages

transistorsvoltage

I have some solenoid valves that I want to drive from a little beaglebone gpio. The beaglebone is a little ARM based microcontroller.

The gpio on the beaglebone outputs 3v3, and the beablebone itself runs on 5V. The solenoid valves run on 12V. I have some 2n2222a transistors and I thought there was a way to use these to run the 12V devices from the 3v3 GPIO in open collector mode (http://en.wikipedia.org/wiki/Open_collector). What I'm confused about is what this circuit should look like.

I know I need to hook the positive of the 12V supply up to the positive end of the solenoid valve. Then, I think I should hook the negative side of the solenoid valve up to the collector of the transistor. The gpio connects to the base of the transistor via a resistor, enabling me to use the transistor as a switch on the 12V line.

What I don't understand is:

1) Which ground should the emitter of the transistor go to? The one for the beaglebone (which comes off the 5V supply) or the one on the 12V supply?

2) How can I figure out what ohm value of resistor to put between the gpio and the base?

For reference, a datasheet for the 2n2222a can be found here: http://www.csus.edu/indiv/t/tatror/projects/met%20highway%20safety%20project%202010/npn%20transistor.pdf

Best Answer

Actually I didn't notice this was about an open collector output until miceuz posted his comment, so for OC output I would use one of these

enter image description here

and the isolated version

enter image description here

If the GPIO can't provide enough current to the optodiode to get the appropriate output current in the transistor side then you'll have to add another transistor either to the input or output.

Note that resistor values may vary depending on the requirements


2) How can I figure out what ohm value of resistor to put between the gpio and the base?

A rule of thumb is that you have to provide 1/10 to 1/20 of the output current in the transistor base in order to saturate the transistor and get a low collector-emitter voltage drop (which means higher voltage output and less heat dissipation)

Related Topic