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.

battery backup for PIC

Status
Not open for further replies.

AndyWatson

New Member
I'm building a datalogger circuit that someone else designed, using a PIC16C773 and a serial EEPROM. I've never done any PIC programming and I don't have time to change the code, so I'm just going to use it as it is for now. They've even written a nice VisualBasic GUI to program and download the logger.

The way it works is that you connect the logger to a PC, initialize it and start the logger. Then you can disconnect the logger from the PC and deploy it, and it'll run until you retrieve it, or till it's full (256k) or till the batteries run out. I've been told by one of the designers that once the PIC chip has been programmed and deployed, if the PIC loses battery voltage for even a few seconds (ie. when changing the logger batteries) then it stops logging and it must be connected to a PC and reinitialized. That's kind of difficult since these loggers will be deployed in far off, hard to get to areas.

So I'd like to install some kind of a battery backup in the circuit, so the PIC will have continuous voltage during battery swaps. What's the easiest way to do that? I've seen stuff like this:
https://www.allelectronics.com/cgi-bin/category.cgi?category=search&item=CBC-14&type=store
Would that work, or would a couple coin-cell lithium batteries work?

By the way, the schematic for the logger is shown below. It's powered by 4 AA batteries (for 6v), but then they've got a 1n4001 diode that connects the batteries to the PIC. I'm guessing that's to drop the voltage down about 0.5V to meet the input voltage specs of the PIC, right? Will that interfere with any battery backup ideas? Thanks for any ideas.
 

Attachments

  • logger12bit-b.jpg
    logger12bit-b.jpg
    89.4 KB · Views: 1,434
I've been told by one of the designers that once the PIC chip has been programmed and deployed, if the PIC loses battery voltage for even a few seconds (ie. when changing the logger batteries) then it stops logging and it must be connected to a PC and reinitialized.
not true...the pic should reset itself .. there is a POR (power on reset)
which restarts the code ..
yes if it is critical that you dont miss any data then a couple Li ion batteries should be fine...as long as the voltage adds up to 5V
and yes that is probably why the diode is there
 
Yep, your designer told you wrong.

The PIC's program will need to be smart enough to keep track of the pointer, otherwise if it loses power if will start logging from the beginning and overwrite the data recorded up to that point. Unless of course you want it to do that. This is not hard, most PICs have some EEPROM on board you can use to store this data. You've also got your external EEPROM. Be careful to check for low voltage before writing the EEPROM, the voltage requirements to correctly write the EEPROM can be a bit higher than what keeps the PIC running code. The Brown Out Detect may be enough to do it. Actually, simply resetting on a dead battery seems kind of dumb to me, since it'll endlessly reset and keep drawing power which can damage a rechargeable battery with a deep discharge. Detecting the low voltage and going to deep Sleep mode makes more sense.

As such, you'll now need a way to initialize the pointer, just turning it on won't do it anymore. Maybe docking can do it, maybe holding down a pointer reset button for 5 sec. Whatever floats your boat.
 
hmmm...

Here's what the designer said: " If you change the batteries, the logger will quit as soon as you disconnect the battery. It will not restart unless it gets a start voltage from a reader through the re-initialization procedure. If it restarts, it starts from the beginning. "

**broken link removed**

Another thing that bothers me about this design is that apparently there is no SLEEP mode, so the PIC is on all the time. I'm told that it'll drain 4 AA batteries in a month. Is there an easy way to add a sleep command to the code without screwing anything else up?

My boss wants me to have this circuit built and ready to deploy in 2 weeks, so I don't have time to experiment with a new design, and I've already ordered the parts to build a couple of these, so I'll just have to build it like this for now. Is there a better datalogger design somewhere that I could use for my next version?
 
warning .. warning .. will robinson.. lol
1) this part( the16C773) is not reprogrammable!!!
 
2) the code is written for a 10 bit A/D it is written for the 16F73 which is no longer in production..
which part did you actually order..?
3) as i said in my second post if at all possible order a reprogrammable part ...!!!!
 
No, it's too late. I already bought a couple of the 16C773 chips. Would I have to change the code much to work with a reprogrammable part?
 
AndyWatson said:
No, it's too late. I already bought a couple of the 16C773 chips. Would I have to change the code much to work with a reprogrammable part?
* shakes head* ..what are ya gonna do when u have used the two you allready ordered..
they send out free parts.. so order some 16F874's or 877's quickly....
 
AndyWatson said:
So, back to my original question: what's the best way to hook up a backup battery to the PIC?
I'm interested in this as well. I think I've seen this answered before, but I'm too lazy to look now.

I'd like to add it to a desktop display project I have, so I can walk around with it and read the display when I want, and I can plug it in when it's on the desk and save batteries.
 
samcheetah said:
AndyWatson said:
No, it's too late. I already bought a couple of the 16C773 chips. Would I have to change the code much to work with a reprogrammable part?

no, provided that you use a 16F773. the F just adds the reprogramability. as far as the functionality is concerned the OTP and the Flash chips are the same.

There is no 16F773 :roll: ...

It's also a misconception that a C and a F part with the same number are exactly the same except for the memory type. There are numerous C and F parts with the same number wich are nothing alike.
 
AndyWatson said:
Here's what the designer said: " If you change the batteries, the logger will quit as soon as you disconnect the battery. It will not restart unless it gets a start voltage from a reader through the re-initialization procedure. If it restarts, it starts from the beginning. "
The pic will start running it's program again as soon as you replace the batteries. however, the program expects input before it starts logging, so it will indeed just sit there and do nothing - that's what the designer programmed it to do.

AndyWatson said:
Another thing that bothers me about this design is that apparently there is no SLEEP mode, so the PIC is on all the time. I'm told that it'll drain 4 AA batteries in a month. Is there an easy way to add a sleep command to the code without screwing anything else up?
Indeed, even though the circuit doesn't need much current it might deplete the batteries in a months time. Using rechargable NIMH batteries will help a lot - how long should it be able to log between battery replacements?

There are several ways to add sleep code, but any code changes would require serious testing before beeing deployed in the field. (I'm assuming the current code was tested and is stable?). Since you don't have time and neigther reprogrammable parts testing may be impossible?

In your original post you asked for a backup during battery replacement, this can be easely done
look at this thread: https://www.electro-tech-online.com/threads/high-side-pmos-reref-prob.11908/
 
Last edited by a moderator:
Thanks for the link, exo. I saw that one earlier. I'm wondering how I can adapt it to this circuit. Since there's already a diode drop from the 6v main batteries, I guess I'd need a 5.5v backup battery. How about using a couple of 3 volt lithium batteries in series, with two diode drops, which would put them half a volt below the main battery?
 
Yes, that would work.
You've got some room to play with, both the pic16c733 and the 24LC256 (assuming you really use a 24LC256) can go as low as 2.5V.
So, if you make your backup 4.5V, for example, it'll still work well.
 
williB said:
2) the code is written for a 10 bit A/D it is written for the 16F73 which is no longer in production..
which part did you actually order..?
3) as i said in my second post if at all possible order a reprogrammable part ...!!!!

It is written for the 16c773 - it it based on code for the 16c73.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top