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

Thread: [queued] USB DAQ with the Teensy

  1. #1

    [queued] USB DAQ with the Teensy

    Working with a senior instrumentation specialist, we have implemented a USB DAQ module using the Teensy 3.2, with analog circuits designed around the electrical characteristics of the Teensy ADCs and DAC. There is also a precision current amplifier that we designed to pair with the board, and the system with software, provides measurement into the pA and pF ranges. The control software is written in Python and provides a GUI and CLI.

    I have been using the system to characterize OLEDS and measure detailed electrical effects of surface contamination. In these studies I routinely clock the two ADCs and DAC together, at 200 kHz without data loss.

    If anyone is interested, please let me know. I am planning to make some extra copies of the boards.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	IMG_7161.small.JPG 
Views:	152 
Size:	217.7 KB 
ID:	14254  
    Last edited by DrM; 07-22-2018 at 03:13 PM.

  2. #2
    I want to add that the noise performance for the Teensy DAQ board is better than 0.1 mV.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    I think it'd be really interesting to see more details, especially on the control software, even just screenshots and a little info about what it does with the data.

    We get questions about doing this sort of project pretty regularly. Sometimes the questions are about pushing the USB limits. I believe quite a few people would be really interested to know more about how you did this, if you're willing to share.

  4. #4
    I am indeed willing to share. This is a screen shot of the python GUI that we use for testing our solid state lighting devices. You'll notice that it is pretty quiet, even though I just now ran it with the unshielded board sitting on my desk with open inputs except for the wire patching the DAC output to the input labeled Voltage.

    Click image for larger version. 

Name:	Screenshot from 2018-10-07 18-42-02.png 
Views:	62 
Size:	51.6 KB 
ID:	14908

    The data is output as floating point or binary values to a column formatted ASCII file.

    The gui runs alongside a console CLI, so that you can enter commands or click buttons and see the interaction between the program and the Teensy DAQ. There is also a stand-alone CLI program.

    There is a help command that lists and briefly explains the complete command set for the firmware along with commands recognized in the CLI.

    The CLI (no graphic) and the GUI programs, can take commands from stdin and write to stdout, and provide syntax to string commands together, sleep, wait, and pipe or tee to a file. I have automated a lot of my data acquisition procedures using bash to feed commands into the CLI or GUI.

    Some of the important DAQ features include
    • a ramp control for the DAC output (this is very impprtant when the test article is capacitive).
    • scanning the DAC while reading the analog inputs
    • generate a tone and save the analog inputs
    • scanning frequency with the tone finction
    • stream data
    • single read and write for analog input and output
    • set and read digital i/o pins

    Here is the Analog input control dialogue. Notice that it has settings for labels, scale, and differential or single ended input (this is controlled by a digital i/o pin). The number of channels is set in CLI or cfg file. There are four input circuits on the TDAQ board, and I have external boards that add more channels,

    Click image for larger version. 

Name:	Screenshot from 2018-10-07 19-15-15.png 
Views:	24 
Size:	7.1 KB 
ID:	14910

    And here is the Analog/DAC output control dialogue. Notice that it has settings for rate and an external gain. The output OP-AMP provides up to 40 mA, and when needed, I also have an external power OP-AMP that works as a fast, voltage controlled power supply or amplifier.

    Name:  Screenshot from 2018-10-07 19-14-51.png
Views: 505
Size:  6.0 KB
    Last edited by DrM; 10-08-2018 at 12:36 AM.

  5. #5
    Here is a capacitance measurement, it was made by measuring amplitudes as a function of frequency. The parallel resistance refers to leakage current.

    In addition to the conventiional DAQ functions (read voltage, set voltage, set/read pin, etc) the firmware also has tone and frequency sweep functions that can use the two ADC's together.

    In this instance, the frequency sweep was run at a clock rate of 200 kS/s per ADC, at 16 bits, and with a command switch that causes it to return an amplitude for each of the two channels at each tone frequency. The firmware uses a Goertzel to extract amplitude and phase.

    Click image for larger version. 

Name:	C10PF.png 
Views:	24 
Size:	8.7 KB 
ID:	14906

    And here is a measurement for a solid state lighting device that we are studying. It has a large capacitance and more leakage current.

    Click image for larger version. 

Name:	MN-0115-3B.png 
Views:	22 
Size:	9.2 KB 
ID:	14907

  6. #6

    USB DAQ with Teensy - Noise measurements

    Here are signal and noise measurement for the four inputs in 16 bit mode, with the first three channels unconnected, and the output from the DAC set at 1.0 V and connected to Ain3. Notice that the bare inputs have noise below 0.1 mV and the DAC output has noise below 1mV.

    Chan Avg Stdev
    Ain0 3.26E-06 5.6E-E05
    Ain1 6.8E-06 7.1E-05
    Ain2 9.3E-06 8.0E-05
    Ain3 1.0 0.00067

  7. #7
    Senior Member
    Join Date
    Nov 2012
    Salt Lake City, UT, USA

    Very interesting, thanks for this thread

    Quote Originally Posted by DrM View Post
    I am indeed willing to share.
    OK that snip is out of context, we can talk off-forum about your board etc.

    This is very interesting. I am interested in the board you developed; would need to know more before deciding if it would work in this application or not. I just sent you a private email.

    The Python GUI looks interesting too... I guess that's running on a PC connected to Teensy? Or something smaller like RPi? On your board I can't make out a uSD card? How do you store acquired data?

    I went ahead and purchased a USD$180 Dataq 1120 USB data logger since it has four true differential inputs which can handle 120V RMS without damage, programmable gain, etc. My intent is to try controlling it with Teensy 3.6 since it has the USB host and the uSD for local logging (in CSV form for easy import and analysis). As well as local we want to push out to Google or AWS cloud. This has to work unattended for at least weeks at a time.

    I'm planning to open source my code, assuming I get something working soon. At the moment I am wrapped around the axle ordering parts and scheduling production for the next run of Teensy-powered environmental control systems...

  8. #8
    A few weeks should be easy. Assuming careful design, the limits are usually storage, cooling and power.

  9. #9
    Senior Member
    Join Date
    Nov 2012
    Salt Lake City, UT, USA
    Quote Originally Posted by DrM View Post
    A few weeks should be easy. Assuming careful design, the limits are usually storage, cooling and power.
    Agreed, for an embedded system. We design and have systems working around the world for years unattended. That's what embedded control does.
    [RANT]But in this case a Windows PC is assumed by vendors (Dataq, Digilent, PicoScope) to be the controlling and logging device. I've set up a test system and it will not run for more than a few days without failing, using the Digilent Waveform software connected to their $300 + accessories Analog Discovery 2 hardware, running under Windows 10 Pro or Ubuntu 18.04 on two different PC hardware platforms! Part of the problem is the USB connection fails (usually a timeout) and their code can't recover. Another problem is holding off all Windows updates and disk scans may be only partly possible... plus Windows is not intended to run unattended for even days without rebooting. It's really frustrating. I have support tickets open with Digilent and other vendors. We are also using a $1500 PicoScope 3425 but their Linux SW (not open source, so we can't even fix it ourselves) has critical missing pieces (only once we purchased the scope and were able to run the SW, we discovered the missing parts include the logging to local storage piece!) so we will be forced to use Windows with it... or do a Teensy or Rpi based interface to it also. So what I thought would be a simple job has turned into a tar pit.[/RANT]
    In this case we have plenty of power (120V mains with battery backup) and storage (local PC disk or onboard uSD card), with tethered cell phone data link to Google Cloud.

  10. #10
    The GUI is written in Python, and I have run it on Linux, Windows 10, and Windows 7, and desktops and laptops for each. I have not seen any crashes.
    Last edited by DrM; 01-11-2019 at 06:32 PM.

  11. #11
    DAQ vendors in general are miserable sources of DAQ software, and very few are conscientious even about their hardware.

    That in part, is why I built this. I needed a system with strong performance metrics that I can trust, I needed to be able to program the internals directly to provide features that are import for my data acquisition application, and I wanted to provide an API that is easy integrate with host software and platform.
    Last edited by DrM; 01-11-2019 at 06:45 PM.

  12. #12
    Senior Member
    Join Date
    Mar 2013
    Very nice, from experience you will have noise issues with the ADC's if you try to run SPI while sampling the ADC's which makes logging or running small screens a pita. What I ended up doing was using an external spi adc with isolation between the Teensy and the SPI ADC. With careful routing it's possible to skip the isolation but that requires far more attention to detail and experience than most of us DIYers have.

    You can read up on some of my trials here. Which reminds me I need to work less and finish my projects....

  13. #13
    In fact, the noise that I reported for our design in #6 above (0.05 mv to 0.08 mv), does not change when I run other interfaces at the same time. It stays in the 10^-5V range.

    In the picture in #1 above, you see that this is a surface mount board. I'll expand on that a little bit to note that we spent about three months on the design, including optimal component selections, detailed circuit analysis and optimal board design. The low noise figure did not just happen, we worked for it.

    @Donziboy2 Compare this to the circuit shown in your link; a collection of loose jumper wires, solderless breadboards and budget circuit pieces. it would be a big surprise if you did not see pick-up when you run the SPI. The assertions you make based on your breadboard experience, are simply not accurate of a professionally designed SMT board. We do not see pick-up of that sort whatsoever.
    Last edited by DrM; 01-14-2019 at 03:51 AM.

  14. #14
    Administrator Paul's Avatar
    Join Date
    Oct 2012
    Quick question - Were extra boards made & sold somewhere? Or still planning to be sold?

    Was supporting Python GUI software published, so still planning to be published?

    Usually when a project is going to be sold or crowdfunded, we try to wait and then post it on the website when you're ready to accept orders or backers.

  15. #15
    Hi Paul, I have one extra board. I am probably going to use it in the lab. Can we talk off-line?

  16. #16
    I am happy to publish the python gui, and probably the firmware that runs the board as well. The intent is that it be a flexible instrumentation grade DAQ interface and still be very affordable. Everything on the market falls short of that.

  17. #17
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Oh, I'm not personally looking for this board, but if you're selling them online, I'd certainly like to help you get the word to people who might want them!

  18. #18
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Sounds like you've made a really useful product here. I totally understand how much extra work it is to sell & support something as a commercial product.

    If you're not going to sell these, but willing to share the info, it'd be really awesome if other people could build & use it.

  19. #19
    And yes, of course, I did plan to produce and sell the board, and would be happy to do it if there is interest. I think there a lot of researchers in science and engineering who would benefit.

  20. #20
    So, can we talk? I emailed you my contact info.

  21. #21
    It takes me about four hours to build one by hand, with tweezers and a magnifier, and then a few minutes in a small reflow oven. Having the pcb service that I regularly use, do the assembly for a small run of 4-5 boards might cost less than $1K all included. There is still some time on my end for preparing files and BOM etc, But, it seems well worth it, we just need a few people who want boards.

  22. #22
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    I asked for feedback on Twitter.

    Let's see what people have to say there today...

  23. #23
    Great, thank you. I see two replies already, the first might be talking about a pci/pcie board from general standards, they usually go for 5-8 K$.

  24. #24
    Hi Paul, the twitter response seems promising. I plan to ask for a quote today for a small production run. Will let you know how it comes out.

Posting Permissions

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