electrical design basics, 101: button, switch?
Archiver
Posts: 46,084
Is it possible to use a single pole single throw slide switch to make a stamp
pin either hi or lo without wasting a lot of electricity? I'm trying to figure
out how to use hardware to set a variable in code to either a "1" or a "0".
ie: PIN 01 --->switch---->10K resistor--->ground
does the resistor prevent free drain of juice from the battery yet still allow
the stamp to tell whether the switch is "on" or "off"??
pin either hi or lo without wasting a lot of electricity? I'm trying to figure
out how to use hardware to set a variable in code to either a "1" or a "0".
ie: PIN 01 --->switch---->10K resistor--->ground
does the resistor prevent free drain of juice from the battery yet still allow
the stamp to tell whether the switch is "on" or "off"??
Comments
|
10K
|
GRD -- SW
To Stamp Input
When SW is open the Stamp sees +5 VDC through the 10K. When SW is closed,
the Stamp sees ground.
The 10K may be anything. I would suggest in the range of 1K to 100K.
When the SW is open the drain is limited to the leakage into the Stamp (on
the order of uA). When closed to ground it is 5V / R or 0.5 mA if using a
10K resistor.
Peter H. Anderson, Morgan State University
pha@p..., http://www.phanderson.com/stamp/
Original Message
From: A.Ron Carmichael <arc@i...>
To: basicstamps@egroups.com <basicstamps@egroups.com>
Date: Saturday, April 29, 2000 10:29 AM
Subject: [noparse][[/noparse]basicstamps] electrical design basics, 101: button, switch?
:Is it possible to use a single pole single throw slide switch to make a
stamp
[noparse]:p[/noparse]in either hi or lo without wasting a lot of electricity? I'm trying to
figure
[noparse]:o[/noparse]ut how to use hardware to set a variable in code to either a "1" or a "0".
[noparse]:ie:[/noparse] PIN 01 --->switch---->10K resistor--->ground
:does the resistor prevent free drain of juice from the battery yet still
allow
:the stamp to tell whether the switch is "on" or "off"??
:
:
:
:
>Is it possible to use a single pole single throw slide switch to make a stamp
>pin either hi or lo without wasting a lot of electricity? I'm trying to
>figure
>out how to use hardware to set a variable in code to either a "1" or a "0".
>ie: PIN 01 --->switch---->10K resistor--->ground
>does the resistor prevent free drain of juice from the battery yet still allow
>the stamp to tell whether the switch is "on" or "off"??
Yes - you can but it takes a second pin. This pin can be any other pin
used somewhere else in your circuit.
One of my projects does exactly this. I have a pin that is used to drive
another part of the circuit and I don't care what the state of that pin is
when the circuit is sleeping. I take a 10k resistor from that pin to the
switch I want to look at, then another 10k resistor from the switch to the
input pin on the PIC. The other side of the switch is grounded. To read
the switch, I wait until the software has driven the output pin is HI, wait
a short time, then read the input pin to see if the switch is HI or LO. I
save that state in memory. When its time to put the whole project to
sleep, I simply make the output pin HI or LO to match the state of the last
measured switch state. Bingo - no current drain from the resistor.
Because I use the 'wake up on change' feature on the PIC, the pic wakes up
as soon as the switch is changed.
dwayne
Dwayne Reid <dwayner@p...>
Trinity Electronics Systems Ltd Edmonton, AB, CANADA
(780) 489-3199 voice (780) 487-6397 fax
Celebrating 16 years of Engineering Innovation (1984 - 2000)
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.
"Peter H. Anderson" wrote:
> +5 VDC
> |
> 10K
> |
> GRD -- SW
To Stamp Input
>
> When SW is open the Stamp sees +5 VDC through the 10K. When SW is closed,
> the Stamp sees ground.
>
> The 10K may be anything. I would suggest in the range of 1K to 100K.
>
> When the SW is open the drain is limited to the leakage into the Stamp (on
> the order of uA). When closed to ground it is 5V / R or 0.5 mA if using a
> 10K resistor.
--
ARC in Lago Vista, TX
See you next week a little further up the creek. - Early Alaskan goldminers
parting words after meeting.
my
head [noparse]:)[/noparse] If it works as I think it does, it's darn clever. (I'm studying it)
What is the "PIC" ? I'm guessing that it is another name for the the basic
stamp
assembly, so that the "input pin on the PIC" for example, would on my system, be
one of my two existing button switch pins (say, Pin 01). The "output pin that
is
driven to HI by software" in your message would be the other pin that the new
slide
switch is attached to (say Pin 05), that I would define as an output pin?
If I understand your message/setup, when the button switch is pushed, you know
it(Pin 01) has just gone high. The software then checks the state of Pin 05,
and
if the slide switch was in the on position then pin 05 goes high also. I'd then
set
my variable = "1". If pin 05 doesn't go high, then set variable = "2".
I don't think I've quite gotten it right, for some reason. Am I even close?
Dwayne Reid wrote:
> Yes - you can but it takes a second pin. This pin can be any other pin
> used somewhere else in your circuit.
>
> One of my projects does exactly this. I have a pin that is used to drive
> another part of the circuit and I don't care what the state of that pin is
> when the circuit is sleeping. I take a 10k resistor from that pin to the
> switch I want to look at, then another 10k resistor from the switch to the
> input pin on the PIC. The other side of the switch is grounded. To read
> the switch, I wait until the software has driven the output pin is HI, wait
> a short time, then read the input pin to see if the switch is HI or LO. I
> save that state in memory. When its time to put the whole project to
> sleep, I simply make the output pin HI or LO to match the state of the last
> measured switch state. Bingo - no current drain from the resistor.
>
> Because I use the 'wake up on change' feature on the PIC, the pic wakes up
> as soon as the switch is changed.
>
> dwayne
>
> Dwayne Reid <dwayner@p...>
> Trinity Electronics Systems Ltd Edmonton, AB, CANADA
> (780) 489-3199 voice (780) 487-6397 fax
>
> Celebrating 16 years of Engineering Innovation (1984 - 2000)
>
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> Do NOT send unsolicited commercial email to this email address.
> This message neither grants consent to receive unsolicited
> commercial email nor is intended to solicit commercial email.
--
ARC in Lago Vista, TX
"Let's face the obvious. Yesterday we were nerds. Today we're the cognitive
elite.
Let's conquer." - Chester G. Edwards
>Dwayne - that sound you hear is that of most of your method shooting right
>over my
>head [noparse]:)[/noparse] If it works as I think it does, it's darn clever. (I'm studying it)
Sorry. I thought that you were asking for a zero power method of reading a
SPST slide switch. If that is not what you need, the method that Peter
Anderson is easier and better. But: I would add a series resistor between
the switch and the input pin. In other words, there are 2 resistors going
to the switch - one is the pullup and the other is the ESD protect resistor
actually feeding the input.
>What is the "PIC" ? I'm guessing that it is another name for the the
>basic stamp
>assembly, so that the "input pin on the PIC" for example, would on my
>system, be
>one of my two existing button switch pins (say, Pin 01). The "output pin
>that is
>driven to HI by software" in your message would be the other pin that the
>new slide
>switch is attached to (say Pin 05), that I would define as an output pin?
Yep - the PIC is the actual processor on the stamp module. Its what I do
all my designs with (I've helped others troubleshoot stamp based designs
but don't use them myself. Just too expensive.).
You have it close. Usually, the output pin is being used to drive some
other portion of the circuit. When I set that pin HI (as required for THAT
part of the code / circuit), I know that a short time later, I can read the
switch. In other words, I can't read the switch until I know that the
output pin with the resistor is HI.
The advantage of this is that I can turn off the output pin when I want to
power down. Then the pullup resistor does not consume any power. In my
case, I set that output pin to match the state of the switch so that the
resistor does not have any voltage across it - the pin might be HI or
LO. Then, if the switch is changed while the processor is sleeping, the
change in state wakes the processor.
dwayne
Dwayne Reid <dwayner@p...>
Trinity Electronics Systems Ltd Edmonton, AB, CANADA
(780) 489-3199 voice (780) 487-6397 fax
Celebrating 16 years of Engineering Innovation (1984 - 2000)
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.
switches. All my pins except pos, tied via a 10K resistor to ground. One
side of the pushbutton goes to a pin, (7 switches, to pin 0 thru pin 6) the
other side goes to the pos. Pushing a switch makes the pin a 1, releasing
the switch makes the pin a 0. My code uses "if pin1 =0 and.... thru pin6 =0
then loop" Thus it sits in a loop until a switch is pushed. However with
many "if and" statements I determing what switches have to be pushed "in
order", to make something occur on pin 7. Thus the right combination must
be used to make a happening on pin 7. Even with only a 4 combination of
switches many people have tried and not hit the right combo. I also did one
with 6 different numbers in order to activate pin 7. Lotsa fun....... ==Mac==
At 09:26 AM 4/29/00 -0500, you wrote:
>Is it possible to use a single pole single throw slide switch to make a stamp
>pin either hi or lo without wasting a lot of electricity? I'm trying to
figure
>out how to use hardware to set a variable in code to either a "1" or a "0".
>ie: PIN 01 --->switch---->10K resistor--->ground
>does the resistor prevent free drain of juice from the battery yet still
allow
>the stamp to tell whether the switch is "on" or "off"??
>
>
>
>