How to count the number of pulses by switching supply voltage itself?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to count the number of pulses by switching supply voltage itself?

3,544件の閲覧回数
embeddedsystem
Contributor I
:smileysurprised: Hello!
 
I want to count the number of pulses by using counter in a fix reference period. The pulses are generated by switching ON-OFF the supply itself. So, how to keep the initialisation constant for reference period of Timer to count pulses in the same period with supply switching. Is it possible to store the pulse count in memory before switching off supply and again call back after turning on the supply ? if yes how to store the number of pulses? 
 
Thanks & Regards.
ラベル(1)
0 件の賞賛
返信
3 返答(返信)

920件の閲覧回数
peg
Senior Contributor IV

Well, I think you need to rewrite your question because I interpreted it differently again. I thought you want to count the number of times power was removed.

If this is the case, just count the number of times it is powered up, powered down is one less than this! You would still need early warning of supply failure though. But you always need this anytime you write to FLASH.

Another possibility if my interpretation is wrong and you want to count something else is to use batteries or supercap to keep RAM alive when power is removed and keep count there. You can always count while the power is "off" using this method too. You can write it to flash when power is back up.

Regards David

 

0 件の賞賛
返信

920件の閲覧回数
bigmac
Specialist III

Hello,

My understanding of your requirement is that you want to count pulses while the power is on, and store the current count value just prior to power being removed, and then recall this value when power is re-applied.  Am I correct?

If so, power would need to be maintained for a period sufficient to program the value to flash memory.  This would be relatively simple to do if the removal of power is controlled by the equipment, so the actual removal of power can be sufficiently delayed.

However, if the removal of power is external to the equipment, the situation would be more complex.  You would need "early warning" of the removal, prior to drop-out of the regulator supplying the MCU.  The capacitors associated with the regulator would then need to supply the MCU for a period, perhaps a few milliseconds - the LV reset circuit of the MCU must not operate until after the data has been programmed to flash.  The early warning voltage detection circuit would need to be isolated from the input capacitor of the regulator, perhaps by means of a series diode.

Another issue that your may need to consider is the limited number of erase cycles allowed for the flash memory.  Assuming only a few bytes of data need to be saved, there are techniques available for cycling the data throughout a flash page, so that many power cycles could occur before a page erase was required.

Regards,
Mac

 

0 件の賞賛
返信

920件の閲覧回数
alex_spotw
Contributor III
Hi:

Well...I don't think it is possible to program the MCU to do something when the power supply itself is off....

What you need is an independent circuit that powers the MCU, and another circuit that powers the output (or load). This way you can count pulses while the Main power supply is off (or on).

Regards,

Alex
0 件の賞賛
返信