I was hoping there might be a hardware way. monitor the power.... loss of power and then dump the current memory.
or hold everything off until power on- then a re-sending of the data.
but the idea of a Jedi-duino mind control of other chips....... nice. very nice.
dave-in-nj:
I was hoping there might be a hardware way. monitor the power.... loss of power and then dump the current memory.
or hold everything off until power on- then a re-sending of the data.
Yes but that uses a pin to detect when the power is going off as well as some hardware to keep the power coming to the arduino long enough to write to EEPROM.
if there was a charge that could be held when power was on, then decayed with the loss of power, there could be a signal to ther reclear pin based on a higher voltage in the charge than incoming power. comparitor ? inductor? ?
this would clear the buffer when the power was lost.. that way, it would start with all pins low.
or, use a ramp to the output enable pin until such time as the time delay took place. say, 3 to 5 times the program cycle time to allow the buffer to be set before the output from the 595 was able to be sent to the relays.
If you want to start a 595 from a blank state then simply wire up the output enable to a pull up resistor and it will power up showing nothing. Then when you have shifted your first data into it set it low.
This appears to be one of those commonly asked questions.
As I gather, you do not want "automatic reset", you actually want non-volatile storage.
If changes to the value in question are infrequent (every few hours, perhaps), you simply copy that value to EEPROM.
If changes are frequent and rapid, there is then a concern that you will "wear out" the EEPROM. There are ways of spreading the values across the EEPROM if you do not need it for any other purpose, but the most straightforward approach is to use a cheap RTC module with a lithium cell and I2C interface.
These have a RAM area which is backed up by the battery and have unlimited write cycles so you will never wear them out. There is some concern about the timekeeping accuracy of the cheaper modules but in this respect that of course does not matter. It will hold the data quite nicely over power outages.
my concern is that if I have a machine that uses relays to activate. and loose power.
then power is restored, the machine will just pick up where it left off.
my main desire is to have the 595 shift register that controls the relays to clear itself.
I am not 100% positive that the Arduino will also receive power and either reset the 595 or clear the memory, or send all 'off' values before any possible action can occur.
I will try the pull-up to see if that works 100% of the time. I suspect it will. much simpler than some elaborate circuit I was thinking about.