I designed a circuit that powers on when the car is started (key is in ACC or ON). The circuit's uC then enables 12V from the battery by setting port PC5 high. The uC detects when the key is switched off when port PC4 goes high via the opto-isolator and the uC then remains on until it sends port PC5 low removing the 12V battery supply disabling the circuit until the key is switched on again. There are many previous questions that cover high-side switching but I haven’t seen one quite like this. The circuit works fine on the breadboard, but I don’t know that it’s the best approach. Should I consider using a FET rather than the 3906 BJT? Would a BJT be more appropriate than the opto-isolator? Any glaring errors with this design (unnecessary or incorrect value components, etc)?uC-switched power supply

  • \$\begingroup\$ You're using a 5V regulator in your "+3.3V supply"... \$\endgroup\$ – Ignacio Vazquez-Abrams Jan 2 '16 at 17:45
  • \$\begingroup\$ The optocoupler is pretty pointless. Just us another 2N3904. \$\endgroup\$ – Matt Young Jan 2 '16 at 17:52
  • \$\begingroup\$ @Ignacio Thanks. I went back and forth between regulators as I tried different uCs. Diagram corrected. \$\endgroup\$ – unix Jan 2 '16 at 19:44
  • \$\begingroup\$ @Matt. I had a 3904 there and got a handful of opto-isolators to experiment with. Not sure it would protect the uC anyway with the grounds on either side connected together. \$\endgroup\$ – unix Jan 2 '16 at 19:53

The 2N3906 power switch looks OK as far as circuit topology is concerned. The 2N3906 is rated for a maximum of 200mA and as long as your total load on the regulator is less than that they you should be good to go. If you need a larger load current than say 150mA or so then I would recommend that you find another PNP transistor with a higher current rating.

As designed right now the base current you pull from the PNP transistor is around 1mA. Considering that the worst case current gain of a 2N3906 is 30 you may want to consider changing the R10 to a lower value to increase the PNP base current up to the 8 mA level so that the PNP can fully saturate when the rated current is drawn.

  • \$\begingroup\$ Ok, so I should select the base R using the hFE curve (Figure 1 of my data sheet)? The curves appear to peak about 8-10mA. Using a 2k2 yields ~5mA and using a 1k yields ~11mA. Either would be ok? \$\endgroup\$ – unix Jan 2 '16 at 21:28
  • \$\begingroup\$ @unix - I look at the maximum collector current I would have in the circuit. Then I round up by 30 to 50%. Then divide that by the minimum current gain (30 in case of 2N3906 data sheet I checked) to get the worst case base current to design for. This is mostly specific to design of switched circuits. In case of linear amplifier circuits there are other factors to consider which are not really important in your application. \$\endgroup\$ – Michael Karas Jan 2 '16 at 23:28
  • \$\begingroup\$ An ammeter reads 45mA for the entire circuit. Even doubling that and dividing by the min current gain gives 3mA but now I understand how the 8mA was derived. Thanks. Do I even need R13 and R10? Can I just set R8 to give the desired base current? My original rationale was to create a voltage divider but 12V is well within the 3904 limit. Don't remember why I added R13 but now it appears unnecessary. \$\endgroup\$ – unix Jan 3 '16 at 3:41
  • \$\begingroup\$ R13 is indeed not needed. However it is R10 that limits the base current of the 2N3906. R8 will help to get the Q1 off a little faster when Q2 goes off. \$\endgroup\$ – Michael Karas Jan 3 '16 at 6:23
  • \$\begingroup\$ Diagram updated. I removed R13 and replaced the optocoupler with a NPN, R1, and R2. The collector of Q4 is connected to an internal pull-up on the uC and goes high when the key is switched off. \$\endgroup\$ – unix Jan 3 '16 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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