Show Posts
Pages: 1 ... 58 59 [60] 61 62 ... 107
886  Using Arduino / Sensors / Re: Static Accuracy Tests of the Arduino Internal ADC. on: August 25, 2012, 11:24:49 am
Both WaveRP and AnalogIsrLogger have configurable sample rates.  You need to look at the programs and documentation for more details.
887  Using Arduino / Sensors / Re: Static Accuracy Tests of the Arduino Internal ADC. on: August 25, 2012, 06:48:53 am
There is documentation in the zip files.

I originally designed SdFat for recording audio and fast data logging.  I added features similar to the POSIX real-time extensions for files.

Large contiguous files can be created quickly.  There is a method to do raw writes to the SD using an efficient multi-block mode.  When a file is closed, the unused space can be truncated.

This allows very low latency writes to high quality SD cards.  The best cards are standard cards (2 GB or less) such as the SanDisk Extreme III.  Manufacturers have stopped producing many of these consumer grade cards so I am now experimenting with industrial grade cards like those made by Swissbit.

The write time for a 512 byte block is about 820 usec with good cards.

I have had some luck with SDHC cards like the 4GB and 8 GB SanDisk Extreme cards but manufacturers assume devices that use these cards have lots of RAM for buffering and can tolerate an occasional long write latency.

Download the 100,000 sample per second logger for an example that uses of these features.
888  Using Arduino / Sensors / Re: Static Accuracy Tests of the Arduino Internal ADC. on: August 24, 2012, 08:07:17 pm
It is possible to record 8-bit 44 ksps audio at PS16. Voice is not bad, like a cheap recorder.  I wrote a library to do it, WaveRP, http://code.google.com/p/waverp/downloads/list.

I also did a 8-bit 100,000 sample per second logger, AnalogIsrLogger20120810.zip http://code.google.com/p/beta-lib/downloads/list.  The Arduino gets an ENOB of about 7.5 at this speed.  You need a low impedance source.  I did a lot of work to reduce time jitter.

MarkT,

These tests are not appropriate for dynamic ADC performance. 

Here is a good article http://www.openmusiclabs.com/learning/digital/atmega-adc/.

You just can't use the AVR Arduino at high sample rates with high impedance sources.  If the ADC clock is 1MHz, the sample and hold time is on the order of a microsecond.

I like to have 10 time constant, RC, periods to charge the sample and hold cap.  10 K Ohms is just too large.

Calibration would change with temperature since gain and offset change.

Integral Nonlinearity is usually less dependent on temperature.

Atmel doesn't publish much about the properties of the AVR ADC so you can't be sure without tests.  Doing tests of ADC properties as a function of temperature for the AVR ADC would be a pain.

The Arduino ADC is not bad for most hobby use with low impedance sources.
889  Using Arduino / Sensors / Static Accuracy Tests of the Arduino Internal ADC. on: August 24, 2012, 01:57:39 pm
Several people have asked about the DC accuracy of the Arduino ADC when used in my data logging applications at slow sample rates.

Here are my results of some "hobby level" measurements of the Arduino ADC.

One question is how important is the ADC clock rate.  I did measurements for an ADC clock rate of 125 kHz to 2MHz.

Another question is how much does Noise Reduction Mode help.  I did a series of measurements using this mode.

Noise Reduction Mode only reduced the mean absolute error slightly.

I do calibration to remove Offset Error and Gain Error.  Calibration is very important for good accuracy.

These tests depend on the Arduino voltage regulator providing a stable voltage during the tests.  The Arduino ADC reference voltage is Vcc for these tests.  This may not be realistic for practical applications

Integral Non-linearity (INL) is the main remaining source of error.

Here are my results for static (DC) tests of the internal ADC for three UNOs.

The Arduinos are powered by a high quality nine volt power supply.

These tests measure a DC level so do not include problems due to time jitter, S/H time, and other dynamic errors.
There are several studies of the dynamic behavior of the Arduino ADC that determine ENOB (Effective Number Of Bits).

I used a shield with a 12-bit MCP4921 DAC to generate voltage levels. This DAC has an output buffer so it provides a very low impedance source.

I measured the voltage of the DAC with a calibrated 18-bit MCP3422 ADC on the shield.

I used DAC levels from 20 to 4075 to avoid zero offset errors at low voltages and DAC buffer problems at high voltages.

Each series of measurements has 4056 data points.

This is a voltage range of about 0.023 to 4.972 volts.

I calibrated the Arduino ADC for each series of measurements with a linear fit of the form.

v = a + b*adcValue

Errors are the difference between the value measured with the 18-bit ADC and the calibrated value measured with the Arduino ADC.

I also show the results for no calibration, the NoCal column, using the datasheet formula.

Vin = Vref*adcValue/1024


The columns in the tables are:

Ideal - results for a perfect 10-bit ADC for comparison.

NoCal - datasheet formula (5/1024)*adcValue with Noise Reduction Mode.

NR128 - Noise Reduction mode with Prescaler of 128 (ADC clock of 125 kHz).

PS64 - analogRead with Prescaler of 128 (ADC clock of 125 kHz).

PS64 - analogRead with Prescaler of 64 (ADC clock of 250 kHz).

PS32 - analogRead with Prescaler of 32 (ADC clock of 500 kHz).

PS16 - analogRead with Prescaler of 16 (ADC clock of 1 MHz).

PS8 - analogRead with Prescaler of 8 (ADC clock of 2 MHz).


The rows in the tables tables are.

Min - minimum error in millivolts

Max - maximum error in millivolts

MAE - mean absolute error in millivolts


Results for three UNO Arduinos (sorry about the ragged tables, I haven't mastered table insertion)

    First Arduino - Error Millivolts
      
       Ideal   NoCal  NR128  PS128   PS64   PS32   PS16    PS8
Min   -2.44  -2.43    -3.72   -4.01  -3.88  -4.53  -6.57  -27.18
Max   2.44  11.69     3.74    4.24    4.15   5.17   8.69   23.21
MAE   1.22   5.02     1.33    1.38    1.37   1.44   1.96     4.11

     Second Arduino - Error Millivolts

       Ideal   NoCal  NR128  PS128   PS64   PS32   PS16    PS8
Min   -2.44  -9.24    -4.87   -4.86  -5.05  -5.34  -6.52  -24.04
Max   2.44  11.62     3.95    4.64    4.69   5.71    8.41   21.29
MAE   1.22   5.33      1.41    1.43   1.44   1.53     2.02    4.05

     Third Arduino - Error Millivolts

       Ideal   NoCal  NR128  PS128   PS64   PS32   PS16    PS8
Min  -2.44   -7.88    -4.12   -4.40   -4.32  -4.41  -6.97  -26.93
Max  2.44   12.53     3.80    4.04     4.18   5.27   8.84   24.59
MAE  1.22    4.85     1.29     1.33    1.34    1.42   1.91    4.10
890  Using Arduino / Storage / Re: 3.3v to 5v inverter by bc547 on: August 22, 2012, 12:49:43 pm
Resistors fail for some newer SD cards that have edge detectors. The SD specification requires clock rise time and fall time to be less than 10 ns.

Worse is the fact that the errors in write data won't be detected.  There is no CRC by default since Arduino has no hardware support.

The latest version of SdFat supports software CRC but this slows transfers.

891  Using Arduino / Storage / Re: Unformatted write to SD on: August 21, 2012, 10:06:39 am
Quote
But only if you are sampling within 3 LSB of the extremes of the dynamic range!
I don't think you meant that.  Here is the definition of dynamic range for an ADC:
Quote
Dynamic Range
Typically expressed in dB, dynamic range is defined as the range between the noise floor of a device and its specified maximum output level. An ADC's dynamic range is the range of signal amplitudes which the ADC can resolve; an ADC with a dynamic range of 60dB can resolve signal amplitudes from x to 1000x. Dynamic range is important in communication applications, where signal strengths vary dramatically. If the signal is too large, it over-ranges the ADC input. If the signal is too small, it gets lost in the converter's quantization noise.
I think you meant full scale of the ADC.  Here is the definition of ENOB:
Quote
Effective Number Of Bits (ENOB)
ENOB specifies the dynamic performance of an ADC at a specific input frequency and sampling rate. An ideal ADC's error consists only of quantization noise. As the input frequency increases, the overall noise (particularly in the distortion components) also increases, thereby reducing the ENOB and SINAD. (See 'Signal-to-Noise and Distortion Ratio (SINAD).') ENOB for a full-scale, sinusoidal input waveform is computed from:

ENOB = (SINAD -1.76)/6.02
Note full-scale.  If you use a smaller signal, you would get the wrong (smaller answer).

Want to bet on Higgs?   I may be wrong, not all properties have been verified.  On the other hand not all group information is public so you might want to think before you bet.  The correct decays have been seen but now the equivalent of oversampling is happening to be totally sure.  Hope you read the latest paper that has just been submitted to "Physics Letters B" when it's published. 

You need to lighten up a bit and so do I.  Here's how http://www.wikihow.com/Lighten-Up.  This is a summary:
Quote
1. Stop assuming you know everything. Nobody knows everything.

2. Stop exaggerating. Exaggerating about your abilities, qualifications, knowledge, hobbies etc. is soon tiresome.

3. Let go of things. It's OK to lose an argument; it's OK to make mistakes.

4. Laugh.

5. Delegate.

6. Stop being so rules focused.

You're welcome for the code and any information you can use.  I will try to lighten up also.
892  Using Arduino / Storage / Re: Unformatted write to SD on: August 20, 2012, 06:22:17 pm
the quotes are by Walt Kester he is the recognized authority on converters.  His book is the standard reference http://www.amazon.com/Data-Conversion-Handbook-Analog-Devices/dp/0750678410.

Actually the 3LSB offset will reduce ENOB.  The reason is that ENOB is based on how well an ADC digitizes a full scale sine wave.  The 3LSB offset error will distort the wave for low values, returning zero when the voltage is not zero.

That's why ENOB is so useful.  Almost any fault in an ADC will lower ENOB.

So I will stick with people like Walter Kester for information on ADCs, not your guesses.

Quote
That is why I suggested that, since you seem to have got a very clean signal, a suitable cyclic perturbation signal would be better than arbitrary, uncharacterised noise.
You don't listen.  I said I don't do oversampling, I get a better converter.  I never suggested a way to inject noise for oversampling.  I just said oversampling won't work because the noise levels are so low.

I played with resistors and pickup by longer wires between the source and ADC to see how sensitive it was.

Adding a cyclic perturbation signal seems like a really bad idea.  You should just spend $5 for a better ADC.

Quote
This is so basic, I don't see why I am having to lay this out for a third time.
I ignore you because what you are saying is at odds with recognized authorities. 

You don't even know what the definition of resolution is for a ADC.  Show me a link to a definition where the it's other than the number of bits output by the converter.

I have spent my career at the finest science labs in the world.  Some of the world's best analog and mixed signal engineers are in these labs.  As a scientist I depended on them and learned from them.

Who are you?  What is the basis of your authority?   You never answered whether you are really an EE.
893  Using Arduino / Storage / Re: Unformatted write to SD on: August 20, 2012, 04:04:23 pm
This a quote from Analog Devices (not mine).
Quote
ENOB specifies the number of bits in the digitized signal above the noise floor, this is accuracy.
Here is another definition, not mine:
Quote
The effective number of bits (ENOB) is a way of quantifying the quality of an analog to digital conversion. A higher ENOB means that voltage levels recorded in an analog to digital conversion are more accurate.
Here is another from Analog Devices.
Quote
Resolution. An N-bit binary converter has N digital data inputs (DAC) or N digital data outputs (ADC). A converter that satisfies this criterion is said to have a resolution of N bits.
Resolution has nothing to do with accuracy.  It's the number of bits an ADC outputs or the number of bits of input to a DAC.

DC accuracy involves these (From Analog Devices), not resolution.
Quote
The static absolute accuracy of a DAC can be described in terms of three fundamental kinds of errors: offset errors, gain errors, and integral nonlinearity.
Another quote from Analog Devices.
Quote
The traditional static specifications such as differential nonlinearity (DNL) and integral nonlinearity (INL) are most certainly reflected in the ac performance.
That's why ENOB is a better measure for quality of signal measurements.  It combines all factors regarding accuracy of the measurement.

For simple DC measurements, non-linearity is the big deal.  Offset errors are easy to calibrate.  Many ADCs like the MCP3421 do it automatically.

From Microchip for the MCP3421
Quote
Self Calibration of Internal Offset and Gain Per Each Conversion.

It's true offset errors may not affect AC performance.  You must compensate for the AVR offset errors for DC measurements.

This is such basic stuff for an EE.  Are you really an EE?  If so when did you go to school?
894  Using Arduino / Storage / Re: Unformatted write to SD on: August 20, 2012, 02:27:12 pm
I missed this.
Quote
I would love to see a theoretical study that shows how adding noise to your signal improves the s/n ratio! I get the gut felling that is violating the second law somewhere on the line
Your funny, wrong but funny.  Time to read the ADC theory.

Quote
Note that this averaging is possible only if the signal contains perfect equally distributed noise (i.e. if the A/D is perfect and the signal's deviation from an A/D result step lies below the threshold, the conversion result will be as inaccurate as if it had been measured by the low-resolution core A/D and the oversampling benefits will not take effect).
The above means adding noise can improve accuracy with enough oversampling.  Too little noise will result in lower resolution.

This is why I never use oversampling, too much can go wrong.  Better to use a more accurate ADC.

Quote
This is why I was cautious about ENOB. It is only a measure of resolution , not accuracy.
Wrong again.

ENOB specifies the number of bits in the digitized signal above the noise floor, this is accuracy.  A 12-bit ADC has 12 bits of resolution but may not be accurate to 12-bits.

Are you really an EE?

Maybe I expect too much.  In physics I work with EEs that design ADCs and other IC parts. 

I worked on the CERN Atlas experiment that discovered the Higgs Boson.  The front end electronics used ASICs (Application Specific Integrated Circuit) designed by CERN engineers.  This is necessary for low noise, high speed, and these parts must be Radiation Hard.

I expect EEs to know theory.
895  Using Arduino / Storage / Re: New fast data logging sketches on: August 20, 2012, 11:58:27 am
Sorry, I get way too many requests to help with code for things like this.
896  Using Arduino / Storage / Re: Unformatted write to SD on: August 20, 2012, 11:10:44 am
I decided To post the DAC/ADC test data.  The DAC is a MCP4921 with 5 V ref. http://ww1.microchip.com/downloads/en/DeviceDoc/22248a.pdf.

I got the noise really clean now as you will see in the attached file.  Only about one reading varied in the set of 64 that I took at each DAC value.

Here is the sketch that generated the data
Code:
#include <McpDac.h>
void setup() {
  Serial.begin(9600);
  mcpDacInit();
  for (uint16_t i = 2000; i < 2024; i++) {
    mcpDacSend(i);
    for (uint16_t j = 0; j < 64; j++) {
      Serial.print(i);
      Serial.write(',');
      Serial.print(j);
      Serial.write(',');
      Serial.println(analogRead(0));
    }
    delay(500);
  }
}
void loop() {}
The sketch loads values from 2000 through 2023 into the DAC.  It then does 64 reads with analogRead() for that DAC value.
There are three columns: DAC value, reading #, ADC value.

The Arduino I used has a large offset error so it reads about 3 counts low.  This is not uncommon for an AVR ADC.  Be sure to calibrate your Arduino http://www.atmel.com/images/doc2559.pdf.

2001 on the DAC should be 500 on the ADC (2001*1023/4095 = 499.9).  The ADC reads 497.

You must be logged in to see the attached file.

Edit: I have now attached files taken with three Arduinos.  Arduino two and three have the fluctuation property since the DAC/ADC values lineup just right.  

This does not mean there is more noise with Arduino two and three.  If you don't understand, read the app notes, you claim to be an engineer so this should be easy.
897  Using Arduino / Storage / Re: Unformatted write to SD on: August 20, 2012, 08:40:42 am
The data looks like 10-bit stair-steps with a little fuzz every once in a while.  It should look like 12-bit stair-steps.  You can't see the fact that the input was from a 12-bit DAC and you can't recover the fact by averaging data.

I'm not going to waste any more of my time.

It's time for you to go back to school and learn what every young EE knows about digital converters.  I work with lots of EE students and they know this stuff.

There are plenty of free sources on the web.

There are newer books but this is a great book and it's free http://www.analog.com/library/analogDialogue/archives/39-06/data_conversion_handbook.html.

Your going to have more problems using a multiplexed AVR ADC to do oversampling on multiple channels.  So learn a little first.

Good luck.
898  Using Arduino / Storage / Re: Unformatted write to SD on: August 19, 2012, 09:24:10 pm
What happens is that three of the steps in the 12-bit DAC result in the same value for all reads with the 10-bit AVR ADC.

The fourth step results in two values but this doesn't mean there is 1 LSB of noise.  Often most of the readings are one of the values.

There is always some voltage where a tiny change will result in the next code.  At this point about half the readings will be n and half will be n+1 even with very low noise.

1LSB for The 10-bit AVR ADC with 5V reference means greater than 5V/1023 of noise.  You really should have more like twice that for oversampling to work.  You need to get more than one code for multiple reads at every voltage.

You really need to read about ADCs, all manufacturers have good app notes on oversampling.

Almost all app notes have charts to illustrate this concept and statements like this.
Quote
In this example, the actual voltage falls between two steps of the 12-bit ADC resolution and there is no
noise riding on the signal. It is easy to see the problem. With no noise on the signal, the ADC result for
each conversion will be the same. Averaging produces no effective gain in resolution.
899  Using Arduino / Storage / Re: Unformatted write to SD on: August 19, 2012, 06:16:22 pm
The tenth bit is the same for 1000 reads with analogRead() for about three out of four steps when I generate a ramp with a 12-bit DAC.

Oversampling just gives the 10-bit values not extra bits.  This is because for oversampling to work you need.
Quote
• The signal-component of interest should not vary significantly during a conversion.
• There should be some noise present in the signal.
• The amplitude of the noise should be at least 1 LSB.
See http://www.atmel.com/Images/doc8003.pdf.

If you power the Arduino with USB or a cheap wall wart there is plenty of noise.

I use a real power supply - one with a three prong grounded plug and low ripple/noise.  This supply is good for lots of amps so it's real overkill.

The DAC is on the Arduino using a shield Limor Fried gave me as a prototype.  She is good with ground planes and filtering.  I even put a big, 100K, resistor between the DAC and ADC and still didn't get noise.  I did get noise when I added about two feet of wire in addition to the resistor.

I would love to see a good case study that shows when ADC Noise Reduction Mode is needed and helps.
900  Using Arduino / Storage / Re: Unformatted write to SD on: August 19, 2012, 01:26:25 pm
What appears sub-optimal?  I just stuck the lines in the loop to test sleep, not as a test of jitter.

I didn't post the Noise Reduction tests.

Appears your C++ is a bit rusty. The first statement is a type declaration so the library will compile.  I could have put it anywhere before the call.
Code:
  int rawAnalogReadWithSleep();
This is the call:
Code:
  rawAnalogReadWithSleep();

The "no-op" ISR is necessary to field the wake-up interrupt.

Most of the time in the loop is spent sleeping.  The person that wrote this function is allowing for wake-up by interrupts other than the ADC.  If the ADC is not done, the function goes back into ADC Noise Reduction Mode.

"no-op" ISRs are not uncommon.  Sometimes they clear a flag or cause other status change. They are very fast since no context needs to be saved.  I use one to clear a timer flag in the 100,000 sample per second logger.

I did more testing on the ADC Noise Reduction Mode.  I used a high resolution DAC to generate a ramp.  The DAC is on a well designed shield on the Arduino I was testing.

I got the noise so low with just analogRead() that I couldn't do oversampling.  For a number of DAC steps the 10-bit Arduino ADC always gives the same value.  I don't need noise reduction, I need noise injection to make oversampling work.
Pages: 1 ... 58 59 [60] 61 62 ... 107