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

Thread: Data logger : Again and again

  1. #1

    Data logger : Again and again

    Hello you all,

    it is my second "post" on this forum.
    Just after the first one I received an e-mail of welcome from Paul (Congratulations paul for what you are doing!!!), mail which invited me to not to limit me to small technical questions but to, first of all, describe in detail what I am trying to accomplish.

    Then I am going to try to do that although my project is at a very vague stage and a textbook case with regard to banality, which risks to bother you profoundly ...

    Originally I bought the teensy 3.6 to command leds ws2812 with the library OctoWs2811, dedicated to the family Teensy ...

    But on the way I wondered by reading the specifications if it would be possible to do the "data logger" of my dreams to record the cerebral activity of my mice...

    In other words : 8-16 channels , 12-16bits, 20-30kHz/channel, record on SD card, control by wifi or bluetooth... hum, hum...

    You see it is quite simple, maybe utopian and perfectly uninteresting for you all...

    Currently I record the EEG of my mice with an OBCI card (http://openbci.com/) of excellent quality, which works very well but which is limited to 250Hz by its design.
    The best that I was able to do by modifying as much as I am capable, the firmware, was :
    8 channels(canals); 2kHz / channel; 24bits; spi SD record only; bluetooth control.
    It is there : https://github.com/yj-xxxiii/OpenBCI_2kHz

    These limitations prevent me to record signals faster than the eeg, such as spikes emitted by neurons themselves... For that I need 20-30kHz approximately.

    It raises the usual questions which we find on this forum (and nxp) and of which I began the reading:
    ADC ; DMA ; SDio.

    I already found to study :
    - The data sheet K66P144M180SF5RMV2.pdf
    - https://github.com/greiman/SdFat
    - https://github.com/tni/teensy-sample...ncy_logger.ino
    - https://forum.pjrc.com/threads/43708...gging-at-10kHz
    - https://forum.pjrc.com/threads/47977...electrish-fish
    - https://forum.pjrc.com/threads/45993...C-DMA-Question
    - https://community.nxp.com/docs/DOC-104395
    - https://www.nxp.com/docs/en/application-note/AN4590.pdf
    - SaileNav and Donziboy2
    - ...

    Thus my question is: do you believe that it is possible or a lost cause?

    You should know also that I am not a good programmer but a simple biologist and that for example, I do not understand the "while(1)" in the "loop" of the program of Donziboy2 (04-15-2017, 01:43 PM) .
    (does it exist a kind of "watch dog" which interrupts this infinit loop while(1)? ) I searched on the web but found nothing clear.

    But I am very motivated ...

    Thank's in advance for any advice.

    Sincerely Yannick.

  2. #2
    Senior Member
    Join Date
    Mar 2013
    Posts
    651
    Hello Yannick, your project is definitely advanced. Your kind of hitting the same rough road I have been working on with my CC Dummy Load project.

    You will face several issues.
    To get decent ADC values you have to go to an external ADC since every time you write to the SD Card it will introduce noise onto any ADC readings you take at that time using the Teensy itself.
    Your going to need to use DMA to handle either the ADC communications (DMASPI) or the SD Card writes. Or maybe both?
    Your data throughput will be pretty high so you need to make sure the SDcard can do it. 20kHz * 8Channels * 16Bit = 2,560,000 Bit/s


    The while(1) creates an infinite loop, its actually left over from when the code was much more complex and it had key presses before it started printing over serial.

  3. #3
    Thank's Donziboy2 for these words of caution.

    To get decent ADC values you have to go to an external ADC
    Would you have in mind a break out card for an ADC that fit?

    since every time you write to the SD Card it will introduce noise onto any ADC readings you take at that time using the Teensy itself.
    I saw that some where on the forum (don't remeber where) It is a big problem, how many bits do we lost?
    Has the source of this noise be diagnosed?
    Is it a contamination of the signal itself before and during sampling or a fluctuation of the ref (AREF-AGND) or the +V? I will try to connect AGND to an input and see what append...
    I expected that a low impedance signal would escape this problem...

    Your going to need to use DMA to handle either the ADC communications (DMASPI)
    Yes it seems vital I learned a lot these last days about DMA and discovered that the scater/gather feature allows acquisition in a big buffer > 64k and more, it works fine...

    Your data throughput will be pretty high so you need to make sure the SDcard can do it. 20kHz * 8Channels * 16Bit = 2,560,000 Bit/s
    Not so much compared to the SD but it is necessary to overcome these strange "busy" states of the SD cards, which ruins the nice 16MB average speed.
    I am currently doing some statistics... Greiman and TNI's exemples helps me a lot, even if I do not know the glaucous CPP...
    At least it seems possible...

    The while(1) creates an infinite loop, its actually left over from when the code was...
    Thank's it made me doubt about my andersanding...

    Thank's again,
    y.j.

  4. #4
    Senior Member
    Join Date
    Mar 2013
    Posts
    651
    Quote Originally Posted by Yannick View Post
    Would you have in mind a break out card for an ADC that fit?
    The only one I have experience with is the one I created for my CC Dummy Load in order to test the ADC before I commit to anything. The PCB will accept at least 4 TI chips in the same 4-8 channel range, with 14 to 18 bit resolutions. I am still trying to figure out if I can use DMASPI on the ADS8698, if not I will just have to live with 60Kish samples per second instead of like 400K lol. The biggest resource hog in my Dummy Load project is the LCD, thankfully a large amount of the work will get done with DMA SPI transfers. I'm hoping the external ADC solves the noise issues, I wont know for a few more weeks depending on how busy RL is.

    Quote Originally Posted by Yannick View Post
    I saw that some where on the forum (don't remeber where) It is a big problem, how many bits do we lost?
    Has the source of this noise be diagnosed?
    Is it a contamination of the signal itself before and during sampling or a fluctuation of the ref (AREF-AGND) or the +V? I will try to connect AGND to an input and see what append...
    I expected that a low impedance signal would escape this problem...
    For my project the culprit is SPI Clock and data transmissions. Due to the size of the micro some of the SPI pins cross under the IC from one side of the board to the other. If you use DMA SPI and try to read the ADC at the same time it produces noise. The amount of noise depends on your setup, the best I got was around 500-1500 pk-pk noise at 16 bit with heavy averaging (see post #76). Also if you look at the datasheet for the Teensy Micro they say that the ADC ratings are will all other peripherals off or inactive. When you cram a lot of features into a small package you will loss something, in this case its the space needed to prevent coupling of signals onto the ADC lines.

Posting Permissions

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