A typical digital pin of a microcontroller usually has 4 possible states:

  1. output, logical 0
  2. output, logical 1
  3. input, tri-state (high impedance)
  4. input, internal pull-up resistor

On a live circuit, what is the simplest safe method to verify which of the above 4 states a specific pin is in? Assume we have a simple multimeter and basic passive components, if necessary. The ground (GND) and power (Vcc) pins are known.

#1 is the simplest to identify. If I measure the voltage between Vcc and the pin, and it's the same as between Vcc and GND, we found it.

#3 should also be obvious, because in theory it neither sources nor sinks any significant current, so I shouldn't measure any significant voltage, neither between the pin and GND, nor between the pin and Vcc. However, due to the characteristics of digital multimeters, and that tri-state doesn't have literally infinite resistance, can this method go wrong? I wouldn't want to measure resistance on a live circuit.

What about differentiating #2 and #4? Both would result in the same: the pin will have the same potential as Vcc. As pins in the output configuration can typically source more current, I guess I could put higher and higher loads on it, but I find this not being without risks. Also, this might highly depend on the type of circuit we want to test.

Edit: Let's assume the pin doesn't change states while the measurement is performed.

  • \$\begingroup\$ What exactly is your definition of "safe" in this case? not hurt yourself? not blow up everything? \$\endgroup\$
    – PlasmaHH
    Jan 11 '16 at 13:24
  • \$\begingroup\$ Why "internal" pullup? Is that different to an external pullup? What about pull-down? What about open drain outputs? What is it that you want to do with this information? \$\endgroup\$ Jan 11 '16 at 13:27
  • 1
    \$\begingroup\$ I doubt I could hurt myself by playing with a microcontroller, typically supplied with 3.3 or 5 Volt, and being able to produce at most a few dozen or a few hundred milliamps. I think we all can assume that "safe" means avoiding any permanent damage to the test object. \$\endgroup\$
    – vsz
    Jan 11 '16 at 13:27
  • \$\begingroup\$ @RogerRowland : if the pullup is external, I could identify it visually. About the other possibilities, a good point. If you have an answer also covering those, feel free to include them. \$\endgroup\$
    – vsz
    Jan 11 '16 at 13:28
  • 2
    \$\begingroup\$ To distinguish between 2 and 4, a resistor producing a current draw of about 10ma should tell you whether it's a strong output or a weak pullup. \$\endgroup\$
    – pjc50
    Jan 11 '16 at 13:35

Think of the pin as a Thevenin source. In order to distinguish the four states you've enumerated, you need to determine two parameters: the Thevenin source voltage and the Thevenin source resistance.

In order to do this, you need to measure both the pin's voltage and current, and you need to do this relative to at least two different external references (e.g., Gnd and Vcc). Only then will you have enough information to derive the Thevenin parameters.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.