Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I'm designing a circuit that will use a combination of switches and resistors to allow a microcontroller to identify which switch was pressed based on the voltage read and perform a switch-specific action. The design that I've come up with involves using a transistor to activate a relay, which powers the microcontroller. When the microcontroller is powered, it pulls a pin high to take over powering the relay. When the action is finished the microcontroller pulls the pin low, deactivating the relay and cutting power to the microcontroller.

I've tested the circuit with one switch and a voltage divider to simulate the largest resistor/lowest voltage combination from my switch array. The voltage that I've calculated at the transistor is 1.6 V, and the current is 0.017 mA. The high resistor values are necessary since I need approximately 0.2 V differential between switches. The problem is that the transistor is not being activated (it works if I feed it 5V directly).

My question: Is this because the current is too low? How would I go about rectifying this (other than decreasing resistances)? If there is a better approach to this problem, I'd love to hear it also.

schematic of non-functioning circuit

Edit

The diagram omits the 15 other switches and resistors for simplicity sake.

This is a circuit for a picture frame that will do specific actions depending on the button that is pressed. This will be battery-operated using 6 D-cell batteries, mounted on the wall. I'd like to get months if not years of operation out of it before having to replace the unit. My Arduino with an attached shield (with using a MAX667 power supply rather than the stock one) consumes 45 mA at low power. The stock Arduino doesn't go into low power mode although with a programmer the chip can be modified to go into low power mode and consume nA of current. At 45 mA, the batteries will last about 11 days (266 hours for a 12000 mAh battery). Hence the requirement that the resistive ladder turn on the device.

share|improve this question
    
BC337-40 has guaranteed Beta in the rangw 250-600. (Family is BC337, BC327, BC807, BC817) –  Russell McMahon May 17 '13 at 18:45
    
BUT a MOSFET needs voltage onl;y to trigger. \\Your power switch can be a MOSFET in place of the rea;y/ –  Russell McMahon May 17 '13 at 18:46
1  
Placing relay in emitter gives it voltage gain of ~~ of 1 –  Russell McMahon May 17 '13 at 18:47
    
It's a bit heath-robinson, all this .. does it offer much real benefit over a low-power microcontroller which is always powered but in sleep most of the time? –  pjc50 May 17 '13 at 19:23
    
@pjc50 What have you got against Mr Robinson's fine products ? :-). | The problems are more to do with the implementation. Properly done this can have advantages and cost very little. Relay should be a MOSFET. Kurt's cct is going in the right direction and is OK as an example BUT the low side switch and hi floating processor will easily cause problems. Putting the MOSFET on the high side and using a switch operated jellybean BJT or another FET to operate the high side FET is most of what's needed. Drain can be so close to true zero as is unmeasureable. –  Russell McMahon May 17 '13 at 20:51
show 2 more comments

6 Answers

Yes; best case the hFe of a BJT will be 100 or so, which means your 0.017 mA will turn into 1.7 mA, which is not enough to power the relay coil.

There's another problem, too: The current out of an Arduino will not be sufficient to drive the coil of a relay, as the typical spec is 25 mA per pin out, and typical relays use 35-100 mA of current for their coils.

I question your assumption, though: What is the "0.2V" that you need for the switch? What do you think that means? Where does this number come from? Specifically, when the switch is open, the voltage gap across the switch will be pretty much VCC, as the switch resistance will be close to infinite. When the switch is closed, the voltage across the switch will be close to zero, as the switch will have close to zero resistance.

There are various solutions to the core problem of "how to turn on a microcontroller with a button, and then keep it on until it's done." You might use a low-side N-channel MOSFET to switch on the relay coil. There would be a pull-down on the MOSFET gate, and the switch would pull it up to VCC. The digital out of the MCU would also be connected to this MOSFET gate, with a current limiting resistor that's lower than the pull-down, but high enough to not interfere with the switch when low. I'd suggest 10 kOhm for the pull-down, and 1 kOhm for the digital pin resistor, and the switch goes straight from the MOSFET gate to VCC. Note that the MCU needs to be able to pull the MOSFET gate both high and low, so a diode wouldn't work in that case.

If you can be more specific about what the "0.2V" requirement actually means, and what it's actually coming from, that would be useful, too. Almost all voltage specifications have to do with insulation ratings, and 0.2V is not within the range of those. Other ratings come from arc gaps, and those are typically 16V or higher as well. Other than that, the main important factor for switches is the amount of current interrupted, and that's typically rated in at least dozens of milliamps.

Thinking about it: Is the reason you need 0.2V differential "between switches" that you want to use an ADC to figure out which of many switches was used to start the MCU? If so, for 5V, a 0.2V differential is achieved with a ratio of resistors, rather than absolute values. A 24 Ohm resistor and 1 Ohm resistor will divide 5V into 4.8V and 0.2V, just like a 24 kOhm resistor and a 1 kOhm resistor will divide 5V into 4.8V and 0.2V, although with different amounts of current running through them!

share|improve this answer
    
The 0.2 V differential is there so that my ADC can accurately detect which switch was pressed (e.g. 5V, 4.8V, 4.6V, 4.4V, 4.2V). I edited my question to explain more what I'm trying to do. The diagram omits the 15 other switches and resistors for simplicity sake. –  n.taco May 17 '13 at 21:54
add comment

There is a lot wrong with your circuit that other people have mentioned. I'm not going to go over those issues, but instead present you with an alternative.

When you say this:

I'm designing a circuit that will use a combination of switches and resistors to allow a microcontroller to identify which switch was pressed based on the voltage read and perform a switch-specific action.

It sounds like you are trying to implement a resistive ladder circuit so that one pin of the ADC can determine different button presses by the resulting voltage. There is nothing wrong with this idea, but you haven't included it in the schematic. The only line going to your ADC is the from the "turn the MCU on" button, which is pointless since the MCU will know this button was pressed because it is already on. If you are trying to use this button to initially turn the MCU on as well as a switch to perform an action once the MCU is on, that is a different story. However, I don't think this would be a good idea if you are including this switch as part of a resistive ladder. As mentioned by other people, the transistor is current driven and is not being driven hard enough to fully turn on. Adding more buttons which will generate different voltage levels will only complicate this issue futher. I would recommend keeping this button separate from your other "action" switches...

I am also confused about your need for a 0.2V differential unless you are referring to the voltage levels to be fed into the ADC. But that further proves you should keep this "turn on" button out of that mess. Another issue in addition to your placement of the relay and trying to drive it from the MCU pin is your use of the relay all together. It seems like you are doing this to save power by keeping the MCU off unless it needs to do something. But relays are constantly consuming quite a bit of current just to keep the coil activated.

Take a look at this circuit:

Controlled MCU Power

When pressed, the button SW1 will put VCC at the gate of the FET transistor. This will "turn on" the FET, connecting the MCU to ground. Once the MCU is on, it can enable PINx as a high output which will keep the transistor gate high and happy. Resistor R2 is there to keep the gate low when it is supposed to be low, and R1 will protect the MCU pin during the time it is a low and the button is pressed. The capacitor C1 should help debounce the switch so the transistor isn't rapidly turned on and off. The transistor should have a logic level gate (gate to source voltage threshold of less than VCC) to ensure proper operation.

Your other switches and resistors can then be fed into an ADC channel for whatever other purposes you have for them.

When the MCU is done, it can lower PINx. Once the capacitor C1 has discharged, the transistor will shut off, disconnecting the MCU from ground.

share|improve this answer
    
General method is good. Having high side connectd floating processor is harder to deal with when off. Using hogh side MOSFET plus whatver else is neededmakes life easier. –  Russell McMahon May 17 '13 at 20:53
    
@RussellMcMahon Very good point. –  Kurt E. Clothier May 17 '13 at 21:06
    
I edited my question to explain more what I'm trying to do. The 0.2 V differential is there so that my ADC can accurately detect which switch was pressed (e.g. 5V, 4.8V, 4.6V, 4.4V, 4.2V). –  n.taco May 17 '13 at 21:56
add comment

Why bother with a bipolar and relay. How about using a Pch connected from +5V input to the Vdd supply pin (arduino)? Use a switch to drive the gate from 5V (off) to gnd (on). The gate signal can be latched or toggled with a 5V logic device (eg. D type flip flop). Choose the PFET such that its Vt is -1 to -1.5V and an Rds-on (100mohms or less) that doesnt drop much under max current load of the arduino.

share|improve this answer
    
I edited my question to explain more what I'm trying to do. My switches will output 5V, 4.8V, 4.6V, etc. Will that work with such a FET? –  n.taco May 17 '13 at 21:56
add comment

There's a huge problem with your circuit: You have the relay in series with the emitter, which means that the relay can only get whatever voltage is on the base, minus the 0.6V or so B-E drop of the transistor.

For what you are trying to do, you need to put the relay in the transistor's collector circuit, and use a second transistor driven by the Arduino to keep it on once activated. If you really need to operate at such low sensing currents, then your existing transistor should be replaced with a Darlington.

schematic

simulate this circuit – Schematic created using CircuitLab

share|improve this answer
    
Aside from my concerns regarding the wasted power in the relay, this is probably the best way to do this. –  Kurt E. Clothier May 17 '13 at 21:25
add comment

Look at my circuit it may be suitable for you:

enter image description here

https://www.circuitlab.com/circuit/dsyqc8/uc-switching-by-bjt/

BJTs Q1 and Q2 form an electronic switch. When SW1 is pressed the microcontroller will get +Vcc and in order to keep the uC powered the HOLD uC output should be made high. This works even at very low input voltage.

share|improve this answer
    
Going in right direction BUT Q1e shoud be ground returned and R5 in collector. As is base neds to be abve emoitter vy 2 x Vbe BUT hold uC cannot get there. –  Russell McMahon May 18 '13 at 13:03
    
thanks Russel for pointing out the mistake.i will update the schematic –  yogece May 18 '13 at 17:45
add comment

here i post the working circuit(constructed myself using MSP430G2553 with internal oscillator & used 2XAA EVEREADY cell.when i decreased the voltage of the R8 below 0.8 and again increased to 0.9 or Vcc,controller freezes,then i reset the controller even you can use watchdog timer to avoid this problem)

https://www.circuitlab.com/circuit/u9j7dk/uc-switch-by-bjt-1_1/

Adjust the pot(R8) to change the voltage applied to the base terminal of Q1(The switch would turn on even @ 0.9V to Vcc). i haven't tested with HOLD uC signal it might work because the minimum voltage required to ON switch is 0.9V (output from the uC approx 3V & drop across D2 would be o.7)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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