# Is this a reasonable way to switch a circuit on and off?

I'm using optical slotted switches to detect the position of a wheel. I may have a dozen or so, and at any given time I only need to have one switched on. The device might be battery powered, so I want to conserve power where I can (the opto switch draws about 25mA and I guess the comparator a little bit too.). Also, I want a way to quickly see that a) the opto switch is powered on and b) if the beam is broken. This allows me to simply connect a 5V source to the circuit and fine tune the positioning of the plastic tab that breaks the beam without having to connect and run the whole system.

Here is my stab at a diagram of what I've got so far on the breadboard:

simulate this circuit – Schematic created using CircuitLab

Is there some glaring deficiency in this circuit? I suppose there must be, because although there are plenty of examples of common emitter configurations, there don't seem to be many examples of sticking a NPN transistor below a whole circuit to power it on and off.

Edit: The Slotted Optical Switch is part no HY505. It specifies an IR diode forward current of 50mA, which I took to be the max. Experimentation revealed that 20mA seems to provide adequate distinction between a blocked slot and not. The op amp was just one corner of a quad comparator I had lying around.

• Please provide part numbers for the opto and the comparator. – WhatRoughBeast Mar 1 '15 at 11:23

You get the local ground above the universal ground. Which generally speaking is bad.

The main reason is it can cause signals generated by the circuit to interact unpredictably with circuits connected to the "true" ground. You also need to remember that ground is not universal when expanding the circuit. Generally it's commonly accepted to disconnect the positive (and/or negative) rail and not ground.

• Where excatly is this "local ground"? I mean, where is the return path? – Golaž Mar 1 '15 at 11:11
• What he calls local ground is Q1 collector, the Cathode of D2 and -ve power supply of the op-amp. When Q1 is off this point floats to near V+ so the whole circuit is at V+. As long as the circuit remains totally isolated it's probably OK. But if anything is electrically connected to any point on this circuit it is liable to be driven in an ill defined way. – Russell McMahon Mar 1 '15 at 20:34
• Even though Russel McMahons' answer gave more incite into the circuit as a whole, this answer provides a definite answer to the question in the title. So I'll mark it as the accepted answer. – mjk Mar 1 '15 at 22:39

Your LED resistors are vastly too small for their purpose.
A modern indicator LED should give an adequate result at 1 mA.
(2 to 5 mA if desired but 30 mA is (O.O.)OTT.)
If D4 is a red LED it draws about 30 mA (which is above what many LEDS are rated at) as does D3.

You should say what OA1 is as it may matter.

The optos should not need to draw 30 mA.
5 mA should do and maybe less.
Again, part number needed.

An opamp should draw perhaps 1 mA quiescent. I've saved you about 20 x that - let the poor creature run all the time.

IF you must have a low side switch so be it, but high side is about as easy and the "ground" of the main circuit can then be at true ground potential. User61143 will tell you why that is a good idea.

You may wish to excise mention of "Arduino". This circuit is quite universal and some people have the strange idea that if it's associated with Arduino's it must be rubbish. While you probably [tm] find that idea puzzling, at least, if it is essentially a general microcontroller question then omitting the unneeded reference to A's helps keep such people perhaps a tiny bit happier.

User61143 used the term "local ground"

What he calls local ground is Q1 collector, the Cathode of D2 and -ve power supply of the op-amp. This is the point to which all current in the circuit flows when Q1 is on - and it is then at true ground potential + the Vce drop of Q1. When Q1 is off this point floats to near V+ so the whole circuit is at V+. As long as the circuit remains totally isolated it's probably OK. But if anything is electrically connected to any point on this circuit it is liable to be driven in an ill defined way.

• Maybe we can update this font for "Unnamed general purpose microcontroller development board" every time the A-word is typed ;o) – jippie Mar 1 '15 at 12:28
• great answer, but what is OOOTT? Haven't heard of that acro' before... google only provided me with the info it's a facial muscle mnemonic for medicine students... – user20088 Mar 1 '15 at 14:21
• Maybe a typo for "OTT" = "over the top" or excessive. – pjc50 Mar 1 '15 at 17:14
• @pjc50 Hm. That'd make some sense... OOOTT == over over over the top? – user20088 Mar 1 '15 at 17:15
• I get the point about "let ground be ground". The circuit is isolated from anything else, but I can see now why it's desirable to have the switch on the high end. But D4 doesn't draw 30mA. There a voltage drop at Q1 + a drop over the IR diode (1.8V), + a drop at the diode itself (2.0). That's 4.5V across the semiconductors. Surely that means only 5mA through R4. – mjk Mar 1 '15 at 21:50

Just a few ideas that may help you out...

1. You mentioned you wanted to be able to tell if the LED is on or not. One thing you have to tell is "is the LED on but blocked by something in the slot?" To do this, you could measure (with another comparator) the voltage drop across the series resistor feeding the LED (a sense resistor).

2. Your other question was a way to make the whole circuit more power efficient. Depending on your application of what is breaking the beam, you could PWM (pulse width modulate) the signal driving the LED so it would be some fraction of the 20mA. This comes at the expense of sensitivity of the phototransistor side of the "slotted switch", but you can give it a shot.

• Thanks for the comment. The "power on" LED is really to help me visually check that the micro controller has switched on the correct sensor. By having it in series with the IR LED, I can be sure also that the IR diode is working too. The PWM idea is also a thought, although my initial design was more based around knowing that only 1 out of 10 sensors needs to be active at any given time. Regardless of what current they draw individually, potentially 90% of the total power is wasted. – mjk Mar 1 '15 at 22:35