Author Topic: Cheap, ultra low power RTC to periodically wake microcontroller from power-down?  (Read 9851 times)

0 Members and 1 Guest are viewing this topic.

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2402
  • Country: us
And as its final action, the microcontroller clears the timer flag.

How would you switch on the MOSFET after a power-on/reset though?

Or 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.

 

Offline I wanted a rude usernameTopic starter

  • Frequent Contributor
  • **
  • Posts: 669
  • Country: au
  • ... but this username is also acceptable.
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?
 

Offline GeorgeOfTheJungle

  • Super Contributor
  • ***
  • !
  • Posts: 2699
  • Country: tr
How would you switch on the MOSFET after a power-on/reset though?

You 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.

But doesn't that cause a constant 30-45 µA current draw through the pull-up?

Through Q2 to GND you mean?
« Last Edit: December 07, 2019, 01:17:26 am by GeorgeOfTheJungle »
The further a society drifts from truth, the more it will hate those who speak it.
 

Offline I wanted a rude usernameTopic starter

  • Frequent Contributor
  • **
  • Posts: 669
  • Country: au
  • ... but this username is also acceptable.
Through the normally-closed reed switch. Seems like the leakage would outweigh the power saving of this design.

You 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.

Could it be done without a switch, so that the microcontroller starts as soon as the device is powered?
 

Offline GeorgeOfTheJungle

  • Super Contributor
  • ***
  • !
  • Posts: 2699
  • Country: tr
Could it be done without a switch, so that the microcontroller starts as soon as the device is powered?

Yes, with a capacitor in parallel with Q2 C-E.
The further a society drifts from truth, the more it will hate those who speak it.
 

Offline I wanted a rude usernameTopic starter

  • Frequent Contributor
  • **
  • Posts: 669
  • Country: au
  • ... but this username is also acceptable.
I lack the fundamental electronics knowledge to understand how that would work.  :o

Fortunately in my applications the quiescent currents are so low that waking the microcontroller directly by interrupt is good enough.
 

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 7990
  • Country: ca
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.

I 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?

PCF8583 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 a Microchip MCP7940M one. 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.
 

Offline GeorgeOfTheJungle

  • Super Contributor
  • ***
  • !
  • Posts: 2699
  • Country: tr
I lack the fundamental electronics knowledge to understand how that would work.  :o

Fortunately in my applications the quiescent currents are so low that waking the microcontroller directly by interrupt is good enough.

It takes a few ms to charge C1 through R1 => the gate is below Vcc => the mosfet is ON:

885628-0
The further a society drifts from truth, the more it will hate those who speak it.
 
The following users thanked this post: I wanted a rude username

Offline I wanted a rude usernameTopic starter

  • Frequent Contributor
  • **
  • Posts: 669
  • Country: au
  • ... but this username is also acceptable.
Check out a Microchip MCP7940M one.

Oh. Oh wow. This would be funny to read if you didn't have to actually use it ...

Quote
If the RTCWKDAY register is written while the oscillator is stopped, it is possible that the value will read back as a different value when the oscillator is started.
 

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 7990
  • Country: ca
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.
 

Offline I wanted a rude usernameTopic starter

  • Frequent Contributor
  • **
  • Posts: 669
  • Country: au
  • ... but this username is also acceptable.
It takes a few ms to charge C1 through R1 => the gate is below Vcc => the mosfet is ON:

I did not understanding that the 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!
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2402
  • Country: us
Through the normally-closed reed switch. Seems like the leakage would outweigh the power saving of this design.

You 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.

Could it be done without a switch, so that the microcontroller starts as soon as the device is powered?

In 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.

« Last Edit: December 07, 2019, 03:31:30 pm by Peabody »
 
The following users thanked this post: I wanted a rude username


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf