testing for high condition trick, stupid?

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

NOTE: for reference I'm working with a mega8 ( 328)

This seems to work very well for me, but I have great concern that its not going to work in all cases. I know the best way to do this is with a external pull down but I'm interested in gathering thoughts on this.

I have found in the past I can send out low, and quickly change the ddr to in like so.

DDRC=0xff;
PORTC=0;
DDRC=0;

Doing this will allow me to detect a high condition on my pin without any interference.

For example doing this

PORTC=0;
DDRC=0;

Just is not good enough. If I run my finger over the pins I pick up the high impedance from my finger. When using the first example I do not have that issue and can easy detect my pin going high. I'm detecting a very low impedance condition ( guessing I would not have as much luck with a higher impedance ).

Now the board I use is the same in every device I make, the wire length changes little ( maybe 5-10 inches ) and I'm in Florida so I do have higher humidity. Would this simply be a bad or stupid practice?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You need to terminate all input pins in some manner, floating inputs won't have a defined state and are sensitive to interference as you have seen. You can use external pulldowns, external pullups, or internal pullups (which are weak).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

May take a look onto:
http://easyelectronics.ru/avr-uc...
Translates a bit funny, but comics and diagrams are very illustrative, think one can manage with that.