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

Thread: Faster Data Logging over USB

  1. #1
    Junior Member
    Join Date
    Dec 2018

    Faster Data Logging over USB

    I have been fumbling around with using Pevide's ADC library over USB for a while now and I thought I would share my efforts. Attached are files that allow for fast data-logging over USB, I call it the Analogger. It is a serial communication messenger and a wrapper for the ADC library. The goal was to have a fairly simple way of prototyping systems with the teensy that required post-processing of data. I wanted to get the data to a computer right away so I could just use it. I didn't see any other simple solutions on the forum, so I made my own.

    The Analogger usage on the teensy side is pretty straight forward: Create an instance of the class, configure it in setup, call the appropriate trigger in your loop, and set the ADC ISR.

    For configuration, it takes up to five fields, all set with defaults if you don't care to change them. The first is the Software Trigger flag. If you want to use the host computer to trigger the teensy to begin reading, set this to true. If you want instead a hardware trigger, set this to false (default). The hardware trigger is accomplished by reading the trigger pin as HIGH.

    The second field is frequency. The analogger accepts frequencies from 1 - 1,000,000 samples per second. I have been able to achieve 1,000,000 samples per second over USB by overclocking a teensy3.6 to 240MHz. At standard clock speeds, my max is about 850,000 samples per second before I start over-running my buffers. Default is 10,000.

    The third field is the sample time per trigger measured in milliseconds. If you want the analogger to sample for 5 seconds on every trigger you send it, set this to 5000. Default is 1 sec.

    The fourth field is the number of triggers. If you want to be able to trigger the analogger 10 times before you are done logging, set this to 10. Default is 1.

    The fifth field is Trigger Delay, measured in milliseconds. If you need a delay after you trigger but before sampling starts, use this. Default to 0.

    The measurements are only configured for ADC0 and only for single-ended inputs. The Analog read pin, and the Digital Read Pin for Hardware triggers are set in Analogger.h. digitalreadfast requires a const so I couldn't really get around that.

    The serial communication is not the greatest. My computer has a lot of problems with communicating over USB as I have found out, so the configuration is a bit slow, and sometimes the readings just hang. I have noticed this most often with multiple software triggers. At some point I may try and shore up the serial comms, but I wrote this for prototyping so I'm not too concerned about it.

    I have tested this on Ubuntu and Windows 7. I have no Mac to try it on, and I did not add Mac support to the serial port code because I can't test it.

    If you have any questions, let me know. If you want to improve/change it, please do. I hope someone finds this useful.
    Attached Files Attached Files

Posting Permissions

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