Author Topic: +3V3 to CR2032 battery switchover?  (Read 6650 times)

0 Members and 1 Guest are viewing this topic.

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
+3V3 to CR2032 battery switchover?
« on: April 06, 2016, 07:43:06 pm »
While designing a rather simple but versatile Test Equipment User Interface (to control the stuff I'm currently working on) I settled for a PIC18F46J11 because of the price, feature set and availability from the supplier I get my parts from...

...and it has a hardware RTCC module which I would like to use. All fine and dandy until power is removed - RTCC loses time.

Obviously a workaround is to use a small CR2032 battery and switch the micro's Vdd from the +3.3V to the 3V battery and turn the core and peripherals off (some sleep mode). This is quite simple if you only have the micro on the +3.3V rail but it's not the case because there are other things supplied like an I/O expander, LCD, etc. so I need to make sure there's no 'ghost power' through diodes going to them. Vdd must be at +3.3V when not running on the RTCC backup battery which means using diodes to switch is not an option on the +3.3V rail.

Any ideas?
Trust me, I'm NOT an engineer.
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 16363
  • Country: za
Re: +3V3 to CR2032 battery switchover?
« Reply #1 on: April 06, 2016, 07:52:22 pm »
How about a gander here?

https://www.maximintegrated.com/en/products/power/supervisors-voltage-monitors-sequencers/battery-backup-ics.html

There are a few to choose from, and if you already have to have a voltage regulator to drive the MCU, and can live with 100mA of power to do it, then this will work.

http://datasheets.maximintegrated.com/en/ds/MAX16023-MAX16024.pdf

 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: +3V3 to CR2032 battery switchover?
« Reply #2 on: April 06, 2016, 08:19:55 pm »
Haven't decided on the voltage regulator yet, but it's going to be fed from 12V-ish for any fans that might be required.

Looking at those Maxim parts gave me an idea...

1. Use a 3.3V regulator (most likely switchmode) for the LCD and other stuff connected to the micro.
2. Use a 3.3V linear regulator with a diode on the input and (if needed) a reverse diode across IN-OUT.
3. Use a comparator and some small MOSFETs to do the switchover with the comparator powered from the battery*
4. This idea might be stupid.

*the comparator should draw a low enough current that the battery (around 200mAh) lasts a few years
« Last Edit: April 06, 2016, 08:25:26 pm by void_error »
Trust me, I'm NOT an engineer.
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5140
  • Country: ro
  • .
Re: +3V3 to CR2032 battery switchover?
« Reply #3 on: April 06, 2016, 08:51:01 pm »
If you're going to turn on your product at least once every few days, you could just slap inside a supercapacitor and be done with it.  The PIC's datasheet says the rtc will work with as low as 2.15v and needs only about 4-8 uA to run .. even with 10uA draw, a 0.5-1F supercap should charge superfast when your device is plugged in and keep the timer for a few days.
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: +3V3 to CR2032 battery switchover?
« Reply #4 on: April 06, 2016, 09:22:39 pm »
It might be weeks until it's powered on again.

More googling eventually took me here.
I'll simulate the circuit tomorrow using LTspice to see how it behaves.
Trust me, I'm NOT an engineer.
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: +3V3 to CR2032 battery switchover?
« Reply #5 on: April 07, 2016, 09:13:09 am »
The circuit doesn't work too well for my needs. There's a significant voltage drop during main 3.3V power rail rise and fall times because the MOSFETs operate in the linear region. Increasing the capacitor size doesn't make things better either.
Time to ditch the idea of a micro with hardware RTCC and use an external RTCC chip which has built-in battery switchover in case I want one.
Trust me, I'm NOT an engineer.
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4193
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: +3V3 to CR2032 battery switchover?
« Reply #6 on: April 07, 2016, 09:54:48 am »
Add one diode and a voltage monitor. Put the battery over 3v3 after the diode. That will be the mcu supply. Nothing else. You can safely run a 3v lithium battery like this.
As soon as the voltage monitor trips, run an high prio interrupt, put all IO into high-impedance, disable any clocks and peripherals. But this might still droop the battery voltage too much during the transition. you can only draw a few mA. It cannot take the full MCU with 10's of mA, not even for a while. You might need an additional stage with a capacitor bank to bridge a few milliseconds.

But you'd save yourself a lot of potential nightmares if you'd get a chip with internal power switch for the RTC, or an external RTC.
 

Offline Fungus

  • Super Contributor
  • ***
  • Posts: 17203
  • Country: 00
Re: +3V3 to CR2032 battery switchover?
« Reply #7 on: April 07, 2016, 10:58:34 am »
But you'd save yourself a lot of potential nightmares if you'd get a chip with internal power switch for the RTC, or an external RTC.

Yep. An external RTC is less than $1.

http://www.ebay.com/sch/i.html?_nkw=arduino+rtc

 

Offline Lunasix

  • Regular Contributor
  • *
  • Posts: 142
  • Country: fr
Re: +3V3 to CR2032 battery switchover?
« Reply #8 on: April 07, 2016, 11:22:04 am »
Power supply switching is often more complicated than an external RTC with I2C interface... That's why I never used the PIC32 internal RTC, and the problem is not reserved for Microchip.
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: +3V3 to CR2032 battery switchover?
« Reply #9 on: April 07, 2016, 11:24:30 am »
But you'd save yourself a lot of potential nightmares if you'd get a chip with internal power switch for the RTC, or an external RTC.

Yep. An external RTC is less than $1.

http://www.ebay.com/sch/i.html?_nkw=arduino+rtc
As I was saying earlier... screw the hardware RTCC, it seems to be useful only on portable stuff with a big (compared to a CR2032) battery. I was just exploring the usefulness of it for mains-powered stuff.

Currently getting randomly stuck in PIC16F18875's datasheet... :scared: holy cow, this new micro has a lot of features, so many in fact that it makes the previous generation 16F1xxx series look like ancient technology (yes, I know, most of the stuff it has it borrowed from its bigger 16-bit brothers).
Trust me, I'm NOT an engineer.
 

Offline Rutger

  • Regular Contributor
  • *
  • Posts: 210
  • Country: us
Re: +3V3 to CR2032 battery switchover?
« Reply #10 on: April 07, 2016, 01:30:12 pm »
I would look at the circuit for the Arduino Uno and see how they switch between USB power and external DC power, they use a fet and opamps.
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7938
  • Country: nl
  • Current job: ATEX product design
Re: +3V3 to CR2032 battery switchover?
« Reply #11 on: April 07, 2016, 01:46:20 pm »
Toss the PIC into the trashcan where it belongs, and use a modern micro, which has dedicated "battery pin" for the backup battery.
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: +3V3 to CR2032 battery switchover?
« Reply #12 on: April 07, 2016, 03:35:42 pm »
Toss the PIC into the trashcan where it belongs, and use a modern micro, which has dedicated "battery pin" for the backup battery.
Like what?

I would look at the circuit for the Arduino Uno and see how they switch between USB power and external DC power, they use a fet and opamps.
A bit late on the post as I already said I'm not going to use the hardware RTCC but an external one instead which has a backup battery pin as some of the people above suggested. I2C bus because even slow is fast enough for a RTCC and only 2 wires.
The Arduino power switching wouldn't help much because you can draw several mA from the external DC power or USB compared to the CR2032 battery which can only supply microamps if you don't want to replace it every few months.
« Last Edit: April 07, 2016, 03:44:24 pm by void_error »
Trust me, I'm NOT an engineer.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8789
  • Country: fi
Re: +3V3 to CR2032 battery switchover?
« Reply #13 on: April 07, 2016, 03:41:51 pm »
Toss the PIC into the trashcan where it belongs, and use a modern micro, which has dedicated "battery pin" for the backup battery.
Like what?

STM32 series, for example. Best thing about modern 32-bit controllers is that you get so much more for less money. On the minus side, you need to learn a new architecture, and the learning curve can be a bit steep first. But I feel that the 8-bit PIC/AVR time is going to be finally over quite soon, given that they have not evolved much and prices are high, except for a few popular chips.
 

Offline Rick60

  • Contributor
  • Posts: 18
  • Country: gb
Re: +3V3 to CR2032 battery switchover?
« Reply #14 on: April 07, 2016, 04:14:37 pm »
The PIC24FJ128GC010 FAMILY have a dedicate vbat pin
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: +3V3 to CR2032 battery switchover?
« Reply #15 on: April 07, 2016, 04:31:49 pm »
STM32 series, for example. Best thing about modern 32-bit controllers is that you get so much more for less money. On the minus side, you need to learn a new architecture, and the learning curve can be a bit steep first. But I feel that the 8-bit PIC/AVR time is going to be finally over quite soon, given that they have not evolved much and prices are high, except for a few popular chips.
I did notice that the STM32 series is dirt cheap. However, I don't find any reason to take my time and learn an architecture all over again. Yes, they're cheap and powerful but so far I haven't felt the need for anything faster than an 8-bit or 16-bit PIC for any of my personal projects such as this one.
Let's not turn this thread into microcontroller wars, ok?

The PIC24FJ128GC010 FAMILY have a dedicate vbat pin
... and more pins than you can poke a stick at. Overkill.

I'm trying to keep everything as simple as possible (not bite off more than I can chew or I'm going nowhere).
Trust me, I'm NOT an engineer.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8789
  • Country: fi
Re: +3V3 to CR2032 battery switchover?
« Reply #16 on: April 07, 2016, 06:21:55 pm »
I did notice that the STM32 series is dirt cheap. However, I don't find any reason to take my time and learn an architecture all over again. Yes, they're cheap and powerful but so far I haven't felt the need for anything faster than an 8-bit or 16-bit PIC for any of my personal projects such as this one.
Let's not turn this thread into microcontroller wars, ok?

Well, how about not specifically asking if you don't want to hear answers to your question, then!?

I have absolutely zero interest in any kind of "microcontroller wars". Your mileage may vary.
« Last Edit: April 07, 2016, 06:24:56 pm by Siwastaja »
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: +3V3 to CR2032 battery switchover?
« Reply #17 on: April 07, 2016, 07:09:06 pm »
If people could just stick to the topic...
Oh, and read more than just the last post in the thread...
 |O
« Last Edit: April 07, 2016, 07:10:52 pm by void_error »
Trust me, I'm NOT an engineer.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf