So I have a Nano V3.0 clone and am looking at detecting power loss
I have a 5v power supply set up on an interrupt pin (2) detecting FALLING voltage, this then triggers the sub to save data to EPROM
The problems begin when i look at the supply to the Nano, there is a capacitor supplying the board, when i put this on Vcc the power drops straight off, when i connect this to +5v pin the program works fine and saves to EPROM?
I understand that its not good to supply voltage through the pins as they are unregulated, the bit i am not understanding is why such a big difference in power decay from Vcc and 5v?
Is the 5v pin only allowing a slow feed into the Nano and draining the caps slower?
Am i correct in thinking that all the ancillaries ie LCD, OLED, ESP are instantly taking all the power when plugged into the Vcc but perhaps not when plugged into the 5v?
Is the only way to get sufficient sized capacitors to be able to feed the whole load on power down? or backup battery or is it possible to 'shut down all the power drain pins and power the processor only?
Graynomad:
The Nano is 5v yes? So what is the difference between Vcc and 5v? Aren't they the same thing?
If you have all that stuff sinking power as well you might struggle to stay up for long enough I would think.
From what i have read in various snippets, it seems like its not good to use the I/O pins to supply the board with, i believe this is because they have no regulation on them, Vcc (5v) has some regulation on it.
The bit i am not understanding is why did the simple circuit work when i connect the caps to the 5v, allowing a slower power drain than when connected to the Vcc?
Maybe this is because Vcc supplies all the I/O pins but the 5v is only linked to the mainboard?
Yes. Based on the 1N4001 part numbers, each diode will have 0.7 volts forward drop. This means the the voltage from the back-up capacitor will be approximately 3.6 volts. Since the capacitor is powering only the processor, this is fine for a 8mhz 328P but at 16mhz but I'd like to see a higher voltage margin.
The easy fix is Schottky diodes... The common 1N5819 will work fine in this application and increase the back-up voltage to approximately 4.4 volts.
The yellow areas are pertinent to this. I use schottky diodes and a .3F super cap. The resistor divider before the schmitt trigger should give me just a little more time.
You can power small devices from a pin, not normally recommended but it works and can be a good way to turn something off that uses too much power when you only need it every now and then.
EDIT: After doing this circuit I remembered that the regulator IC had a PG (Power Good) output, so I'll be removing the NAND gate and resistors, but this is what I planned to do so I added them back for this pic.
SuperCaps are great but unfortunately rather bulky. If you want to save space why not have a tiny 3.7v 500mA (or less) Li-Ion battery with a buck (step up) 5V converter which ensures your Nano will probably stay alive for hours after a power cut (depending on what else you have connected) and allows you to detect power failure very simply on a digital input pin. This would also cost very little.
It just seems that other solutions appear to me to be quite complex for such a simple requirement.
Why not just monitor the supply voltage with an analog pin via a voltage divider, using
the internal voltage reference? This will work however slowly the supply voltages fades (as
with a battery or a mains brown-out), and avoids wasting voltage across diodes. You also
get to set the threshold voltage where you want it.
BTW monitoring a slowly varying voltage with a digital pin is prone to multiple triggering.
Wow, thanks a lot, lots of new ideas for me to go and play with!!
I have still not solved my original lack of understanding on how something is working one way and not the other, going to play with Fritzing and see if i can post a pic for you!
Sorry, just noticed the +ve is connected to the -ve on the caps, this is just an error and is not wired wrong.
So i think i have attached my schematic?
Its all very embryonic at the moment but just bear with me!
The Nano is currently powered through 'power down supply' and 'power loss detection' (neither on the 5v rail!). If i remove power loss detection the program saves to EPROM correctly as the Nano is still supplied through +5v, all that makes sense.
If i remove +5v nothing happens as there is still a feed in through D2, again that makes sense
If i drop all the power the caps feed into +5v and give sufficient delay to write to EPROM, fine!
The bit that confuses me is that when i put +5v into Vcc (this is where i think it should be) and then power off the board light drops straight off?
The only explanation i have for this is that Vcc feeds all the pins and anything attached will suck power, does this mean that +5v is connected differently and seems to only feed back into the board to power it without feeding to the pins?
It all seems to work well other than i am not confident i am breaking the rules and digging a hole for myself!
Has anyone mentioned how much we hate Fritzing diagrams and prefer a real schematic?
That is wrong as far as I can see, you have the Nano's 5v connected directly to GND. Move it to the cathode of the diode. Are the caps the right way around? + to the cathode?
Apart from that it seems to be in line with what we are saying.
EDIT:
Sorry, just noticed the +ve is connected to the -ve on the caps, this is just an error and is not wired wrong.
If you connect the Nanos 5v pin directly to the Vcc rail the Nano is now running from a supply that also hase two displays on it as well and those poor little 470u caps don't have a chance of keeping all that going for long.
Another trap for young players is to have active high digital connections between modules, they can (and often do) try to power the external modules via the ESD protection diodes inside most ICs. However in your case the only connections are I2C and as these are open-collector this should not be a real problem, the SDA and SCL signals may still be trying to power the two displays, but it will be through the two pullup resistors so it won't do very much, this is still however a "leak" that will affect the time the system stays up after power fail. If this was to be a battery-powered remote monitor that had critical powers-usage requirements this leak would have to be plugged.
Thanks again for all the support, i am edging towards a bigger cap rather than a battery as this only needs milli seconds to save to EPROM
I hear what you say about Fritzing and would probably agree but it was quick and simple and a picture speaks a thousands words! (but there is always room for improvement!)