Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Clock that runs on batteries.

Status
Not open for further replies.

alphacat

New Member
Hey,

In our product, there is a MCU which keeps the clock running, once you set the clock to a valid time.
The product is mains-operated.

The thing is that every time the product is turned off, the MCU gets no power and therefore the clock needs to be reset once the product connects to the mains again.

We would like to install a battery in the product that its only purpose is to keep the clock running, even when the product is disconnected from the mains.

How is it commonly done?

when using a battery, is it common that the MCU is still in charge of the time ticking (meaning that the battery will need to power the MCU)?

Or is it common that in such case of using a battery, to use another device (timer) that will be in charge of the time ticking? (of course that such timer will need to be able to report to the MCU on the time).

Thanks fellas.
 
Last edited:
I don't know how it is usually done, but I recently designed a circuit that switches to battery backup. It involves using a DPDT relay to select the output source, with the coil attached to the mains source. You connect the ground of the battery and mains to one switch, and the +ve of the battery and mains to the other switch. When no mains is connected, the battery is selected as the switches sit in their default position. When the mains is plugged in, current flows through the coil and switches the contacts to their secondary position, selecting the mains. I used a 1mF electrolytic capacitor to smooth the output over the switching period (since technically both +ve and GND become NC during the switch over) and used a low value resistor (I think it was 22 ohms) in series with the cap to limit the current flow when the battery is in operation. It did the job, but it's probably not the most elegant solution.
 
The easiest way is to use something like this. If you look at the data sheet it has the schematic.

Mike.
 
You just need 2 schottky diodes, you place one directly between the +5v rail and micro power pin and another diode between a 3-cell 4.5v battery and the micro power pin.

It's an easy enough mod you can do it by cutting one PCB track and soldering the diodes on the bottom.
 
@OP - sorry to hijack your thread a bit but...

Mr RB - Intrigued as to how the schottky diode thing works, as I'm interested in designing something similar. Could you elaborate on the theory of the application?
 
The problem with the diodes is that the display is also powered and if it's an LED display you will be replacing the batteries daily. Even if it's an LCD display, mains powered stuff is normally quite wasteful of power and will still flatten your batteries in a week or two. However, if your device is powered down very infrequently then it may work fine.

Mike.
 
Thank you very much comrades. :)
I'll digest all this info and will probably come back later with some questions. ;)
 
Since you cut the track that supplies the micro +5v and add the diode there the battery only powers the micro, not the LED displays or any other stuff. If possible you find a spot where the track just goes to the micro power pin but try to leave the 0.1uF cap still on the micro side (or just add another cap directly to the micro power pin->ground.

I've done it a few times over the years and even re-engineered some VCR's etc for clock backup when the original battery type or supercap was no longer available when i was a TV repairer.

With LED displays in alarm clocks and the like the micro will never power the display directly, they are matrixed with transistors and even the old 7seg alarm clock displays generally used one common anode and 32 micro-driven cathodes (for all 4 digits and colons). It's possible you might get a device where the micro pins source display current but I don't remember ever seeing one or trying to stick a battery on it. :)

Burningmenace- its a very old system, you just use 2 diodes to connect the 2 supplies to one load. The higher voltage (generally +5v) will run the load, and if that fails the lower voltage (like a 4.5v battery) will then take over. It works good enough so you don't have to reprogram a clock etc everytime someone trips over the power cord.
 
Hey,

I began reading about it, and am currently reading about the timer (DS1307 real time clock) that Pommie gave a link to.

I wanted to ask you guys,
What is the common way of doing it -
Using an external timer that is able to run on a battery,
or is there a different way?
 
Last edited:
If it's a new device, go the 1307 route. Old device, follow RB's advice and just make it work.

Mike.
 
You can also use the RTC (Real Time Clock) inside a PIC. Many PICs can have a 32.768 kHz watch crystal and can run at very low currents when running slowly. If you make sure that everything else is shut down, you can power the PIC from a backup battery for ages.

As a completely different approach, fit a GPS receiver for about $20 and you don't even need to set the time.
 
Do you want the LED's to run on the battery power or for it to just keep time. If you just want it to keep time the longest possible, use an input to check the voltage input from the mains. When the uC detects it is not running on mains power anymore, and has switched to batteries, go into sleep mode, but maintain the clock crystal timer.
 
Thats a very nice idea.
How is it done - switching the power source of the MCU, from mains to battery?

I already have a device which senses the mains voltage, how is the next stage performed?

Thanks comrades.
 
Using the diode method for switching from the higher voltage mains DC source to the batteries, you can detect when the hard connection has been disconnected because there will be a drop in power on your power source to the battery voltage.

I don't know what microcontroller you are using, but generally a uC can run on sleep mode just maintaining an xtal clock for a very long time. Some could do it for years on a couple AA's.

DS1307 is a 5V part only. Keep that in mind if you are running a 3.3V uC.
 
Last edited:
Thank you very much johnnies!

You just need 2 schottky diodes, you place one directly between the +5v rail and micro power pin and another diode between a 3-cell 4.5v battery and the micro power pin.

It's an easy enough mod you can do it by cutting one PCB track and soldering the diodes on the bottom.

About Mr RB's plan, I should have another part in the system that will let the MCU know when it is driven by batteries, so the MCU could get into sleep mode, with only its clock running, right?

One more thing please.
If the power supply wire that connects to the Power pins of the MCU, connects to other devices, then its not good right?
I mean, i'll have to re-trace the wires, isnt it?
 
Last edited:
If you have the ability to modify the code then you have many more options. Post details of the processor used and how you are currently keeping time and people will be able to help more.

Mike.
 
Thanks.
I'm using a CC2430 micro-controller.
Currently the MCU is powered only when the product is connected to the mains.
The time-ticking is being operated by a RTC timer.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top