1

Just starting with my first Arduino project. In order to measure voltage in a circuit I connected my multimeter to two points in the circuit (for example before and after a resistor).

I am interested to know how an input pin can measure its voltage (for example 5v or 0v).

3

Assuming you are asking about digital input pins on an Arduino:

Digital logic operates at the saturation and cut off regions of the transistor logic used. Most modern day processors use CMOS transistors. The logic levels are Low: 0 V to 1/3 VDD and High:2/3 VDD where VDD is the supply voltage. This information can be found here.

So, if your processor is designed to operate at 5 volts and is likely made of CMOS logic gates, the low level voltage is from 0 to 1.67 volts and the high level voltage is from 3.33 to 5 volts.

But to address your question specifically: Digital input pins do not measure the voltage. Not like an ADC input. Instead, it is agreed that nothing operating normally that is to interface with a digital pin will produce (linger at) a voltage other than those designed to force the transistors into cut-off or saturation.

So do be careful not to do this. It could result in unexpected behavior.

Now, if you can not avoid voltage between the designated upper limit of the low logic signal and the lower limit of the high logic signal you man need to buffer your signal with a device called a Schmitt Trigger. This device adds hysteresis to your signal and converts it into either a low or high logic state. Examples of hysteresis include the thermostat control for your furnace.

A final word, do not exceed the voltage at a digital input to that which is supplied at the power pin of that digital circuit. This can cause all kinds of problems. Usually this is not a problem as most devices / projects are powered off of one power source. But in case multiple power supplies are used, keep this in mind.

  • There is no point in using an external Schmitt trigger: there is already one inside each digital input. – Edgar Bonet Oct 17 '17 at 20:55
  • That is good to know. But can you say that for every Arduino? I'm betting there are micros being used on different Arduino platforms which do not have Schmidt trigger like inputs. – st2000 Oct 17 '17 at 22:17
  • Not for all – I don't know them all – but for the AVR-based ones (most Arduinos). I just checked the datasheet of the SAM3X8E (Arduino Due) and it says “With a few exceptions, the I/Os have input Schmitt triggers.” When in doubt, it's always wise to check the datasheet. – Edgar Bonet Oct 18 '17 at 7:26
2

The implementation of the digital inputs may depend on what kind of microcontroller you are using. On AVR microcontrollers (most common Arduinos are AVR-based), the inputs go through Schmitt triggers. This means that the voltage seen by the logic downstream is always a valid logic level. You should then not worry about an invalid input causing “unexpected behavior”.

It should be noted, though, that the characteristics of the Schmitt trigger are very loosely specified. If I take the ATmega328P at Vcc = 5 V as an example (the MCU powering the Arduino Uno), the thresholds are expected to be “typically” around 2.1 V (for the HIGH → LOW transition) and 2.6 V (LOW → HIGH). But these are only typical values. The only thing that is really specified is that the input reads LOW when the pin voltage is below 0.3 Vcc and it reads HIGH above 0.6 Vcc. At 5 V this means that the thresholds could be anywhere between 1.5 V and 3 V).

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.