> Would somebody be so kind as to explain to me why you would need a > pull-up, or > pull-down resistor? > > I'm assuming the pull-up or pull-down would connect +v or 0v to the pin in > question to ensure that the pin 'defaults' to +v or 0v? But would this > junction then be connected to the collector of a transistor? How would > the > transistor pull a pin low if it has a pull-up resistor? > > Actually, I read something in one of the microchip documents last night > about > some of the IO ports having a selectable "weak pull-up resistor". I guess > this is somehow related, but I suspect not enough to pull up my 1.5v to > 5v. Outputs of PICs, opamps, comparators etc are used to "drive" output loads. some loads are ground referenced and some supply referenced - ie the other end is connected to ground or supply. (Some loads are referenced to an intermediate point but lets not get too fancy here). Many devices can drive their outputs just as easily high (Vcc / Vdd) or low (ground / Vss). A typical PIC output pin would be an example of this. BUT some outputs, by design, can eg drive or pull low but not high or vice versa. There are a number of good reasons (and some bad ones) for designing outputs to work this way. Such outputs are referred to as "open collector" because they are effectively the same as a transistor with no load resistor. If an NPN transistor with emitter to ground and collector connected to nothing is turned on, the collector will be clamped to ground. A load referenced to eg 5 volts would sink current into the transistor collector. BUT if the transistor is turned off its collector will 'float". There is nothing to make it go high when the transistor is off. If a resistor is now placed between collector and eg +5v then when the transistor is off the resistor will "pull the collector up" to 5 volts, This is a "pullup resistor". Similarly a PNP transistor with its emitter at +5v would have a pull down resistor from collector to ground to pull the collector low when the transistor is off. A disadvantage of an open collector output is that the pullup resistor is not as flexible or capable as having an active device in its place. eg when the resistor is a high value it does not provide much pullup current so can only drive a small load high. When it is a low value it will dissipate significant power when the transistor is turned on. The time to pull high depends on the time constant of the resistor and any capacitance at the collector and this may be slow and the pull up waveform will be an exponential curve as the capacitance charges. Despite this open collector circuits have some significant uses. These include combining multiple outputs together and driving loads which only require to be driven in one direction. ie the load acts as its own pullup resistor. (An example is a ULN2803 driver IC which drives high referenced loads) Another use of pullups or pulldowns is to pull a high impedance input to a defined voltage level when it would otherwise "float" at an undefined voltage. *ALL* PIC digital input pins must ALWAYS have defined voltage applied - either by being driven by an output of some sort OR by having a pullup to high or low. Digital inputs that are allowed to "float" can cause the IC to draw large currents if they float at about half supply (or near the transition point for ICs that are not symmetrical about high and low). Floating inputs can and do cause many strange and unpredictable problems. Sometimes an IC may be somewhat weaker than desired at driving high or low. In such cases a pullup or pulldown resistor can be added to help provide more current in the desired direction. This has the effect of making the IC work harder in the opposite direction but this is often a worthwhile compromise. eg getting an LM324 quad opamp (or LM358 dual version) to drive really close to ground is helped by an output pulldown resistor. Some ICs are open collector and must have a pullup or equivalent on the output. Look at the datasheet for the LM339 quad comparator (or LM393 dual version) as an example. This is probably about the cheapest IC in the world, and one of the oldest, but still useful and used in quantity. OK? :-) Russell McMahon _______________________________________________ http://www.piclist.com View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist