+3V3 to CR2032 battery switchover? - Page 1
Forum section: electronics / projects

author: void_error
author_rank: Frequent Contributor
timestamp: April 06, 2016, 07:43:06 pm
content: 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?

author: SeanB
author_rank: Super Contributor
timestamp: April 06, 2016, 07:52:22 pm
content: How about a gander here?https://www.maximintegrated.com/en/products/power/supervisors-voltage-monitors-sequencers/battery-backup-ics.htmlThere 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

author: void_error
author_rank: Frequent Contributor
timestamp: April 06, 2016, 08:19:55 pm
content: 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

author: mariush
author_rank: Super Contributor
timestamp: April 06, 2016, 08:51:01 pm
content: 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.

author: void_error
author_rank: Frequent Contributor
timestamp: April 06, 2016, 09:22:39 pm
content: It might be weeks until it's powered on again.More googling eventually took mehere.I'll simulate the circuit tomorrow using LTspice to see how it behaves.

author: void_error
author_rank: Frequent Contributor
timestamp: April 07, 2016, 09:13:09 am
content: 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.

author: Jeroen3
author_rank: Super Contributor
timestamp: April 07, 2016, 09:54:48 am
content: 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.

author: Fungus
author_rank: Super Contributor
timestamp: April 07, 2016, 10:58:34 am
content: Quote from: Jeroen3 on April 07, 2016, 09:54:48 amYep. An external RTC is less than $1.http://www.ebay.com/sch/i.html?_nkw=arduino+rtc

author: Lunasix
author_rank: Regular Contributor
timestamp: April 07, 2016, 11:22:04 am
content: 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.

author: void_error
author_rank: Frequent Contributor
timestamp: April 07, 2016, 11:24:30 am
content: Quote from: Fungus on April 07, 2016, 10:58:34 amAs 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 inPIC16F18875's datasheet...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).

author: Rutger
author_rank: Regular Contributor
timestamp: April 07, 2016, 01:30:12 pm
content: 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.

author: tszaboo
author_rank: Super Contributor
timestamp: April 07, 2016, 01:46:20 pm
content: Toss the PIC into the trashcan where it belongs, and use a modern micro, which has dedicated "battery pin" for the backup battery.

author: void_error
author_rank: Frequent Contributor
timestamp: April 07, 2016, 03:35:42 pm
content: Quote from: NANDBlog on April 07, 2016, 01:46:20 pmLike what?Quote from: Rutger on April 07, 2016, 01:30:12 pmA 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.

author: Siwastaja
author_rank: Super Contributor
timestamp: April 07, 2016, 03:41:51 pm
content: Quote from: void_error on April 07, 2016, 03:35:42 pmSTM32 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.

author: Rick60
author_rank: Contributor
timestamp: April 07, 2016, 04:14:37 pm
content: The PIC24FJ128GC010 FAMILY have a dedicate vbat pin

author: void_error
author_rank: Frequent Contributor
timestamp: April 07, 2016, 04:31:49 pm
content: Quote from: Siwastaja on April 07, 2016, 03:41:51 pmI 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?Quote from: Rick60 on April 07, 2016, 04:14:37 pm... 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).

author: Siwastaja
author_rank: Super Contributor
timestamp: April 07, 2016, 06:21:55 pm
content: Quote from: void_error on April 07, 2016, 04:31:49 pmWell, how about notspecificallyasking 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.

author: void_error
author_rank: Frequent Contributor
timestamp: April 07, 2016, 07:09:06 pm
content: If people could just stick to the topic...Oh, and read more than just the last post in the thread...