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

Thread: Teensy 3.6 ADC Speed and multiple analog signals

  1. #1
    Junior Member
    Join Date
    Mar 2019
    Posts
    3

    Teensy 3.6 ADC Speed and multiple analog signals

    Hello,

    I am rather new to microcontroller programming and electronics in general and would be very grateful for some help with a project I am working on.

    I'm sorry if all if that has already been answered elsewhere, maybe I didn't search for the right terms.

    I have three analog signals that I have to read with a frequency of about 10 kHz and a 12 bit resolution and I am worried about the time all of that takes.

    For two signals, I should be able to use the two ADCs on the Teensy 3.6 to have two simultaneous conversions, right? But how simultaneous is that really? I always assumed that commands in the code were done sequentially. If I write two analogReads for different ADCs directly after one another, would the program wait the multiple clock cycles that the first conversion takes before initiating the second, or would the second one be started directly after the first, with their results coming in almost at the same time?

    For the third signal, I would have to use another pin of an ADC that already converted one of the other two signals. Is that the fastest way to get all three signals or am I missing a better possibility I am missing? I have to do some calculations with the signals before the next ones come in and would love to spend as few clock cycles as possible on the signal reading.

    Thanks to everyone in advance!

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,277
    The "simple" analogRead() function is blocking. That means, code execution will only continue after the conversion is done and the result returned. That is ok for occasional readings but not for continuous sampling with precise timing.

    You should consider looking at the ADC library, contributed by forum member Pedvide, which allows doing continuous multiple channel sampling in the background and to trigger either an interrupt or a DMA transfer when a reading sequence is fully accomplished or when the buffer is full. This allows to do your calculations with the previous readings while the new ones are acquired in the background.

  3. #3
    Junior Member
    Join Date
    Mar 2019
    Posts
    3
    Thank you for your response. I had already found Pedvide's library you mentioned, but it seems I haven't read it properly. I'll look through the documentation more thoroughly.
    So in continuous mode I could basically set some kind of 10 kHz timer and read the values currently stored in the ADCs, even on multiple channels? In the case of two signals on different pins of the same ADC, the conversions would still be done sequentially, correct?

  4. #4
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,277
    Yes and yes. You might also look for inspiration at the source code of the analog input objects in the audio library. Here, the PDB is used to trigger timed conversions (44.1kHz) with high precision.

  5. #5
    Junior Member
    Join Date
    Mar 2019
    Posts
    3
    Thank you again, I will look into that.

Posting Permissions

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