PDA

View Full Version : [queued] USB DAQ with the Teensy



DrM
07-22-2018, 02:03 PM
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.

DrM
10-07-2018, 01:41 AM
I want to add that the noise performance for the Teensy DAQ board is better than 0.1 mV.

PaulStoffregen
10-07-2018, 08:15 AM
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.

DrM
10-07-2018, 09:42 PM
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.

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,

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.

14911

DrM
10-07-2018, 10:19 PM
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.

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.

14907

DrM
10-08-2018, 12:07 AM
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

bboyes
01-11-2019, 04:43 PM
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 (https://www.dataq.com/products/di-1120/) 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...

DrM
01-11-2019, 04:58 PM
A few weeks should be easy. Assuming careful design, the limits are usually storage, cooling and power.

bboyes
01-11-2019, 05:07 PM
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.
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.
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.

DrM
01-11-2019, 05:07 PM
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.

DrM
01-11-2019, 05:09 PM
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.

Donziboy2
01-13-2019, 09:31 PM
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 (https://forum.pjrc.com/threads/34863-Teensy-CC-Dummy-Load-300W?p=155966&viewfull=1#post155966). Which reminds me I need to work less and finish my projects....

DrM
01-14-2019, 02:35 AM
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.

Paul
02-13-2019, 03:16 PM
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.

DrM
02-13-2019, 04:01 PM
Hi Paul, I have one extra board. I am probably going to use it in the lab. Can we talk off-line?

DrM
02-13-2019, 04:04 PM
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.

PaulStoffregen
02-13-2019, 04:07 PM
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!

PaulStoffregen
02-13-2019, 04:12 PM
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. :)

DrM
02-13-2019, 04:12 PM
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.

DrM
02-13-2019, 04:13 PM
So, can we talk? I emailed you my contact info.

DrM
02-13-2019, 04:21 PM
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.

PaulStoffregen
02-13-2019, 05:07 PM
I asked for feedback on Twitter.

https://twitter.com/PaulStoffregen/status/1095745839828480000

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

DrM
02-13-2019, 06:21 PM
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$.

DrM
02-14-2019, 05:29 PM
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.

notthetup
03-04-2019, 04:14 AM
I meant to reply here a while ago, but I got busy. But this is pretty awesome. Something I/We would really find useful. Currently, we use https://www.mccdaq.com/ DAQs but the software support on Linux is inexistent and it's really hard to debug stuff since the hardware is closed source.

DrM
03-04-2019, 01:11 PM
@notthetup Yes, it was the mccdaq and the labjacks, that led me to feel the need to do this. This is better than any of those, for a few reasons.

Here are a few of the specs that I was particular about:


It's a much better quality, lower noise analog interface compared to any of the modestly priced USB DAQ's
The inputs have a reasonable impedance (not like the labjack)
It plays well with python in linux and windows
It has smooth ramps and waveforms for the DAC
The DAC output can drive 40 mA.
You can program the internals to give it what every functionality you want.


There are some accessories also, a precision high gain current amplifier (10^8), expansion boards to add more precision input channels, and a voltage driven power supply that can be used to drive waveforms at 1A. I use this for characterizing OLEDs and doing charge modulation studies.

I have started to look into having a small run made. It could be around $350/board if five people want to pitch in.

FHorn
03-27-2019, 03:11 AM
DAQ vendors in general are miserable sources of DAQ software, and very few are conscientious even about their hardware.

While expensive, DAQ hardware and LabVEW software from National Instruments offers top notch software and hardware with terrific responsive technical support. Accurate low noise DAQ with software ability to configure and control it down to very low level tasks is available.

Steve

DrM
03-29-2019, 02:46 PM
@FHorn

I am a little bit familiar with NI, and I am not a fan. Moreover, with their focus on expensive software (400/year to 5K/seat plus fees for deployment), it is not easy to see why they would be relevant for us. The point here is to provide features and high performance rivalling or exceeding the best commercial offerings, while still at low cost.

To be fair, I just checked and it seems that NI's 16 and 18 bit 250 kS/s (aggregate) products for USB are still spec'd as good to 3 mV and the costs are from about $1,000 to $3,000. That seems pretty miserable. The board we posted here is a factor of 10 better.

The last time I worked with their PCI boards, they were polling rather than using interrupts and they would not let me have a register map to write my own driver. So much for low level access.

My impression is that they seem to be more about selling their high priced graphical software for generating control systems.

The people that I know who use their software, do not consider themselves to be programmers. It was said to me years ago at BNL, in an effort to justify using their stuff, that that is their market. That seems about right.

DrM
04-01-2019, 03:36 AM
The board described in this thread was designed to provide high precision low noise signal acquisition, waveform generation and digital I/O in a programmable board with an open API that interfaces easily with python, and at a price point of a few hundred dollar.

Most of the users here will understand how many clocks the Teensy provides and how to use them to run the ADC or DAC in ways that meet their needs, if I have not already provided it in the embedded code that I wrote for the board.

What NI does and charges thousands of dollars for, is really not the point.

omjanger
06-30-2020, 07:32 AM
I tried to find the files for this project that I think should be in the first post in this thread. But it does not work for some reason.
Can you point me in a direction where to find this? ..if you are still willing to share..=)

DrM
06-30-2020, 01:41 PM
Hi, it is a SMT design. So you have to have the actual board. I am interested to make some more if there are a few people to help dilute the assembly costs.