Advice on using a touch sensor as a power switch.

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Docker
 
Posts: 7
Joined: Fri Apr 11, 2014 9:02 pm

Advice on using a touch sensor as a power switch.

Post by Docker »

Hello all, I'm trying to use a toggle capacitive touch sensor to toggle 5V power to a pro mini. Currently, I'm running a 3.7 lipo cell into a 5V stepup regulator, using that to power the touch sensor, then I'm (currently) attempting to open a PN2222 transistor which has the 5v output going to collector, and my 5V rail to the pro mini fed off of the emitter. What I'm seeing (and I'm absolutely positive I'm doing something wrong, I've only been making circuits as a hobby for a few weeks now), is on touch, the pro mini gets power, keeps power for a few seconds, then the circuit seems to reset, touching the sensor again will turn the circuit on again.

I'm also seeing about a 1V drop coming out of the transistor, which surprised me. Optimally, my circuit would use either a latching or momentary touch sensor to 'gate' 5V at about 1.4 amps of peak current draw.

Ideas? Criticism? Anything but mockery? :D

User avatar
Franklin97355
 
Posts: 23912
Joined: Mon Apr 21, 2008 2:33 pm

Re: Advice on using a touch sensor as a power switch.

Post by Franklin97355 »

5V at about 1.4 amps of peak current draw.
Are you trying to do that from the lipo with the step-up?

User avatar
Docker
 
Posts: 7
Joined: Fri Apr 11, 2014 9:02 pm

Re: Advice on using a touch sensor as a power switch.

Post by Docker »

Not currently right now I just have the pro mini and 8 ws2812 LEDs running a rainbow cycle to test a low-moderate draw.

User avatar
zener
 
Posts: 4567
Joined: Sat Feb 21, 2009 2:38 am

Re: Advice on using a touch sensor as a power switch.

Post by zener »

If you can post a schematic that will help us figure out the trouble.

User avatar
Docker
 
Posts: 7
Joined: Fri Apr 11, 2014 9:02 pm

Re: Advice on using a touch sensor as a power switch.

Post by Docker »

Unfortunately I haven't learned how to derive a schematic from my designs yet. As I said, I'm fairly new to this, and I'm sure my knowledge is a mix of right/wrong/and ridiculous.

User avatar
Docker
 
Posts: 7
Joined: Fri Apr 11, 2014 9:02 pm

Re: Advice on using a touch sensor as a power switch.

Post by Docker »

Apologies for the delay in replying, I spent a bit today figuring out how to make this schematic.
touch_schematic.PNG
touch_schematic.PNG (241.98 KiB) Viewed 484 times
The voltage regulator can be before or after the transistor, it doesn't seem to make a difference to the behavior. What I'm seeing most commonly is the circuit turning on correctly for a few seconds, up to a minute in some cases, then the toggle touch sensor turns itself off. Most times it will turn back on, but if there's a large power draw from the LEDs, it will occasionally 'stick' on and not respond to touch until the circuit shuts itself down again.

Thoughts?

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Advice on using a touch sensor as a power switch.

Post by adafruit_support_mike »

The roughly-1v loss through the transistor is normal.

Transistors take some getting used to, but here are the major pieces to get started:
transistor.jpg
transistor.jpg (18.27 KiB) Viewed 467 times
It looks like a lot, but don't worry.. it's just names and a couple of basic relationships. Voltages are drawn in blue, currents are drawn in red.

The two voltages that are easiest to measure are the voltage at the transistor's base (Vb) and the voltage at its emitter (Ve). The difference between them is called Vbe.

Bipolar transistors like the PN2222 are basically current amplifiers, so sending a little bit of current into the base (Ib) allows a larger amount of current to flow from the collector to the emitter (offically Ice, but usually shortened to Ic). Both the base and collector currents flow out the emitter, so that (offically Ie) is the sum of Ib and Ic.

For doing-it-in-your-head purposes, assume Vbe=0.65v and Ic=100*Ib. The exact values are more complicated, but those values will get you impressively close in most cases.

The basic operating principles of an NPN transistor are:

- Ve will always be about 0.65v below Vb
- Ic will be whatever it takes to put the right Ve across Re

Now, you'll notice that I stated the operating principles in terms of Vbe rather than Ib. Technically Ib is what controls the transistor's behavior, but Vbe is easier to measure. You can calculate Ib (and thus Ic) from Vbe, but the equation is exponential and explaining it takes about two pages more than you probably want to know. The practical result is that changing Vbe by 60mV changes Ib by a factor of 10. As a rule of thumb:

- when Vbe is 0.65v, Ib is about 10uA and Ic is 1mA (100*Ib)
- when Vbe is 0.71v (60mV higher), Ib is 100uA and Ic is 10mA (10x increase)
- when Vbe is 0.59v (60mV lower), Ib is 1uA and Ic is 100uA (10x decrease)

The relationship between Vbe and Ib explains how the transistor is able to do the 'whatever it takes' thing with Ic.

Imagine Vb is 1v and Ic is 1mA. That puts Vbe at 0.65v and Ve at 0.35v. To make that work, Re needs to be 350 ohms.

Let's also imagine that Re is a potentiometer, and we can change its resistance by turning the knob. If we make the resistance slightly higher (400 ohms), leaving Ic at 1mA would raise Ve to 0.4v. Vb is still 1v, so Vbe would drop to 0.6v. That's close enough to a 60mV change in Vbe for horseshoes, hand-grenades, and circuit analysis, so that change would force a 10x reduction in Ic. That would send Ve plummeting to 0.04v, which is much, much too far.

In actual fact, raising Re to 400 ohms will drop Ic to about 0.9mA, Ve will be about 0.41v, and Vbe will drop to about 0.64v. The small reduction in Vbe will change Ic enough to keep the 'whatever it takes' thing working. The same principle holds for any resistance, even ones much larger or smaller than our 350 ohm starting value.

Cranking all that around so it makes sense for your circuit, Ic will be whatever it takes to run the mini, Ib will be about 1% of that, and since you're probably using more than 10mA, Vbe will be somewhere north of 0.7v. If your signal to the transistor's base (Vb) is 5v, the voltage to the mini (Ve) will max out somewhere below 4.3v.

For switching applications (which you're doing), it's usually best to connect the load to the collector. I haven't talked about that part yet, but the collector voltage can get to within about 250mV of Ve. Instead of losing three quarters of a volt (or more) you lose less than half a volt.

User avatar
Docker
 
Posts: 7
Joined: Fri Apr 11, 2014 9:02 pm

Re: Advice on using a touch sensor as a power switch.

Post by Docker »

OK, given that, how would you suggest using your toggle touch sensor to switch power for a circuit? Right now the primary issue I'm running into is if I use the sensor's output as the gate voltage for a MOSFET (like https://www.adafruit.com/products/355), it can't seem to consistently keep the gate open, the touch sensor flips state a few seconds after being turned on if there's a load greater than just the microcontroller on the other end.

Ideas?

User avatar
Franklin97355
 
Posts: 23912
Joined: Mon Apr 21, 2008 2:33 pm

Re: Advice on using a touch sensor as a power switch.

Post by Franklin97355 »

How are you connecting the mosfet? Please draw a diagram.

User avatar
Docker
 
Posts: 7
Joined: Fri Apr 11, 2014 9:02 pm

Re: Advice on using a touch sensor as a power switch.

Post by Docker »

The in-line fritzing breadboard image above is a close representation of what I'm trying to lay out. The biggest difference is the voltage regulator I'm using is one made by Pololu, this one: http://www.pololu.com/product/2562, in place of the 3-pin regulator in the image. Essentially, the layout is 3.7v lipo -> touch sensor -> mosfet -> step-up regulator -> remainder of circuit (microcontroller, LEDs, microphone).

- Alan

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Advice on using a touch sensor as a power switch.

Post by adafruit_support_mike »

Just to check, what capacitive sensor are you using?

User avatar
Docker
 
Posts: 7
Joined: Fri Apr 11, 2014 9:02 pm

Re: Advice on using a touch sensor as a power switch.

Post by Docker »

Sorry for the delay, travel took up my week. I'm using the one you manufacture / sell, https://www.adafruit.com/product/1375

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Advice on using a touch sensor as a power switch.

Post by adafruit_support_mike »

That breakout is designed to toggle between on and off, and driving a mosfet shouldn't be any harder than driving an input pin for an Arduino.. they're basically the same thing.

I can think of three possible reasons for the behavior you're seeing:

1) Parasitic capacitance near the sensor which automatically resets it.
2) Parasitic resistance near the mosfet which causes that to drop to zero
3) Hardware trouble in the breakout

If the sensor works as expected for a light load, I wouldn't expect any problems with the hardware. Parasitic resistance and capacitance happen all the time and are responsible for any amount of unexpected behavior.

Post a photo of your hardware and we'll see if that gives us any clues.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”