Detecting power loss (here: Pixl.js) #1832
Replies: 12 comments
-
Posted at 2019-11-14 by AkosLukacs If you don't have other load just the Pixl and an INA226, it can run several seconds on a relatively small supercap. Bought a 5.5V / 0.something Farad one ages ago, and that can store enough energy to run the Pixl with LCD backlight on for seconds. Or modify your Pixl.js to use CR2032 battery as backup: I think on your schematic the Din would stay floating around 3.3V, if |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-11-14 by ChristianW Thanks, @AkosLukacs. I was considering the CR2032 backup, but was scared to mess with two inputs. Actually it would be enough to have some cycles left for a EEPROM write, so a powercap or elko could just do. It would be nice to use a The NRF52LL reference looks interesting, too. Did not know about it. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-11-14 by @gfwilliams The diode idea sounds good. One other thing you could look at is if you make a potential divider with 2 resistors, you could read the analog value of the pin to get the voltage, but you could also use |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-11-14 by ChristianW I just wired it up. Strange thing: The display flickers and blacks out rhythmically while D7 is not configured. I used this script to test powerdown detection:
It gives me about 6 seconds console feedback before dying with the LED off:
With LED set immediately after power down it is only two seconds (still enough for some cleanup probably). So basically it seems to work. @gfwilliams: is it normal that it behaves strange when certain pins are used as inputs bot not configured yet? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-11-14 by ChristianW PS: Without BLE connection and LED off it is even 9 seconds feedback on the LCD! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-11-14 by @gfwilliams So you're connecting 12v to an input pin via a 10k resistor? I'd expect that to maybe cause issues, yes. Basically 10v drop at 10k is 1mA going in to the chip, but the chip itself draws way less than that when idle. While it's caught by the chips diodes, it means that it is powering the 3.3v supply via an IO pin. I reckon if you look at the 3.3v pins you'll find that the voltage is well above 3v I would add a permanent resistor to pull down, so that the voltage always stays in the 3.3v range - otherwise it might cause damage to the chip. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-11-14 by ChristianW Not quite. For pulldown (in case of power loss) I used the internal resistor via As with the flickering this may have been cause by wrongly wired MOSFETs or a shortage between 3,3V and 5V PIN. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-11-14 by @allObjects Something like that gets you to safety (even while recharging when plugged in):
You could add additional safety paralleling the zener w/ a fast transient suppression device / circuitry (TVS; google for 'transient voltage suppressor circuit'). 'After' that you can then also use the power to feed a regulator that runs you digital electronics, including Espruino. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-11-14 by ChristianW Thanks for the suggestion, I'll change the resistor setup tomorrow to be on the safer side. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-11-14 by @allObjects @christianw, I picked intentionally a bit higher values because you do not want to add additional load on your battery. On the other hand - compared with the power motors consume - current draw is negligible. Important for operating sensitive electronics next to power / servo electronics requires a good 'separation'. The first cars with electronics had two batteries to make sure the power for the controlling electronics is more stable and reliable then the power for driving heavy loads (starter, window motors, etc.). @drazzy has quite some experience in - and sells also components for - driving power hungry devices (lights). Search the forum and go to https://www.tindie.com (do see him not that often anymore on the forum, though). |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-11-15 by ChristianW @allObjects thanks for the clarification. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-11-19 by @gfwilliams
Yes, that should be fine, although 3.3v would be 'nicer' to it if you can do that ;) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-11-14 by ChristianW
I am using a Pixl.js for a bike (velomobile) computer project.
It should monitor the onboard LiPo battery with 11.1 V and is also driven by it.
In case off immediate power loss (battery is dying or just disconnected) there should be a triggered routine to save some current data to flash.
I was considering this:
Battery power is monitored by an INA226.
So one way is to regularly poll and detect an undervoltage.
But this is slow and could only work for a slowly dying battery - no sudden disconnect.
So another idea is this:
Put a capacitor parallel to the Vin Pins to gain some time after power loss.
Put a diode in front so the capacitor only feeds the Pixl, nothing outside.
Wire the feeding current (before the doide) with a resistor (~10k) to a digital input.
Put another small diode between 3,3 V and the input so the voltage will not rise above 3,3 V. (Maybe a Z-diode of about 3,3 V between GND and the input would be better?)
As soon as the outside voltage drops, the pin will change to low and trigger a watch set on that pin.
Will that work?
Anyone tried something similar or has a better idea?
Some ASCII Art sketch for clarification:
Beta Was this translation helpful? Give feedback.
All reactions