Cheap, ultra low power RTC to periodically wake microcontroller from power-down? - Page 1
Forum section: electronics / projects

author: I wanted a rude username
author_rank: Frequent Contributor
timestamp: December 03, 2019, 12:17:18 pm
content: Some microcontrollers have excellent power-down current consumption, but this gets orders of magnitude worse when they are running, even at low frequencies. E.g. at 3.3 V the Padauk PMS134 draws 100 nA in power-down but 40 µA on its internal low-speed oscillator. This would completely drain a CR2032 in less than a year.There are excellent RTCs like theMicro Crystal RV-8803-C7which can be used to periodically wake the microcontroller from power-down via an interrupt, avoiding this waste of power. The RV-8803-C7 draws roughly 250 nA, and is even temperature compensated. However, at $1.60 per unit in volume it nukes all the cost saving of the 10¢ Padauk.Is there a budget RTC for this purpose, in the < 1 µA range, which isn't in a big (SOP) package? Temperature compensation is a nice-to-have but definitely not required. Internal crystal preferred but also not required.

author: krish2487
author_rank: Frequent Contributor
timestamp: December 03, 2019, 12:37:31 pm
content: Is the RTC a necessity or will periodically waking up the micro sufficient?Is something like thishttps://www.digikey.com/product-detail/en/texas-instruments/TPL5110DDCT/296-38830-2-ND/5130143a viable solution for what you are wanting to do??:-)

author: Yansi
author_rank: Super Contributor
timestamp: December 03, 2019, 01:08:04 pm
content: Why do it complicated?Use an MCU with a low power timer (or even the RTC) suited for periodic wakeup in the first place.For example STM32L011, if you want something small with low consumption.

author: Howardlong
author_rank: Super Contributor
timestamp: December 03, 2019, 01:22:16 pm
content: Quote from: krish2487 on December 03, 2019, 12:37:31 pmNice device, I wasn't aware of those, thanks for the info.To the OP: I was discussing these super cheap MCUs the other day with some colleagues, and the end result of the conversation was that in many cases, the family feature sets are limited compared to more mature and industry standard product lines. If you need to spend $0.50 to add the right functionality to a $0.10 MCU, it quickly negates the cost benefit.Furthermore, there are plenty of mainstream options that can provide <1uA 32kHz crystal clock on chip and if you don't mind doing your RTCC in software they're cheap. You can use low power watchdogs if it's not time critical.

author: jhpadjustable
author_rank: Frequent Contributor
timestamp: December 03, 2019, 01:24:18 pm
content: Quote from: I wanted a rude username on December 03, 2019, 12:17:18 pmHow about the PCF85063? Run current 0.22µA (typical) 0.6µA (max), available in a variety of small packages from SO-8 down, 80¢/1 or $54/100 at Digi-Key. The bad news is you have to bring your own tuning fork crystal.Maybe the Padauk route isn't the best route. If I understand correctly, you don't really need the core to be running, just the RTC and its oscillator. The tinyAVR 0-series seems worth a look. Typical power consumption at 3.3V in standby mode, with just the RTC andexternal(EDIT: no, internal) low-speed oscillator running and most other interrupt sources available, appears to be less than 2µA under 85°C. The actual retail price from Digi-Key is 40¢/1.

author: Howardlong
author_rank: Super Contributor
timestamp: December 03, 2019, 01:50:52 pm
content: Quote from: jhpadjustable on December 03, 2019, 01:24:18 pmFWIW I've never understood why so many RTCC devices only provide an I2C interface plus open drain INT pins: the pull-up requirement necessitates unnecessary power consumption overhead to my mind.

author: kamtar
author_rank: Regular Contributor
timestamp: December 03, 2019, 02:57:20 pm
content: Quote from: Howardlong on December 03, 2019, 01:50:52 pmbecause I2C is cheaper, and I don't see the issue with open-drain outputs they consume any noticeable (for most use-cases) power only when used, all these devices aren't designed for constant communication.

author: Howardlong
author_rank: Super Contributor
timestamp: December 03, 2019, 03:12:25 pm
content: Quote from: kamtar on December 03, 2019, 02:57:20 pmI'd have thought SPI would be cheaper to implement. Either way, an option for either plus optional push pull on the INT pin.

author: kamtar
author_rank: Regular Contributor
timestamp: December 03, 2019, 04:47:04 pm
content: Quote from: Howardlong on December 03, 2019, 03:12:25 pmspeed communication and extra pins are what increases price I guess. Again pull-ups matter only when that line is held LOW by something, for something as an interrupt from RTC I don't see the problem in that extra 0.3 mA (3V/10k pull-up) for few microseconds from time to time in most applications. I2C could be a problem if you communicate really often, but these types of chips arent designed for that usecase, you cant have ICs which can do everything for everyone and this is good enough for most uses (even low-power ones).

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 03, 2019, 07:32:49 pm
content: Quote from: Howardlong on December 03, 2019, 03:12:25 pmWell, yeah. I2C is definitely more complex to implement and takes more logic. I can't see how it would be "cheaper". Besides, if I'm not mistaken, I2C used to be licensed, so you had to pay for a license to include it in an IC. I don't know for sure whether it's still the case or if it's in the public domain now?

author: jbb
author_rank: Super Contributor
timestamp: December 03, 2019, 08:07:33 pm
content: I have heard - and might be wrong! - that IO pin drivers need quite a lot of silicon area. So the extra I2Clogicis probably quite cheap compared to 2 IO pins and a larger plastic package required by SPI.I think that quite a few MCUs offer separate crystal oscillators and Real Time Clock logic so that the device can wake up from RTC.We’ve done that with the deeper sleep modes in an STM32. MSP430 devices also offer it (but I haven’t tried myself).

author: jhpadjustable
author_rank: Frequent Contributor
timestamp: December 03, 2019, 10:03:14 pm
content: I just checked that the tinyAVR1-series, particularly ATtiny(2|4|8)14, does have anexternal32k oscillator and typically, at <85°C, consumes about 1-1.5µA in standby mode with that and the RTC running. Active current can be as small as 8µA (but there are minimum speed requirements to access the RTC registers, if you're not just using the periodic interval timer to wake up). Still only 54¢/1 from Digi-Key, looks like 4mm-wide SO-14 only.

author: I wanted a rude username
author_rank: Frequent Contributor
timestamp: December 03, 2019, 11:39:22 pm
content: Thanks for the feedback, kind people.Quote from: krish2487 on December 03, 2019, 12:37:31 pmIf the period of waking the microcontroller is known in advance, for 30¢ this is a good solution. Also its brother theTPL5010, which wakes the microcontroller directly over an interrupt line.Quote from: Yansi on December 03, 2019, 01:08:04 pm540 nA with RTC and full RAM retention for 70¢ is very nice. You're right, this looks like a better approach overall.Quote from: Howardlong on December 03, 2019, 01:22:16 pmAgreed. The window for suitable applications is narrow. They are good for things like toys and appliances in which the user wakes the microcontroller through a button press or other hard interrupt. Step outside this range and the best recourse is a more richly featured microcontroller.I was trying to see how far I could push that window open, but clearly not far enough to squeeze my far arse through.

author: texaspyro
author_rank: Super Contributor
timestamp: December 04, 2019, 04:41:35 am
content: I once built some data loggers. I used a cheap micro (can't say which one) that supported using a watch crystal. That micro's only purpose was to periodically wake up the main instrument. One of these loggers was lost for over 25 years. When it was recovered it was still ticking and logging. The log memory was sized for 3 years of data and was expected to be retrieved and dumped every year or two... the log queue wrapped around over 8 times. The wakeup clock had drifted less than a hour. The power for the loggers was a lithium primary "F" sized cell.

author: Peabody
author_rank: Super Contributor
timestamp: December 04, 2019, 03:40:47 pm
content: If the processor doesn't sleep very soundly, or if there are other circuit components that have the same problem, then it seems you could use an RTC module or similarly efficient tiny processor, powered by its own coin cell, to periodically turn on the power to the main circuit instead of just waking it up. Then the main processor would maintain the power on while it's doing its thing, then shut off the power. The power switching circuit would just be a P-channel mosfet, an NPN and a couple resistors, and use one GPIO pin. And then you wouldn't really have to worry about sleep current or a regulator's quiescent current or current used in dividers since the whole thing would only be powered up briefly.

author: I wanted a rude username
author_rank: Frequent Contributor
timestamp: December 04, 2019, 09:27:11 pm
content: Quote from: Peabody on December 04, 2019, 03:40:47 pmOr run the target device directly from the GPIO.

author: Wimberleytech
author_rank: Super Contributor
timestamp: December 06, 2019, 12:46:29 am
content: QuoteNo, pretty sure the Philips patents have expired.

author: iMo
author_rank: Super Contributor
timestamp: December 06, 2019, 10:41:20 am
content: The lowest power afaik is the PCF8563 (250nA @3V).A CR2032 150mAH will last for 68 years

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 06, 2019, 02:59:57 pm
content: Quote from: Wimberleytech on December 06, 2019, 12:46:29 amI took a look.https://en.wikipedia.org/wiki/I%C2%B2C1. No license fees required since Oct. 2006 (probably explains why the number of ICs with an I2C interface has risen significantly in the last 10 years or so);2. NXP apparently still has a program for allocating slave addresses, and there are fees, although I couldn't find any precise information on this. According to the I2C specs, "Assignment of addresses within a local system is up to the system architect", thus we can understand that registering slave addresses is optional and not required. I guess most vendors don't bother to register these days, all the more that there are only a very limited set of possible addresses, and that the usual addresses used for various types of devices are relatively easy to find.For anyone interested, the latest rev. specs:https://www.nxp.com/docs/en/user-guide/UM10204.pdf

author: I wanted a rude username
author_rank: Frequent Contributor
timestamp: December 06, 2019, 09:33:50 pm
content: Quote from: imo on December 06, 2019, 10:41:20 amFor 20¢ per unit in volume (or 10¢ for the HuaGuan Semiconductor PCF8563M, a copy/clone claiming identical characteristics), this is perfect! It can be used in countdown mode without ever needing to set the time and date, and the countdown interrupt can be set to either latch on or reset. The maximum countdown duration of 4.25 hours is certainly acceptable since the microcontroller can wrap it in a counter loop for longer durations. A brief I2C transmission would only be required when changing the countdown duration.https://www.nxp.com/docs/en/data-sheet/PCF8563.pdfhttps://datasheet.lcsc.com/szlcsc/1910291305_HGSEMI-PCF8563M-TR_C434478.pdf

author: GeorgeOfTheJungle
author_rank: Super Contributor
timestamp: December 06, 2019, 10:28:26 pm
content: Quote from: imo on December 06, 2019, 10:41:20 amQuote from: Peabody on December 04, 2019, 03:40:47 pmI think I'm going to borrow the ideathe PCF8563 /int pin can drive the high side switch

author: I wanted a rude username
author_rank: Frequent Contributor
timestamp: December 06, 2019, 10:56:48 pm
content: And as its final action, the microcontroller clears the timer flag.How would you switch on the MOSFET after a power-on/reset though?

author: floobydust
author_rank: Super Contributor
timestamp: December 06, 2019, 11:03:15 pm
content: I had a datalogger product using PCF8583T and it was unreliable for the wakeups. Set the alarm and no interrupt occured, some of the time. The flag just didn't get set.Found the silicon errata sheet and screamed for quite a while at that bug in 118 or 112. SoI will never again use a PCF family RTC.They are cheap because they are primitive, quirky state-machines that need careful software considerations.Enjoy how complicated the read events are:NXP Semiconductors AN10652 Improved timekeeping accuracy using external temperature sensor PCF8563More info:NXP RTC UM10301 User Manual for NXP Real Time Clocks PCF85x3, PCF85x63, PCA8565, PCF2123, and PCA21125

author: I wanted a rude username
author_rank: Frequent Contributor
timestamp: December 07, 2019, 12:01:03 am
content: Quote from: floobydust on December 06, 2019, 11:03:15 pmI can't find the errata (do NXP publish them?), but did the bug occur because the alarm was used in seconds mode, and the microcontroller's reads/writes of the time/date registers were causing the PCF8583 to stop the clock for one second (to allow atomicity) and thus miss the interrupt?

author: iMo
author_rank: Super Contributor
timestamp: December 07, 2019, 12:09:50 am
content: The key message with this kind of RTC is: "when the read or write I2C operation takes more than 1 second you loose 1 second". Normally your read or write I2C operation takes a few milliseconds with 100kHz I2C clock..PS: 1 second is lost because the I2C operation stops the internal "seconds" counter thus if the operation is longer than 1 second your RTC will show 1 second less.

author: Peabody
author_rank: Super Contributor
timestamp: December 07, 2019, 12:35:33 am
content: Quote from: I wanted a rude username on December 06, 2019, 10:56:48 pmOr the microcontroller could set its own next wakeup time before shutting down its power.The mosfet would be turned on by the RTC module, which would power up the microcontoller. Attached is my circuit for a mailbox notifier which has the power completely shut down until the door is opened, which turns on the mosfet. The microcontroller powers up, sends the notification message, then shuts down its power. The RTC module's open-drain /INT pin would take the place of the magnetic switch. The module would be powered seperately by a coin cell, with common ground with the main battery. Open-drain is perfect for this.

author: I wanted a rude username
author_rank: Frequent Contributor
timestamp: December 07, 2019, 12:48:11 am
content: Thanks, that 100 kOhm pull-up explains how it starts without the interrupt line being asserted. But doesn't that cause a constant 30-45 µA current draw through the pull-up?

author: GeorgeOfTheJungle
author_rank: Super Contributor
timestamp: December 07, 2019, 12:51:08 am
content: Quote from: I wanted a rude username on December 06, 2019, 10:56:48 pmYou just have to momentarily GND the mosfet gate with a pushbutton to turn it on manually. And an open collector gpio to keep it ON the rest of the time.Quote from: I wanted a rude username on December 07, 2019, 12:48:11 amThrough Q2 to GND you mean?

author: I wanted a rude username
author_rank: Frequent Contributor
timestamp: December 07, 2019, 01:05:09 am
content: Through the normally-closed reed switch. Seems like the leakage would outweigh the power saving of this design.Quote from: GeorgeOfTheJungle on December 07, 2019, 12:51:08 amCould it be done without a switch, so that the microcontroller starts as soon as the device is powered?

author: GeorgeOfTheJungle
author_rank: Super Contributor
timestamp: December 07, 2019, 01:13:57 am
content: Quote from: I wanted a rude username on December 07, 2019, 01:05:09 amYes, with a capacitor in parallel with Q2 C-E.

author: I wanted a rude username
author_rank: Frequent Contributor
timestamp: December 07, 2019, 02:06:04 am
content: I lack the fundamental electronics knowledge to understand how that would work.Fortunately in my applications the quiescent currents are so low that waking the microcontroller directly by interrupt is good enough.

author: floobydust
author_rank: Super Contributor
timestamp: December 07, 2019, 02:14:29 am
content: Quote from: I wanted a rude username on December 07, 2019, 12:01:03 amPCF8583 is a 22 year old part, along with the PCF8563. These are antiques. I don't know where the erratas have gone to, but that was when I realized it was never going to work properly and stop killing myself looking for a firmware bug. NXP has Freescale/Kinetis and LPC ARM erratas but no others do I see. Check out aMicrochip MCP7940Mone. Note RTC's are not always great, always look at the RTC erratas, some are pretty awful.I didn't do the original hardware/firmware design, but it landed on my lap when there were problems. The datalogger did once or twice a day wakeup and take readings, flash storage and then radio call-outs, then back to sleep. It was not constantly talking to the RTC. Just a read for timestamp, setup the next alarm time next day and then the MCU went to sleep.... forever... sometimes...My point is, I got burned by the chip and would not use again. Especially an antique. Gotta wonder, if you're freezing the time counters for a read and can't splurge on a secondary buffer/holding register to read the time from, YUCK. Look mom, we saved a few dozen flip flop$.Otherwise, it might be cheaper to make your own RTC with a MCU. ARM parts do have that code.

author: GeorgeOfTheJungle
author_rank: Super Contributor
timestamp: December 07, 2019, 02:31:50 am
content: Quote from: I wanted a rude username on December 07, 2019, 02:06:04 amIt takes a few ms to charge C1 through R1 => the gate is below Vcc => the mosfet is ON:

author: I wanted a rude username
author_rank: Frequent Contributor
timestamp: December 07, 2019, 02:37:38 am
content: Quote from: floobydust on December 07, 2019, 02:14:29 amOh. Oh wow. This would be funny to read if you didn't have to actually use it ...Quote

author: floobydust
author_rank: Super Contributor
timestamp: December 07, 2019, 04:12:44 am
content: With the same parts you can implement a latching power switch, which is good if the MCU takes a while to boot. Circuit shamelessly taken from a Fluke DMM with 9V battery.

author: I wanted a rude username
author_rank: Frequent Contributor
timestamp: December 07, 2019, 05:40:45 am
content: Quote from: GeorgeOfTheJungle on December 07, 2019, 02:31:50 amI did not understanding thatthe MOSFET is controlled by a potential difference between the gate and source. Just thought its gate was somehow magically "active high" ... so the logic seemed backwards. After researching this, it all makes sense. Thanks for the simulation!

author: Peabody
author_rank: Super Contributor
timestamp: December 07, 2019, 03:26:57 pm
content: Quote from: I wanted a rude username on December 07, 2019, 01:05:09 amIn my circuit, the magnetic switch is closed when the magnet is NOT present, and that happens when the door is opened. Closing the door brings the magnet next to the switch, which opens the switch. So no current is flowing while the mailbox door is closed, which is almost all the time. Then after the mosfet turns on, it supplies power to the microcontroller which boots up. The first thing it does is assert that GPIO pin as a high output, which turns on the NPN, thus providing a second path to ground for the mosfet gate. So the controller latches the power on so it stays on after the door is closed. Then ultimately it shuts off its own power by bringing the GPIO low.In your case, the switch would be replaced by the /INT output of the RTC module. That's an open-drain output, which can only pull the pin low when it's active. So it will draw no current until it's time to power up. You might not need the NPN transistor at all if the module can keep /INT low until you tell it otherwise. Then when you're ready to power down, you send the appropriate command to the module over I2C.One potential problem is if the /INT pin has protection diodes that would come into play if the main battery voltage is high enough. There shouldn't be any on an open-drain output, but I haven't checked the datasheets.The ony remaining issue is whether the microcontoller can assert the GPIO high before the /INT turns off. If that's a problem, adding a capacitor should solve it.The whole idea here is that even when it is running, the RTC module uses far less current than the main circuit uses when sleeping. And if it's running on its own coin cell, no current would flow from the main battery when the main circuit is off. So instead of putting the microcontroller to sleep, which still leaves the regulator running and possibly other stuff, you just shut down the main battery power altogether, and let the RTC power everything up again at the right time.