Author Topic: PIC power supply capacitor puzzle  (Read 2454 times)

0 Members and 1 Guest are viewing this topic.

Offline PerranOakTopic starter

  • Frequent Contributor
  • **
  • Posts: 548
  • Country: gb
PIC power supply capacitor puzzle
« on: July 06, 2018, 12:14:30 pm »
In my temperature project (PIC16F1827 and LM35) the PIC is reading the voltage at the LM35 with an accuracy of about +/-1.0degC - about what the tolerance should be, I guess.

I had previously noticed that the accuracy was more like +/-0.1degC and the only thing I changed was to add a 100uF electrolytic cap across the power supply (AA batteries) whereas previously I had none.

So, I replaced this capacitor with a 100nF PET film cap (micro to nano so a thousand times less) and, hey presto! The PIC is now reading back at the original accuracy of +/-0.1degC and everything else is fine.

How can this be?
You can release yourself but the only way to go is down!
RJD
 

Online NorthGuy

  • Super Contributor
  • ***
  • Posts: 3143
  • Country: ca
Re: PIC power supply capacitor puzzle
« Reply #1 on: July 06, 2018, 12:46:01 pm »
If you use VDD as a voltage reference for ADC then all the measurements are relative to VDD and thus all the noise on VDD gets reflected in your ADC readings.

However, don't mistake the smoothness of readings over time for accuracy.
 

Offline PerranOakTopic starter

  • Frequent Contributor
  • **
  • Posts: 548
  • Country: gb
Re: PIC power supply capacitor puzzle
« Reply #2 on: July 06, 2018, 01:19:15 pm »
No, I use the internal FVR and have been monitoring the temp vs a quality thermometer.
You can release yourself but the only way to go is down!
RJD
 

Online NorthGuy

  • Super Contributor
  • ***
  • Posts: 3143
  • Country: ca
Re: PIC power supply capacitor puzzle
« Reply #3 on: July 06, 2018, 01:48:00 pm »
No, I use the internal FVR and have been monitoring the temp vs a quality thermometer.

Interesting. Internal FVR only has 8% accuracy according to the datasheet.

Anyway, I suggest trying an external reference and see if this alleviates the VDD influence. While you have an external reference connected, you can setup ADC to measure FVR directly (ADC channel 0x1f). Then you will know how accurate the FVR is and if it is influenced by the VDD noise or not.
 

Offline PerranOakTopic starter

  • Frequent Contributor
  • **
  • Posts: 548
  • Country: gb
Re: PIC power supply capacitor puzzle
« Reply #4 on: July 06, 2018, 04:26:58 pm »
OK great, thank you.
You can release yourself but the only way to go is down!
RJD
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21658
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: PIC power supply capacitor puzzle
« Reply #5 on: July 06, 2018, 09:26:32 pm »
Note that a measurement done with one source (the LM35) and one measuring device (the PIC) is not statistically significant; it isn't even a statistical set!

You probably got lucky on the parts you have.

Regarding the capacitor, it's impossible to tell without a circuit, layout, and preferably some waveforms.  These are microsecond scale differences (this is apparent from the capacitor value), not something you can figure out with a DMM, and maybe not even from a schematic alone (hence layout too). :)

Tim
« Last Edit: July 06, 2018, 09:32:15 pm by T3sl4co1l »
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Online wraper

  • Supporter
  • ****
  • Posts: 16849
  • Country: lv
Re: PIC power supply capacitor puzzle
« Reply #6 on: July 06, 2018, 09:39:13 pm »
In my temperature project (PIC16F1827 and LM35) the PIC is reading the voltage at the LM35 with an accuracy of about +/-1.0degC - about what the tolerance should be, I guess.

I had previously noticed that the accuracy was more like +/-0.1degC and the only thing I changed was to add a 100uF electrolytic cap across the power supply (AA batteries) whereas previously I had none.

So, I replaced this capacitor with a 100nF PET film cap (micro to nano so a thousand times less) and, hey presto! The PIC is now reading back at the original accuracy of +/-0.1degC and everything else is fine.

How can this be?
Walt, so initially you weren't using decoupling capacitor(s) at all?
 

Offline PerranOakTopic starter

  • Frequent Contributor
  • **
  • Posts: 548
  • Country: gb
Re: PIC power supply capacitor puzzle
« Reply #7 on: July 09, 2018, 12:01:47 pm »
Yes, that's right. In my enthusiasm to build it I forget entirely to put any cap in anywhere!

The only reason I did put one in was when I had trouble with the first reading being way out (even though later readings were fine) that someone suggested the 100uF cap.
You can release yourself but the only way to go is down!
RJD
 

Offline Wilksey

  • Super Contributor
  • ***
  • Posts: 1329
Re: PIC power supply capacitor puzzle
« Reply #8 on: July 09, 2018, 12:33:38 pm »
Just put your 100n in parallel with the 100u (100n closer to the PIC).
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14445
  • Country: fr
Re: PIC power supply capacitor puzzle
« Reply #9 on: July 09, 2018, 06:56:48 pm »
In my temperature project (PIC16F1827 and LM35) the PIC is reading the voltage at the LM35 with an accuracy of about +/-1.0degC - about what the tolerance should be, I guess.

I had previously noticed that the accuracy was more like +/-0.1degC and the only thing I changed was to add a 100uF electrolytic cap across the power supply (AA batteries) whereas previously I had none.

So, I replaced this capacitor with a 100nF PET film cap (micro to nano so a thousand times less) and, hey presto! The PIC is now reading back at the original accuracy of +/-0.1degC and everything else is fine.

How can this be?

Does that mean that there were no decoupling cap close to the Vdd pin of the PIC?
 

Online wraper

  • Supporter
  • ****
  • Posts: 16849
  • Country: lv
Re: PIC power supply capacitor puzzle
« Reply #10 on: July 09, 2018, 07:34:34 pm »
Yes, that's right. In my enthusiasm to build it I forget entirely to put any cap in anywhere!

The only reason I did put one in was when I had trouble with the first reading being way out (even though later readings were fine) that someone suggested the 100uF cap.
So why are you surprised by this. Even if MCU still works without decoupling, ADC certainly cannot maintain it's performance with unstable power.
 

Offline PerranOakTopic starter

  • Frequent Contributor
  • **
  • Posts: 548
  • Country: gb
Re: PIC power supply capacitor puzzle
« Reply #11 on: July 09, 2018, 08:34:59 pm »
But the power is four AA batteries, fully charged. Why would it be unstable?

Anyway, the mad thing is that it worked better when there were no caps in sight. It reminds me of a Dave vid where he removed nearly all decoupling caps from something (can't remember what) and it worked fine.
You can release yourself but the only way to go is down!
RJD
 

Online wraper

  • Supporter
  • ****
  • Posts: 16849
  • Country: lv
Re: PIC power supply capacitor puzzle
« Reply #12 on: July 09, 2018, 08:49:46 pm »
You rather should compare how much effective resolution you get (noise free bits).
Quote
But the power is four AA batteries, fully charged. Why would it be unstable?
Think about their internal resistance and low long wires are + length of the batteries. 100uF cap is no good for decoupling, too much inductance. Besides that, don't forget that PIC16F1827 analog voltage reference has -8/+6% accuracy.
« Last Edit: July 09, 2018, 09:00:06 pm by wraper »
 

Offline Wilksey

  • Super Contributor
  • ***
  • Posts: 1329
Re: PIC power supply capacitor puzzle
« Reply #13 on: July 10, 2018, 11:54:59 am »
Yeah, to show you don't need all of the caps they've put on, but you need some!!  :-//

There are so many internal clocks and calculations that go on you need stable power.
Why do you think that just because you have batteries that the device is automatically stable?  If anything it'll give you bulk but not decoupling properties.  :palm:
 

Offline PerranOakTopic starter

  • Frequent Contributor
  • **
  • Posts: 548
  • Country: gb
Re: PIC power supply capacitor puzzle
« Reply #14 on: July 10, 2018, 02:43:32 pm »
Thanks both.
So, I thought that larger caps were to smooth switched supplies, etc. and therefore not needed with a battery.
I guess then that the 100nF is doing the decoupling that may be needed and the 100uF was doing I-don't-know-what to reduce accuracy.
I see that I must've been lucky with the actual components to get such accuracy and consistency over temp and time.
BTW how do you decide what value of cap should be used for decoupling?
You can release yourself but the only way to go is down!
RJD
 

Offline Wilksey

  • Super Contributor
  • ***
  • Posts: 1329
Re: PIC power supply capacitor puzzle
« Reply #15 on: July 10, 2018, 05:02:53 pm »
RTFM.

Most datasheets will tell you what you need for the device, the PIC datasheet has some good application examples with component values for the surrounding peripheral, standard rule of thumb I go by, 100nF on VDD/AVDD pins to the associated GND pins, there are other scenarios where you might want to add a 10nF or a bulk capacitor to a supply, I always make sure that the smallest value is nearest the power pins on the IC.
 

Offline rx8pilot

  • Super Contributor
  • ***
  • Posts: 3634
  • Country: us
  • If you want more money, be more valuable.
Re: PIC power supply capacitor puzzle
« Reply #16 on: July 10, 2018, 05:13:02 pm »
But the power is four AA batteries, fully charged. Why would it be unstable?

The AA battery is stable, the switching noise is created by the PIC itself. That is why decoupling caps need to be placed as close to the device as possible. The tiny little gulps of current the PIC needs for each transistor cannot make it from the battery all the way to the PIC fast enough so the voltage drops during that time. The local bypass cap will supply those tiny currents while the power source and all the inductance/resistance/capacitance along the way catch up.

Factory400 - the worlds smallest factory. https://www.youtube.com/c/Factory400
 

Offline PerranOakTopic starter

  • Frequent Contributor
  • **
  • Posts: 548
  • Country: gb
Re: PIC power supply capacitor puzzle
« Reply #17 on: July 11, 2018, 12:23:13 pm »
Thank both, I think I might be getting it!

Ah yes I did that but the datasheet for the 16F1827 has no examples of actual circuits and this is the only one I've used.

So, a lower value cap close to the power pins AND a larger one across the power supply  somewhere?
You can release yourself but the only way to go is down!
RJD
 

Offline Wilksey

  • Super Contributor
  • ***
  • Posts: 1329
Re: PIC power supply capacitor puzzle
« Reply #18 on: July 11, 2018, 06:29:47 pm »
Typically yes, lower values (pF range) are also used for EMC to filter different frequencies.

The decoupling removes "noise", so big bulky caps for storage, smaller one to get rid of noise, less noise = more stable.

I'm generalising, but you get the idea!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf