[PIC] 12 bit A/D

43 views
Skip to first unread message

Nicola Perotto

unread,
May 22, 2009, 5:30:54 PM5/22/09
to Microcontroller discussion list - Public.
Hi all,
I need to sample 32 analog (4-20mA) at 1 KHz. The required resolution is
12 bit.
Have anyone experience with the 12 bit A/D converter included in some
PIC, like 18F4558 or dsPIC30F3014?
Or it's better to use some external A/D?
TIA
Nicola


--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Vitaliy

unread,
May 22, 2009, 10:25:31 PM5/22/09
to Microcontroller discussion list - Public.
Nicola Perotto wrote:
> I need to sample 32 analog (4-20mA) at 1 KHz. The required resolution is
> 12 bit.
> Have anyone experience with the 12 bit A/D converter included in some
> PIC, like 18F4558 or dsPIC30F3014?

I used A/D on a 33F and a 24H (they're virtually identical). Here's what the
ADC doc says:

====================
The 10-bit ADC configuration (AD12B = 0) has the following key features:
. Successive Approximation (SAR) conversion
. Conversion speeds of up to 1.1 Msps
. Up to 32 analog input pins
. External voltage reference input pins
. Simultaneous sampling of up to four analog input pins
. Automatic Channel Scan mode
. Selectable conversion trigger source
. Selectable Buffer Fill modes
. DMA support, including Peripheral Indirect Addressing
. Four result alignment options (signed/unsigned, fractional/integer)
. Operation during CPU Sleep and Idle modes


The 12-bit ADC configuration (AD12B = 1) supports all the features
described, except:
. In the 12-bit configuration, conversion speeds of up to 500 ksps are
supported
. There is only one Sample/Hold amplifier in the 12-bit configuration, so
simultaneous
sampling of multiple channels is not supported
====================

Do you need to sample multiple channels simultaneously?

Vitaliy

Xiaofan Chen

unread,
May 23, 2009, 8:28:14 AM5/23/09
to Microcontroller discussion list - Public.
On Sat, May 23, 2009 at 5:30 AM, Nicola Perotto <nic...@nicolaperotto.it> wrote:
> Hi all,
> I need to sample 32 analog (4-20mA) at 1 KHz. The required resolution is
> 12 bit. Have anyone experience with the 12 bit A/D converter included in
> some PIC, like 18F4558 or dsPIC30F3014?
> Or it's better to use some external A/D?

Do you need features like 50 rejection or 60Hz rejection or simulataneous
50/60Hz rejection? If you need any of them, probably it is better to use
external sigma-delta filtering with built-in support for these features.

But yours is 12bit, probably these features are not required. We typically
do 15/16bit and use 24bit sigma-delta converters from ADI and TI.
It is challenging to get 1KHz sampling for true 16bit.

--
Xiaofan http://mcuee.blogspot.com

Peter Restall

unread,
May 23, 2009, 1:48:36 PM5/23/09
to pic...@mit.edu

On Fri, 22 May 2009 23:30:54 +0200, Nicola Perotto wrote:

> Hi all,
> I need to sample 32 analog (4-20mA) at 1 KHz. The required resolution is
> 12 bit.
> Have anyone experience with the 12 bit A/D converter included in some
> PIC, like 18F4558 or dsPIC30F3014?
> Or it's better to use some external A/D?

> TIA
> Nicola

Are you wanting to sample at 1KHz or sample a 1KHz signal ? If sampling at
1KHz you may need to check the datasheets for the PICs; I believe some of
them say that sample rates below 10KHz introduce significant error due to the
S/H capacitor leakage. I think this is mentioned in the dsPIC30F family
reference, but my exposure to other PICs is rather limited.

Regards,

Pete Restall

Peter Restall

unread,
May 23, 2009, 2:31:10 PM5/23/09
to pic...@mit.edu

On Sat, 23 May 2009, Pete Restall wrote:

> Are you wanting to sample at 1KHz or sample a 1KHz signal ? If sampling at
> 1KHz you may need to check the datasheets for the PICs; I believe some of
> them say that sample rates below 10KHz introduce significant error due to the
> S/H capacitor leakage. I think this is mentioned in the dsPIC30F family
> reference, but my exposure to other PICs is rather limited.
>
> Regards,
>
> Pete Restall

Just found that section in the datasheet actually; table 22-39 for the
30F2010. It refers to the internal clock rate of the ADC (Tad) rather than
the sample rate - there's nothing to stop you sampling at low speeds with a
fast Tad time. Makes sense really.

Check out Microchip's product selector - just bash in your criteria and see
what is shows:

http://www.microchip.com/maps/microcontroller.aspx

Nicola Perotto

unread,
May 23, 2009, 5:22:56 PM5/23/09
to Microcontroller discussion list - Public.

Vitaliy wrote:
> Nicola Perotto wrote:
>
>> I need to sample 32 analog (4-20mA) at 1 KHz. The required resolution is
>> 12 bit.
>> Have anyone experience with the 12 bit A/D converter included in some
>> PIC, like 18F4558 or dsPIC30F3014?
>>
>
> I used A/D on a 33F and a 24H (they're virtually identical). Here's what the
> ADC doc says:
>
Before posting I read the "F" datasheets!
I want your opinion because for many thing is more valuable ;-)

> Do you need to sample multiple channels simultaneously?
>
> Vitaliy
>
>
It is a good point; maybe it would not be a problem because I must
anyway share the channels on more than 1 pic (4*8 = 32 maybe) so at
100ksps the timing is enough "simultaneous".
Nic

Nicola Perotto

unread,
May 23, 2009, 5:29:48 PM5/23/09
to Microcontroller discussion list - Public.

Xiaofan Chen wrote:
> On Sat, May 23, 2009 at 5:30 AM, Nicola Perotto <nic...@nicolaperotto.it> wrote:
>
>> Hi all,
>> I need to sample 32 analog (4-20mA) at 1 KHz. The required resolution is
>> 12 bit. Have anyone experience with the 12 bit A/D converter included in
>> some PIC, like 18F4558 or dsPIC30F3014?
>> Or it's better to use some external A/D?
>>
>
> Do you need features like 50 rejection or 60Hz rejection or simulataneous
> 50/60Hz rejection? If you need any of them, probably it is better to use
> external sigma-delta filtering with built-in support for these features.
>
The 50Hz (in Europe) are not a problem: all the system works from a
battery! I need to acquire only for 30 seconds.

> But yours is 12bit, probably these features are not required. We typically
> do 15/16bit and use 24bit sigma-delta converters from ADI and TI.
> It is challenging to get 1KHz sampling for true 16bit.
>
>
I lost big time searching for an AD... it's challenging!

Vitaliy

unread,
May 24, 2009, 4:43:39 AM5/24/09
to Microcontroller discussion list - Public.
Nicola Perotto wrote:
>>> I need to sample 32 analog (4-20mA) at 1 KHz. The required resolution is
>>> 12 bit.
>>> Have anyone experience with the 12 bit A/D converter included in some
>>> PIC, like 18F4558 or dsPIC30F3014?
>>>
>>
>> I used A/D on a 33F and a 24H (they're virtually identical). Here's what
>> the
>> ADC doc says:
>>
> Before posting I read the "F" datasheets!

You did not list either a 33F or 24H in your OP, so there was no way for me
to know that you read the datashets.

> I want your opinion because for many thing is more valuable ;-)

My opinion on what? "Garbage in, garbage out" -- if you want good answers,
you've got to ask the right questions. :)


>> Do you need to sample multiple channels simultaneously?
>

> It is a good point; maybe it would not be a problem because I must
> anyway share the channels on more than 1 pic (4*8 = 32 maybe) so at
> 100ksps the timing is enough "simultaneous".

Well then, use any PIC that has enough channels. :-)

Vitaliy

Olin Lathrop

unread,
May 24, 2009, 8:32:54 AM5/24/09
to Microcontroller discussion list - Public.
Peter Restall wrote:
>> I need to sample 32 analog (4-20mA) at 1 KHz.
>
> Are you wanting to sample at 1KHz or sample a 1KHz signal ?

He says he needs to sample at 1KHz, but it's not clear whether that means
each signal individually or all 32 signals at 1KHz total. This is one
reason I didn't bother reply, since this ambiguity is self-evident. If this
guy can't even write a comprehensible question, he's way over his head
playing with 'puter thingies.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014. Gold level PIC consultants since 2000.

Gerhard Fiedler

unread,
May 24, 2009, 1:35:56 PM5/24/09
to Microcontroller discussion list - Public.
Peter Restall wrote:

> If sampling at 1KHz you may need to check the datasheets for the PICs;
> I believe some of them say that sample rates below 10KHz introduce
> significant error due to the S/H capacitor leakage. I think this is
> mentioned in the dsPIC30F family reference, but my exposure to other
> PICs is rather limited.

Really? How would the sample rate (as opposed to the conversion time)
affect the effect of the S/H leakage? Or is the sample rate linked to
the conversion time?

Gerhard

Olin Lathrop

unread,
May 24, 2009, 4:33:51 PM5/24/09
to Microcontroller discussion list - Public.
Gerhard Fiedler wrote:
> Peter Restall wrote:
>> If sampling at 1KHz you may need to check the datasheets for the PICs;
>> I believe some of them say that sample rates below 10KHz introduce
>> significant error due to the S/H capacitor leakage. I think this is
>> mentioned in the dsPIC30F family reference, but my exposure to other
>> PICs is rather limited.
>
> Really?

Very unlikely.

> How would the sample rate (as opposed to the conversion time)
> affect the effect of the S/H leakage? Or is the sample rate linked to
> the conversion time?

I think this is simply a pile of BS by someone who is repeating heresay,
didn't read the datasheet well, or doesn't understand about acquisition time
versus converion time. I would disregard this as nonsense.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014. Gold level PIC consultants since 2000.

Nicola Perotto

unread,
May 25, 2009, 9:34:42 AM5/25/09
to Microcontroller discussion list - Public.

Olin Lathrop wrote:
> Peter Restall wrote:
>
>>> I need to sample 32 analog (4-20mA) at 1 KHz.
>>>
>> Are you wanting to sample at 1KHz or sample a 1KHz signal ?
>>
>
> He says he needs to sample at 1KHz, but it's not clear whether that means
> each signal individually or all 32 signals at 1KHz total. This is one
> reason I didn't bother reply, since this ambiguity is self-evident.
I'm not a so big genius so can't imagine why to sample 32 signals "at
1KHz total", maybe someone else can explain it.


> If this guy can't even write a comprehensible question, he's way over his head
> playing with 'puter thingies.
>

This is a free insult to myself.
My english is bad but I'm an honest and esteemed professional.

Nicola Perotto

unread,
May 25, 2009, 9:34:23 AM5/25/09
to Microcontroller discussion list - Public.
Mine compliments, Vitaliy! You, finally, written a response in pure
Olin-style!

Maybe someone remember the problems of Jinx with his 18F1320.
I want to say if this 12 bit A/D is working well, like stated in the
datasheet or if somebody encontered some strange problem!
Thanks
Nicola

Peter Restall

unread,
May 25, 2009, 12:48:06 PM5/25/09
to pic...@mit.edu

On Sun, 24 May 2009 16:33:51 -0400, Olin Lathrop wrote:

>> How would the sample rate (as opposed to the conversion time)
>> affect the effect of the S/H leakage? Or is the sample rate linked to
>> the conversion time?
>
> I think this is simply a pile of BS by someone who is repeating heresay,
> didn't read the datasheet well, or doesn't understand about acquisition time
> versus converion time. I would disregard this as nonsense.

It was bad memory and not having the datasheet immediately to hand - but I did
post a correction not long after when I'd got the datasheet in front of me.

And I did wonder if I'd get flak for the first post...I thought my follow-up
would stifle the flames but it was obviously missed...oops (and apologies) !

Regards,

Pete Restall

Vitaliy

unread,
May 25, 2009, 6:09:19 PM5/25/09
to Microcontroller discussion list - Public.
Nicola Perotto wrote:
> Mine compliments, Vitaliy! You, finally, written a response in pure
> Olin-style!

My God, you're right! <:-O


:-)))

Vitaliy

unread,
May 25, 2009, 6:19:42 PM5/25/09
to Microcontroller discussion list - Public.
Nicola Perotto wrote:
>>>> I need to sample 32 analog (4-20mA) at 1 KHz.
>>>>
>>> Are you wanting to sample at 1KHz or sample a 1KHz signal ?
>>>
>>
>> He says he needs to sample at 1KHz, but it's not clear whether that means
>> each signal individually or all 32 signals at 1KHz total. This is one
>> reason I didn't bother reply, since this ambiguity is self-evident.
> I'm not a so big genius so can't imagine why to sample 32 signals "at
> 1KHz total", maybe someone else can explain it.

Slow changing voltage? Like temp sensors, or battery level meters?

I don't know -- it's your project! :)


> My english is bad but I'm an honest and esteemed professional.

I have no doubt that you are. English is my second language too, but I think
in this case it's not about proper syntax or spelling as much as it is about
providing enough detail about what it is you're trying to accomplish.

"Garbage in, garbage out" was not meant as an insult, BTW. It's a common
expression among programmers, which means "bad input = bad output". It
looked like you did not like my reply, so I tried to explain why I thought
you didn't like it, and what you can do about it.

Best regards,

Vitaliy

Nicola Perotto

unread,
May 26, 2009, 4:20:32 AM5/26/09
to Microcontroller discussion list - Public.

Vitaliy wrote:
> "Garbage in, garbage out" was not meant as an insult, BTW. It's a common
> expression among programmers, which means "bad input = bad output". It
> looked like you did not like my reply, so I tried to explain why I thought
> you didn't like it, and what you can do about it.
>
> Best regards,
>
> Vitaliy
>
:-) I know very well the "Garbage in, garbage out" law! I'm used to
teach it soon to my students!
Thanks for your explanation!
Nicola
Reply all
Reply to author
Forward
0 new messages