View previous topic :: View next topic |
Author |
Message |
BotBoy
Joined: 06 Nov 2009 Posts: 6
|
Is possible do this logic? |
Posted: Tue Apr 06, 2010 10:47 am |
|
|
Hi...
An input can be the level 1 if is powered level 0 if is grounded.
Most the time I always do this logic of the input using 1 or 0.
Is possible have a 3rd input state?
Suppose I need only grounding some input pin (level 0) ,
how is possible verify when the pin not is grounded if never i will have a level 1
on this pin.
is possible do this logic?
if PIN is grounding
do something
if PIN not is grounding and dont have high level as input
do something
regards
lucasi |
|
|
jbmiller
Joined: 07 Oct 2006 Posts: 73 Location: Greensville,Ontario
|
|
Posted: Tue Apr 06, 2010 10:59 am |
|
|
There are at least two ways to accomplish this.
First, easy, use an ADC or Comparator input pin.
Second, a little harder, is to sample the Input pin to check for the 'high-float' condition, 'tristate'...which is a trademark btw)
If you use Google, there will be tons of applications of this 'old school' technique to get more information with less pins.
hth
Jay |
|
|
dezso
Joined: 04 Mar 2010 Posts: 102
|
|
Posted: Tue Apr 06, 2010 11:01 am |
|
|
Yes.
I have done similar to check if the remote switch is connected or not.
Turn on the PWM if you pic has one, or just create a 1KHz osc from a 555,
feed the PWM or ext_osc output on a 1K resistor back to your input pin, probe your pin for 500ms to see if you have a pulsing cycles or steady low or high.
There is your 3 state.
1:low
2:high
3:pulsing |
|
|
languer
Joined: 09 Jan 2004 Posts: 144 Location: USA
|
|
Posted: Tue Apr 06, 2010 11:23 am |
|
|
To clarify, you want to determine if:
- Pin is high,
- Pin is low,
- Or Pin is neither high or low - it's tri-stated (or not connected)
If this is the case look at Microchip's Tips'n Tricks 8-pin FLASH PIC Microcontrollers. In particular you're looking for TIP #3 Read Three States From One Pin.
If all you want to do is determine if:
- Pin is low,
- Or Pin is neither high or low - it's tri-stated (or not connected)
Then weakly pull-up the pin and test for HIGH or LOW. |
|
|
BotBoy
Joined: 06 Nov 2009 Posts: 6
|
|
Posted: Tue Apr 06, 2010 1:14 pm |
|
|
Quote: | If all you want to do is determine if:
* Pin is low,
* Or Pin is neither high or low - it's tri-stated (or not connected) |
Exactly it !...
I read the doc and implemented... works fine...
Thank you guys!
BotBoy |
|
|
|