(Ice Tube Clock) Time not being kept while powered under battery backup

For RTC breakouts, etc., use the Other Products from Adafruit forum

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
jarchie
 
Posts: 615
Joined: Sun Jun 24, 2012 2:16 pm

Re: (Ice Tube Clock) Time not being kept while powered under battery backup

Post by jarchie »

@AlexOsadzinski When I suggested that the problem might be firmware-related, I did not mean to contradict Bill's (adafruit_support_bill) suggestion that the problem could be build-related.

It's still worth posting photos of the build... I've seen many hobbyists more experienced than myself make careless errors that, for whatever reason, are much easier to catch with a second set of eyes. And sometimes seemingly identical problems have different causes.

And if Adafruit support rules out the (in my opinion) more likely problems with the build and defective components, I would be willing to program and mail you an ATMEGA328P chip with my unofficial xmas-icetuble firmware to see if the problem is firmware-related.

User avatar
alexosadzinski
 
Posts: 6
Joined: Fri Jul 05, 2013 10:23 am

Re: (Ice Tube Clock) Time not being kept while powered under battery backup

Post by alexosadzinski »

First many thanks to Adafruit support and others with helpful input, and especially to jarchie for "above and beyond" offers of help.

I've looked and looked again to see if I built the clock incorrectly. As I was doing the build, I checked resistor values visually and with a multimeter, so I'm pretty sure that I got all of those right. The Q3 instructions are the most challenging, but I followed them correctly. All the progress tests were just fine.

I've done a bunch of tests, and the behavior is pretty consistent: if I power off the clock, and wait 5 seconds to 15 minutes (my home generator comes online about 10 seconds after a power outage, so that's the mostly likely use case for battery backup), then power it on, it beeps, and the display flashes the time that was correct when the power went off. Setting the time, of course, stops the flashing.

On a couple of occasions, the clock hasn't beeped, some very faint segments light up on the tube, but nothing else. Removing all power, including the battery, and waiting a minute, then replacing the battery and power solve the problem. Interestingly, the clock still remembers the date... I'm wondering if the processor crashes under some circumstances.

In any case, I'm posting photos of the build and am interested in feedback.

Thanks again, and best regards, Alex.
Clock 1.jpg
Clock 1.jpg (99.19 KiB) Viewed 1610 times
Clock 2.jpg
Clock 2.jpg (91.43 KiB) Viewed 1610 times

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: (Ice Tube Clock) Time not being kept while powered under battery backup

Post by adafruit_support_bill »

Looks like a pretty clean build with everything in the right place. We had one similar case a few years back that was cured by cleaning the residual flux from around the oscillator circuit. That may not be the case here, but it is easy enough to try.

If that doesn't help, you can contact [email protected] with a link to this thread and we'll send you a replacement processor.

I'd also be interested to see if Jarchie's firmware solves the problem. I know he's put a lot of good work into improvements and new features.

User avatar
jarchie
 
Posts: 615
Joined: Sun Jun 24, 2012 2:16 pm

Re: (Ice Tube Clock) Time not being kept while powered under battery backup

Post by jarchie »

We had one similar case a few years back that was cured by cleaning the residual flux from around the oscillator circuit. That may not be the case here, but it is easy enough to try.
This also happened with one of my clocks, but in that case the oscillator did not work at all. I scrubbed the board with denatured alcohol and a toothbrush, let it thoroughly dry, and voila! Everything started working perfectly. ATMEGAs do seem to be more sensitive to oscillator issues during sleep mode, so cleaning the board might just solve your problem.

If that doesn't work, I suggest asking Adafruit for a replacement MCU and emailing me your mailing address. I will send an MCU with my unofficial xmas-icetube firmware.

I also have another off-the-wall suggestion: try smaller capacitors on the crystal. I happen to have appropriately sized caps on-hand, so I'll mail them with the MCU.

User avatar
alexosadzinski
 
Posts: 6
Joined: Fri Jul 05, 2013 10:23 am

Re: (Ice Tube Clock) Time not being kept while powered under battery backup

Post by alexosadzinski »

Thanks again for the helpful suggestions.

I cleaned the board thoroughly (a surprisingly therapeutic exercise), but no joy. So I'll try the new MCU. Jarchie, I'll also email you separately, thanks!

User avatar
alexosadzinski
 
Posts: 6
Joined: Fri Jul 05, 2013 10:23 am

Re: (Ice Tube Clock) Time not being kept while powered under battery backup

Post by alexosadzinski »

An update:

I tried the new MCU from Adafruit. No change in behavior. I tried jarchie's MCU with modified firmware. No change in behavior, but a clue: when I remove 9V power, then reapply it, the display shows "bod rset". In all cases, the time is the same as when the power was removed. Strangely, if I remove the battery, then remove 9V power for even a few hours, when I reapply 9V power, I see "bod rset" and the time is the same as when power was removed. I didn't realize that the MCU would retain the time with no 9V or battery power for so long.

My conclusion is that there's something wrong with my backup battery circuit. But, when 9V power is removed, I'm seeing 0.7V on BATT SNSE, and 2.65V on various other MCU pins, plus the MCU block is still running at 32kHz, so I'm at a loss.

I changed C8 and C9 for 12 and 6pF caps. No change. Weird, no?

User avatar
jarchie
 
Posts: 615
Joined: Sun Jun 24, 2012 2:16 pm

Re: (Ice Tube Clock) Time not being kept while powered under battery backup

Post by jarchie »

No change in behavior, but a clue: when I remove 9V power, then reapply it, the display shows "bod rset".
When the MCU first starts, my firmware checks the MCUSR register (MCU status register) to determine why the MCU is starting, and displays a suitable diagnostic message. The "bod rset" message means that BORF (brown out reset flag) was set in the MCUSR register.
I didn't realize that the MCU would retain the time with no 9V or battery power for so long.
Both firmwares write the current time to EEPROM on power loss, so time is retained without power.

My firmware saves the time just in case the battery is dead, so only a few seconds will be lost for a momentary power outage. The display will still flash to indicate a potentially significant time loss.

The Adafruit firmware saves the time so that it can be restored when the firmware restarts in sleep mode. (I'm using the term "restart" loosely. If I remember correctly, the Adafruit firmware jumps to the first program instruction whenever the +9v power is lost or restored.)
My conclusion is that there's something wrong with my backup battery circuit. But, when 9V power is removed, I'm seeing 0.7V on BATT SNSE, and 2.65V on various other MCU pins, plus the MCU block is still running at 32kHz, so I'm at a loss.
That is my conclusion also. But even if the clock briefly dips below the BOD threshold of 1.8 volts, both firmwares should restart during periods of higher battery voltage and time should advance. Like you, I'm a bit stumped, so I'll sleep on it.

In the meantime--since you seem to have access to an oscilloscope--it might be worth checking if the 2.65v clock voltage is consistent during sleep. I am wondering if system voltage could be oscillating between <1.8v and 2.7-3.0v. If you haven't already, it might be worth trying a fresh CR1220 coin cell.

User avatar
alexosadzinski
 
Posts: 6
Joined: Fri Jul 05, 2013 10:23 am

Re: (Ice Tube Clock) Time not being kept while powered under battery backup

Post by alexosadzinski »

Many thanks for all of the feedback. I'll try a new coin cell, as the voltage on the original one is sagging a little.

Your firmware project on github is very impressive and instructive!

User avatar
jarchie
 
Posts: 615
Joined: Sun Jun 24, 2012 2:16 pm

Re: (Ice Tube Clock) Time not being kept while powered under battery backup

Post by jarchie »

At this point, I think you've ruled out the probable causes, so I am going to suggest that you investigate improbable ones...unless, of course, anyone at Adafruit support has better ideas.

I'm beginning to suspect that the problem is not with the battery circuit. Consider this scenario: When the clock loses +9v power, the time and date are saved to EEPROM, and the clock enters sleep mode. Sleep mode functions normally, maintaining the current time in RAM. But when +9v power is restored, the MCU abruptly resets, and during startup, the old EEPROM-stored time and date are restored. Since external power is restored, the clock starts normally after the reset, but flashes the display to indicate a reset has occurred. The problematic reset on restoration of +9v power must be abrupt because my firmware writes the current time to EEPROM immediately after detecting the restoration of +9v power but before enabling the display and other features.

I also realized that it's possible the reset is not BOD-related. Ever since I started saving power during sleep by disabling BOD when unneeded, I've noticed that the brown-out reset flag can be set by an external reset when no brown out has actually occurred. I implemented a workaround last night, but your chip would still exhibit the old behavior.

In other projects--but not in the Ice Tube Clock--I've noticed that the internal pull-up resistor on the MCU !RESET pin is sometimes insufficient to prevent unwanted external resets--especially in noisy environments. In your clock, the rapid rise in voltage during +9v power restoration might be sufficient to trigger such a reset. To eliminate this possibility, try connecting or soldering a temporary a 10k resistor--or even a plain jumper--between MCU pins 1 (!RESET) and 7 (VCC). Or equivalently, you could connect ISP pin 2 (VCC; front-left pin; adjacent to edge of board and linear regulator) and ISP pin 5 (!RESET; back-right pin; adjacent to C4 and MCU) with a 10k resistor or jumper. But if you choose a jumper, be certain not to attach an AVR programmer to the ISP header while the jumper is in place.
ATMEGA328P pin-outs datasheet; ATMEGA168V pin-outs are identical
ATMEGA328P pin-outs datasheet; ATMEGA168V pin-outs are identical
ATMEGA328P.png (27.14 KiB) Viewed 1486 times
If connecting a 10k resistor or jumper does not solve the problem, would you acquire and post additional diagnostic information? I would like to know the voltage in several places, both during normal operation and during sleep:
  • R3 (either side)
  • both ends of D4
  • MCU pins 5 (PD3), 12 (PD6/OC0A), and 13 (PD7/AIN1)
I'll try a new coin cell, as the voltage on the original one is sagging a little.
I still think that it's worth a try.

Your firmware project on github is very impressive and instructive!
Thank you for the kind words! Once your clock is working well, I hope you enjoy the firmware.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: (Ice Tube Clock) Time not being kept while powered under battery backup

Post by adafruit_support_bill »

unless, of course, anyone at Adafruit support has better ideas.
At this point, I think jarchie is more familiar with the low-level code than I am. If the battery doesn't help, his resistor strategy is worth a try.

User avatar
jarchie
 
Posts: 615
Joined: Sun Jun 24, 2012 2:16 pm

Re: (Ice Tube Clock) Time not being kept while powered under battery backup

Post by jarchie »

his resistor strategy is worth a try
And if pulling the !RESET pin high doesn't work, it will at least rule out the possibility of an external reset (BORF and EXTRF set in MCUSR). Only two possibilities will remain: a brown-out reset (BORF set in MCUSR) or a power-failure reset (BORF and PORF set in MCUSR). Either way the voltage to the microcontroller would be falling below the brown-out detection threshold.

Locked
Please be positive and constructive with your questions and comments.

Return to “Clock Kits (discontinued)”