Exact match. Not showing close matches.
PICList
Thread
'[PIC] Question about a/d converter'
2006\02\25@084407
by
Will
Hello,
I was wondering, how useful is the A/D capability of PIC for
signal sampling. I want, if possible, to be able to connect a 12v
ac transformer to the a/d pin and to sample the waveform and
display the sine wave on an LCD. Is it possible?
Tia
2006\02\25@161750
by
Maarten Hofman
Rochester, 25 februari 2006.
Dear Tia,
It is likely that you'll have to "massage" your input signal to comply
with the requirements of the A/D input pin: scale down the voltage,
and possibly use an OPAMP to increase impedance (see a previous
discussion about this on this same list). What is more relevant is the
frequency of your signal: if it is too high, the A/D converter will be
too slow to convert it. With the AC transformer I assume you're
measuring a 50 Hz signal, which should be no problem for any PICmicro
with A/D converter.
Displaying the result on an LCD is a different story, but at 50 Hz
should certainly be possible. Most graphical LCD don't have a fixed
response time, so they might "hang" for a while occasionally as you
write to them. An interrupt buffering the A/D conversions is a
solution there.
Greetings,
Maarten Hofman.
\
2006\02\25@181418
by
Will
|
> It is likely that you'll have to "massage" your input signal to comply
> with the requirements of the A/D input pin: scale down the voltage,
> and possibly use an OPAMP to increase impedance (see a previous
> discussion about this on this same list). What is more relevant is the
> frequency of your signal: if it is too high, the A/D converter will be
> too slow to convert it. With the AC transformer I assume you're
> measuring a 50 Hz signal, which should be no problem for any PICmicro
> with A/D converter.
>
> Displaying the result on an LCD is a different story, but at 50 Hz
> should certainly be possible. Most graphical LCD don't have a fixed
> response time, so they might "hang" for a while occasionally as you
> write to them. An interrupt buffering the A/D conversions is a
> solution there.
Hi,
I can use a pc to display the results, with uart or usb to transfer the
samples. But do I need to think about any other problems. For
example, what about eliminating noise, and also what is the best
sampling period, since I can choose the a/d sampling time. I.e.
if I choose a long sampling period will I be more exposed to the
noise problem. Should I use an RC circuit to filter out noises?
Tia
>
> Greetings,
> Maarten Hofman.
'[PIC] Question about a/d converter'
2006\03\01@094929
by
Will
|
> Rochester, 25 februari 2006.
>
> Dear Tia,
>
> It is likely that you'll have to "massage" your input signal to comply
> with the requirements of the A/D input pin: scale down the voltage,
> and possibly use an OPAMP to increase impedance (see a previous
> discussion about this on this same list). What is more relevant is the
> frequency of your signal: if it is too high, the A/D converter will be
> too slow to convert it. With the AC transformer I assume you're
> measuring a 50 Hz signal, which should be no problem for any PICmicro
> with A/D converter.
It's not "no problem", it will be ok, but there is not a lot of margin,
here is why:
Tacq= Aquisition time= 20usec
n= Number of samples for good waveform display = 100
f= Frequency= 50hz, but for rectified ac it is actually double = 100
1/100 = 0.01 (T= 1/f)
0.01/Tacq = 0.01/20u = 10/20m= 0.5k= 500
namely, we should be able to obtain 500 samples per waveform on
screen, which is very good quality. But you can see that if you increase
your frequency to 500Hz, you are approaching the limit.
>
> Displaying the result on an LCD is a different story, but at 50 Hz
> should certainly be possible. Most graphical LCD don't have a fixed
> response time, so they might "hang" for a while occasionally as you
> write to them. An interrupt buffering the A/D conversions is a
> solution there.
>
> Greetings,
> Maarten Hofman.
2006\03\01@140702
by
Gerhard Fiedler
Will wrote:
> Tacq= Aquisition time= 20usec
> n= Number of samples for good waveform display = 100
> f= Frequency= 50hz, but for rectified ac it is actually double = 100
>
> 1/100 = 0.01 (T= 1/f)
> 0.01/Tacq = 0.01/20u = 10/20m= 0.5k= 500
>
> namely, we should be able to obtain 500 samples per waveform on
> screen, [...]
Maybe you should read up again the ADC section of the manual and pay
attention to the difference between acquisition time and conversion time.
The conversion time is what you always have (and you seem not to be
considering it here). The acquisition time is what you only need after you
switched channels. If you are reading only one ADC channel, you usually can
use an acquisition time of 0.
Gerhard
2006\03\01@145416
by
olin piclist
From: "Gerhard Fiedler" <spam_OUTlistsTakeThisOuT
connectionbrazil.com>
> If you are reading only one ADC channel, you usually can
> use an acquisition time of 0.
Not really. The internal capacitor still has to charge to the new input
voltage.
******************************************************************
Embed Inc, Littleton Massachusetts, (978) 742-9014. #1 PIC
consultant in 2004 program year. http://www.embedinc.com/products
2006\03\01@150211
by
Thomas C. Sefranek
-----Original Message-----
From: .....piclist-bouncesKILLspam
@spam@mit.edu [piclist-bounces
KILLspammit.edu] On Behalf Of
Gerhard Fiedler
Sent: Wednesday, March 01, 2006 1:54 PM
To: .....piclistKILLspam
.....mit.edu
Subject: Re: [PIC] Question about a/d converter
>The conversion time is what you always have (and you seem not to be
>considering it here). The acquisition time is what you only need after you
>switched channels. If you are reading only one ADC channel, you usually can
>use an acquisition time of 0.
>Gerhard
I disagree. Selection of charge source is NOT the sampling switch!
The sampling switch and series impedance dictate a phase/time delay in
combination with the internal charge hold capacitor. (120 pF)
The holding capacitor is NOT continuously refreshed.
Read the example, you will see microseconds for the minimum charging time.
Tom
*
| __O Thomas C. Sefranek EraseMEtcsspam_OUT
TakeThisOuTcmcorp.com
|_-\<,_ Amateur Radio Operator: WA1RHP
(*)/ (*) Bicycle mobile on 145.41MHz PL74.4
ARRL Instructor, Technical Specialist, VE Contact.
hamradio.cmcorp.com/inventory/Inventory.html
http://www.harvardrepeater.org
2006\03\01@151021
by
Michael Rigby-Jones
|
{Quote hidden}>-----Original Message-----
>From:
piclist-bounces
spam_OUTmit.edu [
@spam@piclist-bouncesKILLspam
mit.edu]
>Sent: 01 March 2006 20:02
>To: 'Microcontroller discussion list - Public.'
>Subject: RE: [PIC] Question about a/d converter
>
>
>
>
>-----Original Message-----
>From:
KILLspampiclist-bouncesKILLspam
mit.edu [
RemoveMEpiclist-bouncesTakeThisOuT
mit.edu]
>On Behalf Of Gerhard Fiedler
>Sent: Wednesday, March 01, 2006 1:54 PM
>To:
spamBeGonepiclistspamBeGone
mit.edu
>Subject: Re: [PIC] Question about a/d converter
>
>>The conversion time is what you always have (and you seem not to be
>>considering it here). The acquisition time is what you only
>need after you
>>switched channels. If you are reading only one ADC channel,
>you usually can
>
>>use an acquisition time of 0.
>
>>Gerhard
>
>
>I disagree. Selection of charge source is NOT the sampling
>switch! The sampling switch and series impedance dictate a
>phase/time delay in combination with the internal charge hold
>capacitor. (120 pF) The holding capacitor is NOT continuously
>refreshed.
>From the datasheet diagrams, the capacitor would appear to be continuously connected to the A/D pin once a channel has been selected (the "sampling switch" refers to the analog mux according to my FAE). In fact common sense tells us this must be the case, as you don't have to do anything to initiate an acquisiation once a channel has been selected for the first time. There is some impedance in the analog switch though, so the cap would undoubtedly need some recovery time after a sample has been taken.
Regards
Mike
=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================
2006\03\01@151208
by
Jan-Erik Soderholm
Gerhard Fiedler wrote :
> If you are reading only one ADC channel,
> you usually can use an acquisition time of 0.
Maybe, if the input signal changes slowly (or
"just a little") between two conversions.
No, if the next sample is a complete random value.
Jan-Erik.
2006\03\01@152157
by
Thomas C. Sefranek
Look at the data sheet again,
It shows an internal sample switch AS WELL AS selector switches.
*
| __O Thomas C. Sefranek TakeThisOuTtcsEraseME
spam_OUTcmcorp.com
|_-\<,_ Amateur Radio Operator: WA1RHP
(*)/ (*) Bicycle mobile on 145.41MHz PL74.4
ARRL Instructor, Technical Specialist, VE Contact.
hamradio.cmcorp.com/inventory/Inventory.html
http://www.harvardrepeater.org
{Original Message removed}
2006\03\01@154701
by
Jan-Erik Soderholm
The "holding cap" is disconnected from the input during
the conversion time. After the conversion it is automaticly
connected to the input pin again. Now, if the voltage on the
input pin has changed conciderably during the conversion,
I'd guess that you need a new acquisition time to let the
holding cap re-charge to the new input voltage, before
starting a new conversion, not ?
Jan-Erik.
2006\03\01@160134
by
Maarten Hofman
> No, if the next sample is a complete random value.
This is correct... The example I read (in the manual for the 16F630)
shows that the hold capacitor charging/decharging is the largest part
of the time. However, it also talks about the maximum allowed error.
This all brings me to another point, which is the actual LCD display.
When I read the original question, I was thinking of the usual type of
display I would attach to a PICmicro. Obviously it would need to be
graphical, so a T6963C of 64*128 ($25 on futurlec) pixels seemed like
an appropriate choice. Obviously you can go more expensive, but at
some point a dedicated external A/D converter would become preferable
(as the price/size of the display would outweigh the cost/size of the
A/D converter).
Given a 64*128 bit display you only need 128 samples, and not 500.
Also, you only need 6-7 bits of resolution, which means you can skimp
on the acquisition time (note that the 10F220 manual, with its 8-bit
A/D converter, doesn't even mention acquisition times, and assumes all
conversions can take place within 7us).
Greetings,
Maarten Hofman.
2006\03\01@180712
by
Gerhard Fiedler
Jan-Erik Soderholm wrote:
> The "holding cap" is disconnected from the input during the conversion
> time. After the conversion it is automaticly connected to the input pin
> again. Now, if the voltage on the input pin has changed conciderably
> during the conversion, I'd guess that you need a new acquisition time to
> let the holding cap re-charge to the new input voltage, before starting
> a new conversion, not ?
Yes. That's why I said "usually". This of course means that there /are/
(IMO rare) conditions where this is not the case.
I'd venture a guess and say that in most cases when only one input is read
there is a suitable combination of slow enough input changes and the
program's reaction time to the end of conversion signal that the hold cap
has enough time to charge before the next conversion.
Especially when we are talking about mains wave forms.
Gerhard
2006\03\02@080536
by
Maarten Hofman
> Especially when we are talking about mains wave forms.
Yes, in our current scenario there is no reason to assume that there
would be a sudden change between samples, unless something odd happens
on the input signal (which brings me to the question: if we are
designing this to just display a 50 Hz or 60 Hz curve, why are we even
bothering sampling? We could just make a table, display it and be done
with it... When we are sampling, we would even have to make
intelligent decisions on when to restart at the left of the
screen...).
> Yes. That's why I said "usually". This of course means that there /are/
> (IMO rare) conditions where this is not the case.
Why rare? Wouldn't a proper design of sampling an analog signal (not
for display on a screen by a PICmicro, but for other purposes) use the
Nyquist–Shannon sampling theorem, and therefore be designed such that
at the maximum frequency slightly more than two samples/period are
taken? With only two samples/period the values could be anywhere
within the range.
Greetings,
Maarten Hofman.
2006\03\02@215852
by
Gerhard Fiedler
|
part 1 2751 bytes content-type:text/plain; charset="big5" (decoded quoted-printable)
Maarten Hofman wrote:
>> Yes. That's why I said "usually". This of course means that there /are/
>> (IMO rare) conditions where this is not the case.
> > Why rare? Wouldn't a proper design of sampling an analog signal (not for
> display on a screen by a PICmicro, but for other purposes) use the
> Nyquist¡VShannon sampling theorem, and therefore be designed such that at
> the maximum frequency slightly more than two samples/period are taken?
> With only two samples/period the values could be anywhere within the
> range.
This is correct. I said rare, because I think that in most cases, you need
many more than two samples per period to fulfill your application
requirements. The theorem only says that if you take less than two samples
per period of the highest frequency present in the signal, you get folding
in the frequency domain (that is, you measure frequencies that don't exist
in the signal). It does /not/ say that taking two samples per period gives
you any useful data (for a given purpose).
So in most cases, you would measure many more than two samples per period.
The most frequent case probably is arbitrarily changing signals that do not
actually have a period as such (process signals like temperature,
acceleration, etc.). They have usually components of higher frequencies,
that also usually get filtered out, with filter cut-offs often way below
the maximum conversion frequency. Which then of course means that the
signal changes much slower than one sample at maximum and the next sample
at minimum.
I think it is rare that you get to the point where charging the holding cap
becomes a problem (remember, that's all in the case of measuring one single
analog signal). Has anybody had such an application, where exactly this was
a limiting factor?
At 5V Vdd, the internal resistance that charges Chold (25pF) is about 3k.
Assuming a small source resistance (op amp), that gives a time constant tRC
of 75ns. A full scale jump in the input takes about 7*tRC or 525ns to
dis/charge the cap to within 1/1023th (10 bit resolution) of the final
value. With a PIC running at 4MHz, that's less than a single instruction
cycle, with a PIC running at 20MHz, that's less than three instruction
cycles.
But you're not really measuring any useful data in this situation (in most
applications), because you're too close to the frequency limit. If you want
to measure anything, you need more points, the jumps between points won't
be full-scale anymore, and the time to charge Chold will become smaller.
I don't say it doesn't happen... you can have a bigger source resistance,
for example. But I still think it's rare. Very rare.
Gerhard
part 2 35 bytes content-type:text/plain; charset="us-ascii"
(decoded 7bit)
2006\03\03@090610
by
Maarten Hofman
> This is correct. I said rare, because I think that in most cases, you need
> many more than two samples per period to fulfill your application
> requirements. The theorem only says that if you take less than two samples
> per period of the highest frequency present in the signal, you get folding
> in the frequency domain (that is, you measure frequencies that don't exist
> in the signal). It does /not/ say that taking two samples per period gives
> you any useful data (for a given purpose).
As far as I understood the theorem (and I agree that it has been a few
years since I studied it) it is that if the signal is limited to a
certain maximum frequency f then if you take slightly more than than
two times this number in samples ("slightly more" because of the >
instead of the >=, so just one more is fine, i.e. 40001 samples/second
for a 20000 Hz signal) then, based on those two samples, you can
reproduce the signal perfectly (this is assuming that each sample is
taken with an infinite number of bits, digitizing the sample
introduces an amount of noise equal to the resolution gap).
Note that to do this perfect reproducing, you'll have to do something
more than just convert them back to an analog level: you will need to
multiply each sample with sin(x)/x (1 for x=0). However, the resulting
signal will be identical (except for possible noise caused by
digitizing the signal).
Obviously, for all these calculations you probably will need a dsPIC
to actually process anything, but for merely gathering the data other
PICmicro could suffice. I, however, do agree that I have not seen
these things done with PICmicros, and that therefore it would indeed
be quite rare, and just like you would like to hear from people that
were bothered by the Chold time (the example in one of the manuals
should it being around 20 microseconds, so it could be a significant
time).
Greetings,
Maarten Hofman.
2006\03\03@102808
by
Gerhard Fiedler
|
Maarten Hofman wrote:
>> This is correct. I said rare, because I think that in most cases, you
>> need many more than two samples per period to fulfill your application
>> requirements. The theorem only says that if you take less than two
>> samples per period of the highest frequency present in the signal, you
>> get folding in the frequency domain (that is, you measure frequencies
>> that don't exist in the signal). It does /not/ say that taking two
>> samples per period gives you any useful data (for a given purpose).
>
> As far as I understood the theorem (and I agree that it has been a few
> years since I studied it) it is that if the signal is limited to a
> certain maximum frequency f then if you take slightly more than than two
> times this number in samples ("slightly more" because of the > instead
> of the >=, so just one more is fine, i.e. 40001 samples/second for a
> 20000 Hz signal) then, based on those two samples, you can reproduce the
> signal perfectly (this is assuming that each sample is taken with an
> infinite number of bits, digitizing the sample introduces an amount of
> noise equal to the resolution gap).
This is correct, but only if the signal is time-invariant in the frequency
domain and you can take enough samples (two won't do it :). Which again is
rare in a typical PIC application.
Imagine a pure 20kHz sine wave sampled with 40001 samples/s. You'd start
with a 0. The next sample would be just a bit above 0. The 3rd sample would
be just a bit below 0. There's any number of time domain curves that would
fit through those three points, especially since they are not points, but
small rectangles (or at least lines). The theorem considers the points to
be points, and it considers the signal to be invariant in the frequency
domain. Then it works. But that's rare in a real-world application.
> I, however, do agree that I have not seen these things done with
> PICmicros, and that therefore it would indeed be quite rare, and just
> like you would like to hear from people that were bothered by the Chold
> time (the example in one of the manuals should it being around 20
> microseconds, so it could be a significant time).
I've been bothered by the charging time of Chold (as it can be significant,
especially with higher source resistances), but only when switching between
channels. Then the situation is different, because you may have arbitrary
differences up to full-scale between channels, and you have to wait after
you switch channels. When measuring only one channel, the charging time
starts automatically at the end of the conversion without intervention by
firmware; when switching between channels, the acquisition time only starts
after the firmware switched the input channel.
That's why the programmable acquisition time is such a convenient thing:
you don't have to take care of the acquisition time between switching
channels and the start of the conversion in firmware; it's now taken care
of by the ADC hardware. But that's also why you can set the programmable
acquisition time to 0: if you don't switch channels, usually you don't need
it. IMO, of course :)
Gerhard
More... (looser matching)
- Last day of these posts
- In 2006
, 2007 only
- Today
- New search...