Memory data buffer for high speed data collection

Status
Not open for further replies.

George1

Active member
Hi guys,

I am working on a new gadget that is supposed to perform seismic data logging and the design is going to be based around Teensy 3.2 (I wish Teensy 3.6 with much bigger memory was out and well supported as Teensy 3.2 at this point). The board needs to be able to record snapshots of data collected for duration of 5 seconds from 6 ADC channels sampled at 4KHz. The memory requirement is about 240 KB (5sec X 6 ADC channels X 4KHz X 2 bytes per sample = 240 KBytes) of memory with fast access.

The basic program logic is once the trigger is set is to use 25us (4KHz) timer interrupt to collect data for 5 seconds and load into an array. Once 5 seconds is up transfer collected data from the array and write it on an SD card and wait for next trigger which is expected to occur once per minute so there is plenty of time to transfer data to an SD card. The problem is that Teensy 3.2 doesn’t have enough memory to hold that much data and I need some intermediate memory buffer. I am pretty sure I cannot write data to an SD card every 25us since the access times are in the millisecond range. I am thinking of using Microchip 23LC1024 SPI interface chip but that has only 1Mbit (128Kbytes of memory). I guess I might use two of them sequentially to store data.

Another option might be to use some fancy multiple interrupt routines to write to the SD card in bigger memory chunks while the 25us timer interrupt collects ADC data but I don’t have a good idea for how to do this.

Please let me know if you have any suggestions or ideas for how to best tackle this type of a problem. Both software and hardware ideas will be welcomed as well as pointing me to a previous discussion of on a similar tread (which I was not able to find).

Thanks,
George
 
Hi guys,

I am working on a new gadget that is supposed to perform seismic data logging and the design is going to be based around Teensy 3.2 (I wish Teensy 3.6 with much bigger memory was out and well supported as Teensy 3.2 at this point). The board needs to be able to record snapshots of data collected for duration of 5 seconds from 6 ADC channels sampled at 4KHz. The memory requirement is about 240 KB (5sec X 6 ADC channels X 4KHz X 2 bytes per sample = 240 KBytes) of memory with fast access.

The basic program logic is once the trigger is set is to use 25us (4KHz) timer interrupt to collect data for 5 seconds and load into an array. Once 5 seconds is up transfer collected data from the array and write it on an SD card and wait for next trigger which is expected to occur once per minute so there is plenty of time to transfer data to an SD card. The problem is that Teensy 3.2 doesn’t have enough memory to hold that much data and I need some intermediate memory buffer. I am pretty sure I cannot write data to an SD card every 25us since the access times are in the millisecond range. I am thinking of using Microchip 23LC1024 SPI interface chip but that has only 1Mbit (128Kbytes of memory). I guess I might use two of them sequentially to store data.

Another option might be to use some fancy multiple interrupt routines to write to the SD card in bigger memory chunks while the 25us timer interrupt collects ADC data but I don’t have a good idea for how to do this.

Please let me know if you have any suggestions or ideas for how to best tackle this type of a problem. Both software and hardware ideas will be welcomed as well as pointing me to a previous discussion of on a similar tread (which I was not able to find).

Thanks,
George
FrankB has made a SRAM memory board that holds multiple 23LC1024. The boards are available on OSH
(search the forum for a link, or Frank can advice)
 
Hi George,
I know the post is very old, but have you finally build the logger? I am completely new to the teensy universe and would like to learn from other projects.
 
Today, it's better to use a Teensy 4.1 - it has more RAM, and a fast inbuilt SD Slot. If that's not enough, you can add PSRAM which is faster than the memoryboard. The PSRAM is cached and is connected via fast quad I/O.
 
Thank you.

I actually bought a Teensy 4.1 and found many examples on the internet that do not compile for this device. Most people are using 3.5/3.6.

Georg's project is very similar to my task:
- trigger via push button or every minute
- record a signal in the audio frequency range for about 1/2 second into a buffer from ADC
- do some simple processing of the buffered data
- finally or in parallel to processing, save the buffer to the SD card as a wave file (*.wav) or just as binary (with a known sampling rate)

The signal is a sine wave of about 2kHz with noise. The amplitude decays within less than a second after the trigger. The signal is biased to about 1.65V (resistor divider buffered by an op-amp). Should I also measure the bias voltage via a second ADC? Probably a teensy 3.6 would be a better option for differential input, but I was not aware of this limitation with the teensy 4.1.

I thought, writing to SD-card after sampling would be beneficial to avoid interference.

Unfortunately, I got lost in too many forum posts and projects. I have looked into
- https://github.com/janscience/TeeRec
- https://github.com/muchaste/EOD-Logger
- https://github.com/WMXZ-EU/microSoundRecorder
- ...

Any hint about where to start with ADC, DMA, ... on teensy 4.1 would be very appreciated.
 
Sorry hard to know how to help...

As for ADC stuff beyond the simple analogRead type stuff, you might want to look at the
ADC library (https://github.com/pedvide/ADC)
Which supports both T3.x as well as T4/4.1... Have not checked to see if there were any updates needed for MMod...

But this library does have support in it for DMA capture as well as timers There are a few examples with that library.

There is more details about this library in it's readme file as well as the forum thread: https://forum.pjrc.com/threads/25532-ADC-library-update-now-with-support-for-Teensy-3-1

EDIT: Also meant to say, that if you have specific sketch that does not compile, it would help to see that code as well as what dependencies it has.
 
Ok, I got it. pedvide/ADC examples "adc_timer" and "adc_timer_dma" can be used as a starting point.
Thank you!
 
Status
Not open for further replies.
Back
Top