Electronics > Beginners

help with rapid ADC data aquizition

<< < (3/8) > >>

Wimberleytech:

--- Quote from: powerfly on December 07, 2019, 01:41:35 pm ---
--- Quote from: radiolistener on December 07, 2019, 11:33:45 am ---you can do in on stm32 microcontroller. But the type of controller depends on your needs. If you're needs just to get date from adc and write it to sdcard, you can do it on a cheap two-dollar stm32 microcontroller. And you can use integrated adc.

--- End quote ---

Can do what? I'm not exactly sure what you're replying to, if it's one of the questions in my post above, which one?

cheap integrated ADCs aren't usually 12 bit and are often not 10kHz either.

--- End quote ---

Restating my earlier post...the Silabs ADC IS 12 bits and 100ksps!

jhpadjustable:
Your Arduino mate wasn't quite up to the challenge. He might have had better luck if he batched up a whole sector of data before writing it out, and writing binary instead of ASCII text. Still not bad for a single-threaded approach. I do maintain that you skip the bit-packing and just store your values in aligned 16-bit units, especially if you've got gigabytes of flash to play with, so that you'll never have to worry about alignment on the reading end or the writing end.


--- Quote from: powerfly on December 07, 2019, 01:41:35 pm ---An alternative that I think you mentioned at the end of your comment is to store maybe like 0.5Mb of data on the native RAM and whilst the other code is still reading data in, to dump that 0.5 Mb to a memory card, is that what you were saying?
--- End quote ---
More or less, reserving some space to buffer some of the filesystem metadata. Take care that you don't surpass your filesystem's limitations. You might find it easier on the whole to work in terms round wall-clock time, maybe do 2-second chunks instead, which is more than enough time to create or append a file on the flash.

That card is great, no worries.


--- Quote ---cheap integrated ADCs aren't usually 12 bit and are often not 10kHz either.
--- End quote ---

Welcome to the 32-bit MCU world. :)  Again, the hoary old STM32F103 has two 1Msps ADCs with a headline spec of 12 bits, which you could oversample by 8x (or 16x if you use both) in this application. Other, newer STM32 members are even better equipped, in case that's not enough margin for you.

powerfly:

--- Quote from: jhpadjustable on December 07, 2019, 03:40:44 pm ---Your Arduino mate was doing it wrong. He would have had better luck if he batched up a whole sector of data before writing it out, and I bet he was also formatting the output as text instead of binary.  (But the Arduino fans don't usually think at this level...) I still recommend that you skip the bit-packing and just store your values in aligned 16-bit units, especially if you've got gigabytes of flash to play with, so that you'll never have to worry about alignment on the reading end or the writing end.


--- Quote from: powerfly on December 07, 2019, 01:41:35 pm ---An alternative that I think you mentioned at the end of your comment is to store maybe like 0.5Mb of data on the native RAM and whilst the other code is still reading data in, to dump that 0.5 Mb to a memory card, is that what you were saying?
--- End quote ---
More or less, reserving some space to buffer some of the filesystem metadata. Take care that you don't surpass your filesystem's limitations. You might find it easier on the whole to work in terms round wall-clock time, maybe do 2-second chunks instead, which is more than enough time to create or append a file on the flash.

That card is great, no worries.


--- Quote ---cheap integrated ADCs aren't usually 12 bit and are often not 10kHz either.
--- End quote ---

Welcome to the 32-bit MCU world. :)  Again, the hoary old STM32F103 has two 1Msps ADCs with a headline spec of 12 bits, which you could oversample by 8x (or 16x if you use both) in this application. Other, newer STM32 members are even better equipped, in case that's not enough margin for you.

--- End quote ---

Thanks, that sounds good. the thing with the arduino (and the STM32F103) is that you wouldn't be able to batch up lots of data before writing as their RAM is so small (2kB or 20kB). so whilst the old STM32F103 would be able to read the ADC at a high rate, how could it be storing the data at the high rate with 20s intervals? I mean, if I'm using 7 channels, 20kB would get used up in ~0.2 s. Am I misunderstanding something here?

I'm planning on using a Teensy 3.6 anyway that has 256K (I think that means 256KB) of RAM so that should be able to write then dump to the micro SD card via the native port without a problem (I think).

Also, if you could point me in the right direction regarding how to do all the coding, that would be super helpful as I'm a coding noob. I think I'd like to use the arduino IDE if possible as it seems simplest

rstofer:
In theory, you can transfer multiple megabytes per second to an SD card depending on the model
https://www.expertreviews.co.uk/storage/1404380/how-to-choose-an-sd-card-class-and-speed-ratings-explained

But you probably need something faster than an Arduino to do it and the code probably needs to be tightened up A LOT!  DMA and multiple buffers will help.

Horsepower matters!  How about the Teensy 4?  It is blazing fast (600 MHz) has two 12-bit ADCs along with 14 analog pins.  This doesn't really matter because the ADCs could be external on an SPI or I2C bus and run through the DMA channel.  Given a bunch of internal memory, creating packets for the SD card will be very fast.

https://www.pjrc.com/store/teensy40.html

Not that I would necessarily go there but there is an Arduino compatible library for the chip called TeensyDuino which can be installed under the Arduino IDE although it escapes me why anyone would voluntarily use that IDE.  But the library installation includes the proper toolchain for the chip (ARM, not ATmega, obviously).  Keep the library, moved to anything else for the IDE.

The ARM chip itself:
https://www.nxp.com/docs/en/nxp/data-sheets/IMXRT1060CEC.pdf

powerfly:

--- Quote from: rstofer on December 07, 2019, 08:28:17 pm ---In theory, you can transfer multiple megabytes per second to an SD card depending on the model
https://www.expertreviews.co.uk/storage/1404380/how-to-choose-an-sd-card-class-and-speed-ratings-explained

But you probably need something faster than an Arduino to do it and the code probably needs to be tightened up A LOT!  DMA and multiple buffers will help.

Horsepower matters!  How about the Teensy 4?  It is blazing fast (600 MHz) has two 12-bit ADCs along with 14 analog pins.  This doesn't really matter because the ADCs could be external on an SPI or I2C bus and run through the DMA channel.  Given a bunch of internal memory, creating packets for the SD card will be very fast.

https://www.pjrc.com/store/teensy40.html

Not that I would necessarily go there but there is an Arduino compatible library for the chip called TeensyDuino which can be installed under the Arduino IDE although it escapes me why anyone would voluntarily use that IDE.  But the library installation includes the proper toolchain for the chip (ARM, not ATmega, obviously).  Keep the library, moved to anything else for the IDE.

The ARM chip itself:
https://www.nxp.com/docs/en/nxp/data-sheets/IMXRT1060CEC.pdf

--- End quote ---

I have been discussing using either the teensy 3.6 or 4.0 (see above comments). the advantage of the 3.6 is that it has the built in SD card reader and the processor is probably powerful enough. The 4.0 does have the added power and RAM, and I guess adding a card reader wouldn't be too difficult (although rapidly storing data to the card may be more difficult?)

When you say the code needs to tightened up a lot, how would one go about doing this?

jhpadjustable mentioned some stufff he thinks will help, although having someone point me in the right direction of how to do this would be helpful. I am very much a beginner when it comes to coding. the teensyduino library is appealing as it seems like it would be simple to code in.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod