PDA

View Full Version : And last but not least: static ram?



bearpawz
- 30th October 2004, 23:41
Hi all,

My little odometer is comming along very well. Now I only have one last problem I need some ideas on...

Since this is an odometer, it has to some how retain the current reading when the device is powered off. I tried writing to eprom for every 10th mile change, however thats writing to the eeprom quite a bit and actually ends up messing up the display. So I figure its better to just write to eeprom say, when the key is turned off. But Turning the key off also cuts the power to the whole unit...

I know its a little off topic, but again... just reaching for some Ideas.

mister_e
- 31st October 2004, 09:20
well, the only suggestion that spring to my mind is to use 2 voltage source. 12V constant from battery for the PIC, switched 12V for the rest of your unit. You can also use the switch 12V to turn your PIC into SLEEP mode.... in this case it will get few uA from the car battery + few mA for voltage regulator... 78L05 in TO92 need less minimum current than 7805 in TO220 package.

Usually car cluster work almost like this. There's alway one constant 12Volt going into.

That way, you will be able to do what you want. Will be easier to save data to EEPROM then switch off external stuff(LCD,BacKlite...etc), then turn to SLEEP mode.

Melanie
- 31st October 2004, 10:26
This is quite simple... consider the appended circuit...

Normal power for the PIC is supplied via D1 to the PIC's +5v Power Supply, eg 78L05 or whatever you have. R1/R2 is a potential divider to give you no more than 5v cut down from the maximum vehicle supply. You can have say a 4.7v Zener if you feel uneasy in lieu of R2 to make sure the PIC never gets anything over 5v on it's Power-Fail detect pin.

When the +12v Supply is switched off, the pic detects this via R1/R2, however charged Capacitor C1 keeps it running for another 500mS (or whatever's needed), which is enough time to save the appropriate Data to EEPROM and go into a endless loop waiting for the eventual total Power Loss. Value of C1 will be dependant on your PIC's current draw and how long you need to keep the PIC running after Power-Off.

Melanie

bearpawz
- 31st October 2004, 15:38
Both Excelt suggestions: I think I'll have to give Melanie's a shot though because Not only do I have to account for power just being switched off normally, but I also have to account for some sadistic mechanic disconnecting the battery at inoppertune times.

I'll let you know how it works out.

mister_e
- 1st November 2004, 04:37
>but I also have to account for some sadistic mechanic disconnecting the battery at inoppertune times.

in this case of mecanic.... usually engine is previously turn off. Case not, alternator gives you the voltage again. ;)