WHAT IS A PULL-UP / PULL-DOWN RESISTOR

WHAT IS A PULL-UP / PULL-DOWN RESISTOR-Uncategorized

INTRODUCTION

When using a microcontroller or any other digital logic devices we encounter the concept of pull-up resistors. They ensure us to maintain the desired state of a logic circuit, whatever the conditions. Thus an a high impedance state when the pin is not set in the HIGH or LOW state, but instead float between those two states. A good example of this are Dasduino input pins. Try to command your Dasduino board a code which will in the Serial monitor write digital readout of a pin. The readings that you get should be LOW, or 0 (zero). However, if on the same pin an experimental board cable is connected and you simply touch it with your hand, you will notice that the situation is changing from LOW to HIGH and vice versa. To pin is said to float which is not acceptable, especially for such a precise microcontrollers.

Pull-up resistor on Dasduino Core board

 

PULL-UP VS PULL-DOWN RESISTOR

Pull-up and pull-down resistors are not a special type of resistor but simply a constant value connected via, mainly, + 5V and pin or GND and pins. Resistor between pin and + 5V is called pull-up resistor, while the one between the pin and GND is a pull-down resistor. The default value of this resistor is 4.7kΩ or 10K, but more about that later. When to use a pull-up and when a pull-down resistor, we will study in the example of push-up keys aka pushbuttons.

We will connect one push button on the pull-down resistor (pictured above left), and the other on the pull-up resistor (pictured above right). Resistance value can be 10K ohms supplied in CSP set. We will write a code that will print status of pushbuttons on the serial monitor. To write code, you can use the example of the Arduino IDE under File – Examples – Digital – Button. Alternatively, you can use the code below. It is connected via a pull-down resistor to give us the state of CA 0 (LOW) when it is inactive, or 1 (HIGH) when activated. The opposite will be readings on pin 6 which is connected via a pull-up resistor. Now we are sure that the push button will not be activated “by itself”.

const int button1 = 7;  
const int button2 = 6;   
void setup() {
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  
  Serial.begin(9600);
}
void loop() {
  Serial.print("State of button 1: ");
  Serial.println(digitalRead(button1);
  Serial.print("State of button 2: ");
  Serial.println(digitalRead(button2);
  
}

 

CALCULATING THE VALUE OF THE RESISTOR

The value of the resistor depends on two factors. First is consumption, waste of energy. If the value of the resistor is too low HIGH (+ 5V in the example above), the voltage will go through a pull-up resistor and unnecessarily waste energy when the circuit is closed. The energy will be spent on heating. This condition is called a strong pull-up and should be avoided when your circuit doesn’t not need much power. Another factor is the voltage when the circuit is open, ie. pressed. If the value of the resistor is too large, the input voltage may be too small for microcontroller to register as a change. This situation is called a weak pull-up. Croduino digitally register voltage of 3V or more as HIGH, everything else is LOW .
Usual assay is that we use resistors which are at least 10 times less than the resistance of the input pins. For Croduino, of course, and all other Arduino chips, which use 5V voltage, typical resistor value is 1-10kΩ. Recommended values for sensors are ​​1-5kΩ, and good value for start is 4.7kΩ. Use Ohm’s law, if you want to calculate the exact value of a pull-up resistor for a particular module.

THE INTERNAL PULL-UP RESISTORS

Atmega328 chip, which are located on Dasduino Core have integrated 20kΩ pull-up resistors. If you use an Arduino board with some other microcontroller, the value of an integrated pull-up resistors can be found at this link. We invite you in defining the pin using INPUT_PULLUP.

pinMode(pin, INPUT_PULLUP);