View previous topic :: View next topic |
Author |
Message |
gaugeguy
Joined: 05 Apr 2011 Posts: 303
|
|
Posted: Fri Aug 01, 2014 6:28 am |
|
|
When you "turn off power" your pull-up resistor becomes a pull-down resistor.
What else may happen depends on what the rest of your circuit looks like and how everything is powered. |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Fri Aug 01, 2014 6:36 am |
|
|
simple RF suppression:
pull-up resistor =10k ohm
parallel capacitor = 10nF
capacitor is placed across the switch terminals |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Aug 01, 2014 2:05 pm |
|
|
Sterngleiter wrote: | it's just like having drawn alan. |
I don't think so. In your previous post, you said this:
Sterngleiter wrote: | It's pulled low. |
Then your code below, waits for the pin to go high (when the button is
pressed), and then counts up 'test' while the pin is high:
Code: | while(true)
{
if(input(pin_a1)==1)
{
while(input(pin_a1)==1);
++test;
}
} |
So I strongly suspect that it's really connected like this:
Code: |
Switch +5v
___ |
To _|_|_ |
PIC --------o--------o o-------o
pin |
<
> 4.7K
<
|
--- GND
-
|
If this is not an accurate description of your circuit, then post a schematic
that shows exactly what you have. Show all component values. |
|
|
Sterngleiter
Joined: 07 Jan 2013 Posts: 90
|
|
Posted: Tue Aug 05, 2014 11:34 am |
|
|
Hi, Thank You for so many tips. I thought software debouncing would be enough but unfortunately I have to debounce Hardware |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Tue Aug 05, 2014 3:27 pm |
|
|
Software debouncing is usually sufficient.
The problem all along has been you have adamantly refused to give us enough information to work on.
You say problem is now solved, that's good, but I still can't work out what the real problem was, hence my opt-out earlier.
Mike |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Tue Aug 05, 2014 5:17 pm |
|
|
magic......
it would be nice to see the schematic and code for your solution
it'll help others in the future as it's a common problem...
jay |
|
|
joergn
Joined: 15 Jul 2010 Posts: 15 Location: Hamburg Germany
|
|
Posted: Fri Aug 08, 2014 3:11 am |
|
|
Code: | while(true)
{
if(input(pin_a1)==1)
{
while(input(pin_a1)==1);
}
++test; // should count only when button is released or changed
} |
Polling should not eat up all MCU power , so put it inside a timer
loop. |
|
|
|