Teensy 3.6 ADC documentation

Status
Not open for further replies.

aaaxon

Active member
Sorry, I know I have seen info on this in the past, but search does not seem to find it today:

What are the options for analogReference() on the Teensy 3.6?

Also, is there a source for updated details on ADC pins on the Teensy 3.6?

It is very hard to navigate the ADC documentation for Teensydunio then the 100's of posts on what is apparently an alternative ADC library for the 3.0/3.1, then decide how to apply this to the 3.6. At this point, I can't tell which commands should be used or what options I have.
 
void analogReference(type), void analogReadRes(bits) and int analogRead(pin) will work in ever case, since they are in the core files, no library needed.

Set type=0 for reference=VCC, type=1 for reference=internal (1.2V)

The other functions are self explaining. Everything can be found in the analog.c file in the core directory. A search for "defined(__MK66FX1M0__)" inside that file will point you towards the T3.6 specifics.

The exact analog pin configuration is in the pins_arduino.h file. Another search for "defined(__MK66FX1M0__)" inside that file will point you towards the T3.6 specifics.
 
I agree with Theremingeieur about the best place to find a lot of this information is with the sources. Another place I always suggest is the hardware reference manual, which you can download from:
https://www.pjrc.com/teensy/datasheets.html

Also to see exactly which IO pins do what on the T3.6 I often use my excel spreadsheet, which like many things there are links to on posting #8 in the K66 beta thread: https://forum.pjrc.com/threads/34808-K66-Beta-Test?p=106291&viewfull=1#post106291

The above document, I wen through the pins_arduino.h to figure out which physical pin connects to a Teensy pin, then I extracted the pin information from the K66 document.
For example pin 14(A0) you see
14 PTD1 ADC0_SE5b ADC0_SE5b PTD1 SPI0_SCK UART2_CTS_b FTM3_CH1 FB_CS0_b

So it uses ADC0 with channel 5...
 
Help! Theremingenieur suggests using this statement:-

void analogReference(type), void analogReadRes(bits) and int analogRead(pin) will work in ever case, since they are in the core files, no library needed.

Set type=0 for reference=VCC, type=1 for reference=internal (1.2V)

to select the AREF voltage. However, in Pedvide's examples the "new" format is given as adc->setReference(ADC_REFERENCE::REF_1V2, ADC_0);. I have tried both because Pedvide's command does not appear to reduce the voltage on AREF to 1.2V - it remains 3.3V. I also get an error message
analogSYNCarray:11: error: variable or field 'analogReference' declared void
using Theremingenieur's suggested command, probably because I'm not sure where it should be used or whether it should be alongside Pedvide's.
 
Last edited:
ADC Vref hardware issue

If you see an error in the ADC library, please post it here: https://github.com/pedvide/ADC/issues
My problem is with the T3.6 hardware.

I am trying to install a buffer preamp (MCP602 datasheet fig. 4-11) for the T3.6 ADC using the same 3.3V supply as the T3.6. I had assumed that pin AREF outputs the Vref but it has 3.3V on it at all times, including when using the code:

adc->setReference(ADC_REFERENCE::REF_EXT, ADC_0); etc.

This value cannot be used to offset the signal to the ADC from the single supply preamp. A lower value, about 3.3V/2 is necessary.

Pedvide's ADC.h file specifies that the AREF pin should be used to input external Vref voltages but I cannot do so - AREF remains at about 3V when I try to impose a smaller external voltage. I am currently unable to find the internally-generated Vref when it is specified as 1.2V (the AREF stays at 3.3V), nor can I input an external Vref of my preferred value; 1.6V. So I have two questions: is pin AREF where the internally generated Vref values are outputted on the T3.6 and should it alternatively accept an external Vref using the code line above? Secondly, are other pins used for these purposes on the T3.6?
 
I've never used AREF, but I can tell you that, as far as I know, it's an input only pin. You need to provide enough current at your desired voltage though, I'm not sure how many mA are needed. Perhaps you source at 1.6 V has too much impedance? When AREF is not connected to anything, it floats to 3.3 V, as it's connected to it with a 470 Ohm resistor, I imagine your external source needs to have a lower impedance that that.

I don't think there's an external pin connected to the 1.2V reference, I think it's a completely ADC-internal part.

If you need a lower voltage as reference you can use the 1.2V source with adc->setReference(ADC_REFERENCE::REF_1V2, ADC_0), but you won't have access to it I think.
Otherwise you need a external reference with a low enough impedance and connect it to AREF and use adc->setReference(ADC_REFERENCE::REF_EXT, ADC_0)
 
I've never used AREF, but I can tell you that, as far as I know, it's an input only pin. You need to provide enough current at your desired voltage though, I'm not sure how many mA are needed. Perhaps you source at 1.6 V has too much impedance? When AREF is not connected to anything, it floats to 3.3 V, as it's connected to it with a 470 Ohm resistor, I imagine your external source needs to have a lower impedance that that.

I don't think there's an external pin connected to the 1.2V reference, I think it's a completely ADC-internal part.

If you need a lower voltage as reference you can use the 1.2V source with adc->setReference(ADC_REFERENCE::REF_1V2, ADC_0), but you won't have access to it I think.
Otherwise you need a external reference with a low enough impedance and connect it to AREF and use adc->setReference(ADC_REFERENCE::REF_EXT, ADC_0)

Thanks for the advice (and Shinji). I now have a working preamp using the INA114 with an external Vref. Now for some data.
 
I agree with Theremingeieur about the best place to find a lot of this information is with the sources. Another place I always suggest is the hardware reference manual, which you can download from:
https://www.pjrc.com/teensy/datasheets.html

I'm still confused. Is Pedvide's ADC library stable with the 3.6? (The thread I see in this forum does not mention the 3.6.) If so, does it require a library call to use it with the 3.6, or has it been included in the basic Teensyduino for the 3.6?

I'd prefer not to use an external ADC library because there is no way to know how long or how actively any library will be supported by its author. Where do I look to find documentation for only the ADC commands that are native to plain vanilla Teensyduino for the 3.6?

Thanks,
Michael
 
I'm still confused. Is Pedvide's ADC library stable with the 3.6? (The thread I see in this forum does not mention the 3.6.) If so, does it require a library call to use it with the 3.6, or has it been included in the basic Teensyduino for the 3.6?

I'd prefer not to use an external ADC library because there is no way to know how long or how actively any library will be supported by its author. Where do I look to find documentation for only the ADC commands that are native to plain vanilla Teensyduino for the 3.6?

Thanks,
Michael[/QUOTE]

I have found most information in the lengthy forum thread "ADC library update, now with support for Teensy 3.1" started in 2014 by Pedvide. I think a new thread started recently as well. His github page (https://github.com/pedvide/ADC) has all the software. The ADC.h and other files can be read and are full of advice. If you get the latest Teensyduino installed, and install Pedvide's latest ADC package (make sure you remove any previous ADC library first) you also have access to several ADC examples with advice embedded within them telling you which work with particular versions of the T3.* boards, particularly 3.5 and 3.6. You can also clone/download the examples direct from the github page by selecting "examples" and then pressing the "Clone or Download" button. That's as far as I have got for documentation. I have found it easier to work with the single ended inputs on A9 and A3, rather than the differential inputs, on the T3.6. I am still working on a low impedance signal source to get the best performance and have been amazed by the ADC's speed. I use a clock speed of 24MHz and small (a few microsecs) delays between acquisitions so to not get successive identical values. The averaging is no use to me - it just averages n adjacent values and then spews them out to fill all the n acquisitions with those identical, average, values.
 
aaaxon, The ADC library is fully stable with Teensy 3.5 and 3.6. Of course there may be bugs, like in all software. Thankfully many people use it and report them.

You're right that nobody can guarantee that I'll keep working on it for ever, but of course, being open source, if you download the library and it works for you then there's no maintenance necessary! It's yours now and forever.

If you only need simple single-ended conversion and no continuous mode or other features, then by all means use the core analog functions, you can find all of them in analog.c
If you want to use the ADC library, then read the first page of https://forum.pjrc.com/threads/25532-ADC-library-update-now-with-support-for-Teensy-3-1
Then there's the documentation in the library itself, the examples, and finally the source code.
 
Status
Not open for further replies.
Back
Top