• 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.

Electronik very long timer and memory circuit

qwertyqwq

Member
Hi folks.

Im thinking of a circuit which will incloude timer and memory. What i want to do is , i ll build a circuit which will count time when it energeized and will stop counting time when its turn off. Although energy gone ,memory will not forget the count. Like car’s km counters. But it will be electronic and it will has a small pcb area.
Is there any example of circuit like that. ?
And also i forgot to tell the counter will reset every year.

That is all idea may its stupid. But i really wondering how can i do and whixh components should i use.
THANKS.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
You use a micro-controller, and either EEPROM memory, or use the internal data EEPROM included in many micro-controllers (and particularly PIC's).

A fairly simple and easy project.
 

qwertyqwq

Member
You use a micro-controller, and either EEPROM memory, or use the internal data EEPROM included in many micro-controllers (and particularly PIC's).

A fairly simple and easy project.
Thanks.
Can you tell me with more details please. Arduino and Stm are reseting when their powers are gone. They are Eeprom also. Do you mean something different ?

How about without using microcontroller. Is there any possible method to save counts ?
 

dr pepper

Well-Known Member
Most Helpful Member
An arduino can do that, using the eeprom as it doesnt reset on power off, it has years of data retention without power.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
Thanks.
Can you tell me with more details please. Arduino and Stm are reseting when their powers are gone. They are Eeprom also. Do you mean something different ?
You can use an Arduino or STM to store readings in non-volatile memory (EEPROM or FLASH), but you have to specifically do so (and then read it back when the device restarts).

However, for a long term long battery life device, you really need a bare processor, and not a complete board (which includes devices that will waste power).

How about without using microcontroller. Is there any possible method to save counts ?
Why would you want to? - a microcontroller gives simple, cheap, small and easy - doing it otherwise means complicated, expensive, large and difficult.
 

atferrari

Well-Known Member
To minimize consumption use the smallest micro (well, the one which spends the minimum power) and serves your purpose.

If you program it, make sure that the writing of the EEPROM is not affected by an accidental turn off so you do not loose former data.
 

Pommie

Well-Known Member
Most Helpful Member
A 16F18313 is an 8 pin chip costing less than a dollar that will easily do what you want. It has 3.5k of program memory, 256 bytes ram and 256 bytes EEPROM.

Mike.
 

AnalogKid

Well-Known Member
Most Helpful Member
What is the maximum amount of time your circuit might accumulate in one year?

ak
 

Pommie

Well-Known Member
Most Helpful Member
If you use a 50ppm crystal the maximum error over a year will be about 25 minutes.

Mike.
 

mpgMike

New Member
So you need to be able to track "hours of ON time", correct? What about partial hours? If the device is on for 1 hour, 23 minutes, 41.3288 seconds, how accurate must your tracking be?

The reason I ask is when using the PIC processor, you will need a Timer configured for the time resolution to increment your base counter every time the Timer runs its course. If you only need 1 second resolution, then setting Timer2 for 1 second interrupts allows you to increment a Seconds variable. Every 60 seconds increment a Minutes variable. Every 60 minutes increment your Hours variable, and so on. If you can detect power-down, yet still have a few milliseconds of residual power (like a hefty capacitor on the board), that gives the PIC time to commit the new time values to the EEPROM.

Next question; you stated you need to access the total hours once per year. Does the device automatically report via bluetooth or something? Or do you physically read the value and press a reset button? How would your device know it's January 1 (or your chosen reporting date)?
 

Nigel Goodwin

Super Moderator
Most Helpful Member
All those are commonplace and very easily solved, first off use a 32KHz xtal on TMR2, this will run during sleep and wake the processor every second to allow it to update the RTC - this interrupt routine simply keeps a couny of hours, minutes, seconds, days, months and years as you wish. There are a number of such application notes at MicroChip, and loads more online. The device 'knows' it's January the first simply because it maintains a full clock and calendar count.

An alternative would be to use one of the numerous I2C battery backed clock chip/modules, which can be set to output a 1 second pulse, and again use that to wake the PIC from sleep.

More of a concern is probably setting the clock in the first place, you could either add a few buttons and do it with those, but as it's a 'very occasional' setting a little keypad and another PIC that you plug in to set it is perhaps the easiest? (it's a lot easier to type in 12:04 28/02/2019 than hundreds of button presses to do the same thing). Or a laptop and an FDTI USB/Serial interface chip/lead.
 

Kart31

New Member
How will you know when it turns off? When the power is removed, it will power down and not record anything. To overcome the last. Use a large capacitor and connect one input pin from incoming power to the chip. When the incoming power goes low, store the clock reading (I suggest and RTC). The reading will be stored using the power from the large capacitor. When the capacitor runs out, you don't care as you were able to collect the reading. The capacitor only needs to be large enough to run the circuit for 1/10 second.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
How will you know when it turns off? When the power is removed, it will power down and not record anything. To overcome the last. Use a large capacitor and connect one input pin from incoming power to the chip. When the incoming power goes low, store the clock reading (I suggest and RTC). The reading will be stored using the power from the large capacitor. When the capacitor runs out, you don't care as you were able to collect the reading. The capacitor only needs to be large enough to run the circuit for 1/10 second.
A lot depends on the exact application, but obviously a capacitor used in that way is one easy way to save things when power fails. Likewise, a battery backed RTC (it could even be the PIC, removing the need for the large capacitor used to save as the power goes off) is essential, but again it depends entirely on the application - it would be VERY easy to get well in excess of a years battery life using just a PIC to do the RTC, depending what else (if anything) the battery is doing.
 

Kart31

New Member
A lot depends on the exact application, but obviously a capacitor used in that way is one easy way to save things when power fails. Likewise, a battery backed RTC (it could even be the PIC, removing the need for the large capacitor used to save as the power goes off) is essential, but again it depends entirely on the application - it would be VERY easy to get well in excess of a years battery life using just a PIC to do the RTC, depending what else (if anything) the battery is doing.
The capacitor is not suggested for the same purpose as a battery backed RTC. The capacitor is to provide enough power for the microprocessor to detect the power has been lost and to note the time before there is no power for the microprocessor to run on..

Granted the OP said " stop counting when the power is lost". Of course it will stop counting when the power is lost. If we want to record the amount time energized, that requires knowing the start and stop time. The catch becomes how do you record the stop time when the power is lost if the power is lost when you need to record the stop time. The capacitor is there (battery, or whatever you would like to use) to provide just enough power for the microprocessor to know it is about to lose power and to record the time.

Of course the best thing to do would to record the time when you are going to lose power. Then you don't need any of this nonsense. If someone invents that, I would like to modify it to tell me the next lottery numbers.
 

Latest threads

EE World Online Articles

Loading

 
Top