Leonardo Digital Pins Flip at 1.5/1.6 volts, not 2.4/2.5 like the uno!

So, I was playing with a Leonardo (it has it uses) and discovered even though the analog pins are referencing 5 volts, the digital pins switch states at 1.5 to 1.6 volts which is 3.3 volt processor behavior. So, what do we have here? Some kind of wild hybrid cross between a 3.3 and a 5 volt processor? Is there a way to make the digitals switch at 2.4 to 2.5 volts like an Uno (or to date myself, my favorite Duemilanove)? Haven't read about this behavior in any of the Leonardo write-ups.

elmerfudd:
So, I was playing with a Leonardo (it has it uses) and discovered even though the analog pins are referencing 5 volts, **the digital pins switch states at 1.5 to 1.6 volts which is 3.3 volt processor behavior. ** So, what do we have here? Some kind of wild hybrid cross between a 3.3 and a 5 volt processor? Is there a way to make the digitals switch at 2.4 to 2.5 volts like an Uno (or to date myself, my favorite Duemilanove)? Haven't read about this behavior in any of the Leonardo write-ups.

Well the Atmel datasheet for the device will show what the 'legal' digital switching voltage are, and that is all one can go by. Section 29.2 covers the electrical specifications. The analog default reference will be whatever the Vcc operating voltage of the chip is, so a Leonardo will have a 0-5vdc analog input range.

Thanks lefty for linking the data sheet that we all love to read because it is SO clear, but that is not the point. If I'm working with a 5 v processor I expect the digitals to switch at somewhere close to half voltage. We're talking common-sense here. Leonardo is part of the 5v Arduino family. If Leonardo is an odd cousin, then that eccentric behavior needs to be communicated and accepted by all. I believe my bench top analysis is correct. If it is, it should be added as a note on the Arduino hardware page.

According to the Atmega32U4 datasheet the minimum voltage at which (most) pins are guaranteed to read HIGH is:

0.2Vcc + 0.9V

So in a 5V system that would be 1.9V.

On the Atmega328P it is:

0.6Vcc (if Vcc >= 2.4V)

So that is 3.0V on a 5V system.

The maximum for reading LOW on the Atmega32u4 is:

0.2Vcc - 0.1V

So, 0.9V to guarantee LOW on a 5V system

On the Atmega328P it is:

0.3Vcc

So that is 1.5V on a 5V system.

To summarise:

Atmega328P: 0 to 1.5 = LOW,  3.0 to 5 = HIGH
Atmega32u4: 0 to 0.9 = LOW,  1.9 to 5 = HIGH

Yes, they are different. But you shouldn't really be trying to use digital inputs as a sort of analog comparator. The margins they give there give some sort of allowance that in an ideal world 0V probably isn't quite zero, and 5V probably isn't quite 5V.

I expect the digitals to switch at somewhere close to half voltage

On the Atmega328P the behaviour at 2.5V is undefined, so I wouldn't be relying on that anyway.

Thanks. That is very enlightening, but again, the Arduino family is aimed at the novice and can be used by the expert. Let's make sure these discrepancies are clearly advertised, or a beginners project could lead to frustration instead of joyous discovery. I can see a program relying on an interrupt failing miserably without this knowledge.

Discrepancies between what and what? Where does the page(s) for the Uno/Duemilanove state that it switches between HIGH and LOW "at about 2.5V"?

Digital reads are supposed to read LOW at or about 0V, and HIGH at or about 5V. They both do that. There is an undefined area in between. It differs between processors. The exact area probably differs between different chips due to manufacturing tolerances, and other things like the temperature.

I can see a program relying on an interrupt failing miserably without this knowledge.

I can't. I use interrupts a lot, and never rely upon the exact voltage. I assume that HIGH requires around 5V, and low around 0V.

"I can't. I use interrupts a lot, and never rely upon the exact voltage. I assume that HIGH requires around 5V, and low around 0V."

You have an interesting bunch of sensors in your drawer! Mine are quite different from yours and each other.

Thanks for your insight. I think something aimed at beginners should work in a consistent fashion or state the differences (without forcing the newbie to crack open a microprocessor tome), so apparently we see things differently, and that's fine. Now if someone searches this forum they will see a difference that may be important to their project between a UNO/Duemilanova and the Leonardo. Case closed. I appreciate your reply.

elmerfudd:
If I'm working with a 5 v processor I expect the digitals to switch at somewhere close to half voltage. We're talking common-sense here.

maybe in the old days of 4000 series cmos and rca cosmac processors. with modern day move to 3.3v microcontrollers and logic virtually complete and 1.8v devices well on their way, a lower threshold voltage is a step in the right direction. considering the rube goldberg level conversion schemes many hobbyists (and some professionals) come up with, lower switching voltage sounds like an improvement to me. its amazing the complicated and expensive transistor/zener kluges people use when a simple 1k resistor will often suffice.

A digital pin should be fed with a voltage near Vcc for high and a voltage near Gnd for low. If you have sensors that don't provide that sort of signal, perhaps they are not intended for connection to digital logic without additional signal conditioning. Do you have a specific example of a sensor where the change in switching levels causes problems?

The "novice definition" is low = 0, high = vcc. You won't have any problems if that's what you aim for...

Traditionally, (real) TTL logic wants zero below .8V and high above 2V, while CMOS has a switching point closer to the middle of the supply voltage. The new switching levels are more compatible with TTL, and more compatible with lower-voltage external components (3.3V logic, for instance.) I think I like the new levels!

Perhaps that is so, your "Sensor Issues" but it sounds more like you didn't read the data sheet first and instead Assume'd it followed your preconceptions for what 5V logic should do.
old carpenters maxim "Read Twice, Cut once"...measure or read it's all the same...
It's the attention to detail that is the difference between wearing short or long pants in the Electronics Industry.

Bob