Ultra low energy switch detection?

M

mike

Jan 1, 1970
0
I want to monitor the state of a mechanical SPST switch.
I have access to both ends of the floating switch.

I have zero experience with low energy design and am
looking for clever ways to monitor hardware using extremely
low energy. I'm not sure exactly what terms are normally used, but
I think energy is the one I mean. At the end of the day,
the fewer electrons required by the system, the better.

I'm currently using a microcontroller in sleep mode
with wake on pin change. This has at least two problems.
The pullup resistor takes current when the switch is closed.
There's a tradeoff between current and noise immunity.
I can't put the processor back to sleep until the contacts
quit bouncing. A lot of wasted electrons go thru the processor
during that time.

A cap mitigates the bounce problem 'cuz I think I can temporarily
change the in to an out and slam it to the rail. I have not yet
counted the electrons required to do that tho...

A SPDT switch solves both problems, but that's NOT the question.
The switch is SPST.

IF I had a lot of switches, waking the processor and polling
is probably cheaper trading cpu current for pullup current.
I'd like to have options.
Yes, I'll have to make mix/match tradeoffs for a total system.
At this point I'm looking at options for only ONE part: the switch.

In the interest of focusing input...
I'm NOT interested in a discussion of replacing the switch.
I'm NOT interested in a global system discussion that doesn't directly
solve this specific problem.
I'm NOT interested in discussing WHY. I'm interested in learning HOW.
If you're gonna tell me to google it, at least tell me the search terms
that you used to find the answer. Mine didn't.

Yes, there can be many issues. In this thread, I'm asking about
ONE of them.
I AM interested in ways to use a microcontroller to monitor a SPST
switch using as near zero energy as I can.

TIA, mike
 
T

tm

Jan 1, 1970
0
mike said:
In the interest of focusing input...
I'm NOT interested in a discussion of replacing the switch.
I'm NOT interested in a global system discussion that doesn't directly
solve this specific problem.
I'm NOT interested in discussing WHY. I'm interested in learning HOW.
If you're gonna tell me to google it, at least tell me the search terms
that you used to find the answer. Mine didn't.

Yes, there can be many issues. In this thread, I'm asking about
ONE of them.
I AM interested in ways to use a microcontroller to monitor a SPST
switch using as near zero energy as I can.


Are you interested in paying for this engineering or just mooching?




tm
 
D

Don Klipstein

Jan 1, 1970
0
<In my words, need of very-low-power-consumption microprocessor monitoring
of status of mechanical switches>

I have heard of microprocessors that have power consumption roughly
proportional to clock frequency. Many of these have power consumption
getting impressively low when clock frequency dips down to audio
frequencies.

As for a micropower clock oscillator: A 4049 stage with a resistor from
output to input and a capacitor from input to ground oscillates. Have the
output go through another stage of the 4049 to clean it up somewhat.

Put a .022 uF capacitor from Vdd pin of the 4049 to ground, and put a
high value resistor (100K to 470K ohms ? ) between Vdd pin and positive
power supply.

From the 4049's final output, add a resistor from output to positive
power supply for pullup to full supply voltage of the microprocessor.
The 4049UB ("4000-B-series CMOS 4049") was designed for "logic level
conversion" with pullup to a voltage higher than that at its Vdd pin.

If you need cleanup to shorter risetimes and falltimes, use additional
stages of the 4049. Maybe add a stage or 2 of a 40106 into the "cleanup
chain", but make the last stage of the "cleanup chain" a stage of the
4049 since the 4049 can use a pullup resistor for "logic level
conversion".

I publish a "4049 abuser" used to pulse a high-efficiency LED at an
instantaneous current at which it is more efficient, with a low duty
cycle. The purpose is to light an LED to brightness useful for use
as an indicator lamp at 50 microamps, which is a low amount of current
where most LEDs do not work efficiently.

Look for the schematic in: http://members.misty.com/don/ledlocu.html

(I hope I got my "4049 abuser" schematic correct there!)
 
T

TTman

Jan 1, 1970
0
SNIP
In the interest of focusing input...
I'm NOT interested in a discussion of replacing the switch.
I'm NOT interested in a global system discussion that doesn't directly
solve this specific problem.
I'm NOT interested in discussing WHY. I'm interested in learning HOW.
If you're gonna tell me to google it, at least tell me the search terms
that you used to find the answer. Mine didn't.

Yes, there can be many issues. In this thread, I'm asking about
ONE of them.
I AM interested in ways to use a microcontroller to monitor a SPST
switch using as near zero energy as I can.

TIA, mike
Use the switch with pullups.... In sleep mode, turn off the pullups etc..Use
an external pullup of xMeg.
In sleep mode, with an Atmel Mega48 running internal 8MHz RC osc., I get
sleep current of <1 uA.@3V3
I don't worry about switch bounce as the wakeup is edge detected, but you
might have to , depending on the time between wakeup and sleep
again.(re-enabling switch edge detection)
Can't help you if it's PIC..... :)
 
M

Martin Brown

Jan 1, 1970
0
One option depending on how fast you have to respond to changing state
is to have the CPU wake up at a very modest clock rate and then if it
has to do real work switch to a faster clock. PICs provide a means to
vary RC based system clock speed with a little ingenuity.

Slugging the switch with a bit of RC or debouncing it switch with
discretes or a humble CMOS 555 might be another option.

You have to state your power budget and timing requirements before
meaningful answers are possible. A very tiny current drain can sometimes
increase battery life. Your idea of ultra low power may not coincide
with mine.

How many years does it need to run on say a pair of AAAs or a button cell?
How fast do you need to respond? How noisy is the environment? Are there
other considerations (how clean is it, how much current leakage when the
switch is 'open')? Does your processor have a really low-power 'sleep
with clock' mode?

Using a high pull-up resistor would reduce current, as would waking up
the processor periodically to sample the switch.

Debounce is an issue, but why not let the processor sleep while it's
waiting for the switch to debounce? Or just check the switch seldom
enough that the bounce will always settle out? Or assume that any
transition is "real", then wait out any bounce before you recognize more
transitions?

It is usually fair game to assume that a transition means the switch has
changed state and allow a dead time after the initial transition. This
is less costly if the CPU clock is relatively slow eg ~10kHz.

Regards,
Martin Brown
 
J

John - KD5YI

Jan 1, 1970
0
I want to monitor the state of a mechanical SPST switch.
I have access to both ends of the floating switch.

I have zero experience with low energy design and am
looking for clever ways to monitor hardware using extremely
low energy. I'm not sure exactly what terms are normally used, but
I think energy is the one I mean. At the end of the day,
the fewer electrons required by the system, the better.

I'm currently using a microcontroller in sleep mode
with wake on pin change. This has at least two problems.
The pullup resistor takes current when the switch is closed.
There's a tradeoff between current and noise immunity.
I can't put the processor back to sleep until the contacts
quit bouncing. A lot of wasted electrons go thru the processor
during that time.

A cap mitigates the bounce problem 'cuz I think I can temporarily
change the in to an out and slam it to the rail. I have not yet
counted the electrons required to do that tho...

A SPDT switch solves both problems, but that's NOT the question.
The switch is SPST.

IF I had a lot of switches, waking the processor and polling
is probably cheaper trading cpu current for pullup current.
I'd like to have options.
Yes, I'll have to make mix/match tradeoffs for a total system.
At this point I'm looking at options for only ONE part: the switch.

In the interest of focusing input...
I'm NOT interested in a discussion of replacing the switch.
I'm NOT interested in a global system discussion that doesn't directly
solve this specific problem.
I'm NOT interested in discussing WHY. I'm interested in learning HOW.
If you're gonna tell me to google it, at least tell me the search terms
that you used to find the answer. Mine didn't.

Yes, there can be many issues. In this thread, I'm asking about
ONE of them.
I AM interested in ways to use a microcontroller to monitor a SPST
switch using as near zero energy as I can.

TIA, mike


How about charging a small capacitor, say about 150 pF through a large
resistor, say 20M, while the switch is open. When the switch closes, it
dumps the cap into the port pin. As Tim said, don't allow the processor
to wake again for the switch bounce time, probably somewhere around 10
to 50 ms. Or, maybe it is possible to adjust your values such that the
cap discharges completely on the first bounce.

Just a thought.

Cheers,
John
 
J

John - KD5YI

Jan 1, 1970
0
How about charging a small capacitor, say about 150 pF through a large
resistor, say 20M, while the switch is open. When the switch closes, it
dumps the cap into the port pin. As Tim said, don't allow the processor
to wake again for the switch bounce time, probably somewhere around 10
to 50 ms. Or, maybe it is possible to adjust your values such that the
cap discharges completely on the first bounce.

Just a thought.

Cheers,
John

If the switch closes once per second, the average current drain would be
about .75 nA. I think that would make no difference to the battery life.

John
 
J

John - KD5YI

Jan 1, 1970
0
Or, maybe it is possible to adjust your values such that the
cap discharges completely on the first bounce.

Just a thought.


Arrrgh! I meant on the first contact before the first bounce.

John
 
M

mike

Jan 1, 1970
0
John said:
How about charging a small capacitor, say about 150 pF through a large
resistor, say 20M, while the switch is open. When the switch closes, it
dumps the cap into the port pin. As Tim said, don't allow the processor
to wake again for the switch bounce time, probably somewhere around 10
to 50 ms. Or, maybe it is possible to adjust your values such that the
cap discharges completely on the first bounce.

Just a thought.

Cheers,
John
Thanks for the input. I need just a little more detail. I haven't been able
to come up with any cap-related topology
that allows detecting BOTH transitions
of the switch without wasting current through the switch. If the switch
maintains current when it's closed, I might as well use a pullup.
If the switch current is zero, the circuit can't tell when it
opens. yes???

When the typical cpu sleep current is 100nA, a couple of microamps
per pin for pullups is a BIG percentage.
Once you give up and poll the switch, it becomes trivial, but costs cpu
energy.

I don't think a solution exists, but if we took that attitude, nothing
would ever be invented.

So, I'm here polling the greatest bunch of designers on the planet.
 
J

John - KD5YI

Jan 1, 1970
0
Thanks for the input. I need just a little more detail. I haven't been able
to come up with any cap-related topology
that allows detecting BOTH transitions


I missed that part. What I proposed will not detect both transitions either.

Sorry.
 
T

TTman

Jan 1, 1970
0
Thanks for the input. I need just a little more detail. I haven't been
able
to come up with any cap-related topology
that allows detecting BOTH transitions
of the switch without wasting current through the switch. If the switch
maintains current when it's closed, I might as well use a pullup.
If the switch current is zero, the circuit can't tell when it
opens. yes???

When the typical cpu sleep current is 100nA, a couple of microamps
per pin for pullups is a BIG percentage.
Once you give up and poll the switch, it becomes trivial, but costs cpu
energy.

I don't think a solution exists, but if we took that attitude, nothing
would ever be invented.

So, I'm here polling the greatest bunch of designers on the planet.

What processor are you using ??
 
D

Don Lancaster

Jan 1, 1970
0
As for a micropower clock oscillator: A 4049 stage with a resistor from
output to input and a capacitor from input to ground oscillates. Have the
output go through another stage of the 4049 to clean it up somewhat.

Nope.
Such a circuit cannot remotely compete with a conventional transistor
oscillator for ultra olw power.

--
Many thanks,

Don Lancaster voice phone: (928)428-4073
Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552
rss: http://www.tinaja.com/whtnu.xml email: [email protected]

Please visit my GURU's LAIR web site at http://www.tinaja.com
 
D

Don Klipstein

Jan 1, 1970
0
output go through another stage of the 4049 to clean it up somewhat.

Nope.
Such a circuit cannot remotely compete with a conventional transistor
oscillator for ultra olw power.

I have already achieved 5-6 microamp current consumption by a 4049 and
its associated components for an oscillator.

Also, I have tried my hand at 2-transistor "direct coupled oscillator"
for low power consumption. Maybe I did not try hard enough, but I did get
whatever I do giving me worse results for very low duty cycle and low
current draw when frequency gets up to around or over 100 Hz.

Or, is what you had in mind being the astable multivibrator? How good
is that at extreme duty cycle with current draw only a few microamps?
 
K

Kevin McMurtrie

Jan 1, 1970
0
mike said:
I want to monitor the state of a mechanical SPST switch.
I have access to both ends of the floating switch.

I have zero experience with low energy design and am
looking for clever ways to monitor hardware using extremely
low energy. I'm not sure exactly what terms are normally used, but
I think energy is the one I mean. At the end of the day,
the fewer electrons required by the system, the better.

I'm currently using a microcontroller in sleep mode
with wake on pin change. This has at least two problems.
The pullup resistor takes current when the switch is closed.
There's a tradeoff between current and noise immunity.
I can't put the processor back to sleep until the contacts
quit bouncing. A lot of wasted electrons go thru the processor
during that time.

A cap mitigates the bounce problem 'cuz I think I can temporarily
change the in to an out and slam it to the rail. I have not yet
counted the electrons required to do that tho...

A SPDT switch solves both problems, but that's NOT the question.
The switch is SPST.

IF I had a lot of switches, waking the processor and polling
is probably cheaper trading cpu current for pullup current.
I'd like to have options.
Yes, I'll have to make mix/match tradeoffs for a total system.
At this point I'm looking at options for only ONE part: the switch.

In the interest of focusing input...
I'm NOT interested in a discussion of replacing the switch.
I'm NOT interested in a global system discussion that doesn't directly
solve this specific problem.
I'm NOT interested in discussing WHY. I'm interested in learning HOW.
If you're gonna tell me to google it, at least tell me the search terms
that you used to find the answer. Mine didn't.

Yes, there can be many issues. In this thread, I'm asking about
ONE of them.
I AM interested in ways to use a microcontroller to monitor a SPST
switch using as near zero energy as I can.

TIA, mike

How fast does the response need to be? You only need to power the
pullup resistor just before checking the switch, and you probably don't
need to check the switch all the time. And why do you need to run the
processor during debounce? It seems like a very low power circuit
wouldn't be running fast enough to see bouncing.
 
M

Martin Brown

Jan 1, 1970
0
I have already achieved 5-6 microamp current consumption by a 4049 and
its associated components for an oscillator.

You can run an entire PIC 16877 with a 32kHz crystal and a direct drive
LCD display for around 10-12uA on 3v. Making it sleep about half the
time would get the average current consumption down to 5uA.

The OP hasn't answered the question of what battery and for how long
this is expected to run. There isn't a lot of point in making the
current draw so low that noise immunity suffers, or the battery shelf
life expires and it starts leaking due to corrosion before it runs down.

For instance 10uA from an AA cell with nominal 2000mAh capacity would
last for ~2x10^5 hours or around 20 years and button cells typically
around 200mAh will last a couple of years.

Regards,
Martin Brown
 
M

mike

Jan 1, 1970
0
Kevin said:
How fast does the response need to be? You only need to power the
pullup resistor just before checking the switch, and you probably don't
need to check the switch all the time. And why do you need to run the
processor during debounce?

Switch closes.
Processor runs at 4MHz for 100 instructions or so deciding which
interrupt happened and what to do.
Put processor to sleep.
How do I keep the interrupt from happening on the bounce?
If I wait, how do I tell when the wait interval is over without
running the CPU? Or at least some internal timer that I don't have.

It seems like a very low power circuit
wouldn't be running fast enough to see bouncing.

If you're gonna poll the switch or use a DPDT switch, the solution is
trivial. But to get the desired resolution, I'd have to wake up
the processor about 5000 times for each switch close.

Let's not go off on tangents. The switch isn't the only input.
The processor runs at 4MHz. to service the other interrupts.
Yes, with a sufficiently capable processor, one could use multiple
sleep modes and clock frequencies. That's for another thread.
The additional complexity isn't worth saving a couple of microamps
of pullup current.
This thread is about SPDT switches.
Like I said in the "in the interest of focusing the input" section...
I'm not interested in discussing WHY. I'm interested in HOW.
I think there is probably NOT a solution. Thought maybe someone
might have a clever solution.
Looks like that's not the case. Might as well close the thread and
move on.
 
T

TTman

Jan 1, 1970
0
Switch closes.
Processor runs at 4MHz for 100 instructions or so deciding which
interrupt happened and what to do.
Put processor to sleep.
How do I keep the interrupt from happening on the bounce?
If I wait, how do I tell when the wait interval is over without
running the CPU? Or at least some internal timer that I don't have.

It seems like a very low power circuit

Let's not go off on tangents. The switch isn't the only input.
The processor runs at 4MHz. to service the other interrupts.
Yes, with a sufficiently capable processor, one could use multiple
sleep modes and clock frequencies. That's for another thread.
The additional complexity isn't worth saving a couple of microamps
of pullup current.
This thread is about SPDT switches.
Like I said in the "in the interest of focusing the input" section...
I'm not interested in discussing WHY. I'm interested in HOW.
I think there is probably NOT a solution. Thought maybe someone
might have a clever solution.
Looks like that's not the case. Might as well close the thread and
move on.

There is a solution, you just don't want to seem to hear it...
Why not answer questions you have been asked like what CPU...
What's wrong with a capacitor to debounce the switch ?
 
M

mike

Jan 1, 1970
0
TTman said:
There is a solution, you just don't want to seem to hear it...
Why not answer questions you have been asked like what CPU...
OK, I'll play.
Currently, the system is a PIC16F877A at 3.58MHz.
Why? 'cuz that's what's on my prototyping board, I
need to do 4800 baud serial and I'm set up to
write code for it.
Could I use another processor??? SURE!
Can I use a different switch??? Not in this application.

I'm measuring the duration and period of the SPST switch
closure. Since I can't do timing if the uC is sleeping,
I just report the transitions and let the PDA worry about
the timing and logging and user interface.
Typical duration is 5 minutes. Typical period
is 85 minutes, but can be anything.

But, this is to be a general purpose interface that could
be used for anything connecting hardware to a computer.
I've described the FIRST application.

I decided, in a fit of boredom, to lose the wall-wart
and run it from the RS232 port. But the RS232 port hooks to
a battery-powered PDA. Might as well cut the current to as near
zero as possible. Maybe I'll want to run it off a vibration power
scavenger...I don't know...just try to learn something about low
power design...
I converted it from polled to interrupt driven, switched from
hardware to software uart and
put it to sleep between interrupts. It's 333 bytes. Should run on a
much lesser PIC.
At that point,
I realized that the internal pullup resistors were a SIGNIFICANT use of
current compared to the sleep mode that it's in almost 100% of the time.
A 1M external resistor still consumes 5uA while the switch is closed.

I couldn't come up with a more efficient way of sensing the switch, so
I came here to see if anyone else had an idea.

I've been looking at MSP430 and polling with multiple clock speeds. But
the gain
doesn't seem to justify the effort to build whole new development tools
and learning "C".
I started working on it, but I think the effort exceeds my attention span.

If the processor is asleep, they all seem to use about the same
power...WAY less than the pullup resistor for the switch. Since
the duty factor is small, the active power is almost irrelevant too
as long as I don't keep waking it up to poll the switch.
If I use a big enough battery, NOTHING matters.

My biggest concern is the pullup current for the switch.
I attempted to narrow the scope of the thread to address that issue.
What's wrong with a capacitor to debounce the switch ?

If you'd bothered to read the original post, you'd have seen
that I already stated that a cap mitigates the bounce problem.

And let me add that I can dispense with the whole uC and hook the switch
directly to the PDA serial port and it works fine. The uC was added
during another fit of boredom
to allow communication of the switch state thru a RS-232 to bluetooth
adapter and to add as yet unspecified functionality.
It's not possible to communicate all the reasons I might want to sense
a switch.

Now that you know what I'm doing, my question is still the same:
"is there a clever way to sense the state of a SPST switch at VERY LOW
energy consumption? I want to be able to apply the solution to this and
alternate
and future projects, independent of the processor and whatever other
changes YOU THINK I should make to my plan. I'm perfectly capable
of making tradeoffs. I'm asking for ADDITIONAL options to consider in this
tradeoff process.
I put a lot of effort in my original post to narrow the scope of the thread.
Capacitors and polling were tradeoffs I stated in the original posting.
I'm looking for NEW info that I didn't disclose in my original posting.

I'll say it for the third time...I don't think there is a solution.
But, since you claim to have one,
Tell me the solution that I don't want to hear...pleaseandthankyou
 
Top