Skip to content

Commit

Permalink
HappyHare & other related dev (Frix-x#371)
Browse files Browse the repository at this point in the history
* HappyHare MMU integration in Klippain

* Spoolman support

* Multiple MCU templates added or modified, especially MMU templates

* LED system rework to support the LED_effects plugin and rainbow barf, etc... ( Frix-x#416 )

* TMC Autotune moonraker updater predefined config (add your motor defs to your overrides.cfg or mcu.cfg)

---------

Co-authored-by: Jan-Gerrit Drexhage <102791900+Surion79@users.noreply.github.com>
Co-authored-by: claudioguareschi <33001685+claudioguareschi@users.noreply.github.com>
Co-authored-by: Félix Boisselier <felix@fboisselier.fr>
Co-authored-by: ksummers92 <66363414+ksummers92@users.noreply.github.com>
  • Loading branch information
5 people authored and reineruhry committed Feb 13, 2024
1 parent 06ce119 commit 5daaaa0
Show file tree
Hide file tree
Showing 21 changed files with 161 additions and 205 deletions.
1 change: 0 additions & 1 deletion config/hardware/lights/config_colors.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ variable_colors: {
'on': {'r': 0.0, 'g': 0.2, 'b': 0.4, 'w':1.0},
'off': {'r': 0.0, 'g': 0.0, 'b': 0.0, 'w': 0.0},
'error': {'r': 0.4, 'g': 0.0, 'b': 0.0, 'w':0.0},
'shutdown': {'r': 0.0, 'g': 0.0, 'b': 0.0, 'w': 0.0},
},
'thermal': {
'hot': {'r': 1.0, 'g': 0.0, 'b': 0.0, 'w': 0.0},
Expand Down
3 changes: 1 addition & 2 deletions config/hardware/lights/neopixel_caselight_effects.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

[gcode_macro _USER_VARIABLES]
variable_status_leds_caselight_enabled = True
variable_status_leds_effects_enabled = True
variable_status_leds_caselight_led_name: "caselight"
variable_status_leds_caselight_led_name: "caselight_effects"
gcode:

# Also include directly the leds control macros from here
Expand Down
5 changes: 2 additions & 3 deletions config/hardware/lights/status_leds_effects.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

[gcode_macro _USER_VARIABLES]
variable_status_leds_enabled: True
variable_status_leds_effects_enabled: True
variable_status_leds_logo_led_name: "status_leds"
variable_status_leds_logo_led_name: "status_leds_effects"
variable_status_leds_logo_idx: '1'
variable_status_leds_nozzle_led_name: "status_leds"
variable_status_leds_nozzle_led_name: "status_leds_effects"
variable_status_leds_nozzle_idx: '2,3'
gcode:

Expand Down
1 change: 0 additions & 1 deletion config/hardware/lights/status_leds_rainbow_barf.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

[gcode_macro _USER_VARIABLES]
variable_status_leds_enabled: True
variable_status_leds_effects_enabled: False
variable_status_leds_logo_led_name: "status_leds"
variable_status_leds_logo_idx: '1,2,3,4,5,6,7,8'
variable_status_leds_nozzle_led_name: "status_leds"
Expand Down
5 changes: 2 additions & 3 deletions config/hardware/lights/status_leds_rainbow_barf_effects.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

[gcode_macro _USER_VARIABLES]
variable_status_leds_enabled: True
variable_status_leds_effects_enabled: True
variable_status_leds_logo_led_name: "status_leds"
variable_status_leds_logo_led_name: "status_leds_effects"
variable_status_leds_logo_idx: '1,2,3,4,5,6,7,8'
variable_status_leds_nozzle_led_name: "status_leds"
variable_status_leds_nozzle_led_name: "status_leds_effects"
variable_status_leds_nozzle_idx: '9,10'
gcode:

Expand Down
1 change: 1 addition & 0 deletions config/hardware/mmu.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ max_extrude_cross_section: 50.0


# Also include directly the MMU macros and config from here
[include ../../mmu/base/mmu_*.cfg]
[include ../../macros/hardware_functions/mmu.cfg]
21 changes: 13 additions & 8 deletions config/machine.cfg
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
[virtual_sdcard]
path: ~/printer_data/gcodes
on_error_gcode:
{% set probe_type_enabled = printer["gcode_macro _USER_VARIABLES"].probe_type_enabled %}

{% if printer["gcode_macro _USER_VARIABLES"].status_leds_enabled %}
STATUS_LEDS COLOR="ERROR"
{% endif %}

{% if probe_type_enabled == "dockable" %}
{% if printer["gcode_macro _USER_VARIABLES"].probe_type_enabled == "dockable" %}
_PROBE_ON_ERROR_ACTION
{% endif %}

[exclude_object]
CANCEL_PRINT

[idle_timeout]
timeout: 1800
gcode:
RESPOND MSG="Idle timeout reached"
TURN_OFF_HEATERS
M84
{% if printer["gcode_macro _USER_VARIABLES"].light_enabled %}
LIGHT_OFF
{% endif %}
{% if printer["gcode_macro _USER_VARIABLES"].status_leds_enabled %}
STATUS_LEDS COLOR="OFF"
{% endif %}

[pause_resume]

[display_status]

[exclude_object]
[respond]

[force_move]
Expand Down
50 changes: 29 additions & 21 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,61 @@

Klippain requires a few simple steps to configure and customize it for your printer: please follow the following documentation step by step in order to get your printer running.

> **Warning**
> **Warning**:
>
> General rule to keep the auto-update feature working: **never modify Klippain files directly**, but instead add overrides as per the following documentation. To proceed, you can modify all the pre-installed templates in your config root folder (`printer.cfg`, `mcu.cfg`, `variables.cfg` and `overrides.cfg`) as they will be preserved on update.
> General rule to keep the auto-update feature working: **never modify Klippain files directly**, but instead add overrides as per the following documentation. To proceed, you can modify all the pre-installed templates in your config root folder (`printer.cfg`, `mcu.cfg`, `variables.cfg` and `overrides.cfg` and, if applicable, the MMU configs files in the `mmu` directory created when you install Happy-Hare) as they will be preserved on update.
## 1. MCU Settings

Before configuring Klippain, you will need to configure your MCUs and wiring. If you didn't select any templates during the installation (or want to customize the default wiring), modify your `mcu.cfg` file according to the [MCU pinout and wiring documentation](./pinout.md).

Don't forget to fill in the serial_port or can_uuid of your MCUs. Refer to the [official Klipper documentation](https://www.klipper3d.org/FAQ.html#wheres-my-serial-port) for help.


## 2. Printer Settings, Overrides, and Variables

Don't overlook, this section is the most important. Now that your MCU is configured, you will need to follow some additionnal steps to configure Klippain:

1. In `printer.cfg`, uncomment lines corresponding to your printer hardware or software components to enable them (e.g., extruder type, XY motors, Z motors, QGL vs Z_TILT, etc.).
1. Then, edit `overrides.cfg` according to the [overrides documentation and examples](./overrides.md). Use overrides to tweak machine dimensions, invert motor directions, change axis limits, currents, sensors type, or anything you feel the need to change.
1. Once Klipper boots successfully, adjust the `variables.cfg` file to match your machine's configuration. This file provides additional customization for macro behavior (coordinates, enabling/disabling software features, etc.).

> **Note**:
>
> If you plan to use an ERCF, Klippain is only compatible with the [Happy Hare](https://github.com/moggieuk/ERCF-Software-V3) software backend.
> Enable the ERCF lines in Klippain's `printer.cfg` and then install Happy Hare directly by following its official documention. **When the Happy Hare installer ask if you want to include all the ERCF files into your printer.cfg: answer no** as everything is already included in Klippain!
> If you want to use an MMU/ERCF with Klippain, you need to install the [HappyHare](https://github.com/moggieuk/Happy-Hare) backend. Also, have a look at the Klippain [MMU documentation](./docs/mmu.md) for more specific details about its configuration.
## 3. Initial startup of the machine

Before your first print, **carefully check all features to prevent issues on your machine!** Begin with the [config checks section from the official Klipper documentation](https://www.klipper3d.org/Config_checks.html).

Next, ensure the mechanical probe (if used) can be attached/detached, verify that QGL/Z_TILT works, and confirm correct coordinates for all components (purge bucket, physical Z endstop, etc.). Check your first layer calibration (and the `switch_offset` parameter of the automatic Z calibration plugin, if used), etc.
Next, ensure the mechanical probe (if used) can be attached/detached, verify that QGL/Z_TILT works, and confirm correct coordinates for all components (purge bucket, physical Z endstop, etc.). Check your first layer calibration (and the `switch_offset` parameter of the automatic Z calibration plugin, if used), etc...

Then, add this custom print start G-code to your slicer (example for SuperSlicer):
```
START_PRINT EXTRUDER_TEMP={first_layer_temperature[initial_extruder] + extruder_temperature_offset[initial_extruder]} BED_TEMP=[first_layer_bed_temperature] MATERIAL=[filament_type] SIZE={first_layer_print_min[0]}_{first_layer_print_min[1]}_{first_layer_print_max[0]}_{first_layer_print_max[1]} INITIAL_TOOL={initial_extruder}
```
## 4. Slicer configuration

Klippain will work out of the box with most slicers on the market and your profiles should be almost ready to go. You will just need to set some custom start print and end print gcodes to give Klippain the correct info.

There is also a couple of other optionnal parameters that are supported in Klippain (they need to be added on the same one line following the other parameters):
- `CHAMBER=[chamber_temperature]` to be able to specify a target heatsoak temperature for the START_PRINT sequence
- `TOTAL_LAYER=[total_layer_count]` to be able to set the PRINT_STATS_INFOS in Klipper. If using this, you will need to add on your slicer custom layer change gcode the appropriate `SET_PRINT_STATS_INFO CURRENT_LAYER={layer_num}`
### Custom print start Gcode

Finally, add custom print end G-code to your slicer:
| Slicer | Custom start print gcode |
|:-------|:-------------------------|
|[SuperSlicer](https://github.com/supermerill/SuperSlicer)|`START_PRINT EXTRUDER_TEMP={first_layer_temperature[initial_extruder] + extruder_temperature_offset[initial_extruder]} BED_TEMP=[first_layer_bed_temperature] MATERIAL=[filament_type] SIZE={first_layer_print_min[0]}_{first_layer_print_min[1]}_{first_layer_print_max[0]}_{first_layer_print_max[1]} INITIAL_TOOL={initial_extruder}`|
|[OrcaSlicer](https://github.com/SoftFever/OrcaSlicer)|`START_PRINT EXTRUDER_TEMP=[nozzle_temperature_initial_layer] BED_TEMP=[bed_temperature_initial_layer_single] MATERIAL=[filament_type] SIZE={first_layer_print_min[0]}_{first_layer_print_min[1]}_{first_layer_print_max[0]}_{first_layer_print_max[1]} INITIAL_TOOL=[initial_tool]`|
|[PrusaSlicer](https://github.com/prusa3d/PrusaSlicer)|`START_PRINT EXTRUDER_TEMP={first_layer_temperature[initial_extruder]} BED_TEMP=[first_layer_bed_temperature] MATERIAL=[filament_type] SIZE={first_layer_print_min[0]}_{first_layer_print_min[1]}_{first_layer_print_max[0]}_{first_layer_print_max[1]} INITIAL_TOOL={initial_extruder}`|

In addition, there are a few other optional parameters that are supported in Klippain (they must be added on the same line after the first parameters):
- `CHAMBER=[chamber_temperature]` *(for SuperSlicer and OrcaSlicer)* or `CHAMBER=[idle_temperature]` *(for PrusaSlicer)* to set a target heatsoak temperature during the START_PRINT sequence.
- `TOTAL_LAYER=[total_layer_count]` to be able to set the PRINT_STATS_INFOS in Klipper. If you use this, you will also need to add the corresponding `SET_PRINT_STATS_INFO CURRENT_LAYER={layer_num}` to your slicer custom layer change gcode.
- `TOOLS_USED=!referenced_tools!` *(only for MMU users)* is highly recommended to check only the used tools with the HappyHare [Moonraker gcode preprocessor](https://github.com/moggieuk/Happy-Hare/blob/main/doc/gcode_preprocessing.md).
- `CHECK_GATES=0` or `1` *(only for MMU users)* that will override the corresponding variable defined in Klippain `variables.cfg` for this specific print.
- `SYNC_MMU_EXTRUDER=1` *(only for MMU users)* if you want to stay with the default `sync_to_extruder: 0` value of HappyHare (defined in `mmu/mmu_parameters.cfg`), but still want to use the sync for a specific print.


### Custom print start Gcode

All slicers will be happy with a simple:
```
END_PRINT
```

> **Note** for ERCF users:
>
> By default, Klippain unloads the filament at the end of the print, but you can change the default behavior by modifying the variable `variable_ercf_unload_on_end_print` in your `variables.cfg` file.
> You can also specify the wanted behavior directly in your slicer end print custom gcode by using `END_PRINT ERCF_UNLOAD_AT_END=0`.
In addition, there are a few other optional parameters that are supported in Klippain (they must be added on the same line after the first parameters):
- `FILTER_TIME=600` that will override the corresponding variable defined in Klippain `variables.cfg` for this specific print. Time is expressed in seconds.
- `MMU_UNLOAD_AT_END=0` or `1` *(only for MMU users)* that will override the corresponding variable defined in Klippain `variables.cfg`.
48 changes: 30 additions & 18 deletions docs/pinout.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,83 @@

In Klipper, once a `[board_pins]` is defined, the aliases are used in all sections to make them more readable ([official board_pins Klipper documentation](https://www.klipper3d.org/Config_Reference.html#board_pins)). I use this mechanism extensively on a two-level model to add genericity and simplify the MCU configuration for everyone.


## Configuring your mcu.cfg file

Klippain is designed using a two-level [board_pins] model:

1. First level: Some rules and pin naming conventions (let's call them "Frix-x names") were defined and used in all config files. Then a set of [user board_pins templates](./../user_templates/mcu_defaults/) were created for the most common MCUs of the market. This is basically what you need to put in your `mcu.cfg` file.
2. Second level: Since it's always a pain to retrieve the pin names from the boards manufacturer's documentation like `PA12` or `gpio23` (let's call them "controller names"), I added a second layer of [board_pins] to link some "easy to retrieve names" (ie. what's printed on the MCU boards around the ports and easy to read with "MCU_" as a prefix) to these "controller names". This second layer of board_pins is located [in this folder](./../config/mcu_definitions/) and is not intended to be modified.

To summarize, we have two board_pins used for each MCU. One user board_pins and one manufacturer board_pins. They link the following:

```
Frix-x names -> Manufacturer (PCB print) names > controller names
```

So in order to populate your own `mcu.cfg` file, just copy one of the [user template](./../user_templates/mcu_defaults/) into it. Then feel free to change the wiring to your liking. For example, if you have wired your part fan to port `FAN3` instead of `FAN0`, just change the definition to `PART_FAN=MCU_FAN3` and that's it!

> **Info**
> **Info**:
>
> Klipper does not allow `[board_pins]` sections to contain pin modifiers such as `!`, `^` and `~`. Moreover, when configuring multiple MCUs at the same time, all the aliases used in the hardware sections must be prefixed with the MCU name. This is a current limitation of Klipper and is why you need to use the overrides.cfg file to add them.

## Using a new MCU

If you want to use a new MCU that is not yet supported in my config, you just have to define a new [board_pins] in your `mcu.cfg` file and use the same convention. Also feel free to also add a manufacturer board_pins to my config and submit a PR: I'll be happy to merge it and extend MCU support for new boards :)

Here is a list of all the "Frix-x names" available to use in your own board_pins:

#### Steppers

- `[EXYZ1-3]_STEP`: drivers step pins
- `[EXYZ1-3]_DIR`: drivers dir pins
- `[EXYZ1-3]_ENABLE`: drivers enable pins
- `[EXYZ1-3]_TMCUART`: drivers UART pins
- Beside standard axis there is also the support for the `GEAR_...` and `SELECTOR_...` drivers used in the ERCF
- `DRIVER_SPI_MOSI`, `DRIVER_SPI_MISO`, `DRIVER_SPI_SCK`: used in case of SPI drivers
- Beside standard axis there is also the support for the `MMU_GEAR_...` and `MMU_SEL_...` drivers used in the MMU/ERCF/TRADRACK

#### Endstops & Probe

- `[XYZ]_STOP`: classic axis endstops pins
- `PROBE_INPUT`: classical probe like Klicky, Omron, Pinda, TAP, etc...
- `PROBE_INPUT`: classical probe input like Klicky, Omron, Pinda, TAP, etc...
- `MMU_SEL_ENDSTOP`: for the MMU/ERCF physical selector endstop

#### Heaters

#### Heaters
- `E_HEATER`: hotend heater cartridge
- `BED_HEATER`: bed heating pad (or bed SSR)

#### Temperature sensors

- `E_TEMPERATURE`: hotend temperature sensor
- `BED_TEMPERATURE`: bed temperature sensor
- `CHAMBER_TEMPERATURE`: chamber temperature sensor
- `CHAMBER_TEMPERATURE`: chamber temperature sensor (used to heatsoak the chamber during the START_PRINT sequence)
- `ELECTRICAL_CABINET_TEMPERATURE`: electrical cabinet temperature sensor (not really used in the config, but if present, this sensor is added to the Mainsail / Fluidd web interface as an additional info)

#### Fans

- `E_FAN`: hotend fan. This fan should stay at 100% whenever the hotend is hot, so a PWM capable pin is not mandatory
- `PART_FAN`: part fan used during the print. This pin should be a PWM capable pin to allow power modulation
- `EXHAUST_FAN`: for an exhaust filter (such as the Voron basic exhaust). This pin should be a PWM capable pin to allow power modulation
- `FILTER_FAN`: for a filter (such as a Nevermore filter). This pin should be a PWM capable pin to allow power modulation
- `PART_FAN`: part fan used during the print. This pin should be a PWM capable pin to allow modulation of the fan speed
- `EXHAUST_FAN`: for an exhaust filter (such as the Voron basic exhaust). This pin should be a PWM capable pin to allow modulation of the fan speed
- `FILTER_FAN`: for a filter (such as a Nevermore filter). This pin should be a PWM capable pin to allow modulation of the fan speed
- `CONTROLLER_FAN`: to cool down your MCUs or electronic bay
- `HOST_CONTROLLER_FAN`: to cool down your Pi (or equivalent Klipper host controller)

#### Lights

- `LIGHT_OUTPUT`: simple chamber lights (such as 24v leds or 24v fcob light bars)
- `LIGHT_NEOPIXEL` : neopixel chamber lights
- `STATUS_NEOPIXEL` : toolhead neopixel lights (such as the one used on the Voron StealthBurner toolhead)
- `LIGHT_NEOPIXEL` : neopixels chamber lights
- `STATUS_NEOPIXEL` : toolhead/machine status led neopixels (such as the one used on the Voron StealthBurner toolhead)
- `MMU_NEOPIXEL`: for the specific MMU/ERCF neopixel leds

#### Other I/Os
- `RUNOUT_SENSOR`: filament motion sensor
- `ERCF_ENCODER`: filament motion sensor used in the ERCF carriage
- `TOOLHEAD_SENSOR`: toolhead filament sensor used for the ERCF
- `SERVO_PIN`: for a mechanical and movable probe dock or brush (such as the ones that are commonly found on the Voron V0 mods)
- `ERCF_SERVO`: for a the ERCF servo

- `RUNOUT_SENSOR`: filament runout sensor (currently only one motion or switch sensor is supported in Klippain)
- `MMU_ENCODER`: filament motion sensor used in the MMU/ERCF carriage
- `TOOLHEAD_SENSOR`: optional toolhead filament sensor used for the MMU/ERCF/TRADRACK
- `SERVO_PIN`: for a mechanical and movable probe dock or brush (such as the ones that are commonly found on the Voron V0 mods)
- `MMU_SERVO`: for the MMU servo
- `MMU_GATE_SENSOR`: for the MMU/TRADRACK gate sensor
- `MMU_PRE_GATE_[0-11]`: for the MMU/ERCT sensors

## External references

Expand All @@ -78,4 +90,4 @@ For more information on the boards and pinouts, please see directly the manufact
- [Fly SHT](https://mellow.klipper.cn/#/board/fly_sht36_42/)
- [BTT EBB](https://github.com/bigtreetech/EBB)
- [BTT SKR Mini E3](https://github.com/bigtreetech/BIGTREETECH-SKR-mini-E3)
- [Fysetc S6](https://github.com/FYSETC/FYSETC-S6)
- [Fysetc S6](https://github.com/FYSETC/FYSETC-S6)
Loading

0 comments on commit 5daaaa0

Please sign in to comment.