0

Teensy for high speed data aquisition
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Teensy for high speed data aquisition

by standardrockets on Thu Jul 29, 2010 1:54 pm

So I have a teensy from Adafruit I'd like to use for some samples of 4 inputs somewhere between 2KHz and 10KHz. That range will depend on testing results.

A rate within that range might be do-able based on the info this Adafruit fan has published:
http://sites.google.com/site/measuringstuff/the-arduino

The first device to sample is input from an Sparkfun ACS712 current sensor breakout.
The second and third items will be simply reading the voltage from a voltage divider which will bring 0-14v down to a range of 0-5v.
The fourth device to be sampled will be a TAOS TSL237S-LF

Teensy good stuff = USB HID FAST data output - This should eliminate most of the bottlenecks identified by the measuringstuff testing.

possible Teensy bad stuff = the atmel ADC shortcoming when sampling multiple analog inputs - The was not tested on the measuringstuff. I'd test this myself if I had the parts to whip up a 2 channel signal generator...


So I'm wondering would I be better off using a dedicated ADC like the MCP3208 to sample the 4 inputs.

Also to get a consistent frequency I'm planning on using a 555 (because I can) to consistently trigger an ISR that does the sampling.

I'll put together a couple of reference current circuits to calibrate the current sensor before I start.

I was wondering, is it alright for a teensy plugged into USB to have it's ground tied to the negative (ground) of a 5V reference power supply? I'm planning on using a netbook running off of the internal battery as the "management station", Then I'll have a 12V battery on one end of the test rig, and the DUT at the far end of the rig, and have a precision 5v source to power the current sensor, TSL237S-LF, and MCP3208, along with being tied to AREF.

Does anyone see any issues? Should I put together a schematic?

standardrockets
 
Posts: 11
Joined: Mon Feb 15, 2010 1:08 pm

Re: Teensy for high speed data aquisition

by standardrockets on Wed Aug 04, 2010 9:06 pm

So my marginal schematic is attached.

Any feedback or suggestions on this are welcome.

I'm not using a dedicated ADC chip in this config.

I'm sampling the light output by the device under test along with voltage drop across 50 feet of cat5 when I turn it on and current consumption.

So do I need decoupling caps near any of these devices?
Attachments
test-setup-DAQ.GIF
test-setup-DAQ.GIF (26.94 KiB) Viewed 4398 times

standardrockets
 
Posts: 11
Joined: Mon Feb 15, 2010 1:08 pm

Re: Teensy for high speed data aquisition

by Entropy on Thu Aug 05, 2010 10:55 am

I cannot at all understand why you're using the 555 for timing when you can just use the internal timers of the AVR. I don't see anything about your design that makes me think you're eating up timer resources...

As to the limitations with sampling from multiple analog inputs, if you configure the opamps in a quad opamp package as voltage buffers that should solve that problem.

Also, define "high speed". The AVR's ADCs aren't that fast, definately not suitable for what I consider high speed data acquisition (However I don't consider something "high speed" until it's at least 1 MSPS...)
Entropy
 
Posts: 472
Joined: Tue Jan 08, 2008 12:43 am
Location: Owego, NY USA

Re: Teensy for high speed data aquisition

by paulstoffregen on Tue Aug 10, 2010 8:54 am

It's not clear from the schematic what you're driving into F0 and F6 (analog inputs), but at least F0 appears to have resistors attached to the positive and negative terminals of the 12 volt battery. Presumably you're measuring a divided-down copy of the battery voltage?

One point of concern is the analog inputs don't work well if ANY pin is driven higher than 5 volts (or whatever power is applied to the AVR chip). Normally if using only digital signals, you can use a fairly high value resistor (like 10K) to limit the current that flows through the protection diodes inside the chip, so a too-high voltage will result in about 5.7 volts on the pin. But if any pin is driven in such a way, the analog accuracy of all inputs suffers. So be sure to choose the resistors appropriately to prevent that. Both connected to F0 are labeled "R", and if that means equal value, the nominal voltage (with conduction in the protection diode inside the chip) would be 6 volts, which is too high. If the resistor values limit the current, the protection diode will save the chip at least, but any conduction in those protection diodes ruins the chip's analog performance!

Also, I would agree with the statement about the 555 timer. The internal timers may involve a little complex programming, but they are clocked from the 16 MHz crystal which is FAR more accurate than the capacitor attached to a 555 timer!

Teeny's direct USB will let you send vast amount of data... much more than you can collect from the on-chip ADC, or probably from an off-chip one. If you want best possible speed with lowest overhead, use usb_serial_write (if using C) or Serial.write (if using Arduino) to send many bytes at once.

paulstoffregen
 
Posts: 436
Joined: Sun Oct 11, 2009 11:23 am
Location: Portland, Oregon, USA

Re: Teensy for high speed data aquisition

by standardrockets on Tue Aug 17, 2010 10:09 am

F0 and F6 will be voltage divided measurements from the 12V circuit under test. Because I'm only going to have the circuit turned on for a second and running a couple amps down some cat 5 cable I want to see how the voltage drop at the far end changes over that second I have the circuit on.

I forgot to label the voltage divider R values. I think I'll divide down a 15v to 0v range to a 5v to 0v range. I just need to take a look at what I have for resistor values in the parts box. Now I think I need to perform a little more research on using a divider for this as I read there might be problems in using them. So I might just use a voltage sensor like this:
http://www.phidgets.com/products.php?ca ... ct_id=1135

The arguments for using the internal timer have won. Thanks for all of the advice guys.

This fast transport off of the AVR is the main reason I'm using the teensy. It looks like I could get a 5k samples per second rate and have bandwidth to output the various sensor samples.

standardrockets
 
Posts: 11
Joined: Mon Feb 15, 2010 1:08 pm

Re: Teensy for high speed data aquisition

by paulstoffregen on Tue Aug 17, 2010 6:32 pm

I would try the resistor divider first and see if it works well enough. It just might.

Teensy can easily send 5000 samples per second, assuming the software on the PC can receive that fast (eg, if you receive in the same thread that updates a GUI, it's amazing how slow a mulit-GHz computer can become). As a rule of thumb, it's pretty easy to send up to about 50 kbytes/sec with Teensy. It's possible to send far more, though beyond about 50 to 100 kbytes/sec, coding efficiency starts to matter much more.

paulstoffregen
 
Posts: 436
Joined: Sun Oct 11, 2009 11:23 am
Location: Portland, Oregon, USA

Re: Teensy for high speed data aquisition

by standardrockets on Thu Sep 16, 2010 8:34 pm

So I'm testing the voltage dividers on a Duemilanove and teensy 2.0. The Duemilanove is operating fine. GND = 0, 1.68v = 338, and VCC (5.07v) = 1023 on the analog inputs. I also have a MCP3208 SPI ADC measuring the voltages and it gives similar values on a 12 bit scale. Yay for me. I didn't burn anything out yet.

The teensy 2.0 is giving me a little more difficulty. I'm using simple hil;lbilly code as simple as it gets:
Code: Select all | TOGGLE FULL SIZE
//teensy
void setup()
{               
  Serial.begin(38400);
}

int val;

void loop()                     
{
/* uncomment next two lines to
   removes oddity  */
//  val = 45;
//  Serial.print(val);

/* or uncomment this to do a double
   read to remove oddity */
// val = analogRead(0);

  val = analogRead(0);
  Serial.print("A0 is: ");
  Serial.print(val);
  val = analogRead(1);
  Serial.print(" A1 is: ");
  Serial.print(val);
  val = analogRead(2);
  Serial.print(" A2 is: ");
  Serial.println(val);

  delay(107);
}


With GND connected to A0, the voltage divider to A1, and VCC to A2 I am getting the following output:

Code: Select all | TOGGLE FULL SIZE
A0 is: 0 A1 is: 342 A2 is: 1023
A0 is: 0 A1 is: 341 A2 is: 1023
A0 is: 0 A1 is: 342 A2 is: 1023
A0 is: 0 A1 is: 342 A2 is: 1023
A0 is: 1022 A1 is: 341 A2 is: 1023
A0 is: 0 A1 is: 342 A2 is: 1022
A0 is: 0 A1 is: 341 A2 is: 1021
A0 is: 0 A1 is: 342 A2 is: 1022
A0 is: 0 A1 is: 341 A2 is: 1023
A0 is: 0 A1 is: 341 A2 is: 1022
A0 is: 0 A1 is: 341 A2 is: 1023
A0 is: 0 A1 is: 341 A2 is: 1023
A0 is: 0 A1 is: 342 A2 is: 1022
A0 is: 0 A1 is: 341 A2 is: 1023
A0 is: 0 A1 is: 341 A2 is: 1023
A0 is: 0 A1 is: 341 A2 is: 1023
A0 is: 0 A1 is: 342 A2 is: 1023
A0 is: 1023 A1 is: 341 A2 is: 1023
A0 is: 0 A1 is: 341 A2 is: 1023
A0 is: 0 A1 is: 342 A2 is: 1022


I cannot figure out why I get a sporadic value near VCC on the GND. I've tried pulling all the other analog inputs to GND and VCC to see if there is a difference. There was none. Now with a 100ms delay, it seems to be I get either 12 or 20 good readings before I get the anomaly. If I uncomment either the setting val=45+print or do a double read, I no longer get the glitches.

I suppose when I crank up the frequency to 1-2K, I'll still have room to do a double read to eliminate that oddity. But as I do in my day job, I want a root cause figured out.



Now on to that light sensor outputting a frequency, it is not going to work for what I want. For measuring a frequency there are two general methods out there that I have found:

1) Using interrupts
http://interface.khm.de/index.php/lab/e ... r-library/
2) counting the length of pulses
http://www.sullivan-county.com/ele/arduino_tsl230r.htm

Now the drawback of #1 is it uses up the timers needed for the software interrupts I want to use to get a 1-2K sample frequency on the analog inputs.

Number 2 works for reading the frequency except with minimal light, the frequency is very low and that it slows things down.

So I think for the light sensor I'll switch to is the TEMT6000 which I can read using an analog input.

standardrockets
 
Posts: 11
Joined: Mon Feb 15, 2010 1:08 pm

Please be positive and constructive with your questions and comments.