Multi-channel Fast Analogue Capture and Stream

Bunter

New member
Hi All,

I'm new here and would be grateful for advice please. I want to develop a system that can do the following: capture up to four ADC samples concurrently and at up to about 200 kHz sample rate. When I say concurrent, I'd ideally like absolutely synchronous sampling, but a gap of significantly less than the sample interval (sub microsecond) would be OK. I would ideally like to stream these 4 ADC streams (at 4 x 200x10^3 x 2 bytes/sample = 1.6 MBytes/s) to a host computer (Apple MacBook Pro) for further data processing.

I would ideally like these captures to be semi-continuous, i.e. once I start capturing, I want that to continue until I stop. The captured data could either: (a) be buffered locally in Tenny-<xyz> then sent to the host MacBook in periodic bursts (e.g. double-buffering), or (b) data can be streamed continuously at the average rate at which it arrives.

I realise this is a non-trivial project, but I've a lot of experience doing this kind of thing professionally, but not on a platform such as Teeny, and this is a personal project for fun, not work.

Among the many things I'm unsure about are:
  1. Is synchronous ADC over 4 channels possible?
  2. What's the recommended way to transfer data to my host MacBook?
  3. It seems that Teeny-4 (or 4.1) is the best choice, due to the high CPU speed, or is there a better alternative?
  4. I'd prefer to develop in vanilla C or C++, is that possible, and if so can I still link with available libraries?
  5. If not using C/C++, what's the run-time performance of the script-like code examples I've seen in some YouTube videos?
  6. Any specific recommendations for the best IDE/tool-chain to use on a new MacBook with ARM CPU?
  7. Did I miss anything else? I bet I did!
Sorry to have so many questions and thank you in advance for your wisdom!
 
What is the ADC requirement: resolution, noise, voltage range, ....
If you implement an external ADC converter, it will add somme complexity in buffering all the links. But nothing impossible.
 
Hi Tu
What is the ADC requirement: resolution, noise, voltage range, ....
If you implement an external ADC converter, it will add somme complexity in buffering all the links. But nothing impossible.
I will have an external LNA and nyquist filter so the signal amplitude is under my control, target SNR is 80 dB, so 14+ bits resolution, or I can oversample and decimate if necessary.
 
Maybe something like 4 x MCP33151-10T-E/MS, being cheap 14 bit fast SPI single channel ADCs - run the 4 in parallel off SPI bus and read the 4 data lines simultaneously via port-wide operations? That would guarantee synchronous sampling. You need precisely repeated sampling intervals for any useful DSP so the SPI would need to be DMA driven I believe.

You didn't mention what voltage your signals are at, nor if you wanted single-ended or differential ADC.
 
Maybe something like 4 x MCP33151-10T-E/MS, being cheap 14 bit fast SPI single channel ADCs - run the 4 in parallel off SPI bus and read the 4 data lines simultaneously via port-wide operations? That would guarantee synchronous sampling. You need precisely repeated sampling intervals for any useful DSP so the SPI would need to be DMA driven I believe.

You didn't mention what voltage your signals are at, nor if you wanted single-ended or differential ADC.
Thanks for your reply Mark. After reading more about Teensy I decided to go with an alternative processor (STM32+DSP), and I will indeed be using a separate PCB (own design) with 4x concurrent ADCs, LNA and other signal conditioning + fast data interface etc.
 
Sounds like you might need a QSPI or parallel data interface to the ADCs. I have a system sampling 4 channels at 128ksps and 16bit with a 50MHz SPI interface, and this bus would not be able to support 200ksps. If a QSPI port can be made available on the Teensy 4/4.1 this would be very helpful to increase this throughput.
 
The Teensy 4.1 has a QSPI port exposed on the bottom side - where the memory expansion chips go.

You also have FlexIO 1/2 which can give up to 4 consecutive bits of parallel port that support DMA transfers
 
The Teensy 4.1 has a QSPI port exposed on the bottom side - where the memory expansion chips go.

You also have FlexIO 1/2 which can give up to 4 consecutive bits of parallel port that support DMA transfers
Yes Rezo, good point (I'm using this for a large RAM buffer at the moment)

Might need to go to a full custom Teensy4.1 board to get access to the FlexIO for some really high performance ADC.
 
Hi, I am also new to teensy and microcontrollers.
I am working on a uni project that requires a high synchronous sampling across two analog inputs, I am wondering if you did manage to do your project or not.
If so, could you please give me some guidelines on how I can achieve a high sampling rate while measuring synchronously. I did achieve a high sampling rate, though none of my values makes sense to me. I am always getting near constant values after conversion, I have two piezos on my analogue inputs, yet even when I hit them I still don't see any change
 
Hi Roni, we will need a bit more information to be able to assist you.

Directly connecting piezo sensors to the Teensy ADC inputs is not a great idea since Piezo devices can produce quite high voltages without suitable clamping/limiting circuitry in place. So it is possible you have damaged the ADC channels. Alternatively they may be generating very low voltages.

Don't forget they can generate a negative voltage so just hooking them up to the ADC channel without any buffering or biasing will not work well since you will not see the negative going part of the signal.

Can you hook up an alternative signal to these channels to check they are still working? eg simple dc voltage or sine wave from a signal generator etc

Regarding synchronous sampling. You will need to use an external ADC device with an ADC per channel OR one with multiple sample and hold circuits/buffers to capture all the signals at the same time.

An example part I'm using that has multiple parallel converters is: ads131M04 from TI
 
Hi Roni, we will need a bit more information to be able to assist you.

Directly connecting piezo sensors to the Teensy ADC inputs is not a great idea since Piezo devices can produce quite high voltages without suitable clamping/limiting circuitry in place. So it is possible you have damaged the ADC channels. Alternatively they may be generating very low voltages.

Don't forget they can generate a negative voltage so just hooking them up to the ADC channel without any buffering or biasing will not work well since you will not see the negative going part of the signal.

Can you hook up an alternative signal to these channels to check they are still working? eg simple dc voltage or sine wave from a signal generator etc

Regarding synchronous sampling. You will need to use an external ADC device with an ADC per channel OR one with multiple sample and hold circuits/buffers to capture all the signals at the same time.

An example part I'm using that has multiple parallel converters is: ads131M04 from TI
Thank you for your input, it is really helpful.

My setup is simple, it is made of a voltage divisor and the piezo that is hooked on the 3.1v pin, so it should be shifted by +3.1V and divided by 3.
My setup (Though I am using a Teensy 4.1 and I have the same setup for a second piezo):
1731429552590.png

I can modify it so that I always have a voltage between 0 and 5.1V.


By Alternative signal do you mean AC signal varying between 0 and 5.1V?


Could you elaborate more on this please "Regarding synchronous sampling. You will need to use an external ADC device with an ADC per channel OR one with multiple sample and hold circuits/buffers to capture all the signals at the same time."

I have no prior knowledge on ADC, I want to be able to constantly measure and write the values of both piezo simultaneously with a high sampling rate.
Again, thank you again for your help, it is much appreciated.
 
You can control the output voltage of a piezo sensor with a parallel resistor since they are current sources, not voltage sources, no need for a divider. So divide the power supply 1:1 to one wire of the sensor and connect the other to the analog input, and add a parallel resistor to the sensor to set the sensitivity. The divider resistors act as current limiters too.
 
ads131M04_block_diagram.png


The block diagram above shows an ADC chip by TI that has 4x internal ADCs which therefore allows it to sample all channels at the same time, eliminating and phase/time shift between samples.

This may be beyond what you are trying to do, I'm not sure.

The reason I suggest you inject a different signal into the ADC port on the arduino is to determine if your problem is in the firmware/configuration OR your circuit.

Based on your schematic, I think it is possible you are biasing the piezo to the point that you will not see a change in the signal. Also it is rather easy to generate high voltage spikes from these devices and damage an input.

Checkout this really well put together youtube clip on interfacing to piezo transducers and making a suitable analog interface.

Teensy 4.1 - Piezo Drum Trigger Signal Conditioner Interface (4-ch)
 
View attachment 36319

The block diagram above shows an ADC chip by TI that has 4x internal ADCs which therefore allows it to sample all channels at the same time, eliminating and phase/time shift between samples.

This may be beyond what you are trying to do, I'm not sure.

The reason I suggest you inject a different signal into the ADC port on the arduino is to determine if your problem is in the firmware/configuration OR your circuit.

Based on your schematic, I think it is possible you are biasing the piezo to the point that you will not see a change in the signal. Also it is rather easy to generate high voltage spikes from these devices and damage an input.

Checkout this really well put together youtube clip on interfacing to piezo transducers and making a suitable analog interface.

Teensy 4.1 - Piezo Drum Trigger Signal Conditioner Interface (4-ch)
Thanks for all of this info and for the video.
 
View attachment 36319

The block diagram above shows an ADC chip by TI that has 4x internal ADCs which therefore allows it to sample all channels at the same time, eliminating and phase/time shift between samples.

This may be beyond what you are trying to do, I'm not sure.

The reason I suggest you inject a different signal into the ADC port on the arduino is to determine if your problem is in the firmware/configuration OR your circuit.

Based on your schematic, I think it is possible you are biasing the piezo to the point that you will not see a change in the signal. Also it is rather easy to generate high voltage spikes from these devices and damage an input.

Checkout this really well put together youtube clip on interfacing to piezo transducers and making a suitable analog interface.

Teensy 4.1 - Piezo Drum Trigger Signal Conditioner Interface (4-ch)
I tried a couple of experiments; I think that indeed I did damage the Teensy internal ADC.

I switched temporarily to an Arduino (until I receive the new teensy), however I am having a small problem.

I used to have the piezo taped to a piece of wood and then I was able to capture a 100 Hz sine wave (audio) through it which I attached below.
1731786041584.png

Now, I changed to double sided tape beneath the piezo, and I changed the piezo due to soldiering coming off it, however I am no longer able to even detect a 100Hz voice. I am a moron for doing so many changes without constantly checking if the results are correct or not, I realized this a bit late lol.
I never had an amplifier to the piezo signal, why am I now failing to capture the signal?
I tried several piezos, and I even tried attaching it to the oscilloscope, yet I am still not able to detect the 100Hz signal coming from a speaker.
Do you have any ideas of why is this happening?
I even tried removing the voltage dividor and connecting the piezo to 3.1V followed by 1M Ohm resistor and I was measuring the voltage around the resistor.
 
Try a high value across the piezo to remove its DC offset (which is ill-defined given piezo's are basically ceramic capacitors).
 
Hi All,

I'm new here and would be grateful for advice please. I want to develop a system that can do the following: capture up to four ADC samples concurrently and at up to about 200 kHz sample rate. When I say concurrent, I'd ideally like absolutely synchronous sampling, but a gap of significantly less than the sample interval (sub microsecond) would be OK. I would ideally like to stream these 4 ADC streams (at 4 x 200x10^3 x 2 bytes/sample = 1.6 MBytes/s) to a host computer (Apple MacBook Pro) for further data processing.

I would ideally like these captures to be semi-continuous, i.e. once I start capturing, I want that to continue until I stop. The captured data could either: (a) be buffered locally in Tenny-<xyz> then sent to the host MacBook in periodic bursts (e.g. double-buffering), or (b) data can be streamed continuously at the average rate at which it arrives.

I realise this is a non-trivial project, but I've a lot of experience doing this kind of thing professionally, but not on a platform such as Teeny, and this is a personal project for fun, not work.

Among the many things I'm unsure about are:
  1. Is synchronous ADC over 4 channels possible?
  2. What's the recommended way to transfer data to my host MacBook?
  3. It seems that Teeny-4 (or 4.1) is the best choice, due to the high CPU speed, or is there a better alternative?
  4. I'd prefer to develop in vanilla C or C++, is that possible, and if so can I still link with available libraries?
  5. If not using C/C++, what's the run-time performance of the script-like code examples I've seen in some YouTube videos?
  6. Any specific recommendations for the best IDE/tool-chain to use on a new MacBook with ARM CPU?
  7. Did I miss anything else? I bet I did!
Sorry to have so many questions and thank you in advance for your wisdom!
Sketch attached lets you synchronously sample at 12 bits resolution 4 channels with 500 kHz. Using Teensy4.x A0, A1, A2, A3 analog inputs. Channels A2 and A3 are sampled at the same time just a fraction of a microsecond or so later than A0 and A1 were sampled at the same time. This is with a circular DMA buffer in the Teensy, good for 32768 samples of all 4 input channels. In this example only doing output to host PC over USB Serial monitor. Type t to stop recording in circular buffer, then type p to print out the 32768 ADC raw readings. with s it restarts the circular DMA buffer recording.

As mentioned already: never allow >3.3 or <0.0 volts on any of the Teensy i/o pins. If using a piezo element, make sure you have protecting diodes and a series resistor in what goes to the Teensy analog input pins. probably best to bias the analog inputs to VDD/2 volts with two resistors, and then AC couple the piezo signal via a capacitor.
 

Attachments

  • Example_ADC_ETC_DMA-241118a.zip
    7.2 KB · Views: 19
Back
Top