Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

What is the function of the resistor R13 in this circuit?

schematic

share|improve this question
2  
This is know as a pullup resistor. I go into a lot more details about pullup resistors here: electronics.stackexchange.com/a/23647/4512 –  Olin Lathrop Mar 5 at 14:34
1  
If the resistor wasn't there, the line would be floating (voltage determined by chip internals, EMI, and many other factors. Can be just about anything, including <0V and >VCC) when the switch was open, and grounded (or 0V) when the switch was closed. The pullup resistor is added so that the line will be VCC when the switch is open, and still be grounded when the switch is closed. –  Ross Aiken Mar 5 at 16:07
1  
Also, and of uttermost importance in my opinion, if the resistor wasn't there, and you closed SW1, you would create a short circuit, with far more nasty consequences than these zeroes-and-ones-confused-digital-state issues. –  NothingsImpossible Mar 6 at 2:54
    
NothingsImpossible: Absent the resistor, there would not be a short circuit. You must be visualizing replacing the resistor with a wire (ie: R = 0). –  gwideman Mar 20 at 7:08
    
All the "this looks like a pullup resistor" answers and explanations are relevant. However, thinking this through, switch SW1 is probably intended to perform the "clear" function, which would use the /MCLR/Vpp pin in /MCLR mode. When in that mode, the PIC specs say that pin 1 already has a pullup resistor internally. So on the face of it, R13 is unnecessary. One might then ask "why is it there, despite PIC already having an internal pullup?" –  gwideman Mar 20 at 7:12

6 Answers 6

This is a pull up resistor. When the switch is open, the resistor sets the MCLR pin at VCC.

Without the resistor the pin would be left floating. The MCLR input is a logic input. Which can be 0 or 1. But in the real world, there is no such things as 0 or 1.

A convention could be defined:

  • if the voltage is below Vcc/2 it is considered as a 0.
  • If the voltage is above Vcc/2 it is considered as a 1.

A problem with this approach arise when the input voltage crosses the threshold. At some point in time, it is at the threshold. And if there is some noise on the signal, the pin could see a 0 or a 1 bouncing very quickly. Imagine that the input is a clock signal and you would see clock edges where you don't want to.

The following approach solves that problem:

There is are two thresholds: Namely Vih and Vil. A signal is considered as 0 if it is below Vil and a 1 if above Vih. The two threshold are separated by a grey zone that prevent toggling by added noise (up to a certain level).

The following figure found on the web explains that feature:

Vih Vil

The resistor in you schematics is here to make sure that, when the button in not pressed, the voltage at MCLR is above Vih (not in the forbidden region).

But, as @Spehro Pefhany expains in his answer, this is not enough.

A press button is not prefect. When you release it, you may (and you will, actually) see bounces.

This picture, also found on the web shows this:

enter image description here

A way to overcome this issue is to "smooth" the output signal using a capacitor as shown in the datasheet of the micro controller. The capacitor would be quickly discharged through the low impedance path of the pressed button, but would take some time to charge though the resistor when the button is open due to bounces. If you choose the right resistor-capacitor pair, you could make sure that it would take longer to the MCLR voltage to cross the Vil that it take to the button to stop bouncing.

share|improve this answer

This resistor is known as pull up resistor. It is connected to the first pin of PIC for resetting. When this pin is grounded or active low PIC get reset. So for making IC in working mode, this pin is pulled up through this resistor.A switch is used to ground the pin to reset the program.

share|improve this answer

From the PIC16F877 datasheet:

enter image description here

In this case, the switch takes the place of the capacitor, to cause a reset whenever the switch is pressed (as opposed to only when the power is applied and the capacitor voltage is presumed to be about zero).

The upper limit to the value is the recommended 40K ohms (relatively high values will increase noise sensitivity as well). The lower limit is set by how much current you want to draw out of the power supply when the switch is pressed. A few K to 15 or 20K is a reasonable range for most purposes.

Note that when there is a capacitor, there should also be a series resistor, according to Microchip, of something like 1K or 2K. It's not a bad idea to put it in there even with no capacitor (only a switch) because of possible ESD transmitted through the switch actuator.

share|improve this answer

There are several answers explaining how a pullup resistor works, so I won't go into that. Instead I'll try to explain why it is there.

Pullup resistors are used when an input on a microcontroller needs to be controlled by several sources. For example, in your case, SW1 can be pressed to reset the microcontroller by bringing its !MCLR/VPP line low. What you don't show in your schematic is the programming interface from your programmer (e.g. ICD 3) which also needs to reset the microcontroller by bringing its !MCLR/VPP line low.

If MCLR was active high instead of low, then it would be possible for two inputs to be driving it at the same time, with slightly different voltages (for example, VCC from the switch and VPP from the programmer interface), and you could end up with all sorts of problems (especially if one input was at VCC and another at ground, creating a direct short.

Instead the devices driving the !MCLR line are configured as open-drain (or in the case of the switch, having it be an open-circuit until it is closed). Open-drain outputs can be driven low, but cannot be driven high (the default high state is tri-stated, meaning it doesn't drive the line to VCC -- instead it looks like an input). So any number of devices can be connected to an active-low line like this, and if more than one are driven low (ground), there are no problems .

However since none of these inputs are configured to drive the input high, the pull-up resistor provides the default high level (VCC), and it brought down to ground when any of the inputs go to ground.

share|improve this answer

Diagram is rather small; but that's a "pullup". It brings ~MCLR up to logic 1, except when the button is pressed. Replacing it with a wire would short out the circuit when the button was pressed.

share|improve this answer

The resistor is there to limit the current going into that pin... when the switch is open. You can reduce the resistance depending on current requirement for the ic.

When the switch is closed, the resistor is there to prevent Vcc from shorting to ground.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.