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

internal pull-ups.....when are they used?

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







internal pull-ups.....when are they used?
PostPosted: Tue Nov 23, 2004 9:34 am     Reply with quote

hello again guys
thanks again for being so helpful. without this forum things would be much more difficult.

anyway my question is if there is a definative time to use pullups and when not to use them? what do they enable you to do or do better?

thanks
matt
Ttelmah
Guest







Re: internal pull-ups.....when are they used?
PostPosted: Tue Nov 23, 2004 9:53 am     Reply with quote

buckeyes1997 wrote:
hello again guys
thanks again for being so helpful. without this forum things would be much more difficult.

anyway my question is if there is a definative time to use pullups and when not to use them? what do they enable you to do or do better?

thanks
matt

Every pin, should always be 'driven' in some way or other. When used as an output, the chip provides this, but when used as a input, the external circuit normally has to do this. If you are connecting to something like a switch, where the pin will be driven low if the switch is closed, but 'floating' (undriven), when the switch is open, it becomes necessary to provide something like a resistor, to avoid this 'undriven' state. On PortB, there are a set of (effectively) internal resistors that can be enabled in software. Hence these are ideal if the inputs are going to be used to scan a keyboard, avoiding the need to provide seperate pull-up resistors on the lines. You don't want the pull-ups enabled, if the signal is being driven by another source, since this just results in wasted power.

Best Wishes
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Nov 23, 2004 10:37 am     Reply with quote

Quote:
Every pin, should always be 'driven' in some way or other. When used as an output, the chip provides this,

There is a gotcha on pin RA4 on most pics. It's open collector so it can't drive high. Depending on what you connect to it, you might need some sort of pullup.
buckeyes1997
Guest







okay so about this...
PostPosted: Tue Nov 23, 2004 6:37 pm     Reply with quote

okay so if i want to source from the pic on port b to output a simple waveform toggle i MUST have the internal pull ups enabled or provide pull ups externally??
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Nov 23, 2004 7:06 pm     Reply with quote

Quote:
okay so if i want to source from the pic on port b to output a simple waveform toggle i MUST have the internal pull ups enabled or provide pull ups externally??


No. If you are driving the output both high and low then you do not need a pull up. Generally you would use a pull-up for an input for a switch or on a shared bus.

For example, the easiest way to connect a switch to port B is to connect on end of the switch to Ground (0 volts) and the other to the input pin and enable the pull-ups on port B. When the switch is in the open state the PIC sees a +5V input via the pull up resistor. When the switch is pressed the PIC sees 0V through the switch. The pull-up can be either internal to the PIC or an external resistor. Without the pull-up resistor the PIC would not be able to detect when the switch is open circuit (actually not strictly true but true enough).

Here's a quick TRUE or FALSE quiz: A PIC port configured as an output can be used to read the state of a switch.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
buckeyes
Guest







PostPosted: Wed Nov 24, 2004 1:10 am     Reply with quote

im going to say no. if the port is set as an output and you are adding no additional hardware nor taking it into any other pins then i dont see how you could read anything from the switch.

am i correct??
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Nov 24, 2004 2:28 am     Reply with quote

Quote:
am i correct??


No. What happens is you end up reading the output port pin. If the output is pulled hard high or low externally then that is what you will read back. It is not a good idea because the PIC will be driving into a short circuit. The typical PIC can supply 25mA to a pin under these conditions.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Nov 24, 2004 7:07 am     Reply with quote

Quote:

Here's a quick TRUE or FALSE quiz: A PIC port configured as an output can be used to read the state of a switch.


The answer is FALSE.

Quote:
am i correct??

Yes

asmallri:
This guy is a newbie. Don't try and blow his mind with the technical aspects. The reason I answered FALSE is because if I have the output set low and a 1K pullup and a switch connected, I ain't never going to see that thing go high Very Happy
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Nov 24, 2004 8:59 am     Reply with quote

Quote:
This guy is a newbie. Don't try and blow his mind with the technical aspects.


Twisted Evil

Quote:

The reason I answered FALSE is because if I have the output set low and a 1K pullup and a switch connected, I ain't never going to see that thing go high.


Mark is both right and wrong - hence the quiz Very Happy

This stunt will enable hard pull-ups, hard pull downs and open circuit to be detected - more versatile than a normal input but consumes a lot of current and can only be used on devices that have inbuilt output short circuit detection. A small value series resistor can be used to limit the current. This mechanism allows a PIC to measure all positions of a three position switch using only a single I/O pin.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Nov 24, 2004 9:10 am     Reply with quote

Quote:
Mark is both right and wrong


Mark is always right Very Happy Hence if you read my reason:
Quote:
The reason I answered FALSE is because if I have the output set low and a 1K pullup and a switch connected, I ain't never going to see that thing go high.

Then you cannot dispute the fact. I didn't say what you said was techinically wrong. Sure it will work but in my opinion is a bad design idea and there are very few people out there that would do such a thing. Your statement only adds to this guy's confusion. If you really want to detect all three positions, use an analog input Razz
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