Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for power lost detection #233

Open
eliasbakken opened this issue Sep 21, 2021 · 1 comment
Open

Add support for power lost detection #233

eliasbakken opened this issue Sep 21, 2021 · 1 comment

Comments

@eliasbakken
Copy link

A decreasing voltage level can be detected by the STM32. This event can be used to save information in the MCU itself and to signal the host SoC (A64) that power has been removed. During normal standstill operation, the time from a voltage drop can be safely detected until power is lost on the 3.3V line has been measured to be about 6 ms.

@eliasbakken
Copy link
Author

I've done some tests on the STM32 and with few changes to the mainline Klipper code, it is possible to check the input voltage at a frequency of 0.1 ms which should be sufficient. Further more, I've managed to save the position to Flash in the upper page. Erase size is 1 KB, the code is only about 12K and the total flash size is 16K. The time to store 5 half words to flash is 275 us.
If this is going to be a working solution, the host needs to send it's position at regular intervals. That information is not available to the MCU.
There is also some work that needs to be done in order to get information back form the MCU once power is reapplied. For testing, this can be done by the stm32flash program to read out a location in flash, but as a part of klipper it can be done with an MCU command.
It is important that a page erase is not done automatically on boot of the MCU, that would remove any information stored during shutdown. A cleanup could be done last minute as part of starting a new print.
SDS5034X_PNG_5
This picture shows the time it takes to run a "save to flash" operation. The sequence was triggered by shutting off power.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant