Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 18 of 18

Thread: Teensy 3.1 analog inputs - explanation

  1. #1

    Teensy 3.1 analog inputs - explanation

    Hi!

    I'm making MIDI drums with about 20 piezo sensors. Teensy 3.1 have 21 analog inputs.

    I don't understand part of pinout diagram:
    A18 = A0
    A19 = A1
    A20 = A2

    I will be grateful if someone can explain me that.
    Also, should I use Zener (3.3 V) in parallel with the piezo or just 1 MOhm resistor?

  2. #2
    Senior Member
    Join Date
    Aug 2014
    Posts
    125
    I think you are confused when you look the top pin out and the bottom pinout.

    The top pinout is for the headers, that most of the time you would usually solder male pin headers.

    Click image for larger version. 

Name:	teensy31_front_pinout.png 
Views:	378 
Size:	164.4 KB 
ID:	3553

    The bottom pinout is for the pads (on the middle of the board), you can solder wires to it or use a breakout board to access it.

    Click image for larger version. 

Name:	teensy31_back_pinout.png 
Views:	940 
Size:	125.9 KB 
ID:	3554

    I never played with piezo sensors so I can not help you with that question.

    Vitor Henrique

  3. #3
    Thank you Vitor Henrique!

  4. #4
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    486
    If you hit the piezo hard, it can generate quite high voltages. It is unlikely these can have enough energy to damage the Teensy, but either a 1 Meg in series or a zener in parallel would work. The risk with the zener is that if the Teensy isn't powered up, impulses still get through to the IC.

  5. #5
    Wait, 1 MOhm in series? I found on the Internet something like this:

    http://pablotrigo.com/blog/wp-conten.../09/Filter.jpg

    Also, I found something like this:

    http://www.rossbencina.com/static/co...ezocircuit.gif

    What is better? Thanks in advance!

  6. #6
    Senior Member
    Join Date
    Jan 2015
    Location
    frisia
    Posts
    285
    With a series resistor, you essentially use the internal ESD protection diodes for clamping. The resistor just acts as a current limiting resistor, albeit that 1 Meg is a bit on the safe side.
    The resistor divider in the second picture has the same effect.
    The first picture is really clamping it externally. The schematic however was made for a 5V circuit (5.1V zener diode). You need to adjust it to 3.3V.
    I do not know the resistance of your piezo, but assuming say 500 ohm, a 1uF capacitor would give a bandwidth of only 300 Hz. Depending on your piezo resistance you might want to lower this capacitor 1 or 2 decades. Furthermore, I personally would still put a series resistor of say 10k between the first circuit and the teensy input. Just as a second layer of protection towards the teensy. The clamping of the zener as a first layer. Than the internal esd diodes with the 10k resistor as a second layer

    Edit: Or as Jp3141 said, a series resistor also protects when the teensy is off.
    Last edited by kpc; 02-17-2015 at 05:56 PM.

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,468
    Your point about the series resistor is good, but 1K should be plenty of impedance. Using 1M might work, but that's such a high impedance that problems are very likely.

  8. #8
    Senior Member
    Join Date
    Jan 2015
    Location
    frisia
    Posts
    285
    Just to be clear: I was being sarcastic when I said
    1 Meg is a bit on the safe side.

  9. #9
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    14,433
    I saved this v3.1 Analog Pinout card (source?) that has more pixels and info with a focus on Analog. It shows alternate names as show in the K20 reference.

    This may help here as well - I'm looking at this hoping to find a 16bit analog read pin so I can listen to sound with INMP401 a 1,000 times a second more or less to detect events - may end up doing FFT to see frequencies and not just peaks if I need to.

    Hopefully I've interpreted these pins right and these are 16bits on the Teensy Hardware [the square braces are my reading of the attached image]?
    K20 Chip pins 6.6.1 ADC electrical specifications
    The 16-bit accuracy specifications listed in Table 24 and Table 25 are achievable on the differential pins ADCx_DP0 [ADC0_DP0==Pin22==A10], ADCx_DM0 [ADC1_DM0==Pin20==A13].
    Click image for larger version. 

Name:	Teensy3_1_AnalogCard.png 
Views:	722 
Size:	539.2 KB 
ID:	3569
    Last edited by defragster; 02-17-2015 at 07:20 PM.

  10. #10
    Senior Member
    Join Date
    Jan 2015
    Location
    frisia
    Posts
    285
    I checked the clamping diodes an unfortunately(?) there is no positive clamping diode on digital pins. So you should add this yourself.
    https://www.pjrc.com/teensy/K20P64M72SF1.pdf, pg. 11
    1. All 5 V tolerant digital I/O pins are internally clamped to Vss through a ESD protection diode. There is no diode connection to Vdd.
    Also the function to calculate the resistor value is given. Note that this resistor value is for a dc voltage. The limitation will be dissipation. Since a piezo will give spikes, the value of either 1k (Paul) or 10k (me) will be more than sufficient. I did not calculate the datasheet value yet.

  11. #11
    The resistance of my piezo is 500 Ohm.

    Can you draw me schematic you assume that could work?

  12. #12
    Senior Member
    Join Date
    Jan 2015
    Location
    frisia
    Posts
    285
    Just basically the first image of post #5
    Code:
                             +--- 3V3
                             |
                            --
                            /\  diode
                             |
      +-----+----+--+---Rs---+--- Input
      |     |    |  |
    piezo zener  C  Rp
      |     |    |  |
      +-----+----+--+----------- GND
    The C is always good as a bandwidth limitation
    f-3db = 1/(2*pi*R*C), where R = 500, so C o.o.m. 10n
    Rs = 1k...10k
    Rp is to define the potential at the input, either >> 500. Or use a smaller value in case you need attenuation

    instead of the secon diode, you could also put a second zener between input and gnd
    Edit: Oops, sorry no protection in off state disregard this remark
    Last edited by kpc; 02-17-2015 at 07:44 PM.

  13. #13
    Many thanks!

  14. #14
    Senior Member
    Join Date
    Oct 2012
    Location
    Portland OR
    Posts
    706
    Quote Originally Posted by defragster View Post
    I'm looking at this hoping to find a 16bit analog read pin so I can listen to sound with INMP401 a 1,000 times a second more or less to detect events - may end up doing FFT to see frequencies and not just peaks if I need to.
    Hopefully I've interpreted these pins right and these are 16bits on the Teensy Hardware [the square braces are my reading of the attached image]?
    What the datasheet claims and what the chip delivers are not always the same thing :-). Paul has always been careful to claim only 13 bits of ADC resolution for Teensy 3/3.1. My old measurements of Teensy 3.0 ADC resolution in single-ended mode are here: http://dangerousprototypes.com/forum...php?f=2&t=4606

  15. #15
    Senior Member
    Join Date
    Jan 2015
    Location
    frisia
    Posts
    285
    Actually if you read the datasheet carefully, a minimum SFDR of 78 dB is specified. Assuming SFDR is approximately SINAD, the effective number of bits is 12.7. So Pauls claim is in fact exactly what is stated in the datasheet.

  16. #16
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    14,433
    Good Info, Thanks. 12.7 will be good - but if 16 were sitting there no sense in picking the wrong pin.

    read the datasheet carefully
    I thought I was doing good to find that in the 67 page manual - also glad for the msg#9 linked image associating the names with pins - those quoted notes and SFDR don't even show in search of the 1377 page RM. Thanks for decoding the 'Min. 78 dB' in that 'table 25' (Typ. is 90 dB) as 12.7 bits. For differential mode if I put ground on one pin and signal on the other would that push me to Min. 82 dB and Typ. is 95 dB? I have the pins to use - and my Analog Mic device will be mounted on/near the Teensy. This doesn't help the OP with 20 inputs and 21 analog pins and a longer run to a drum set.

    I've read many of the web pjrc.com notes looking to find v3.1 info - they are so blended across versions with most exceptions and details focused on the v3.0 or before that some v3.1 details are not apparent when they are the same or better.

    This where were I got the Analog pinout detail - and more to read on the thread for ADC library details.https://forum.pjrc.com/threads/25532...for-Teensy-3-1
    Last edited by defragster; 02-18-2015 at 12:50 AM. Reason: add ptr to ADC thread

  17. #17
    Senior Member
    Join Date
    Jan 2015
    Location
    frisia
    Posts
    285
    The improved dynamic range of the differential mode comes from the fact that most spurious due eg. crosstalk and ground bounce is common mode. Futhermore it helps to suppress even order intermodulation products. By grounding one pin you destroy this improvement.
    If you have to. At least connect your source ground pin also to the ground of the differential input and not just to some ground anywhere. Preferably with the 'differential ground' connected to the 0V by a resistor with the same resistance as the source impedance.

    Edit: When I read this back it is some what fague.
    The idea is to run one ground wire from the teensy 0V to your source -. Then run a wire from the + of your source back to the teensy ADC+. Also run another ground wire from the - of your source to the ADC- of the teensy. Preferably this last wire should have a resistor equal to the source impedance in series, placed close at the source -. Keep at least the wires connected to the ADC+ and - close together. From a low frequency perspective the two 'ground' wires (the ones connected to 0V and ADC-) seem to have the same voltage, but due to all kinds of parasitic coupling effects this is not the case. (FYI. I design circuits up to 120 GHz for my day job).

    Oops should have read better
    my Analog Mic device will be mounted on/near the Teensy
    Last edited by kpc; 02-18-2015 at 01:46 AM.

  18. #18
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    14,433
    Good call - I was forgetting the pins are "VCC/GND/AUD" - it is a single ended output. The Sparkfun breakout seems to implement the need support hardware. Again just wanted to have the best pin I could since I have my pick - there is a 24bit I2S version just days in the future from @onehorse.
    Last edited by defragster; 02-18-2015 at 05:03 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •