View previous topic :: View next topic |
Author |
Message |
buckeyes1997 Guest
|
internal pull-ups.....when are they used? |
Posted: Tue Nov 23, 2004 9:34 am |
|
|
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? |
Posted: Tue Nov 23, 2004 9:53 am |
|
|
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
|
|
Posted: Tue Nov 23, 2004 10:37 am |
|
|
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... |
Posted: Tue Nov 23, 2004 6:37 pm |
|
|
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
|
|
Posted: Tue Nov 23, 2004 7:06 pm |
|
|
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
|
|
Posted: Wed Nov 24, 2004 1:10 am |
|
|
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
|
|
Posted: Wed Nov 24, 2004 2:28 am |
|
|
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
|
|
Posted: Wed Nov 24, 2004 7:07 am |
|
|
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.
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 |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Wed Nov 24, 2004 8:59 am |
|
|
Quote: | This guy is a newbie. Don't try and blow his mind with the technical aspects. |
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
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
|
|
Posted: Wed Nov 24, 2004 9:10 am |
|
|
Quote: | Mark is both right and wrong |
Mark is always right 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 |
|
|
|