Skip to main content
mostly wordsmithery
Source Link
Seamus
  • 22.8k
  • 4
  • 38
  • 79

Finally on the subject of resistor selection for a voltage divider interface, thisthere is an opportune timeone other important topic to address another topic:

RPi GPIO are all digital IO, meaning there are only two valid states: High (1) and Low (0). But voltage, resistance and current are clearly creatures from the analog domain. This means that, as part of our voltage divider design, we shouldmust consider the voltage thresholds imposed onupon us by this binary system as part of our voltage divider design.

"Worst case" here means that for any (defined) value of VDD IO, the thresholds in the table above are valid. For the case at hand, the designer may use a value for R4 as low as ~1.8Kš®. Since playing at the margins is usually risky business, the following values of 10Kš® for R3 and 2.7Kš® ā‰¤ R4 ā‰¤ 3.3Kš® seemsseem reasonable.:

  • R3 = 10Kš®
  • 2.7Kš® ā‰¤ R4 ā‰¤ 3.3Kš® .

A functional equivalent alternative to the voltage divider is to use a potentiometerpotentiometer with the wiper connected to the GPIO pin - see Schematic B below:

4. Option IV: External voltage clampVoltage Clamp

The Clampingclamping diodes shown in Schematic C below offer valuable risk reduction if a resistive divider, or a potentiometer, is used. You've indicated a preference for resistors only, but for the sake of completeness I'll include this option. A pair of clamping diodes connected across the GPIO input will provide additional protection. Note that the GPIO circuitry on the RPi already includes a pair of clamping diodes, but as they are elements of the integrated circuit (parasitic FETs most likely), they have a very limited current-carrying capacity.

Finally on the subject of resistor selection for a voltage divider interface, this is an opportune time to address another topic:

RPi GPIO are all digital, meaning there are only two valid states: High (1) and Low (0). But voltage, resistance and current are clearly creatures from the analog domain. This means that we should consider the voltage thresholds imposed on us by this binary system as part of our voltage divider design.

"Worst case" here means that for any (defined) value of VDD IO, the thresholds in the table above are valid. For the case at hand, the designer may use a value for R4 as low as ~1.8Kš®. Since playing at the margins is usually risky business, values of 10Kš® for R3 and 2.7Kš® ā‰¤ R4 ā‰¤ 3.3Kš® seems reasonable.

A functional equivalent alternative to the voltage divider is to use a potentiometer with the wiper connected to the GPIO pin - see Schematic B below:

4. Option IV: External voltage clamp

Clamping diodes offer valuable risk reduction if a resistive divider, or a potentiometer is used. You've indicated a preference for resistors only, but for the sake of completeness I'll include this option. A pair of clamping diodes connected across the GPIO input will provide additional protection. Note that the GPIO circuitry on the RPi already includes a pair of clamping diodes, but as they are elements of the integrated circuit (parasitic FETs most likely), they have a very limited current-carrying capacity.

Finally on the subject of resistor selection for a voltage divider interface, there is one other important topic to address:

RPi GPIO are all digital IO, meaning there are only two valid states: High (1) and Low (0). But voltage, resistance and current are clearly creatures from the analog domain. This means that, as part of our voltage divider design, we must consider the voltage thresholds imposed upon us by this binary system.

"Worst case" here means that for any (defined) value of VDD IO, the thresholds in the table above are valid. For the case at hand, the designer may use a value for R4 as low as ~1.8Kš®. Since playing at the margins is usually risky business, the following values seem reasonable:

  • R3 = 10Kš®
  • 2.7Kš® ā‰¤ R4 ā‰¤ 3.3Kš® .

A functional equivalent alternative to the voltage divider is to use a potentiometer with the wiper connected to the GPIO pin - see Schematic B below:

4. Option IV: External Voltage Clamp

The clamping diodes shown in Schematic C below offer valuable risk reduction if a resistive divider, or a potentiometer, is used. You've indicated a preference for resistors only, but for the sake of completeness I'll include this option. A pair of clamping diodes connected across the GPIO input will provide additional protection. Note that the GPIO circuitry on the RPi already includes a pair of clamping diodes, but as they are elements of the integrated circuit (parasitic FETs most likely), they have a very limited current-carrying capacity.

additional info & clarity?
Source Link
Seamus
  • 22.8k
  • 4
  • 38
  • 79

The illuminated pushbutton switch may be a DPST switch - as shown in Schematic A below. IfBut even if it's SPST, it doesn't change the fact that the LED must have a current-limiting resistor. ItThe form of the switch (SPST v DPST) doesn't change the interface requirements either. A part number or schematic of the switch would enable us to sort that out, but again, I don't feel it makes a huge difference unless it's a very specialized switch.

The schematic below (Schematic A) shows two options for the interface - Option I & Option II:

1. Option I: Zener Diode

A zener diode limits the voltage at the GPIO pin to 3.3V. It will maintain this 3.3V limit over a wide range of power supply voltages. This reduces yourthe risk of damaging your RPi - and the circuitry behind the GPIO pins is very fragile.

2. Option II: Voltage Divider

A voltage divider will also work - although over a smaller range of input voltages than Option I. You have indicated this is your preferred solution due to parts availability - and that's fine as long as you're, but you should be clear on the tradeoffs you're making.

Schematic A:

From Ohm's Lawschematic

simulate this circuit – Schematic created using CircuitLab

Voltage Divider Calculations for Option II:

The RPi's GPIO pins operate from a 3.3V supply; (and the Wikipedia page)damage is almost guaranteed (see warning) if input voltages exceed that level. Consequently, the resistor values ofneeded to set the two resistors mayvoltage to be easily calculated as followsinput to the RPi must be determined with some accuracy. This is a critical step; an error in this calculation may destroy your RPi. Fortunately for our RPi hardware, Ohm's Law, and the Wikipedia page on voltage dividers, provide guidance for calculating these resistor values:

Vout = Vin * R3 / (R3 + R4)

Vout = Vin * R3 / (R3 + R4)

schematic Finally on the subject of resistor selection for a voltage divider interface, this is an opportune time to address another topic:

Voltage Thresholds for Logic HI (1) and Logic LO (0)

simulate this circuit – Schematic created using CircuitLab RPi GPIO are all digital, meaning there are only two valid states: High (1) and Low (0). But voltage, resistance and current are clearly creatures from the analog domain. This means that we should consider the voltage thresholds imposed on us by this binary system as part of our voltage divider design.

These voltage thresholds are currently defined in the "Official" documentation. They are summarized as follows:

Binary Logic LevelWorst-Case Voltage
Low / LO / 0Vin ā‰¤ 0.6 Volts
High / HI / 1Vin ā‰„ 1.6 Volts

"Worst case" here means that for any (defined) value of VDD IO, the thresholds in the table above are valid. For the case at hand, the designer may use a value for R4 as low as ~1.8Kš®. Since playing at the margins is usually risky business, values of 10Kš® for R3 and 2.7Kš® ā‰¤ R4 ā‰¤ 3.3Kš® seems reasonable.

3. Option III: Potentiometer

AnA functional equivalent alternative to the voltage divider is to use a potentiometer with the wiper connected to the GPIO pin - see the second schematicSchematic B below.:

Schematic B:

schematic

simulate this circuit

4. Option IV: External voltage clamp

UseClamping diodes offer valuable risk reduction if a resistive divider, or a potentiometer with clamping diodesis used. You've indicated a preference for resistors only, but for the sake of completeness aI'll include this option. A pair of clamping diodes connected across the GPIO input will provide some additional protection. Note that the GPIO circuitry on the RPi already includes a pair of clamping diodes, but as they are elements of the integrated circuit (parasitic FETs most likely), they have a very limited current-carrying capacity. External

Schottky diodes are much favored over p-n junction diodes for voltage clamps can carry more current & will likely reduce the risk of damage. An external Schottky diode offers superior performance (and protection in this application) for three reasons:

  1. Schottky diodes can carry more current & thereby reduce the risk of damage to the RPi's GPIO circuitry

  2. Schottky diodes have a significantly smaller forward voltage drop than a p-n diode

  3. Schottky diodes have very low effective capacitance, and as a result are extremely fast - speed matters in device protection.

Schematic C:

 

The illuminated pushbutton switch may be a DPST switch. If it's SPST, it doesn't change the fact that the LED must have a current-limiting resistor. It doesn't change the interface requirements either. A part number or schematic of the switch would enable us to sort that out, but again, I don't feel it makes a huge difference unless it's a very specialized switch.

The schematic shows two options for the interface:

1. Option I:

A zener diode limits the voltage at the GPIO pin to 3.3V. It will maintain this 3.3V limit over a wide range of power supply voltages. This reduces your risk of damaging your RPi - and the circuitry behind the GPIO pins is very fragile.

2. Option II:

A voltage divider will also work - although over a smaller range of input voltages than Option I. You have indicated this is your preferred solution due to parts availability - and that's fine as long as you're clear on the tradeoffs you're making.

From Ohm's Law (and the Wikipedia page), the values of the two resistors may be easily calculated as follows:

Vout = Vin * R3 / (R3 + R4)

schematic

simulate this circuit – Schematic created using CircuitLab

3. Option III:

An alternative is to use a potentiometer with the wiper connected to the GPIO pin - see the second schematic below.

schematic

4. Option IV:

Use a resistive divider, or a potentiometer with clamping diodes. You've indicated a preference for resistors, but for the sake of completeness a pair of clamping diodes connected across the GPIO input will provide some additional protection. Note that the GPIO circuitry on the RPi already includes a pair of clamping diodes, but as they are elements of the integrated circuit, they have a very limited current-carrying capacity. External clamps can carry more current & will likely reduce the risk of damage.

The illuminated pushbutton switch may be a DPST switch - as shown in Schematic A below. But even if it's SPST, it doesn't change the fact that the LED must have a current-limiting resistor. The form of the switch (SPST v DPST) doesn't change the interface requirements either. A part number or schematic of the switch would enable us to sort that out, but again, I don't feel it makes a huge difference unless it's a very specialized switch.

The schematic below (Schematic A) shows two options for the interface - Option I & Option II:

1. Option I: Zener Diode

A zener diode limits the voltage at the GPIO pin to 3.3V. It will maintain this 3.3V limit over a wide range of power supply voltages. This reduces the risk of damaging your RPi - and the circuitry behind the GPIO pins is very fragile.

2. Option II: Voltage Divider

A voltage divider will also work - although over a smaller range of input voltages than Option I. You have indicated this is your preferred solution due to parts availability - and that's fine, but you should be clear on the tradeoffs you're making.

Schematic A:

schematic

simulate this circuit – Schematic created using CircuitLab

Voltage Divider Calculations for Option II:

The RPi's GPIO pins operate from a 3.3V supply; damage is almost guaranteed (see warning) if input voltages exceed that level. Consequently, the resistor values needed to set the voltage to be input to the RPi must be determined with some accuracy. This is a critical step; an error in this calculation may destroy your RPi. Fortunately for our RPi hardware, Ohm's Law, and the Wikipedia page on voltage dividers, provide guidance for calculating these resistor values:

Vout = Vin * R3 / (R3 + R4)

Finally on the subject of resistor selection for a voltage divider interface, this is an opportune time to address another topic:

Voltage Thresholds for Logic HI (1) and Logic LO (0)

RPi GPIO are all digital, meaning there are only two valid states: High (1) and Low (0). But voltage, resistance and current are clearly creatures from the analog domain. This means that we should consider the voltage thresholds imposed on us by this binary system as part of our voltage divider design.

These voltage thresholds are currently defined in the "Official" documentation. They are summarized as follows:

Binary Logic LevelWorst-Case Voltage
Low / LO / 0Vin ā‰¤ 0.6 Volts
High / HI / 1Vin ā‰„ 1.6 Volts

"Worst case" here means that for any (defined) value of VDD IO, the thresholds in the table above are valid. For the case at hand, the designer may use a value for R4 as low as ~1.8Kš®. Since playing at the margins is usually risky business, values of 10Kš® for R3 and 2.7Kš® ā‰¤ R4 ā‰¤ 3.3Kš® seems reasonable.

3. Option III: Potentiometer

A functional equivalent alternative to the voltage divider is to use a potentiometer with the wiper connected to the GPIO pin - see Schematic B below:

Schematic B:

schematic

simulate this circuit

4. Option IV: External voltage clamp

Clamping diodes offer valuable risk reduction if a resistive divider, or a potentiometer is used. You've indicated a preference for resistors only, but for the sake of completeness I'll include this option. A pair of clamping diodes connected across the GPIO input will provide additional protection. Note that the GPIO circuitry on the RPi already includes a pair of clamping diodes, but as they are elements of the integrated circuit (parasitic FETs most likely), they have a very limited current-carrying capacity.

Schottky diodes are much favored over p-n junction diodes for voltage clamps. An external Schottky diode offers superior performance (and protection in this application) for three reasons:

  1. Schottky diodes can carry more current & thereby reduce the risk of damage to the RPi's GPIO circuitry

  2. Schottky diodes have a significantly smaller forward voltage drop than a p-n diode

  3. Schottky diodes have very low effective capacitance, and as a result are extremely fast - speed matters in device protection.

Schematic C:

 
add stuff
Source Link
Seamus
  • 22.8k
  • 4
  • 38
  • 79
  1. Option I: A zener diode limits the voltage at the GPIO pin to 3.3V. It will maintain this 3.3V limit over a wide range of power supply voltages. This reduces your risk of damaging your RPi - and the circuitry behind the GPIO pins is very fragile.

  2. Option II: A voltage divider will also work - although over a smaller range of input voltages than Option I. You have indicated this is your preferred solution due to parts availability - and that's fine as long as you're clear on the tradeoffs you're making.

    From Ohm's Law (and the Wikipedia page), the values of the two resistors may be easily calculated as follows:

    Vout = Vin * R3 / (R3 + R4)

    Vin = 12 V
    Vout = 3.3 V Choose a value for R3, and calculate R4.

    IOW, there are numerous combinations of R3, and R4 that will give the needed 3.3V - or close enough to it. For example:

    Choose R3 = 10Kš® & solve for R4:

    R4 = R3 * 1 / ((Vin / Vout) -1)

    R4 = 10,000 * 1 / ((12 / 3.3) - 1)

    R4 = 3,793š®

1. Option I:

A zener diode limits the voltage at the GPIO pin to 3.3V. It will maintain this 3.3V limit over a wide range of power supply voltages. This reduces your risk of damaging your RPi - and the circuitry behind the GPIO pins is very fragile.

2. Option II:

A voltage divider will also work - although over a smaller range of input voltages than Option I. You have indicated this is your preferred solution due to parts availability - and that's fine as long as you're clear on the tradeoffs you're making.

From Ohm's Law (and the Wikipedia page), the values of the two resistors may be easily calculated as follows:

Vout = Vin * R3 / (R3 + R4)

Vin = 12 V
Vout = 3.3 V Choose a value for R3, and calculate R4.

IOW, there are numerous combinations of R3, and R4 that will give the needed 3.3V - or close enough to it. For example:

Choose R3 = 10Kš® & solve for R4:

R4 = R3 * 1 / ((Vin / Vout) -1)

R4 = 10,000 * 1 / ((12 / 3.3) - 1)

R4 = 3,793š®

And so you see that the process is to try to find a combination of resistors in your stock that will give the required value.

simulate this circuit – Schematic created using CircuitLab

3. Option III:

An alternative is to use a potentiometer with the wiper connected to the GPIO pin - see the second schematic below.

schematic

4. Option IV:

Use a resistive divider, or a potentiometer with clamping diodes. You've indicated a preference for resistors, but for the sake of completeness a pair of clamping diodes connected across the GPIO input will provide some additional protection. Note that the GPIO circuitry on the RPi already includes a pair of clamping diodes, but as they are elements of the integrated circuit, they have a very limited current-carrying capacity. External clamps can carry more current & will likely reduce the risk of damage.

enter image description here

  1. Option I: A zener diode limits the voltage at the GPIO pin to 3.3V. It will maintain this 3.3V limit over a wide range of power supply voltages. This reduces your risk of damaging your RPi - and the circuitry behind the GPIO pins is very fragile.

  2. Option II: A voltage divider will also work - although over a smaller range of input voltages than Option I. You have indicated this is your preferred solution due to parts availability - and that's fine as long as you're clear on the tradeoffs you're making.

    From Ohm's Law (and the Wikipedia page), the values of the two resistors may be easily calculated as follows:

    Vout = Vin * R3 / (R3 + R4)

    Vin = 12 V
    Vout = 3.3 V Choose a value for R3, and calculate R4.

    IOW, there are numerous combinations of R3, and R4 that will give the needed 3.3V - or close enough to it. For example:

    Choose R3 = 10Kš® & solve for R4:

    R4 = R3 * 1 / ((Vin / Vout) -1)

    R4 = 10,000 * 1 / ((12 / 3.3) - 1)

    R4 = 3,793š®

And so you see that the process is to try to find a combination of resistors in your stock that will give the required value.

simulate this circuit – Schematic created using CircuitLab

1. Option I:

A zener diode limits the voltage at the GPIO pin to 3.3V. It will maintain this 3.3V limit over a wide range of power supply voltages. This reduces your risk of damaging your RPi - and the circuitry behind the GPIO pins is very fragile.

2. Option II:

A voltage divider will also work - although over a smaller range of input voltages than Option I. You have indicated this is your preferred solution due to parts availability - and that's fine as long as you're clear on the tradeoffs you're making.

From Ohm's Law (and the Wikipedia page), the values of the two resistors may be easily calculated as follows:

Vout = Vin * R3 / (R3 + R4)

Vin = 12 V
Vout = 3.3 V Choose a value for R3, and calculate R4.

IOW, there are numerous combinations of R3, and R4 that will give the needed 3.3V - or close enough to it. For example:

Choose R3 = 10Kš® & solve for R4:

R4 = R3 * 1 / ((Vin / Vout) -1)

R4 = 10,000 * 1 / ((12 / 3.3) - 1)

R4 = 3,793š®

And so you see that the process is to try to find a combination of resistors in your stock that will give the required value.

simulate this circuit – Schematic created using CircuitLab

3. Option III:

An alternative is to use a potentiometer with the wiper connected to the GPIO pin - see the second schematic below.

schematic

4. Option IV:

Use a resistive divider, or a potentiometer with clamping diodes. You've indicated a preference for resistors, but for the sake of completeness a pair of clamping diodes connected across the GPIO input will provide some additional protection. Note that the GPIO circuitry on the RPi already includes a pair of clamping diodes, but as they are elements of the integrated circuit, they have a very limited current-carrying capacity. External clamps can carry more current & will likely reduce the risk of damage.

enter image description here

Source Link
Seamus
  • 22.8k
  • 4
  • 38
  • 79
Loading