What's new
VORON Design

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members!

PSA - GPIO pins to set at micro-controller startup

Duke

Member
I recommend when setting up make menuconfig to build the Klipper firmware to tic the box that says "Enable extra low-level configuration options" and add the pin that is controls your hotend cooling fan to the option "GPIO pins to set at micro-controller startup".

The reason to enable this feature is to prevent jamming your hotend, or melting your toolhead if the controller is reset while your extruder is hot. This can happen after a momentary power outage, or pressing the reset button on your display, for example. After the MCU resets, it will turn on the hotend fan and keep it on until communication with Klipper is reestablished and Klipper has determined that the hotend is cool and the fan no longer needs to be on.

If you have multiple pins that you need or want to enable at startup, separate them with a comma. For example, if you have an SKR Mini E3 V2 (that requires PA14 to be held low at startup) and you have your hotend fan connected to PC7, you would enter "!PA14,PC7". If you also wanted to have your cooling fan that is controlled by PC6, you can enter "!PA14,PC7,PC6". If you want to enable any steppers at startup you can add the enable pins for those steppers as well (stepper enable pins are typically active low so add an exclamation point in front of the pin, just like it's written in your printer.cfg).
 
Isn't this the default behavior. On my printer, every time the MCU looses connection with the PI, the hotend fan turns on to max. When Klipper reconnects, it turns off.
 
Emergency stop or loss of communication isn't the same as MCU reset. After reset all output pins are normally left floating. Observe the behavior of your printer when it is first powered on. This is the state that your machine will be in after an MCU reset. The MCU won't know which pins to set to what value until after communication is established, because the printer configuration isn't stored in the MCU firmware. The MCU needs to connect to kipper and be told that pin x is the fan, pin y is the bed heater, etc, before it can properly set those outputs to the appropriate state. That's why it's important to define those outputs when compiling the firmware for the MCU.
 
Emergency stop or loss of communication isn't the same as MCU reset. After reset all output pins are normally left floating. Observe the behavior of your printer when it is first powered on. This is the state that your machine will be in after an MCU reset. The MCU won't know which pins to set to what value until after communication is established, because the printer configuration isn't stored in the MCU firmware. The MCU needs to connect to kipper and be told that pin x is the fan, pin y is the bed heater, etc, before it can properly set those outputs to the appropriate state. That's why it's important to define those outputs when compiling the firmware for the MCU.
If this is truly the case, you should bring it up with both the Voron docs guys and Klipper so the documentation will be updated. I am fairly certain that this would be a welcomed safety precaution.
 
I don't really know who to talk to about it. I don't have much of a "presence" within the Voron community, which is why I decided to post it here, hoping someone in the design team would take notice. This really should be in the Klipper documentation, as it can affect any printer running Klipper.
 
I don't really know who to talk to about it. I don't have much of a "presence" within the Voron community, which is why I decided to post it here, hoping someone in the design team would take notice. This really should be in the Klipper documentation, as it can affect any printer running Klipper.
If you have a serial, there is a #documentation-open channel on Discord. Otherwise, you could may be post to #voron-electronics.

As for Klipper, it has a discord server where you can report issues.
 
Is this how all MCU function, or are model or brands different on how they handle pins on reset?
This is a function of the firmware. It is because Klipper firmware is setup to be universal. The same firmware is loaded into every board that has the same model of MCU, and the functionality of the firmware is the same regardless of what type of MCU is used. This is how Klipper's pin assignments can be changed without having to reflash firmware. The MCU isn't aware of the pin assignments until after it connects to the Klipper host, so everything is left off. Once it connects to the host, the pin assignments are then loaded from the config, into the MCU's memory. If the MCU is reset, the memory is cleared and the pin assignments are lost.

One thing that I feel should be noted is that not all display/controller combinations have the same reset button functionality on the display. On some (probably most) printers, the reset button on the display is connected to the [hardware] reset circuit on the controller, which will hard reset the controller. Some printers have a software reset, or "Emergency Stop" function which may not reset the MCU. Some printers have a separate, dedicated MCU for the display which might have a hardware or software reset circuit, but won't reset the printer's main MCU. Because of the different possible configurations, pressing the reset button on the display may have a different response on different printers, but if the printer's MCU is actually reset, the pins will be set to their default state.
 
This is a function of the firmware. It is because Klipper firmware is setup to be universal. The same firmware is loaded into every board that has the same model of MCU, and the functionality of the firmware is the same regardless of what type of MCU is used. This is how Klipper's pin assignments can be changed without having to reflash firmware. The MCU isn't aware of the pin assignments until after it connects to the Klipper host, so everything is left off. Once it connects to the host, the pin assignments are then loaded from the config, into the MCU's memory. If the MCU is reset, the memory is cleared and the pin assignments are lost.

One thing that I feel should be noted is that not all display/controller combinations have the same reset button functionality on the display. On some (probably most) printers, the reset button on the display is connected to the [hardware] reset circuit on the controller, which will hard reset the controller. Some printers have a software reset, or "Emergency Stop" function which may not reset the MCU. Some printers have a separate, dedicated MCU for the display which might have a hardware or software reset circuit, but won't reset the printer's main MCU. Because of the different possible configurations, pressing the reset button on the display may have a different response on different printers, but if the printer's MCU is actually reset, the pins will be set to their default state.
I would really get the Klipper devs involved with this. It is my understanding that no matter how the MCU is reset, it will boot the flashed Klipper firmware. The firmware, itself, might have some basic default definitions on how to set pins. It seems odd that the MCU firmware will be leaving pins as floating, knowing that some of those pins are connected to heating elements.
 
Top