Semi obvious question. Teensy 3.0/3.1 Analog pins as Digital Inputs?

Status
Not open for further replies.

MuShoo

Well-known member
What it says on the tin! The pinout diagram that comes with Teensy 3.1 leads me to believe that A10 through A14 aren't available as digital pins (I'm assuming this means no output). But, will they work with digitalRead() somehow? Like, digitalRead(A13)? Or would I have to make my own little sub function that outputs a boolean if the analog value is over a threshold?
 
The pinout diagram that comes with Teensy 3.1 leads me to believe that A10 through A14 aren't available as digital pins

Yes, that's correct.

But, will they work with digitalRead() somehow? Like, digitalRead(A13)?

No, you can't use digitalRead with those pins. Inside the chip, those pins simply do not have the transistors needed for digital input buffers.

Or would I have to make my own little sub function that outputs a boolean if the analog value is over a threshold?

Yes, you can use analogRead(), or write your own code that reads the pin using the ADC, and then implement a threshold in software.
 
Also, please keep in mind the analog-only pins are NOT 5 volt tolerant.

Only the pins with digital functions have 5V tolerant input circuitry. The pins with both digital and analog functions are 5V tolerant even when configured in analog mode. Of course, the full scale analog range is either 3.3V or 1.2V, so this doesn't let you actually read 3.3V to 5.0V signals as analog, but you can safely apply up to 5.0V, even if the pin isn't in a digital mode.

The analog-only pins do not have 5V tolerance, so they should never be driven with more than 3.3V.

Only Teensy 3.1 has 5V tolerance on the digital-capable pins. Teensy 3.0 is not 5V tolerant on any I/O pins.
 
Oops! This thread helped me diagnose my code. I was mistaken because I believe arduino mega analog pins can read at digitalRead() and I was running off that old experience.

Anyway, analogread at 8-bit and 10-bit is plenty fast enough for my application, even though I then need to compare that value to a threshold.

Thanks for the thread OP! Solved my problem.
 
EDIT:

New question:

Here you seem to indicate all the analog pins are not-digital pins. However, elsewhere on the forums you just phrase it <<Like the analog only pins on the teensy 3.1, A10 and A11>> which suggests only some of the analog pins on the teensy are analog-only. Could anyone confirm that all of the analog pins on the 3.1 are analog-only?
 
In the Teensy 3.1, pins A0..A9 and A15..A20 can be used for either digital input, digital output, or analog input operations. In addition A6..A9 can be used for PWM (aka analogWrite), and pins A1 .. A5 and A8/A9 can be used for touch input. These pins are 5v tolerant for digital input. If you give it voltage > 3.3v, an analog read will return 1,023 just the same as reading 3.3v. Pins A10 .. A14 cannot be use for digital input or output, only analog input and you must not feed it voltage > 3.3v. In addition, pin A14 can be used for true analog output (using the analogWrite function also). This is a true digital to analog conversion, and not repeated on/off's like the PWM pins use.

The Teensy 3.0 is similar, except none of the pins are 5v tolerant. The underneath pads that A15..A20 are on the Teensy 3.1 are not analog input pins on the Teensy 3.0, just digital pins. What is A14 on the Teensy 3.1 is the reset action on the Teensy 3.0.

I wrote this spreadsheet so I could more easily keep track of the pin capabilities of various microprocessors: https://docs.google.com/spreadsheet/ccc?key=0AqMAmYxHItUAdDdlcURnY1NRRlFfLWdIbkdWamxfckE#gid=0.
 
Last edited:
The guidelines for use of the Teensy 3 are numerous and seemingly nowhere consolidated. This good spreadsheet (above posting) is a good example of so much valuable information on T3 that is posted, and not consolidated. So people keep asking the same questions again and again. And no doubt a lot of hours are wasted among users.

It would be so beneficial if PJRC could take a breath and correct this, for the benefit of many. Especially in the user and PJRC authored libraries, where they are (Teensyduino vs. github vs forum posting enclosures).
Perhaps after 1.20 it's time to stop developing for a bit and document so that people can know what exists, where it is, and how to use it.
 
The problem of course is multifacted.

One, it is likely no one wants paul to stop developing. The success of Teensy is dominantly the fact it's so well supported (and I'm sure a number of the behind-the-scenes things I'm [general random person] not privy to.) There are other Arm-32 platforms, but none I've seen as well done as teensy. He also has two or three major and very interesting projects going on (low-cost ARM teensy, teensy 3.1++, and apparently NDA processor teensy board, though it may be that those represent 2 projects not 3. I dont remember if there is overlap.)

Two, it's not easy to get someone to document things, because it does take a thorough and expensive understanding of the situation to properly document things. I say expensive because I don't think your average out-of-college ECE understands all of this stuff, and I think a lot of it does take an engineering background to know. So we're looking at experienced ECEs for some things, or a way of apportioning work to those who know enough (so a team of people, or a well designed crowd-sourcing of information.)

Three, it seems unlikely that Paul's talents lie BOTH in development, AND, in an inclination to thoroughly document things. I'm certain he *can* do it, but I question how interested he would be past the bare necessities.

I'm not sure what the solution is, though. There are some efforts to consolidate things (there's thread here somewhere that's something like "the best posts" kind of thread. A collection of links to common posts, details, and what not.) But they're not perfect.

Anyway, I'm spitting hot air.I think what you said has serious merit, I just pointed out the downsides too. Oi.
 
Last edited:
It is true, I develop a lot of stuff where the documentation lags by months, sometimes even years.

But documentation is tricky. A perfect example would be the versions of Arduino the Teensyduino installer supports. Often people have complained this wasn't documented, when they couldn't get the "Next" button to enable. Of course, it's pretty plainly documented on the download page and also on the installer's first screen. The trouble was people simply didn't see the info in those locations. This has been on my TO-DO list for a long time, and finally in 1.20-rc5, I added a help button beside the "Next" button. It's still too early to know how effective that little "?" button will be, but my hope is it will finally solve this long-standing "documentation" problem.

Likewise, with the specific question on this thread, design of the pinout card is tricky. On Teensy 3.1, that card has now on it's 7th revision. It's difficult process, to balance the need for detailed information without causing "information overload". Even from the OP, the card at least gave the general idea that A10-A14 don't have digitalRead() capability, so even if it wasn't perfectly clear, it seems to be on the right track.

For more than 10 years, even back in the height of the 8051 days, I've dreamed of someday doing actual usability testing, where we get people to come to a conference room and watch them (fail to) use the website and product, and hopefully gain some insights. I even bought a few books, and (a couple years ago) loaned the best one to a friend who we were going to pay to help us do this. But that was shortly before Teensy 3.0, when there wasn't a mountain of awesome hardware features in need for software support.

Lately, website updates have slipped, mainly due to so much work on the Teensy Audio Library. I know Steve isn't terribly interested in audio, but many people are. I am. It's been a long-time dream of mine to write this library. In fact, one of the reasons I went with the Freescale chip (rather than the only other chips available 3-4 years ago, from NXP and Atmel and Luminary Micro) was because Freescale had DMA and I2S. Even the audio library, with probably more comprehensive documentation than most other things I've written, is _still_ in need of introductory a couple videos. Detailed documentation isn't enough.

So, the best I can tell you is I really do care about this stuff. I'm aware documentation is lacking, and I'm also very aware that some of the stuff that is well documented isn't found when or where people need it. I do intend to work on these issues. I also am working on two more Teensy 3.x models, which I really want to get released this year. Ultimately, there's only so many hours in every day and far more to do than will ever get completely finished... but I'm trying!
 
Real problem is, lots of people don't know that wonderful new libraries and how-to's and other even exist.
It's a shame if good things don't benefit users simply because the existence of the things isn't known. Or reasonably easy to search/find.

I truly don't want to preach, but as a young engineer, it was impressed upon me that engineering isn't engineering unless others can reproduce and use what you've designed.
Not about library du jour - audio - but month to month, quarter to quarter, the intrigue changes.

Is there a way to carve out some dollars or find some good gratis intern / student that can help? Step one is simply creating a single indexed place to know what exists and what it does.
Maybe get into the habit of putting minimal doxygen comments in the code. But that's 2nd priority to just indexing what exists and where it is, and avoid wandering trails of forum posts and disjointed tidbits all on the same thing.

Many people would benefit from a brief time-out after audio is released, to correct this problem.
 
Last edited:
Here's a hopefully-simple-to-implement thought about the issue of documentation. I know there's been talk about a wiki, but not much progress has been made on it for various reasons, including the ones you listed above, Paul.

What about another subforum, simply called "Tutorials" or 'Community Documentation?' Either give a few of the very tech savvy members on here some sort of mod-powers just to that forum (IE, moving threads out of it if they're not tutorial based, maybe approving threads before they're posted or something) if they're interested, and you and Robin probably don't want to have to be mods on something like that. Basically a place for people to post small code tidbits that show interesting features or pitfalls they've discovered along the way. Eventually, when there's enough tutorials and whatnot in the subforum, it can be split into chunks and a bit more organized (IE, "Audio Board tutorials," "USB Device Type tutorials," "PWM Tutorials," "Serial/I2C/SPI Tutorials" etc etc etc.

I'm thinking essentially something like the Adafruit learning system, only all the tutorials are user-created, and live on the forums where they'll show up on searches and the like.

One other thing - it's becoming a growing frustration with me on various forums these days - I know there's very good reasons to only allow search terms that are greater than a certain number of characters, but not being able to search for "SPI," "USB," or "I2C" (system throws a 'no results found' error) is a bit of problem. I don't think this forum does the 'that search term appears too often' (try searching for 'dual extruder' on the lulzbot forums to see what I mean) error, but that one is equally frustrating.
 
Also, please keep in mind the analog-only pins are NOT 5 volt tolerant.

Only the pins with digital functions have 5V tolerant input circuitry. The pins with both digital and analog functions are 5V tolerant even when configured in analog mode. Of course, the full scale analog range is either 3.3V or 1.2V, so this doesn't let you actually read 3.3V to 5.0V signals as analog, but you can safely apply up to 5.0V, even if the pin isn't in a digital mode.

The analog-only pins do not have 5V tolerance, so they should never be driven with more than 3.3V.

Only Teensy 3.1 has 5V tolerance on the digital-capable pins. Teensy 3.0 is not 5V tolerant on any I/O pins.

By mistake, I gave A10 5V - and the pin seems to be alright. Given 5V, it returns 1023 to analogRead(A10) which is ok with me. Will the pin «break» over time? Thanks for clearing the electronics behind analog only pin A10. Dani
 
Status
Not open for further replies.
Back
Top