Forums

PIC Micro Picky About Power Supplies

Started by Robert Wade August 17, 2014
I have a PIC 16F628-20 micro running code to generate two dial tones. 

It seems to be very fussy about how it is powered. Sometimes it starts
on batteries, and sometimes not. On my lab supply, it puts out a
steady PWM frequency, but with no modulation. Same goes with an
LM7805. In all instances the voltage is 5V.

I don't think it is the PIC chip, since it will operate under what it
perceives to be "ideal" conditions.

At present, I have only a 104 decoupling cap between the rail pins.
That seems to be a general recommendation.

There must be some best practice thing I am overlooking with regard to
making this reliable.

Can someone please point me in the right direction?

Robert Wade
On Mon, 18 Aug 2014 12:44:10 +1000, the renowned Robert Wade
<rwade@santos.com> wrote:

> >I have a PIC 16F628-20 micro running code to generate two dial tones. > >It seems to be very fussy about how it is powered. Sometimes it starts >on batteries, and sometimes not. On my lab supply, it puts out a >steady PWM frequency, but with no modulation. Same goes with an >LM7805. In all instances the voltage is 5V. > >I don't think it is the PIC chip, since it will operate under what it >perceives to be "ideal" conditions. > >At present, I have only a 104 decoupling cap between the rail pins. >That seems to be a general recommendation. > >There must be some best practice thing I am overlooking with regard to >making this reliable. > >Can someone please point me in the right direction? > >Robert Wade
Are you sure the voltage off the batteries is 5V? At 20MHz it needs 4.5 to 5.5VDC power. If that's not it, then something silly like a missing ground or a floating input pin sounds likely. Best regards, Spehro Pefhany -- "it's the network..." "The Journey is the reward" speff@interlog.com Info for manufacturers: http://www.trexon.com Embedded software/hardware/analog Info for designers: http://www.speff.com
Hi Robert,

On 8/17/2014 7:44 PM, Robert Wade wrote:
> > I have a PIC 16F628-20 micro running code to generate two dial tones. > > It seems to be very fussy about how it is powered. Sometimes it starts > on batteries, and sometimes not.
Meaning: "sometimes it powers up and properly executes the intended code; other times it just sits there like a blob of inert plastic"? (and, reading ahead: and doesn't even output a steady PWM frequency!)
> On my lab supply, it puts out a > steady PWM frequency, but with no modulation. Same goes with an > LM7805. In all instances the voltage is 5V.
Meaning: "it has obviously executed *some* code -- to set up the PWM -- but not *all* the code -- to modulate the output as intended" Is this a correct interpretation?
> I don't think it is the PIC chip, since it will operate under what it > perceives to be "ideal" conditions.
I'm not sure I understand this statement in the context of those preceding... (but, then again, its raining and I'm a bit distracted)
> At present, I have only a 104 decoupling cap between the rail pins. > That seems to be a general recommendation. > > There must be some best practice thing I am overlooking with regard to > making this reliable. > > Can someone please point me in the right direction?
What does the application of power look like? I.e., does it come up and into spec promptly? Or, does it have a slow, unsteady rise time? Perhaps even non-monotonic?
Robert Wade <rwade@santos.com> wrote:
> It seems to be very fussy about how it is powered. Sometimes it starts > on batteries, and sometimes not.
What kind of batteries? Any regulator between the batteries and the PIC?
> At present, I have only a 104 decoupling cap between the rail pins. > That seems to be a general recommendation.
Do you have something like 1 to 10 uF (or more) on the "input" side of the LM7805?
> There must be some best practice thing I am overlooking with regard to > making this reliable.
Are you running the internal oscillator, an external resonator, or an external crystal? Are all the oscillator configuration bits set to match what you are using? What oscillator frequency are you trying to use? If you are using an external resonator or crystal, are you using the capacitors specified in the data sheet? Do you have a PC board, or some breadboard setup (which adds capacitance)? Can you swap for another resonator or crystal - even if it's not exactly the frequency you want - just to eliminate it from consideration? Has this ever worked under some set of conditions? Matt Roberds
On a sunny day (Mon, 18 Aug 2014 12:44:10 +1000) it happened Robert Wade
<rwade@santos.com> wrote in <rpo2v9tj6pl8fa9ht9sgvk8sthvlb29ir5@4ax.com>:

> >I have a PIC 16F628-20 micro running code to generate two dial tones. > >It seems to be very fussy about how it is powered. Sometimes it starts >on batteries, and sometimes not. On my lab supply, it puts out a >steady PWM frequency, but with no modulation. Same goes with an >LM7805. In all instances the voltage is 5V. > >I don't think it is the PIC chip, since it will operate under what it >perceives to be "ideal" conditions. > >At present, I have only a 104 decoupling cap between the rail pins. >That seems to be a general recommendation. > >There must be some best practice thing I am overlooking with regard to >making this reliable. > >Can someone please point me in the right direction? > >Robert Wade
Power supply rise time -> reset look into that. Does the 628 have a delayed clock feature? Reset pin floating? Not used? RC value?
Robert Wade <rwade@santos.com> wrote in 
news:rpo2v9tj6pl8fa9ht9sgvk8sthvlb29ir5@4ax.com:

> > I have a PIC 16F628-20 micro running code to generate two dial tones. > > It seems to be very fussy about how it is powered. Sometimes it starts > on batteries, and sometimes not. On my lab supply, it puts out a > steady PWM frequency, but with no modulation. Same goes with an > LM7805. In all instances the voltage is 5V. > > I don't think it is the PIC chip, since it will operate under what it > perceives to be "ideal" conditions. > > At present, I have only a 104 decoupling cap between the rail pins. > That seems to be a general recommendation. > > There must be some best practice thing I am overlooking with regard to > making this reliable. > > Can someone please point me in the right direction? > > Robert Wade
The usual problems are the PIC failing to reset properly on powerup, or floating input pins. In the configuration you need to enable BOR (BODEN bit) and PWRT (/PWRTEN bit). With BOR enabled, the PIC is held in reset till Vdd is above a nominal 4V then PWRT holds it in reset for a further nominal 72ms. This ensures the power is stable before the PIC starts running. The /MCLR pin must *NEVER* be left floating. An external 10K pullup is recommended even if it is disabled by the configuration. If LVP is left enabled, the PIC will reset unpredictably if the PGM pin is floating. PGM should have a pull-down for reliable programming, but with LVP disabled this isnt needed at runtime.. Set *ALL* unused I/Os as outputs and set them low. Don't leave any floating! -- Ian Malcolm. London, ENGLAND. (NEWSGROUP REPLY PREFERRED) ianm[at]the[dash]malcolms[dot]freeserve[dot]co[dot]uk [at]=@, [dash]=- & [dot]=. *Warning* HTML & >32K emails --> NUL
On Mon, 18 Aug 2014 11:36:20 +0000 (UTC), Ian Malcolm
<See.My.Sig.for.email@totally.invalid> wrote:

>The usual problems are the PIC failing to reset properly on powerup, or >floating input pins. > >In the configuration you need to enable BOR (BODEN bit) and PWRT (/PWRTEN >bit). With BOR enabled, the PIC is held in reset till Vdd is above a >nominal 4V then PWRT holds it in reset for a further nominal 72ms. This >ensures the power is stable before the PIC starts running. > >The /MCLR pin must *NEVER* be left floating. An external 10K pullup is >recommended even if it is disabled by the configuration. > >If LVP is left enabled, the PIC will reset unpredictably if the PGM pin >is floating. PGM should have a pull-down for reliable programming, but >with LVP disabled this isnt needed at runtime.. > >Set *ALL* unused I/Os as outputs and set them low. Don't leave any >floating! >
This was the kind of reply I was looking for. I will try these recommendations tomorrow on the bench. Thanks to everyone who responded. Robert Wade
On Mon, 18 Aug 2014 12:44:10 +1000, Robert Wade <rwade@santos.com> wrote:

> >I have a PIC 16F628-20 micro running code to generate two dial tones.=20 > >It seems to be very fussy about how it is powered. Sometimes it starts >on batteries, and sometimes not. On my lab supply, it puts out a >steady PWM frequency, but with no modulation. Same goes with an >LM7805. In all instances the voltage is 5V. > >I don't think it is the PIC chip, since it will operate under what it >perceives to be "ideal" conditions. > >At present, I have only a 104 decoupling cap between the rail pins. >That seems to be a general recommendation. > >There must be some best practice thing I am overlooking with regard to >making this reliable. > >Can someone please point me in the right direction? > >Robert Wade
Sounds like incorrect power on reset to me. ?-) =20
If anyone is still watching this thread, I found the problem. The
16F628-20 wil not run off the 5V regulator.

It needs 5.1VDC. This seems out-of-spec, and thus caught me buy
surprise.

Isn't electronics fun?

Robert Wade
On a sunny day (Thu, 28 Aug 2014 12:04:21 +1000) it happened Robert Wade
<rwade@santos.com> wrote in <mc3tv91s8o819oa7ev674vduq8bcm9pk0i@4ax.com>:

> >If anyone is still watching this thread, I found the problem. The >16F628-20 wil not run off the 5V regulator. > >It needs 5.1VDC. This seems out-of-spec, and thus caught me buy >surprise. > >Isn't electronics fun? > >Robert Wade
datasheet page 105?