Hi people,
I have a board that uses a PIC16F873(A) and a DS1307. The board also
has 4 7 segment displays that are continuously showing the time (so, they
are never off).
The power supply is a very standard one. 4 diodes, 1 LM7805 with
it's 2 input caps of 1uF and a filter capacitor of 10.000 uF (yes, 0.01 F x
50V). The filter cap is so big, because the Cap voltage (input * 1.41) is
used from time to time to shortly make a motor work. This motor consumes low
operation current but due to it's reduction gear it consumes some start
current.
Well, that said, let me present the problem. Oh, the PIC has it vcc
filter cap (.1uF tantalium) and a 10K + 100nF for the /MCLR Pin.
The problem specifically is that when the voltage drops there are
miss writes to the ds1307, because the fall time of the power supply is
about 5 seconds.
So, sometimes when I just unplug the power supply from the wall and
plug it on again the time is corrupted (7F:7F, all 1's, the upper bits are
masked).
I solve it a little with a 330ohm 1W resistor in parallel with the
0.01F capacitor. I also turn off the BOD of the PIC. Here's an interesting
thing also. The pic is supposed to reset itself when Vcc is lower than 4V,
but I see that it happens to be many resets while vcc is going down, off
course because the fall time is long.
Now, with the BOD tuned off, the PIC goes down that extra bit that
is needed until de RTC is self turned off
(~3.75V), but still have some random failures...
A diod form the 7805 to the filter cap and sense "power gone" directly after the 78L05 but before the diod. Will get you some time to put things in a safe state.
>Hi people,
> I have a board that uses a PIC16F873(A) and a DS1307. The board also
>has 4 7 segment displays that are continuously showing the time (so, they
>are never off).
>
> The power supply is a very standard one. 4 diodes, 1 LM7805 with
>it's 2 input caps of 1uF and a filter capacitor of 10.000 uF (yes, 0.01 F x
>50V). The filter cap is so big, because the Cap voltage (input * 1.41) is
>used from time to time to shortly make a motor work. This motor consumes low
>operation current but due to it's reduction gear it consumes some start
>current.
>
> Well, that said, let me present the problem. Oh, the PIC has it vcc
>filter cap (.1uF tantalium) and a 10K + 100nF for the /MCLR Pin.
>
> The problem specifically is that when the voltage drops there are
>miss writes to the ds1307, because the fall time of the power supply is
>about 5 seconds.
>
> So, sometimes when I just unplug the power supply from the wall and
>plug it on again the time is corrupted (7F:7F, all 1's, the upper bits are
>masked).
>
> I solve it a little with a 330ohm 1W resistor in parallel with the
>0.01F capacitor. I also turn off the BOD of the PIC. Here's an interesting
>thing also. The pic is supposed to reset itself when Vcc is lower than 4V,
>but I see that it happens to be many resets while vcc is going down, off
>course because the fall time is long.
>
> Now, with the BOD tuned off, the PIC goes down that extra bit that
>is needed until de RTC is self turned off
>(~3.75V), but still have some random failures...
>
> Anyone has any pointer as how to proceed?
>
>Best regards,
>Mauricio
>
>
>
--- Mauricio Jancic <.....jancicKILLspam@spam@ciudad.com.ar> wrote:
> Hi people,
> I have a board that uses a PIC16F873(A) and a DS1307. The board also
> has 4 7 segment displays that are continuously showing the time (so,
> they
> are never off).
This should be sent to the EE group instead, as it's not a software or
programing issue. {Quote hidden}
>
> The power supply is a very standard one. 4 diodes, 1 LM7805 with
> it's 2 input caps of 1uF and a filter capacitor of 10.000 uF (yes,
> 0.01 F x
> 50V). The filter cap is so big, because the Cap voltage (input *
> 1.41) is
> used from time to time to shortly make a motor work. This motor
> consumes low
> operation current but due to it's reduction gear it consumes some
> start
> current.
You should not run the motor and PIC from the same power supply, this
is the real source of your problem, and potentially a future source of
trouble as well. Use a diode to seperate a logic supply from the main
supply add an inductor in series to filter out transients, feed this to
a more conventional linear regulator for only your logic. This way
power failure causes much more predictable behavior AND you won't have
noise from other devices causing strange problems with the PIC and
other supply sensitive devices.
>
>
> Best regards,
> Mauricio
>
Good fortune!
Stephen R. Phillips was here
Please be advised what was said may be absolutely wrong, and hereby this disclaimer follows. I reserve the right to be wrong and admit it in front of the entire world.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
>Yes... But the problem is that the PIC is in a reset or unknow state at 4V
>and the RTC resets when voltage drops below
>~3.75 V
>
>Mauricio Jancic
>Janso Desarrollos - Microchip Consultants Program Member
>infoKILLspamjanso.com.ar
>http://www.janso.com.ar
>(54) 11 - 4542 - 3519
>
>
>
>
What I was thinking of was to not do read/writes to the RTC when the power is in an unsafe state. So when the voltage in drops to a certain level ( < 5 but > 4 ) your code enters some safe state that just waits for power to come back to a safe level again and then do normal stuff. You go to the same code at start up.
> The power supply is a very standard one. 4 diodes, 1 LM7805 with
>it's 2 input caps of 1uF and a filter capacitor of 10.000 uF (yes, 0.01 F x
>50V). The filter cap is so big, because the Cap voltage (input * 1.41) is
>used from time to time to shortly make a motor work. This motor consumes
low
>operation current but due to it's reduction gear it consumes some start
>current.
OK from this I take it that you have a bridge rectifier (4 diodes) to feed
the large capacitor. You may like to add another two lower current diodes
(1n400x series) and have a low current supply for the PIC, so this is not
affected by current draw from the large cap, and also use a smaller cap for
the PIC supply so it falls faster when switched off. The two diodes repeat
the "top half" of the bridge rectifier.
Now the next point from this - are you really feeding the 50V into a 78xx to
drop it to 5V for the PIC etc? I would suggest that you look at some way of
having a two stage drop, either a resistor or a higher voltage 78xx
regulator before the 5V one, to limit power dissipation in the regulator.
> The problem specifically is that when the voltage drops there are
>miss writes to the ds1307, because the fall time of the power supply is
>about 5 seconds.
Do you have any pull up resistors on the enable lines of the Ds1307? I
haven't checked the data sheet or app notes, but Dallas/Maxim must publish
something about what is required to stop data corruption.
> What I was thinking of was to not do read/writes to the RTC
> when the power is in an unsafe state. So when the voltage in
> drops to a certain level ( < 5 but > 4 ) your code enters
> some safe state that just waits for power to come back to a
[SNIP]
Well, I see your point, it could be good, but I'm not shure. I think that my
problem is the PIC doing something wrong, I mean, the PC going somewhere
wrong in the Program memory. So, I don't think that putting the pic in a
"safe" state will work, asuming that the Program counter is wrong...
> --- Mauricio Jancic <EraseMEjancicspam_OUTTakeThisOuTciudad.com.ar> wrote:
> > Hi people,
> > I have a board that uses a PIC16F873(A) and a DS1307.
> > The board also has 4 7 segment displays that are
> > continuously showing the time (so, they are never off).
>
> This should be sent to the EE group instead, as it's not a software or
> programing issue.
How do you know that ?
Or that the "issue" might have a software solution ?
At least there is a PIC involved, and I'd rather not missed
this thread (since I don't subscribe to EE...).
> You should not run the motor and PIC from the same power
> supply, this is the real source of your problem, and
> potentially a future source of trouble as well. Use a diode
Ohh... God, was I soooo blind? Dam! Really, seriously, I was trying to solve
the problem in the current circuit, never consider that, even as it looks
like the obvious solution....
My current solution, which I'm now testing, is to put a diode in series with
the vcc line at the DS1307
The pic is still working at 5V so the data lines are at that voltage, but at
the DS1307 I have VCC+0.7V which is good. This solution makes the RTC to
power down when its VCC is 3.75V, but the voltage at the PIC is at that
point 3.75+0.7 = 4.45V, so is still within the PICs voltage range...
> -----Original Message-----
> From: piclist-bouncesspam_OUTmit.edu On Behalf Of Mauricio Jancic
> Sent: Thursday, May 05, 2005 9:14 AM
>
> Hi people,
> I have a board that uses a PIC16F873(A) and a DS1307. The board also
<snip>
> The problem specifically is that when the voltage drops there are
> miss writes to the ds1307, because the fall time of the power supply is
> about 5 seconds.
Do you have a good 3V lithium battery connected to the DS1307?
With a good lithium battery attached, the DS1307 has very good power down
data corruption prevention circuits. Without a good battery, the protection
becomes non-functional. (good battery = 2.5V to 3.0V)
This sounds similar to a problem I had recently -- switching PS supplied power
to various PICs, but also acted as a signal for another PIC (digital clock)
to turn on it's display. The clock had its own 7805 PS so it could
sleep/count when the main PS was off. During power-down, the long decay
would cause the clock PIC to flicker a few times, then finally go off. My
solution was to isolate the filter cap of the main PS using a rectifier
diode, so the signal to the clock PIC would drop abruptly. Perhaps this is
possible for your app?
Is that filter cap on the output side of the 7805? If so, isn't that a no-no?
Cheers,
-Neil.
On Thursday 05 May 2005 08:13 am, Mauricio Jancic scribbled: {Quote hidden}
> Hi people,
> I have a board that uses a PIC16F873(A) and a DS1307. The board also
> has 4 7 segment displays that are continuously showing the time (so, they
> are never off).
>
> The power supply is a very standard one. 4 diodes, 1 LM7805 with
> it's 2 input caps of 1uF and a filter capacitor of 10.000 uF (yes, 0.01 F x
> 50V). The filter cap is so big, because the Cap voltage (input * 1.41) is
> used from time to time to shortly make a motor work. This motor consumes
> low operation current but due to it's reduction gear it consumes some start
> current.
>
> Well, that said, let me present the problem. Oh, the PIC has it vcc
> filter cap (.1uF tantalium) and a 10K + 100nF for the /MCLR Pin.
>
> The problem specifically is that when the voltage drops there are
> miss writes to the ds1307, because the fall time of the power supply is
> about 5 seconds.
>
> So, sometimes when I just unplug the power supply from the wall and
> plug it on again the time is corrupted (7F:7F, all 1's, the upper bits are
> masked).
>
> I solve it a little with a 330ohm 1W resistor in parallel with the
> 0.01F capacitor. I also turn off the BOD of the PIC. Here's an interesting
> thing also. The pic is supposed to reset itself when Vcc is lower than 4V,
> but I see that it happens to be many resets while vcc is going down, off
> course because the fall time is long.
>
> Now, with the BOD tuned off, the PIC goes down that extra bit that
> is needed until de RTC is self turned off
> (~3.75V), but still have some random failures...
>
> Anyone has any pointer as how to proceed?
>
> Best regards,
> Mauricio
Hi,
- The voltage at the cap is 12 VAC rectified ( ~17 V) not 50V,
that's the cap rating voltage
- The DS1307 has its corresponding 2x10K resistors on the data lines
> The power supply is a very standard one. 4 diodes, 1 LM7805 with
>it's 2 input caps of 1uF and a filter capacitor of 10.000 uF (yes, 0.01 F x
>50V). The filter cap is so big, because the Cap voltage (input * 1.41) is
>used from time to time to shortly make a motor work. This motor consumes low
>operation current but due to it's reduction gear it consumes some start
>current.
>
> Well, that said, let me present the problem. Oh, the PIC has it vcc
>filter cap (.1uF tantalium) and a 10K + 100nF for the /MCLR Pin.
>
> The problem specifically is that when the voltage drops there are
>miss writes to the ds1307, because the fall time of the power supply is
>about 5 seconds.
I would tackle this by adding 2 more diodes (A to AC input, C tied
together) feeding a smaller filter cap and regulator. This smaller supply
would feed the logic power but not display or motor power. Current is
small, so you need only a small reservoir cap and tiny regulator - even a
simple series resistor / zener shunt works well.
I often add a P-channel JFET (J175) to ensure that the PSU discharges
completely. S to gnd, D to +5V logic, G to Vunreg via 1M0 resistor. This
assumes that Vunreg is at least 4V higher than Vreg during normal operation.
I've often mentioned how much trouble one can run into if the PIC Vdd
doesn't go all the way to 0V. The simple JFET shunt mentioned above
eliminates those problems and is very inexpensive.
Celebrating 21 years of Engineering Innovation (1984 - 2005)
.-. .-. .-. .-. .-. .-. .-. .-. .-. .-
`-' `-' `-' `-' `-' `-' `-' `-' `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.
I was testing all the time that a bit on the seconds register (read from the
RTC) was not 1, which would mean that the oscillator was off. If that
condition was true, I re-write the current time (recently read) to the RTC
after modifying that bit.
The problem was that when the 1307 turns off, your read 0xFF (the
pull-up resistor...) so, evry time the 1307 was off I write a 0xFF:0xFF:0xFF
time.... Something like that, I'm just trying that.
So, the question revolves around what's happening
between 4V and 3.75V (which is actually 1.25 * Vbat).
Right? Its not obvious to me that the PIC resetting
is some how writing garbage to the RTC. I2C takes
some very specific sequences, kind of hard to have
random garbage write 1s to all the registers. The
results you are seeing look more like symptoms of a
power outage, not a sequence of commands from the PIC.
Do you have a fully charged battery? Maybe the PIC
reset is causing power glitches?
As an aside, why are you writing the the RTC? Does
this only happen at startup? Maybe you should put
some sort of delay into the write code so that is
doesn't happen within a certain period of time after
reset.
There are lots of ways to detect the voltage level
(though it takes a little care) but I don't see what
that buys you as you still have to deal with the BOD
reset issue (if that is what's causing the problem.
It seems to me that you already have a reasonable
solution.
> Hi people,
> I have a board that uses a PIC16F873(A) and a
> DS1307. The board also
> has 4 7 segment displays that are continuously
> showing the time (so, they
> are never off).
>
> The power supply is a very standard one. 4 diodes,
> 1 LM7805 with
> it's 2 input caps of 1uF and a filter capacitor of
> 10.000 uF (yes, 0.01 F x
> 50V). The filter cap is so big, because the Cap
> voltage (input * 1.41) is
> used from time to time to shortly make a motor work.
> This motor consumes low
> operation current but due to it's reduction gear it
> consumes some start
> current.
>
> Well, that said, let me present the problem. Oh,
> the PIC has it vcc
> filter cap (.1uF tantalium) and a 10K + 100nF for
> the /MCLR Pin.
>
> The problem specifically is that when the voltage
> drops there are
> miss writes to the ds1307, because the fall time of
> the power supply is
> about 5 seconds.
>
> So, sometimes when I just unplug the power supply
> from the wall and
> plug it on again the time is corrupted (7F:7F, all
> 1's, the upper bits are
> masked).
>
> I solve it a little with a 330ohm 1W resistor in
> parallel with the
> 0.01F capacitor. I also turn off the BOD of the PIC.
> Here's an interesting
> thing also. The pic is supposed to reset itself when
> Vcc is lower than 4V,
> but I see that it happens to be many resets while
> vcc is going down, off
> course because the fall time is long.
>
> Now, with the BOD tuned off, the PIC goes down that
> extra bit that
> is needed until de RTC is self turned off
> (~3.75V), but still have some random failures...
>
> Anyone has any pointer as how to proceed?
>
> Best regards,
> Mauricio
>