Electrical Characteristics of Digital Inputs

Created:  
Updated:   06Aug2024   05:16:16   UTC 2024-08-06T05:16:16Z
Rating:   (0 reviewsThis article has not been rated yet)

The electrical characteristics of digital inputs into the GPIOGeneral Purpose Input Output of a microcontroller board or Single Board Computer (SBCSingle Board Computer) includes digital voltage thresholds, leakage current, pull resistors, and maximum voltage and current levels. Each of these electrical characteristics will be covered in this article.


Digital signals represent data as a discrete sequence of voltages over time in contrast to analog signals that have continuous values over time. Binary or logic digital signals have two voltage values: one near the reference voltage (ground or zero volts) and the other at the supply voltage. The ground voltage is represented by binary digit bit 0 and the supply voltage is represented by the binary digit bit 1. This is illustrated in the figure below.

Digital Binary Logic Signal

Most modern GPIOGeneral Purpose Input Output pins on a microcontroller or SBCSingle Board Computer are implemented as a tri-state buffer, where the pin can have three different values:

  1. Logical Low (0) connected to ground
  2. Logical High (1) connected to the positive voltage supply VCCVoltage Collector Collector (VCC) is the supply voltage at the collector of a transistor. The double subscript notation of repeating letters "CC" is used to denote a power supply voltage that is relative to ground.
  3. High Impedance (also referred to as "floating" or "Hi-Z")

In order for the digital signal to be read as a digital low (0) or high (1), the voltage levels need to be within a specified range and solidly connected to ground or VCCVoltage Collector Collector (VCC) is the supply voltage at the collector of a transistor. The double subscript notation of repeating letters "CC" is used to denote a power supply voltage that is relative to ground. with pull resistors; otherwise the input line is put into a high impedance configuration where it is disconnected from the circuit and its low/high logic state is indeterminate. The input voltage and current levels must also be within the maximum specification values to avoid damaging the device. These electrical characteristics will be explained in more detail throughout this article.

Digital Voltage Level Thresholds

For most MCUMicrocontroller Units and SBCSingle Board Computers, the voltage thresholds for logic low (0) and high (1) digital bits are usually found in the datasheet as:

VIH:
lowest input voltage for logic high (1)
VIL:
highest input voltage for logic low (0)
Logic Voltage Thresholds
Digital Signal Logic Voltage Thresholds

The voltage thresholds vary for different MCU and SBC devices as shown in the table below.

Logic Voltage Thresholds for Different Devices
Device VIH (Min) VIL (Max) Reference
ATmega328P in
Arduino Uno and Nano
0.6VCC, 3V
@ VCC = 5V
0.3VCC, 1.5V
@ VCC = 5V
ATmega328P Datasheet
(Section 28.2 Electrical Characteristics)
RP2040 in RPi Pico 2V @ VCC = 3.3V 0.8V @ VCC = 3.3V RP2040 Datasheet
(Section 5.3.3.4 Electrical Characteristics)
RPi 4B SBC 2V @ VCC = 3.3V 0.8V @ VCC = 3.3V elinux.org
BeagleBone Black SBC 2V @ VCC = 3.3V 0.8V @ VCC = 3.3V AM3358 Datasheet
(Section 5.7 Electrical Characteristics)

Input pins on an MCU or SBC typically only read voltage with a high impedance that will not allow much current to flow in or out, but there is some leakage current from transistors in the GPIO circuitry. This leakage current occurs when in a low or high state and is usually specified in the datasheet as:

IIH:
leakage current for logic high (1)
IIL:
leakage current for logic low (0)

Leakage currents for IIH and IIL for MCUs and SBCs are typically around 1μA.

Floating Inputs & Pull Resistors

A common mistake when working with digital inputs in combination with components such as switches and transistors is to leave inputs disconnected and floating. An example of this is shown in the figure below where VCCVoltage Collector Collector (VCC) is the supply voltage at the collector of a transistor. The double subscript notation of repeating letters "CC" is used to denote a power supply voltage that is relative to ground. is connected to a switch and current limiting resistor (RIN) to the input of an MCU or SBC GPIOGeneral Purpose Input Output configured to a high impedance state (usually the default state). When the switch is closed, the input reads VCC. However, when the switch is open, the input is not connected to anything and is floating. When an input pin is "floating" its state is indeterminate, meaning that it is neither connected to VCC or to ground. Leakage current from within the device can give false input readings, randomly switching between high and low states. The floating input also acts like an antenna that picks up all kinds of Electromagnetic Interference (EMIElectromagnetic Interference) from within the device and surroundings. A floating pin is also very susceptible to static electricity, which can damage the device.

Floating Input Schematic

Implementing a pull-up or pull-down resistor in the interface will ensure a direct connection to VCC or ground with deterministic logic states of high (1) or low (0). A pull up/down resistor with low resistance (where more current flows) is often called a "strong" pull up/down resistor because it will pull the output high/low quickly. A pull up/down resistor with high resistance (less current flows) is often called a "weak" pull up/down resistor because it will pull the output high/low more slowly.

A schematic of a pull-up resistor RPU connected to VCC with the switch to ground is shown in the figure below. When the switch is open, the input to the device is pulled high. When the switch is closed, the input is pulled low to ground. The resistor (RIN) connected to the input of the GPIO is a current limiting resistor for protecting the GPIO in case a mistake is made programming the input as an output, which without this resistor would short circuit the output to ground and damage the GPIO. An RIN resistance of about 1kΩ limits any output current to a safe value, while doing nothing for its normal input function.

External Pull-Up Resistor Schematic

A schematic of a pull-down resistor RPD connected to ground with the switch to VCC is shown in the figure below. When the switch is open, the input to the device is pulled low to ground. When the switch is closed, the input is pulled high.

External Pull-Down Resistor Schematic

External Pull Up Resistors

There are trade-offs when selecting the size of the pull-up resistor that depend on your application:

Input Voltage Drop:
The pull up resistor drops the input voltage down to VCC - IIH·(RPU+RIN), where RIN is the current limiting resistance, so the resistance needs to be low enough to pull the line to a logic high above VIH.
Noise Interference:
The pull resistance needs to be low enough to reduce electrical noise interference that occurs with low currents.
Rise Time:
The pull resistance needs to be low enough for fast rise time so the input pin does not respond slowly to voltage changes
Power Consumption:
The pull resistance needs to be high enough not to cause to much current to flow, heating the device and consuming an unnecessary amount of power.

For the input voltage drop requirement, you should refer to the datasheet of the device to estimate the maximum RPU from VCC, VIH(Min), and IIH given in the figure below.

Maximum Pull-Up Resistor Equation

This maximum resistance leaves no room for error as it will drop the input voltage all the way down to VIH(Min) with the current at its minimum. However, we want the input voltage well above VIH(Min) in order to guarantee a high logic 1 when the switch is closed to allow for any variation from the tolerance error of the resistor and/or supply voltage VCC being off from expected. Reducing the pull-up resistor value will give a greater error margin. Midway between VIH(Min) and VCC seems like a good compromise. To achieve this the voltage drop will be scaled by a Threshold Margin Factor (TMF) of 0.5 as shown in the figure below.

Input Voltage Threshold Margin Pull-Up Resistor Equation

Noise and interference is another consideration that is harder to quantify. Every node in a circuit has some capacitive coupling to all other nodes. If these nodes have signals on them, they could couple into your digital signal when the current is very low. A lower value of the pull-up resistance would increase the current and reduce the amount of stray signal it will pick up. How much do you need to lower the resistance to make it immune to interference? It's nearly impossible to determine exactly, so a cautious order of magnitude margin (1/10) can be used if there is plenty of room to work with on the pull-up resistor value. This margin is included in the figure below with a scalar Interference Reduction Factor (IRF).

Interference Reduction Pull-Up Resistor Equation

The following gives an example of estimating the pull-up resistance using the ATmega328P MCUMicrocontroller Unit in the Arduino Uno or Nano. The ATmega328P Datasheet in section 28.2 DC Characteristics specifies the input high voltage VIH as 3V and the leakage current IIL as 1μA at a VCC of 5V. The pull-up resistor value is calculated in the figure below as 99 kΩ.

Pull-Up Resistor Calculation for Arduino ATmega328P

The rise time of the digital signal is another consideration for high frequency pulses or data communication. The pull resistance needs to be low enough for fast rise time so the input pin does not respond slowly to voltage changes. The line will have some stray capacitance to ground (often from the input gate capacitance and the PCBPrinted Circuit Board trace capacitance), so will exponentially decay towards the supply value instead of instantly going there. If the pull-up resistor value is too high, the line may not rise to a logical high before it is pulled low. The response can be characterized as an RCA resistor–capacitor circuit (RC circuit) is an electric circuit composed of resistors and capacitors in series with a voltage or current source. circuit to a voltage step of amplitude VCC with a time constant RC. If the rise starts at time t = 0, the voltage waveform can be written as given in the figure below.

Pull-Up Resistor Rise Time Voltage Waveform Equation

Typical capacitance values are in the range of 10pF - 20pF. The ATmega328P specified the serial bus capacitance for each I/OInput/Output pin as 10pF maximum, but not for the GPIOGeneral Purpose Input Output. The capacitance of the lines going into the input also add capacitance, so lets say the capacitance is at 20pF. The time constant RC for 100kΩ would be about 2μs. It takes 3 time constants to get to 95% of the settling value, which gives 6μs for the rise time. This response time is fast enough for just pushing a button, but if you wanted to run data through the line at a high rate (> 100 kHz), then the rise time would be too slow, so you would need to lower the pull-up resistance. For more details, Texas Instruments has a document that explains how to calculate the pull-up resistor for data communication in their I2C Bus Pullup Resistor Calculation Application Report (PDF).


As described above, there are several trade-offs when selecting the size of the pull-up resistor that depend on your application. Below is a diagram summarizing resistor values on a spectrum for different applications.

Recommended External Pull-Up Resistor Values

External Pull Down Resistors

There are trade-offs when selecting the size of the pull-down resistor that depend on your application:

Input Voltage Drop:
The pull down resistor drops the input voltage down to IIL·(RIN + RPU), where RIN is the current limiting resistance, so the resistance needs to be low enough to pull the line to a logic low below VIL.
Noise Interference:
The pull resistance needs to be low enough to reduce electrical noise interference that occurs with low currents.
Fall Time:
The pull resistance needs to be low enough for fast fall time so the input pin does not respond slowly to voltage changes.
Power Consumption:
The pull resistance needs to be high enough not to cause to much current to flow, heating the device and consuming an unnecessary amount of power.

For the input voltage drop requirement, you should refer to the datasheet of the device to estimate the maximum RPD from VCC, VIL(Max), and IIL as given in the figure below.

Maximum Pull-Down Resistor Equation

This maximum resistance leaves no room for error as it will only drop the input voltage down to the threshold VIL(Max). However, we want the input voltage well below VIL(Max) in order to guarantee a high logic 0 when the switch is open to allow for any variation from the tolerance error of the resistor, electrical noise, and/or variation in the leakage current. Reducing the pull-down resistor value will pull the voltage closer to ground and give a greater error margin. Midway between VIL(Max) and 0 seems like a good compromise. To achieve this the voltage drop will be scaled by a Threshold Margin factor (TMF) of 0.5 as shown in the figure below.

Input Voltage Threshold Margin Pull-Down Resistor Equation

Noise and interference is another consideration that is harder to quantify. As with the pull-up resistor, capacitive coupling interference occurs when the current is very low. A lower value of the pull-down resistance would increase the current and reduce the amount of stray signal it will pick up. How much do you need to lower the resistance to make it immune to interference? It's nearly impossible to determine exactly, so a cautious order of magnitude margin (1/10) can be used if there is plenty of room to work with on the pull-down resistor value. This margin is included in the figure below with a scalar Interference Reduction Factor (IRF).

Interference Reduction Pull-Down Resistor Equation

The following gives an example of estimating the pull-up resistance using the ATmega328P MCUMicrocontroller Unit in the Arduino Uno R3 or Nano. The ATmega328P Datasheet in section 28.2 DC Characteristics specifies the maximum VIL as 1.5V and the leakage current IIL(Max) as 1μA at VCC of 5V. The pull-down resistor value is calculated in the in the figure below as 74kΩ.

Pull-Down Resistor Calculation for Arduino ATmega328P

The fall time of the digital signal is another consideration for high frequency pulses or data communication. The pull resistance needs to be low enough for fast fall time so the input pin does not responds slowly to voltage changes. The line will have some stray capacitance to ground (often from the input gate capacitance and the PCBPrinted Circuit Board trace capacitance), so will exponentially decay towards ground instead of instantly going there. If the pull-down resistor value is too high, the line may not fall to a logical low before it is pulled high again. The response can be characterized as an RCA resistor–capacitor circuit (RC circuit) is an electric circuit composed of resistors and capacitors in series with a voltage or current source. circuit with a voltage fall from amplitude VCC over a time constant RC. If the fall starts at time t = 0, the voltage waveform can be written as given in the figure below.

Pull-Down Resistor Fall Time Voltage Waveform Equation

R in the equation above is the total resistance from the input to ground (RIN + RPD). Typical capacitance values are in the range of 10pF - 20pF. The ATmega328P specified the serial bus capacitance for each I/OInput/Output pin as 10pF maximum, but not for the GPIOGeneral Purpose Input Output. The capacitance of the lines going into the input also add capacitance, so lets say the capacitance is at 20pF. The time constant RC for R = 75kΩ and C = 20pF would be about 1.5μs. It takes 3 time constants to get to 95% of the settling value, which gives 4.5μs for the fall time. This response time is fast enough for just pushing a button, but if you wanted to run data through the line at a high rate (> 200kHz), then the rise time would be too slow, so you would need to lower the pull-down resistance.


As described above, there are several trade-offs when selecting the size of the pull-down resistor that depend on your application. Below is a diagram summarizing resistor values on a spectrum for different applications.

Recommended External Pull-Down Resistor Values

Internal Pull Resistors

The GPIOGeneral Purpose Input Output circuitry in MCUMicrocontroller Unit and SBCSingle Board Computer devices usually have internal pull resistors that can be enabled in software. In general, there GPIO inputs are primarily configured in one of three ways:

  1. High-impedance (often the default - floats if not driven)
  2. Pull-up (internal resistor connected to VCC)
  3. Pull-down (internal resistor connected to Ground)

The pull up and pull down resistor circuitry of the GPIO is shown in the figure below.

GPIO Internal Pull Up/Down Resistor Schematic

MCUs and SBCs typically have "weak" internal pull resistors with relatively low resistance values (1kΩ - 100kΩ). The values of the internal resistance varies across different devices and even on the same device. The table below gives shows this variation on a few devices.

Internal Pull Resistance for Different Devices
Device Internal
Pull-Up
Resistance
Internal
Pull-Down
Resistance
Reference
ATmega328P MCU in Arduino Uno and Nano Min 20kΩ
Max 50kΩ
N/A ATmega328P Datasheet (PDF)
Section 28.2
RP2040 MCU in RPi Pico Min 50kΩ
Max 80kΩ
Min 50kΩ
Max 80kΩ
RP2040 Datasheet (PDF)
Section 5.3.3.4 Electrical Characteristics
RPi 4B SBC Min 50kΩ
Max 65kΩ
Min 50kΩ
Max 60kΩ
elinux.org
Note: the two GPIO's normally used for I2C have 1.8kΩ pull-up resistors to 3.3V
BeagleBone Black SBC 30kΩ 30kΩ Measured

This internal weak pull can often be used without the need of an external pull resistor,, depending on the external circuitry and environment. For instance, if you run a long lead to the switch or operate in an electrically noisy environment, you might get false triggers on the digital input when using internal resistors because they have a weak pull. Under these circumstances, it would be best to turn off the internal pull resistors and use a stronger external pull resistor.


Measuring Internal Pull Resistance

The internal pull resistance values are sometimes not provided in datasheets of the device, but they can measured using a multimeter and external known resistor. This is illustrated in the figures below. The external resistor acts as a voltage divider by connecting it across the GPIO input pin and ground if an internal pull-up resistor is enabled or across the GPIO input pin and the GPIO power supply if the internal pull-down resistor is enabled. The resistance value of the external resistor should be comparable to the expected internal pull resistance so VCC can be divided significantly enough to infer the pull resistance. Since an internal pull resistance can be from anywhere 10kΩ to 100kΩ, an external resistance from 50kΩ to 100kΩ would suffice to drop the voltage down enough by roughly half the voltage.

To measure the internal pull-up resistance, you can put an external known resistor (RKnown) across the GPIO input pin to the ground as shown in the figure below, then use a multimeter to measure the voltage (VDivider) across the external resistor.

Measuring GPIO Internal Pull-Up Resistance (with Pull-Up Enabled)

To measure the internal pull-down resistance, you can put an external known resistor (RKnown) across the VCC pin to the GPIO input pin as shown in the figure below, then use a multimeter to measure the voltage (VDivider) across the external resistor.

Measuring GPIO Internal Pull-Down Resistance (with Pull-Down Enabled)

The measured voltage should be the voltage divided by the external known resistor (RKnown) and internal pull resistor (RP) as given in the figure below.

Internal Pull Resistance Voltage Divider Equation

Solving for the unknown pull resistance RP gives the following equation in the figure below.

Internal Pull Resistance Equation

The resistance of the external resistor RKnown and the VCC used in the calculation should be measured to get more accurate values rather than using their expected values.

Maximum Voltage & Current Levels

The maximum input voltage and current levels are usually specified in the MCU datasheet under Electrical Characteristics. Levels beyond the absolute maximum ratings may cause permanent damage to the device. Exceeding the ratings may have immediate and drastic effects, like burning of the bonding wire. Sometimes you can exceed the absolute maximum ratings for a short period without apparent damage, but it can create hot spots in the die which may cause errors only noticeable later on. Exposure to absolute maximum rating conditions for extended periods may affect device reliability.

Maximum Input Voltage

The maximum input voltage for GPIO pins varies for different devices, but is usually the I/O supply voltage plus some small overhead voltage. For example, the ATmega328P in the Arduino Uno R3 and Nano has an absolute maximum GPIO voltage rating of VCC + 0.5V in section 28.1 Absolute Maximum Ratings of the ATmega328P Datasheet (PDF). For the RP2040 in the RPiRaspberry Pi Pico the absolute maximum GPIO voltage rating of IOVDD + 0.3V in section 5.3.3.4 IO Electrical Characteristics of the RP2040 Datasheet (PDF). The BeagleBone Black SBCSingle Board Computer has its absolute maximum voltage ratings at the I/O supply voltage plus 0.3V in section 5.1 in the AM3358 Datasheet (PDF).

This is the threshold beyond which the manufacturer can no longer guarantee the chip will not be damaged, so you should always ensure you are safely below this limit and allow margin for any variation in the power supply.

Many MCUs, like the ATmega328P and RP2040, have Electrostatic Discharge (ESDElectrostatic Discharge) protection diodes on the GPIO that protect against overvoltage events that are only very short-lived. These diodes are not rated for any continuous overvoltage, which will simply burn out the diode and stop protecting the pin and other components.

Maximum Input Current

The CMOSComplementary Metal-Oxide Semiconductor circuitry of GPIO pins are voltage operated devices rather than current operated devices because the input impedance is very high. Datasheets for devices often give an absolute maximum GPIO pin current rating. For example, the ATmega328P in the Arduino Uno R3 and Nano has an absolute maximum GPIO per pin current rating of 40mA in section 28.1 Absolute Maximum Ratings of the ATmega328P Datasheet (PDF). One common misconception is that this current limit applies to inputs. The 40mA "maximum sink" is only applicable when the pin is set to output and is driven low, where the pin is connected to ground through a MOSFETMetal-Oxide-Semiconductor Field-Effect Transistor.

Conclusion

This was an overview of the electrical characteristics of digital inputs that covered digital voltage thresholds, leakage current, pull resistors, and maximum voltage and current levels. How to interface externally powered circuits to extract a digital signal, where the compatibility of voltage levels and current between the devices must be taken into account, is covered in the Interfacing Digital Inputs article.

Related Content


Interfacing Digital Input with Signal Coverter Circuit

Created:   27Mar2023   22:51:48   UTC 2023-03-27T22:51:48Z
Updated:   24Jun2024   08:11:19   UTC 2024-06-24T08:11:19Z
Rating:  (0 reviewsThis article has not been rated yet)

Covers the electrical compatibility of a microcontroller board or single board computer with external devices: Voltage Dividers, Level Converters/Shifters, Over-Voltage Protection, and Electrical Isolation.

Products

Resistor Kits



Potentiometers



Article Rating

Sign in to rate this article

Sign In


(0) Comments

Sign in to leave a comment

Sign In