CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Is possible do this logic?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
BotBoy



Joined: 06 Nov 2009
Posts: 6

View user's profile Send private message

Is possible do this logic?
PostPosted: Tue Apr 06, 2010 10:47 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 06, 2010 10:59 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 06, 2010 11:01 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 06, 2010 11:23 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 06, 2010 1:14 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group