Power Consumption of STC15/DS1302 Based Watch - Page 1
Forum section: electronics / general

author: ruthsarian
author_rank: Contributor
timestamp: June 20, 2017, 08:41:01 pm
content: I picked up a watch kit off eBay that has anSTC15L204EA MCUand a DS1302 RTC and a 4 digit LED display. It's all powered by a CR2032. The firmware that comes with it just displays the time in 24 hour format. I wanted to write some new firmware for it to display 12 hour format. I foundthis firmwaresomeone else had created for another STC15-based clock and forked it as a base formy new firmware.Long story short, I've got it displaying the time in 12 hour format and added a few more features. Now I'm focusing on power consumption because it's powered by a CR2032 and the case is annoying to take apart to change batteries, so I'd like them to last a while.I did some tests and found the stock firmware in powered down mode would draw about .35mA. Mine was drawing .75mA. The solution I've found is that I had to set the I/O pins connected to the DS1302 all high (logic 1; which i assume is 'high') before putting the MCU into powered down mode. Now my firmware draws about .35mA too, but I don't get why that is and was wondering if someone could explain that to me.My thought is by leaving the I/O pins low they're sinking current from the DS1302 and setting them high stops that from happening. TheDS1302 datasheetstates "If the CE input is low, all data transfer terminates and the I/O pin goes to a high-impedance state". Shouldn't putting the MCU pin connected to CE low stop any current coming out of the DS1302? That shuts the I/O pin off, and the other two (CE and SCLK) shouldn't be doing anything. I've got to be missing something (probably simple and obvious). What is it?In looking at the DS1302 datasheet it seems with some small tweaks to the PCB, even more power could be consumed if there was a way to block power to Vcc2 (pin 1) on the DS1302 while in powered down mode, putting the chip into low power mode. Unfortunately both Vcc1 and Vcc2 are tied to the CR2032. I can't cut the trace to Vcc2 because SPI stops working without power to Vcc2.

author: technix
author_rank: Super Contributor
timestamp: June 21, 2017, 12:01:10 am
content: STC15 have true high-Z inputs and push/pull outputs.

author: ruthsarian
author_rank: Contributor
timestamp: June 21, 2017, 02:23:31 am
content: Changed the code to set the CE, SCLK, and IO pins to high-Z before power down, rather than setting them to 1 in quasi bi-directional mode. Now it's drawing .30mA. Sweet.

author: technix
author_rank: Super Contributor
timestamp: June 21, 2017, 04:00:48 am
content: Change your output pins to true push pull configuration and save some more power. Also put unused pins to push-pull output node.

author: ruthsarian
author_rank: Contributor
timestamp: June 22, 2017, 06:25:49 pm
content: The MCU is a 20-PIN version of the STC15L204EA which can operate off 3V; same pinout as an STC15S204EA, but at 3v.I can't get power consumption under power down mode below .3mA. I went back and re-measured an original firmware and it looks like my original measurement was wrong. The stock firmware has it below what I can measure on my multimeter (<100uA).I'll attach a copy of the schematic.Any ideas how I'd conserve power? I've tried setting all the pins to every possible pin (4) and logic level(2) configuration and the lowest I can get is .3mA. I'll write up some code tonight that focuses on just power down mode and share it to see if there's anything obvious I'm missing.Thanks

author: StillTrying
author_rank: Super Contributor
timestamp: June 23, 2017, 06:02:29 pm
content: 3V across one of the 10Ks would be suspiciously close to 0.3mA.

author: ruthsarian
author_rank: Contributor
timestamp: June 24, 2017, 01:21:26 pm
content: Looks like the issue is having those 10k pullups to the IO, SCLK, and CE/RST pins on the DS1302. There's an internal 40k pulldown resistor on each of those pins. So regardless of what the MCU is doing, with a battery plugged in it'll always be dropping around 180uA into those pins.When the MCU pins are logic low before powering down, the pulldown transistor is enabled, taking more current. That's why setting logic 1's removed a lot of the power drain; high impedance mode has no pulldown transistor.With VCC1 and VCC2 on the DS1302 both wired to the battery, the DS1302 will always be full-on. I cut the trace to VCC1 and VCC2 then measured the current and it was using around 40uA.That covers about 220 of the 300 uAs I'm measuring. Maybe a little more if those resistors aren't spot on.Do I need those 10k pullups?

author: technix
author_rank: Super Contributor
timestamp: June 24, 2017, 01:47:55 pm
content: Quote from: ruthsarian on June 24, 2017, 01:21:26 pmI think you can live without them (but keep the footprints there so you can add them back once you need them again.)

author: ruthsarian
author_rank: Contributor
timestamp: June 25, 2017, 01:56:06 pm
content: I've pulled the three 10k resistors. I found I needed to set the pins to the DS1302 to push-pull output configuration with the resistors gone, but it appears to be working. In power down mode, with both VCC1 and VCC2 wired up, it's drawing 50uA. A massive improvement.With only VCC1 wired, I can't set the time, but it does draw below 1uA when in power down mode. I think I'll try wiring VCC2 to pin 3.0 on the STC and try powering the DS1302 through that when the display is on, then cut it in power down mode. One potential problem is VCC2 power needs to be 0.2v higher than VCC1 for the DS1302 to switch to VCC2 for power. Maybe connecting the battery to VCC1 on the DS1302 via a diode to bring the voltage down a bit would help.

author: technix
author_rank: Super Contributor
timestamp: June 25, 2017, 02:57:54 pm
content: Quote from: ruthsarian on June 25, 2017, 01:56:06 pmVCC1 and VCC2 on DS1302 are intended for different power supplies - VCC2 is the main battery, and VCC1 is the backup battery. You can disconnect VCC1 from system power rail and hook a 5V supercap or a 3V lithium coin cell there so the time is kept when the power is disconnected. Do not enable the charger with lithium coin cell, but do enable it with the supercap. And the circuit have built-in diodes and resistors to charge the supercap.

author: ruthsarian
author_rank: Contributor
timestamp: June 26, 2017, 02:42:16 pm
content: I think I've got it working.I cut the trace to VCC1 (pin 8) and VCC2 (pin 1) on the DS1302 and also the trace connecting the two together. I wired VCC2 to port 3.0 (pin 11) on the STC15 microcontroller, which was unused. I then connected VCC1 to the positive battery terminal using a small diode that has a 0.6v forward voltage so that VCC1 would always have a lower voltage than VCC2. This way when VCC2 is powered the DS1302 switches to the higher voltage source at VCC2 and operates in normal mode, then when power to VCC2 is cut it'll operate in low-power mode from VCC1.When the MCU starts up, port 3.0 is configured as push-pull output and set high to power the DS1302. When the MCU enters power down mode, port 3.0 is set low to remove power from VCC2 and the DS1302 continues to operate off VCC1 in low power mode. When the MCU comes out of power down mode, port 3.0 is set high again and the DS1302 operates off VCC2 power again.In power down mode the watch now draws 0.4uA (that's as low as my EEVBlog multimeter will measure). I'll set it aside for a few weeks to a few months just to make sure it continues to work, but for the last 12 hours or so at least it's been working great!I did try wiring up VCC1 without the diode and it seemed to have problems switching to VCC2 power when the MCU came out of power-down mode. The 0.6v drop across the diode seems to be needed.Is there a more 'correct' solution to creating that voltage drop to VCC1? A voltage divider with a pair of resistors would create a path to ground that would eat up a few microamps, so it seemed to me a diode is the way to go.

author: technix
author_rank: Super Contributor
timestamp: June 26, 2017, 03:28:38 pm
content: Now try make it smaller in the next revision: the MCU, RTC and crystal all have surface mount variants that is much smaller. You may have to stick to through hole buttons for reliability and height matching, otherwise surface mount variants can work too.Also if you want to give it some connectivity, a small USB to Serial adapter can be added to allow the watch to be reprogrammed or being fed the current time from a computer. Adding the USB also allows you to replace the Lithium primary cell with a (much smaller) Li-Po cell with a SOT-23 charger.