Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
4ckatro
PostPosted: Apr 16, 2012 - 07:51 PM
Newbie


Joined: Apr 12, 2012
Posts: 7


Hi there!

I had ordered a sample of ADS7813 form TI and tried to get work with an Arduino board. And my problem is i cant get out a better resolution than two decimal place. The first 10 bit seems ok, from MSB, but the last 6 bits are togglin. Here are my conversion results:

3.2569353 10100110101110
3.2569353 10100110110101
3.2584612 10100110110110
3.2599871 10100110111001
3.2609026 10100110110101
3.2609026 10100110111000
3.2609026 10100110110001
3.2657856 10100110110100
3.2599871 10100110110100
3.2566301 10100110110001
3.2526626 10100110110100
3.2566301 10100110110101
3.2593767 10100110101100
3.2609026 10100110110110

The first column values is in voltage the second columns values is the conversion result.

I bulid the circuit in a bread-board i used the same capacitors as in the datasheet i tried another input values and i got the same results. I tried with battery or with lab supply but i got the same result.


here is my code in Arduino (same as C):


digitalWrite(CLOCK,LOW);

digitalWrite(CONV,LOW);
//this start the conversation

delayMicroseconds(1);

digitalWrite(CONV,HIGH);



while(busy==0){ // while BUSY is high still wait

busy=digitalRead(BUSY);

}


for(int i=0;i<16;i++){ //here start the read of the 16 bit

digitalWrite(CLOCK,HIGH);

x[i]=digitalRead(DATA);

delayMicroseconds(20);

digitalWrite(CLOCK,LOW);

}




for(int j=1, c=16384j<16;j++,c=c/2){ //this is how i piece together the 16 bit data in decimal, 15bit because the firs is the sign bit

val+=x[j]*c;

}



val=5*val*(double)1/32767; //this is how i convert the number to voltage with +-5V input range

I tried to contact with TI community, but they sucked.
What did i mess up?

Cheers
Robert
 
 View user's profile Send private message  
Reply with quote Back to top
Kartman
PostPosted: Apr 17, 2012 - 03:40 AM
Raving lunatic


Joined: Dec 30, 2004
Posts: 8723
Location: Melbourne,Australia

Board layout is critical for low noise operation. What is the source of the voltage you are measuring? What makes you sure that the ADC is not telling you the truth? Realise that once you start getting into sub 1mV values, that there are a number of physical effects that come into play. One is thermocouples that cause temperature related drift. The major contributor is noise.

Put your cell phone near your circuit and watch it go stupid as the phone reports in.
 
 View user's profile Send private message  
Reply with quote Back to top
Chuck99
PostPosted: Apr 17, 2012 - 06:33 AM
Hangaround


Joined: Oct 31, 2009
Posts: 148
Location: Vancouver, WA, USA

4ckatro wrote:
And my problem is i cant get out a better resolution than two decimal place. The first 10 bit seems ok, from MSB, but the last 6 bits are togglin.


From the ADS7813 datasheet:
Quote:
SENSITIVITY TO EXTERNAL DIGITAL SIGNALS
All successive approximation register-based A/D converters are sensitive to external sources of noise. The reason for this will be explained in the following paragraphs. For the ADS7813 and similar A/D converters, this noise most often originates due to the transition of external digital signals. While digital signals that run near the converter can be the source of the noise, the biggest problem occurs with the digital inputs to the converter itself.
...
For the ADS7813, error correction is done when the tenth bit is decided. During this bit decision, it is possible to correct limited errors that may have occurred during previous bit decisions.
However, after the tenth bit, no such correction is possible.

This seems to indicate that your problem is external noise.

Also, in the schematic you provided, I don't see a capacitor on the input from the pot. Adding one might also help.
 
 View user's profile Send private message  
Reply with quote Back to top
4ckatro
PostPosted: Apr 17, 2012 - 06:41 AM
Newbie


Joined: Apr 12, 2012
Posts: 7


Thanks for fast reply!
I found a description about i should use an RC filter and a OP amp on the analoge input for signal conditioning. I will try that method then i will back.
Btw i tried to measure a cellphone battery or a lab supply voltage but i got the same result.
 
 View user's profile Send private message  
Reply with quote Back to top
DocJC
PostPosted: Apr 17, 2012 - 02:29 PM
Raving lunatic


Joined: Dec 11, 2007
Posts: 6841
Location: Cleveland, OH

Quote:
I found a description about i should use an RC filter and a OP amp on the analoge input for signal conditioning.


This, unfortunately, won't change the problem you are having.

The RC filter is based on digital sampling theory. High Frequency signals, where the frequency components are higher then 1/2 of the sampling frequency, appear as low frequency signals when sampled. This can give errors in the measurements.

See Wiki Nyquist-Shannon Sampling Theory for a technical discussion on this.

A simplier example is shown here: National Instruments: Bandwidth, Sample Rate, and Nyquist Theorem .

The op-amp is to buffer the LPF and probide a low impedance signal source to drive the ADC.

JC
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
jgmdesign
PostPosted: Apr 17, 2012 - 02:36 PM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6061
Location: Long Island New York

You will NEVER get ALL the bits to sit still no mater what filtering you add. The higher the resolution the more 'jumpiness' you will get because the last few bits will jump around from the slightest input variations. Even 8 bit A/D's do this, but not as bad because the resolution/bit is not as high. Keep in mind you are showing results 7places to the RIGHT of the decimal. just about anything is going to make those bits move around.

What you can do is set a 'reference zero' where you ignore the last couple of bits. This cn be accomplished by a bitwise AND to remove the offending bits, then shift them right xBITS to get your 'stable' reading.

Another option is to sample the input readings and take an average. More code to write.

Don't get me wrong, adding input filtering will help, but it will not eliminate the jumping.

Ask yourself, "DO I really need 7 places to the right of the decimal?"

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
theusch
PostPosted: Apr 17, 2012 - 02:54 PM
10k+ Postman


Joined: Feb 19, 2001
Posts: 25880
Location: Wisconsin USA

Quote:

Ask yourself, "DO I really need 7 places to the right of the decimal?"

And if you do, you need a "squeaky clean" analog subsystem. There can be >>no<< ripple in power supply or ground or reference or signal. And that ripple can easily be from external sources as well as internal (e.g. power supply). Breadboard setups are likely to never be squeaky-clean.
 
 View user's profile Send private message  
Reply with quote Back to top
DocJC
PostPosted: Apr 17, 2012 - 03:26 PM
Raving lunatic


Joined: Dec 11, 2007
Posts: 6841
Location: Cleveland, OH

And, after you add whatever "averaging" you want for several samples, then one can add yet another layer with a "window". If the newest value, (already averaged), deosn't vary my more than X amount, then just keep displaying the previous value. This can be used to get rid of the last digit(s) jitter, bouncing back and forth between two values, that simple averaging does not eliminate.

JC

Edit: typo


Last edited by DocJC on Apr 17, 2012 - 07:01 PM; edited 1 time in total
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Plons
PostPosted: Apr 17, 2012 - 03:30 PM
Raving lunatic


Joined: Nov 01, 2005
Posts: 6323
Location: Hilversum - the Netherlands

OP wrote:
Quote:
I bulid the circuit in a bread-board i used the same capacitors as in the datasheet i tried another input values and i got the same results. I tried with battery or with lab supply but i got the same result.
With a 16 bit A-to-D on a breadboard it is almost impossible to get 16 bit accuracy. The pot gets the 5V and Gnd from the Arduino. That's a no-go. The use of a floating cellphone battery is better when you do these accurate measurements. But then still: where gets the ADS7813 the power from ? And how and where do you connect the cellphone battery ?
Signal routing as well as power routing is what this is all about.
You need a floating powersource for the ADS7813. Most powersupplies have their ground (or negative) output connected to safety ground. So that does not float. Your PC does not float either: with as a result: a groundloop. So noise and hummm.
Alternative: use a laptop running of the built-in battery. No other connections allowed, except for the Arduino USB. Power the Arduino from the laptop.
Connect the ground from Arduino to Ground of the ADS7813. Power the ADS7813 from a GOOD lab powersupply (Which doesn't have to float now since the laptop is floating). Use proper decoupling.
Disconnect the ISP-programmer (if you use that)

Add 330 Ohm resistors in all digital signal lines between Arduino and breadboard.
Connect the cellphone battery to pins 4 and 8 of the ADS7813, but only when the lab-powersupply is on !

Now test again. I cannot predict if you will achieve 16 bit accuracy with this setup. But the results will be much better !

_________________
Dragon broken ? Or problems with the Parallel Port Programmer ? Scroll down on my projects-page http://www.aplomb.nl/TechStuff/TechStuff.html for tips
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
4ckatro
PostPosted: Apr 17, 2012 - 05:57 PM
Newbie


Joined: Apr 12, 2012
Posts: 7


Quote:
This, unfortunately, won't change the problem you are having.


You right, i tried and i got the same problem.

Quote:
You will NEVER get ALL the bits to sit still no mater what filtering you add. The higher the resolution the more 'jumpiness' you will get because the last few bits will jump around from the slightest input variations. Even 8 bit A/D's do this, but not as bad because the resolution/bit is not as high. Keep in mind you are showing results 7places to the RIGHT of the decimal. just about anything is going to make those bits move around.


I had used a 12bit Max186 ADC on protoboard and i got the results 5-6 places accurate on the right of dec. That is why i thought the ADS7813 would work on protoboard.

Maybe i not need a 6-7 places accurate on the right of the decimal but if i had this IC why shouldnt i use it with the best resolution.

Quote:
There can be >>no<< ripple in power supply or ground or reference or signal. And that ripple can easily be from external sources as well as internal (e.g. power supply).


I tried to change the supply. With a laptop battery + 7805 same result. I tried with a lab supply same thing..

Quote:
Add 330 Ohm resistors in all digital signal lines between Arduino and breadboard.
Connect the cellphone battery to pins 4 and 8 of the ADS7813, but only when the lab-powersupply is on !


I will try it! But did you mean i shoulld direct connect the resistor between Arduino and breadboard or pull up this line to 5V?

At worst case i will make a PCB layout and build it. But i still hope it will work on protoboard well, because this AD would be a little piece of the measurment equipment.

Thanks to all for responding i will think about these things then will back.

PS: Sorry my bad english Razz
 
 View user's profile Send private message  
Reply with quote Back to top
Plons
PostPosted: Apr 17, 2012 - 08:27 PM
Raving lunatic


Joined: Nov 01, 2005
Posts: 6323
Location: Hilversum - the Netherlands

Quote:
I will try it! But did you mean i shoulld direct connect the resistor between Arduino and breadboard or pull up this line to 5V?
in between, IN the line, so in series. Close to the Arduino, that's the best.

I am really surprised that the best you can achieve is 10 bits. I think you need to post a photo of the setup that performs best. We then can try to spot the flaw.

_________________
Dragon broken ? Or problems with the Parallel Port Programmer ? Scroll down on my projects-page http://www.aplomb.nl/TechStuff/TechStuff.html for tips
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
4ckatro
PostPosted: Apr 17, 2012 - 09:17 PM
Newbie


Joined: Apr 12, 2012
Posts: 7


On thursday forenoon i will be in the lab and i will try it. I will take some photos then i'll back.
 
 View user's profile Send private message  
Reply with quote Back to top
Plons
PostPosted: Apr 17, 2012 - 11:49 PM
Raving lunatic


Joined: Nov 01, 2005
Posts: 6323
Location: Hilversum - the Netherlands

Attached a sketch of a setup that *should* give you better results. This sketch is a drawing of the setup I described earlier.

Make sure you use all the capacitors that are recommended in the datasheet of the ADS7813.

If you replace the clean PSU with a laptop-battery, followed by a 7805 or alike:
1. Don't make shorts !
2. Add 2 capacitors at In and Out of the voltage regulator: a tantalum cap in parallel with a ceramic one.

Good luck !


Edit: there is a lot of valuable info in the datasheet of the BurrBrown datasheet of the ADS7813. It also explains why less significant bits are jittering.

_________________
Dragon broken ? Or problems with the Parallel Port Programmer ? Scroll down on my projects-page http://www.aplomb.nl/TechStuff/TechStuff.html for tips
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
jgmdesign
PostPosted: Apr 18, 2012 - 03:42 AM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6061
Location: Long Island New York

Nard,
That CAD software package you used for the schematic is JUST what I have been looking for. What is the name and how much?

I have been using PADSLogic for so long, it would be nice to have a decent software package.

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
Plons
PostPosted: Apr 18, 2012 - 01:59 PM
Raving lunatic


Joined: Nov 01, 2005
Posts: 6323
Location: Hilversum - the Netherlands

Glad you ask that, Jim.

It's called P&P and has been around for ages. There are an awfull lot of versions around.
Nice features are:
1. Direct printing
2. Freedom of shapes, lines and fonts
3. Easy to correct/adapt the design
4. Very well protected against copying: the source will be yours for always, unless you send it someone else: so it is transferable to another author, but only if *you* choose to

Drawbacks are:
1. No re-scaling, no re-draw. But there is a workaround using scissors and a fresh sheet.
2. Not all fonts are optimized for reading.

I have been using it for years and quite happy with it.

Check it out !

Nard

_________________
Dragon broken ? Or problems with the Parallel Port Programmer ? Scroll down on my projects-page http://www.aplomb.nl/TechStuff/TechStuff.html for tips
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
jgmdesign
PostPosted: Apr 18, 2012 - 02:55 PM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6061
Location: Long Island New York

Laughing

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
toalan
PostPosted: Apr 19, 2012 - 03:44 AM
Posting Freak


Joined: Jul 21, 2005
Posts: 1373


Breadboard is very tough to get anything accurate, 10 bits is actually very decent on breadboard.

My preference is integrating and Delta Sigma ADCs for high resolution. SAR is too noise prone.
 
 View user's profile Send private message  
Reply with quote Back to top
valusoft
PostPosted: Apr 19, 2012 - 05:18 AM
Raving lunatic


Joined: Jul 02, 2005
Posts: 5915
Location: Melbourne, Australia

I have two cad methods worth mentioning; LTS&S and HTS&S. The maximum lifetime of the images created with LTS&S is about 6 hours even on weekends. Laughing

_________________
Ross McKenzie
ValuSoft
Melbourne Australia
 
 View user's profile Send private message  
Reply with quote Back to top
4ckatro
PostPosted: Apr 19, 2012 - 04:58 PM
Newbie


Joined: Apr 12, 2012
Posts: 7


Well, i tested the circuit with the offered method and i didnt get a better res. I used the laptop usb 5V for the arduino with unplugged charger, the adc was supplied with a lab supply. I connceted the USB gnd with the Lab supply GND. The measurment voltage was a battery. A took some photos. And i used 3 330 resistor to the CLOCK,DATA and CONV line.









 
 View user's profile Send private message  
Reply with quote Back to top
Plons
PostPosted: Apr 19, 2012 - 11:37 PM
Raving lunatic


Joined: Nov 01, 2005
Posts: 6323
Location: Hilversum - the Netherlands

Thanks for the detailed decription and pictures, guys.

toalan wrote:
Quote:
My preference is integrating and Delta Sigma ADCs for high resolution. SAR is too noise prone.
That's a good point: successive approximation is fast but very sensitive for noise. In the datasheet it's very well explained. Delta Sigma ADCs are better

Back to the setup: I spot a few possible causes for the jitter.
1. PSU is grounded, I presume. And the oscilloscope as well. Same problem why I recommended a floating laptop. Take the scope-probes off, including the groundclips when checking the jitter.
2. Wires from the digital side of the ADS7813 "fly over" the analog circuit. And induce noise there.
3. I think you're using tinned stranded wire for the connections. There is always flux residu on the tinned ends. Noisy. Same for the tin-oxide: noisy as well. Use solid wire. With clean ends. And a good breadboard.
4. There is no decoupling close to the Vcc ( 16 ) and Gnd ( 8 ) pin of the ADS7813. Place those capacitors diagonally over the DIP-package.
5. Wires from the cellphone battery are too long for this purpose. And add a capacitor from R3in to pin 8.

I will get back to this tomorrow (Saterday)

Bedtime here.


PS In the meantime: make a program that spits the conversion results from the Arduino to a PC, running a terminal program. Use the highest baudrate that is possible. Each result is (between -32768 and +32767) should be terminated with a <CR>.
Terminalprogram saves the incoming results in a file, with .csv as type. Import that file in a spreadsheet and make it do some statistics on the numbers. We are interested in Average value and Standard Deviation.

With this SW tool you can see the effect of each measure you take.

_________________
Dragon broken ? Or problems with the Parallel Port Programmer ? Scroll down on my projects-page http://www.aplomb.nl/TechStuff/TechStuff.html for tips
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
Plons
PostPosted: Apr 20, 2012 - 01:26 PM
Raving lunatic


Joined: Nov 01, 2005
Posts: 6323
Location: Hilversum - the Netherlands

To find out what contributes to the wobbling LSB's, we need somne SW effort.
Setup a timer that interrupts every 20ms. On that interrupt, do one conversion and spit the result out to the PC's terminal program. Gather 1000 samples or so. Do the histogram thingie I described in my previous post.
If the standard deviation is much less than in your previous experiments, we are facing interference from the mains (50Hz hummmm). If the results are simular to what you found first, take the next step.



With the input configuration you use, the input range is -5V to +5V (page 4 of the datasheet)
16 bit over 10V range, that's appr. 153uV per bit.
The reference voltage is 2.5V, so 38uV deviation results in 1 bit deviation in result. Pretty sensitive that Reference, huh ?

Why these figures ? To show you in what area we're in: the microVolt domain.
Have a look at the way the DIP-package pinning is defined by the manufacturer: all analog stuff at the lower pins, all digital on the higher pins.
Have a look at page 16: see the histogram ? That is the best you can achieve.

I don't have an ADS7813 in stock, so I use something else to show how I would set this up to achieve maximum performance. So mine is just a mock-up Smile
Short wires on components, close to the pins of the ADS7813. The only long wires are those that leave the board.
(Btw, in my setup I left out the 330R close to the Arduino: I didn't want to solder those to the breadboard wires. But you should put them in.)

I added an LC low pass filter to the measurement input and an inductor in the Vcc-powerline from the lab supply. Try it, and check the result of each step with the histogram.

Enjoy the ride !

Nard

_________________
Dragon broken ? Or problems with the Parallel Port Programmer ? Scroll down on my projects-page http://www.aplomb.nl/TechStuff/TechStuff.html for tips
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
4ckatro
PostPosted: Apr 20, 2012 - 09:14 PM
Newbie


Joined: Apr 12, 2012
Posts: 7


Thanks for the advice and the pictures!
Next week i will try it. Sounds good, i hope it will work!
 
 View user's profile Send private message  
Reply with quote Back to top
sparrow2
PostPosted: Apr 20, 2012 - 10:43 PM
Raving lunatic


Joined: Oct 07, 2002
Posts: 2011
Location: Denmark

Here are some general things to try, but in general you cant get more than 12 bit without a special ground plan!
1: feed the 5V thru a LC filter.
2: make sure that the time the sample hold is open no IO's on the micro change level (best is sleep if it can be timed).

to test what you max can expect, feed the analog input with VCC/2 from two res placed close to the ADC, you will never get a better result that that !
 
 View user's profile Send private message  
Reply with quote Back to top
Plons
PostPosted: Apr 20, 2012 - 10:59 PM
Raving lunatic


Joined: Nov 01, 2005
Posts: 6323
Location: Hilversum - the Netherlands

sparrow2 wrote:
Quote:
to test what you max can expect, feed the analog input with VCC/2 from two res placed close to the ADC, you will never get a better result that that !
I don't agree. Vcc may vary several mV's. Better is to take Vref, feed that to an OpAmp (follower) and feed the output to AnalogIn. But hehe, OpAmps produce noise as well, so another RC or LC between OpAmp and AnalogIn.
Where does it end ??? Wink

It is a PDQ converter and I don't see a S&H in the datasheet. But keeping the Arduino quiet (I/O-wise) during conversion-time is a good idea !

_________________
Dragon broken ? Or problems with the Parallel Port Programmer ? Scroll down on my projects-page http://www.aplomb.nl/TechStuff/TechStuff.html for tips
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
sparrow2
PostPosted: Apr 21, 2012 - 12:11 AM
Raving lunatic


Joined: Oct 07, 2002
Posts: 2011
Location: Denmark

sorry if there is a vref use that and not vcc, I just didn't see it on the diagram.
 
 View user's profile Send private message  
Reply with quote Back to top
sparrow2
PostPosted: Apr 21, 2012 - 12:15 AM
Raving lunatic


Joined: Oct 07, 2002
Posts: 2011
Location: Denmark

from the data sheet for not conv pin :
Convert Input. A falling edge on this input puts the internal sample/hold into the hold state and starts a conversion regardless
of the state of CS

so there must be a SH !
 
 View user's profile Send private message  
Reply with quote Back to top
4ckatro
PostPosted: Apr 21, 2012 - 09:02 AM
Newbie


Joined: Apr 12, 2012
Posts: 7


And is it important to change the CS HIGH to LOW with arduino or if i connect to ground does it also good enough?
 
 View user's profile Send private message  
Reply with quote Back to top
Plons
PostPosted: Apr 21, 2012 - 11:10 PM
Raving lunatic


Joined: Nov 01, 2005
Posts: 6323
Location: Hilversum - the Netherlands

4ckatro wrote:
And is it important to change the CS HIGH to LOW with arduino or if i connect to ground does it also good enough?
Two ways to check that: 1. datasheet and 2. try it Smile

Nevertheless: a good question. My latest board design included a Nokia color display and since it was the only device on the SPI-bus, I assumed that tying /CS to ground was OK. But I found out later that the controller needed a high-to-low transition on /CS to work. Crap. The connection between Ground and /CS sits under the 10 pin (very small) smd connector.
Assumption is the mother of all f*&^% ups. How true.

sparrow2 wrote:
Quote:
so there must be a SH !
Agree. A bit odd it's not in the block diagram.

_________________
Dragon broken ? Or problems with the Parallel Port Programmer ? Scroll down on my projects-page http://www.aplomb.nl/TechStuff/TechStuff.html for tips
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits