Skip to content

A Python post-processor for 3D printer G-code files, implementing advanced flow and temperature smoothing for improved print quality and layer adhesion.

Notifications You must be signed in to change notification settings

Yury-MonZon/MZ_Flow_Temp_processor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🔥 MZ Flow Temp Processor

Advanced G-code post-processor that intelligently smooths flow and adjusts temperature for superior 3D print quality and layer adhesion.

Benchy temperature visualization Graphs

Features

  • 🌊 Flow Smoothing: Extracts extrusion moves and smooths flow transitions for better print quality
  • 🌡️ Dynamic Temperature Control: Adjusts nozzle temperature based on actual flow demand with gradual transitions
  • ⚡ Feedrate Clamping: Prevents exceeding printer's maximum volumetric flow capability
  • 📊 Real-time Visualization: Live plotting of flow and temperature profiles
  • 🔗 Slicer Integration: Works as post-processing script (OrcaSlicer tested)
  • ⚙️ Automatic Configuration: Reads parameters from G-code comments or config blocks
  • 👀 Viewer Relaunch: Optionally relaunches slicer viewer after processing

Quick Start

Installation

Python 3 required with these packages:

  • numpy
  • matplotlib
  • PyQt5
  • psutil

Install dependencies:

Ubuntu/Debian:

sudo apt install python3-matplotlib python3-numpy python3-pyqt5 python3-psutil

Arch/Cachyos:

sudo pacman -S python-matplotlib python-numpy python-pyqt5 python-psutil

Windows:

pip install matplotlib numpy PyQt5 psutil

Basic Usage

python mz_flow_temp.py <input.gcode>

Debug Mode

By default, the script shows informational messages in terminal (if run manually). A log file is created only when an error occurs.

Enable debug logging: Create an empty file called DEBUG_ON in the script folder.

This enables verbose debug output and creates a detailed log file for troubleshooting.

OrcaSlicer Integration

1. Configure Machine G-code

Go to Printer Settings > Machine G-code and add:

  • At the end of Machine start G-code: ; MZ FLOW TEMP START
  • At the beginning of Machine end G-code: ; MZ FLOW TEMP END

Machine G-code

2. Add Script Settings

In Printer Settings > Notes, add:

mz_flow_temp_sec_per_c_heating = 6
mz_flow_temp_sec_per_c_cooling = 4
mz_flow_temp_launch_viewer = true

Printer notes

3. Configure Filament Settings

Set these values in your Filament profile:

  • Temperature ranges (low/high)
  • First layer temperature
  • Maximum volumetric flow rate
  • Minimum print speed

Filament settings First layer temp Max flow rate Min print speed

4. Add Post-processing Script

In Print process > Others > Post-processing scripts:

Linux/MacOS:

python <path to script>/mz_flow_temp.py

Windows:

  1. Find Python path: where python
  2. Add full command: "C:\Users\<USER>\AppData\Local\Programs\Python\Python313\python.exe" <path to script>/mz_flow_temp.py

Post script

Viewer Behavior

Important: OrcaSlicer doesn't automatically show post-processed G-code. The script can relaunch the viewer to display changes.

  • ESC key: Close plot without launching viewer
  • Window close/Q key: Close plot and launch viewer (if enabled)

Disable viewer: mz_flow_temp_launch_viewer = false

Required Parameters

Your G-code must include:

; nozzle_temperature_range_high = 260
; nozzle_temperature_range_low = 220
; filament_diameter = 1.75
; slow_down_min_speed = 30
; filament_max_volumetric_speed = 12
; nozzle_temperature_initial_layer = 240
; initial_layer_print_height = 0.2

Plus in printer notes:

mz_flow_temp_sec_per_c_heating = 6
mz_flow_temp_sec_per_c_cooling = 4
mz_flow_temp_launch_viewer = true

How It Works

  1. Parse G-code: Extract extrusion moves and calculate flow rates
  2. Smooth Flow: Apply smoothing algorithms for better flow consistency
  3. Adjust Temperature: Modify temperature according to actual flow demand
  4. Clamp Feedrate: Ensure printer limits aren't exceeded
  5. Visualize: Display real-time flow and temperature profiles
  6. Save & Launch: Write processed G-code and optionally open viewer

Expected Results

The tool smooths flow consistency and adjusts temperature according to actual flow demand, helping your printer handle variations effectively. This prevents under-extrusion and improves layer bonding, especially for complex or fast prints.

Exit Codes

Code Description
0 Success
1 Incorrect usage
2 Input file not found
3 Missing EXECUTABLE_BLOCK markers
4 Missing MZ FLOW TEMP markers
5 Error parsing settings
6 Missing required parameters
7 No moves found in G-code
8 Error writing output file
9 Unhandled exception

Troubleshooting

  • No plots/output: Check dependencies and G-code parameters/markers
  • Script not running: Verify post-processing script path and permissions
  • Incorrect adjustments: Ensure filament/printer settings match hardware

License

GPL v3

Support

Donate

If this project helps you, consider supporting my work: https://ko-fi.com/yurymonzon

Author

Developed by Yury MonZon, inspired by BELAYEL Salim's original temperature controller: https://github.com/sb53systems/G-Code-Flow-Temperature-Controller

About

A Python post-processor for 3D printer G-code files, implementing advanced flow and temperature smoothing for improved print quality and layer adhesion.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages