Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

ADC Are differential voltages always sampled simultaneously?

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Various
View previous topic :: View next topic  
Author Message
olhexy

Bascom Member



Joined: 03 Apr 2011
Posts: 192
Location: Tilburg, Netherlands

netherlands.gif
PostPosted: Mon Feb 24, 2014 2:14 pm    Post subject: ADC Are differential voltages always sampled simultaneously? Reply with quote

Hi,

I would like to measure the inductivity of a coil with mega1284P. It has to be fast (~0.2 msec) and 'accurate'.

As far as I understand: the samples for a differential ADC measurement are taken for both channels at the same time.

But I would like to take 2nd channel sample a short time after 1st channel, and then treat them as a differential voltage measurement.
Do I want the impossible, or is there a trick?

(I am afraid I need some kind of extra 'sample and hold' for that...)

(BASCOM-AVR version : 2.0.7.7 )
Back to top
View user's profile
Meister

Bascom Member



Joined: 27 May 2010
Posts: 319

blank.gif
PostPosted: Mon Feb 24, 2014 5:34 pm    Post subject: Reply with quote

Quote:
But I would like to take 2nd channel sample a short time after 1st channel, and then treat them as a differential voltage measurement.

That's not a good idea... You have to switch the MUX register and there will be lot of delay. See the manual on switching MUX. Or, look for an Xmega that has two separate ADCs (there are several). Then you don't need to switch MUX.

It is diificult to find out if there are Megas with two ADCs since the Atmel selection guides are just listing "Channels" and generally those are MUXed channels. My research ended with the conclusion that Megas just have one (muxed) ADC.
Regards, Meister
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Tue Feb 25, 2014 12:51 am    Post subject: Reply with quote

A differential measurement using the ADC MUX does exactly what it says, samples the difference in level between two channels. Not by measuring each channel separately, and than subtracting, but by differencing ( in analog terms ) the two channels, then measuring the result with the ADC. So it makes no sense to ask to delay the channels in this way.

But that said, in processor terms, 0.2 msec is a long time. You can get up around 50-100 ksamples per sec on a standard Atmega ADC. So just sample ( differentially if necessary ) once, wait 200 us, and then sample again. Then use the two readings. Sending a pulse on an unrelated line on each sample, and scoping that line to measure the actual time between samples will give you an idea of the timing, and how long to wait to get the interval you want.

Something like:
Code:

Dim var1 as word
dim var2 as word
Setup ADC
config pulseline as output 'pick a spare line

do
set pulseline 'drive pulse line high
var1 = ReadADC 'read ADC into var1
reset pulseline 'drive line low, width of pulse = time to read the ADC
waitus 200 'adjust as necessary
set pulseline
var2 = ReadADC 'read ADC into var2
reset pulseline 'drive pulseline low

'processs the data var2 - var1
loop
 

Then the time between the two pulses gives you the real delay time. Adjust the waitus timing to suit what you want.

Of course if you dont have access to a scope, you can also start a timer running, and read its time into variables at the start and end of each process, then print the variables to see the elapsed time in timer counts. That works just as well.

_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
olhexy

Bascom Member



Joined: 03 Apr 2011
Posts: 192
Location: Tilburg, Netherlands

netherlands.gif
PostPosted: Tue Feb 25, 2014 4:13 pm    Post subject: Reply with quote

Meister and Adrian, thanks for your replies.

Adrian, it was my first idea to do repetative samples at 5 kHz. But the problem is that within such a short time the voltage differences are minimal in relation to the full scale. So there is almost no resolution left.
A differntial sample is easily amplified 10x or 200x.
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Wed Feb 26, 2014 2:48 am    Post subject: Reply with quote

I see your point. A sample and hold is another way, as you suggest. Another would be to use a much higher resolution ADC, like a Delta-Sigma converter. But beware the sampling speed, and the system noise !

You say you want to measure the inductance of a coil, presumably by applying a constant current, and measuring the voltage at two times. Any other special requirements ? Or can you afford just to wait longer, hence getting a bigger voltage difference.

_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
olhexy

Bascom Member



Joined: 03 Apr 2011
Posts: 192
Location: Tilburg, Netherlands

netherlands.gif
PostPosted: Wed Feb 26, 2014 2:00 pm    Post subject: Reply with quote

(I am playing with a solenoid. Main inspiration is from this document: http://158.132.178.85/norbert/Papers/C005.pdf The plunger position has to be found by measuring the systems changing selfinduction.)

Adrian, I am trying to avoid a complex S&H.

Found this: http://memo.cgu.edu.tw/wu-shiung/course/CommunIC/9__Sample_and_Hold_4_24.pdf

My idea: 2 equivalent S&H circuits with just a BS170 and a capacitor like shown at page 9 ("Fully different sampling" - slide 33). This looks very simple. The difference is that each FET has to be separately switched: second FET a short time dt after the first FET.
I could give some microseconds settling time before picking up the voltages by AVR's ADC, and then get a pretty good differential voltage measurement result, I think. Because both S&H are the same the combined errors are widely eliminated.
Your thoughts?
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Wed Feb 26, 2014 11:42 pm    Post subject: Reply with quote

Firstly, we should probably move this discussion to a different forum, like "Various". At this stage it has not much to do with Bascom.

Moved to:
http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&p=63515#63515

_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
kimmi

Moderator



Joined: 24 Feb 2006
Posts: 1922
Location: Denmark

denmark.gif
PostPosted: Thu Feb 27, 2014 12:03 am    Post subject: Reply with quote

topic moved to Various
_________________
/ Kim
Back to top
View user's profile Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Various All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum