i have a project which runs on a battery which is in turn connected to a powersupply...
the problem is i want the arduino to know when there is a powercut and when the power is back on...
so i was thinking
____________________________________________(to arduino interrupt)
| |
Power source -------------- |>|---------------- |=====| ------------- Arduino
(diode) (battery)
i was thinking when the power is not there the battery voltage does not flow back because of the reverse bias so the interrupt pin would go low so the arduino could detect a powercut...
what diode should i be using here? battery will be 12 volts...
The Arduino has a built in power switch.
If the i/p is > 6.2 volts USB power is turned off and the Arduino is powered by the i/p 12V (in this case).
If you were to connect a 4.8V P.S. (3 X 1.6 = 4.8V Alkaline D cells) to the USB power pins, no power would be drawn normally.
When the power fails the switch would turn on and the Arduino would be powered by the batteries (while power is off).
Then use cjdelphi idea of the voltage divider to detect the power loss.
while i was trying to implement it, i realized it was just one value which i had to store incase of powercut, so i thought i will store it into eeprom
but i read eeprom had only 100,000 life cycles...
so i want to know how do i switch between multiple locations so that lifecycle is not completed, and remember which memory location even when power goes out???
i mean to say, i write into 1st location and then when power comes back on i read it from 1st location.... but in case somehow in my code i implement it to write into second location how do i get arduino to check in the second location for the data..??
i suppose one way would be to use start off by wiping them all to #0 / null chars (all the eeprom memory) and then start at byte 0, and have a marker eg x,[inservalue] and then simply scan the eeprom for the 'x,' part and pull out your data next time there's a power out, it wipes them 3 chars out and you shift right 1 byte start again...
well the data has to be retained after the powercut, but the data is written everytime a sensor is triggered, so at max 50 times a day... that gives me about 6 years!!
i know that is a lot but just want it to run without glitches
the unwritten eeprom contains FF, that is interesting... will give it a try
but how do i write to a next cell??? how will the arduino get to know that it has written enough in this location and it is time to switch on to the next memory location ??
alnath im from india, so most probably thrice or 4 times a day a powercut
kiriti:
the unwritten eeprom contains FF, that is interesting... will give it a try
but how do i write to a next cell??? how will the arduino get to know that it has written enough in this location and it is time to switch on to the next memory location ??
kiriti:
what diode should i be using here? battery will be 12 volts...
That depends on the battery and charger. The forward current rating of the diode should be the max. charging current and some extra. A car battery used with a 15A charger should have a diode capable of handling 20A.
well the data has to be retained after the powercut, but the data is written everytime a sensor is triggered, so at max 50 times a day... that gives me about 6 years!!
Why save it to EPROM at every reading, only store it to EPROM when the power failure occurs.