Go Down

Topic: Threshold Voltage and Hysteresis for Digital Inputs (Read 5473 times) previous topic - next topic

dlloyd

Researching this forum, most replies mention 0.3Vcc for LOW (logic 0) and 0.6Vcc for HIGH (logic 1).
Here's the results of some actual measurements on an UNO Rev3:



Description:

As the input voltage increases from 0V, the input is read as 0 and switches to 1 at 2.60V.
As the input voltage decreases from 5V, the input is read as 1 and switches to 0 at 2.35V.
Hysteresis is 0.25V.

Expressed in terms of Vcc:

Input low voltage   0.47 Vcc
Hysteresis          0.05 Vcc
Input high voltage  0.52 Vcc

Delta_G

Researching this forum, most replies mention 0.3Vcc for LOW (logic 0) and 0.6Vcc for HIGH (logic 1).
Here's the results of some actual measurements on an UNO Rev3:

I think those are  meant as the guaranteed extreme values.  As in you can always count on 0.6Vcc to read HIGH and 0.3Vcc to read low.  The actual points may vary from chip to chip and IIRC that is even mentioned in the datasheet somewhere.  But between those points I don't think anything is guaranteed and will probably vary from chip to chip and from application to application.   
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

dlloyd

Yes, I agree. It covers the full temperature range and voltage voltage range for the MCU. The values I got are quite close to what these charts show at 25 deg and Vcc = 5V.   EDIT: Except for hysteresis.

EDIT: Updated to refer to latest datasheet (thanks Delta_G): 

33.1.9. Pin Threshold and Hysteresis (page 391-392)
Figure 33-25. I/O Pin Input Threshold Voltage vs. VCC (VIH, I/O Pin read as '1')
Figure 33-26. I/O Pin Input Threshold Voltage vs. VCC (VIL, I/O Pin read as '0')
Figure 33-27. I/O Pin Input Hysteresis vs. VCC
Atmel-42735B-ATmega328/P_Datasheet_Complete-11/2016

holmes4

Quote
Researching this forum, most replies mention 0.3Vcc for LOW (logic 0) and 0.6Vcc for HIGH (logic 1).
THEY ARE NOT THE CORRECT VALUES. Try reading the datasheet. And you are the first I've seen to give those values on this forum.

Mark

Delta_G

THEY ARE NOT THE CORRECT VALUES. Try reading the datasheet. And you are the first I've seen to give those values on this forum.

Mark
Can you quote what you see in the datasheet?  I've seen the values 0.3Vcc and 0.6Vcc a lot of places.  Most notably table 30-1 in the datasheet.  It lists EXACTLY those values except when the chip is running at really low voltages. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

Delta_G

|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

holmes4

Current datasheet section 30.2 table 30.1 for a chip run at 5v ,

gives

low as < than (VIL - first row) as 0.3Vcc (aka 0.3 * Vcc) or 1.5V and
high as >than (VIH - second row) as  0.6Vcc (aka 0.6 * Vcc) or 3.0V

With limits for how far bellow ground and above Vcc you can go.

Anything in between "floats" and gives an undefined result when read.

The xVcc notation instead of x * Vcc has been known to cause problems.

This is nowhere near dlloyd 's figures
Quote
Researching this forum, most replies mention 0.3Vcc for LOW (logic 0) and 0.6Vcc for HIGH (logic 1).
Mark

PS The datasheet link in the Uno's documentation  no long works (Atmel have moved and rewritten the datasheet.)

M

Delta_G

OK, I'm either misunderstanding your previous post or this one.  You quote here low is less than 0.3 * Vcc and high is greater than 0.6 * Vcc.  Which is exactly the same levels you just said were wrong (in all caps). 

 
PS The datasheet link in the Uno's documentation  no long works (Atmel have moved and rewritten the datasheet.)
Yeah, I noticed.  That's why I came back and linked to the current one. 


You know, in math when we write 0.6x it means the same as 0.6 * x.  Without the * is, by the way, exactly how it is written in the datasheet. 

|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

dlloyd

Quote
Anything in between "floats" and gives an undefined result when read.
Incorrect. It's always defined.

Within the hysteresis region:
  • the result is 1 if previously above the hysteresis region
  • the result is 0 if previously below the hysteresis region

Delta_G

Or were you thinking he was saying 0.3 volts and 0.6 volts?  I don't think that is what he meant at all.  I think he meant just what he wrote, 0.3Vcc (1.5V for 5V supply) and 0.6Vcc (3.0V for 5V supply).
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

Jiggy-Ninja

#10
Feb 02, 2017, 06:10 am Last Edit: Feb 02, 2017, 06:11 am by Jiggy-Ninja
Incorrect. It's always defined.

Within the hysteresis region:
  • the result is 1 if previously above the hysteresis region
  • the result is 0 if previously below the hysteresis region

For the sake of others, I am compelled to point out that this is only true because the AVRs have a Schmitt triggers on the digital inputs, which can be seen in the GPIO diagram in the dataheet. This is not generally true for other digital chips, you must consult the individual datasheet to figure out what features the digital inputs have. For pins without a Schmitt trigger, metastability will be a very real problem.
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

dlloyd

Thanks holmes4, Delta_G, Jiggy-Ninja (for pointing out the latest datasheet). I see the re-write is a lot more detailed.  I like the addition of "Figure 33-27. I/O Pin Input Hysteresis vs. VCC" The older version didn't have this. I may need to re-visit and do more testing, as I was getting 0.25V hysteresis but the new graph shows about 0.53V

Delta_G

I still want to know how this:

low as < than (VIL - first row) as 0.3Vcc (aka 0.3 * Vcc) or 1.5V and
high as >than (VIH - second row) as  0.6Vcc (aka 0.6 * Vcc) or 3.0V
is nowhere near this:
Researching this forum, most replies mention 0.3Vcc for LOW (logic 0) and 0.6Vcc for HIGH (logic 1).
Let me cut that down more.  @holmes4 is contending that

0.3Vcc
is nowhere near
0.3Vcc
and

0.6Vcc
is nowhere near
0.6Vcc
It looks like exactly the same thing to me.  Even stated in the same way. 

@holmes4 --  Where's the difference?


|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

dlloyd

I'll do a more accurate test at higher precision (12-bit) using an Arduino Due to generate a slow triangle wave with 20µs step interval. On the Uno, this should give time to read pin 2 and output the result on pin 13. Hopefully the results will closely match the 3 graphs mentioned in reply#2. The Due can only output 1/6 to 5/6 of 3.3V (0.55V to 2.75V) ... should be enough to cross the thresholds.


dlloyd

Results:








                     VCC     Volts   Volts (Datasheet Page 391)
Input low voltage    5.098   2.32    2.15  (Figure 33-26)
Hysteresis           5.103   0.36    0.55  (Figure 33-27)
Input high voltage   5.108   2.68    2.70  (Figure 33-25)

Using the datasheet graphs with VCC = 5V,

the threshold levels of 2.15V and 2.7V are much more accurate than using 1.5V and 3.0V (0.3*VCC and 0.6*VCC).

Go Up