Power failure rescue

Bonjour à tous !

J'aimerais développer un plugins pour un module PCB qu'un ami à conçu.
C'est un module de power loss recovery.
Du coup mon idée serait ceci :

Le module envoie 6V lorsque le 220V est présent. Lorsque le 220V disparaît, le module envoie 0V.
Le module alimentera l'imprimante via une banque de condensateur pour parquer la tête et reffroidir tant que c'est possible.
Il me faut donc un plugin qui :
-Détection perte du courant via GPIO.
-Envoie Gcode prioritaire pour parquer la tête.
-Log de la dernière ligne Gcode effectuée.
-Si courant reviens avant que la banque de condensateur soit vide, reprise d'impression.
Merci pour votre aide !

Hello everyone !

I would like to develop a plugins for a PCB module that a friend has designed.

It is a module of power loss recovery.
So my idea would be this:

The module sends 6V when the 220V is present. When the 220V disappears, the module sends 0V.
The module will power the printer via a capacitor bank to park the head and cool as much as possible.
So I need a plugin that:
-Detection power loss via GPIO.
-Send priority Gcode to park the head.
-Log of the last line Gcode performed.
-If 220V come back before the capacitor bank is empty, resume printing.

Thanks for your help !

That's an interesting project.

Honestly, it feels a bit like the similar sort of functionality you might find in a better-quality UPS. For example, here is a service daemon for the APC brand of UPSs. It can be configured to run scripts when the power is temporarily unavailable, for example. It is a mature project that has been well-supported.

If you do decide to try to detect a voltage on the GPIO pin of your Raspberry, you must limit that voltage to 3.3V or you could destroy the board. If you're good with electronics and the math involved, you could create a mini circuit with two resistors of equal value, for example, and put the GPIO pin in the center. This is called a voltage divider circuit. Since they're the same value, each resistor would drop half that 6V and 3V then would be in the middle and now safe to present to the GPIO pin.

6V 1KΩ
3V ° GPIO pin
0V 1KΩ

Reading the value in Python is easy enough using RPi.GPIO.

Salut =)
Merci pour ta réponse =) Oui j'ai déjà prévu de déscendre la tension à 3.3V.
Ce qui me bloque, c'est la création du plugin, n'ayant aucune expérience en développement octoprint.
Cependant, je connais quelqu'un de doué dans python et C++.
Ce qui me bloque aussi, c'est pour intégrer les commandes Gcodes à ce Daemon.
C'est pour la partie logiciel que j'ai besoin de votre aide.
Merci =)

Hi =)
Thank you for your answer =) Yes I already planned to break the voltage to 3.3V.
What blocks me is the creation of the plugin, having no experience in development octoprint.
However, I know someone gifted in python and C ++.
What blocks me too is to integrate the Gcodes commands to this Daemon.
It's for the software part that I need your help.
Thank you =)

Last year I taught software development. In a case like this where you wish to invent something, I think you might want to buy a book on how to program with Python and make an attempt at doing this yourself. First learn a little about how this works and then read how to make an OctoPrint plugin here.

You'd need to understand things like how (and where) to install a Python module like Rpi.GPIO in this case. So it would be good to understand how a virtual environment works or this will be frustrating.

There are several books available which teach Python programming specifically for the Raspberry Pi. You might find them to be very specific to what you're doing because they will talk about detecting a voltage on a GPIO pin. The Raspberry Pi Cookbook comes to mind. Page 163 includes "8.3 Installing Rpi.GPIO", section 8.2 discussed the voltage safety I just spoke about earlier. The author also mentions WiringPi as another good library. :laugh: Section 8.12 is called "Converting 5V Signals to 3.3V with Two Resistors". If you had this book in your hand, you could turn to Chapter 11 on inputs and figure this out.

At least here in the states, we also have a few magazines which are directly about the Raspberry Pi computer. I've seen how-to guides inside them with article after article of things just like this.

You're probably wondering why I might tease you like this instead of simply answering your questions. But if you buy the book and learn something, then you'll become a programmer like me and you'll then know something in the end. Isn't that better?

Merci pour ton aide =)
Je comprends ta démarche, et c'est aussi mon but d'apprendre.
Je vais de ce pas acheter plusieurs livre sur ce que tu me conseille.
Merci =)

Thank you for your help =)
I understand your approach, and it's also my goal to learn.
I will not buy several books on what you advise me.
Thank you =)

1 Like