-
-
Notifications
You must be signed in to change notification settings - Fork 13
Macros_en_old
A macro is a small program written in Klipper/Gcode.
It can be called from:
- A GCODE file
- The Fluidd/Mainsail console (press the
C
key in Fluidd).
Default values are shown in parentheses.
Set the language for zmod to work in.
- LANG - language, en - English, ru - Russian, de - German, fr - French, it - Italian, es - Spanish, zh - Chinese, ja - Japanese, ko - Korean (en)
Example:
LANG LANG=en
Replaces the native start G-code (if using the screen, add M140/M190 for bed temp and M109/M104 for extruder temp).
- EXTRUDER_TEMP: Extruder temperature (245).
- BED_TEMP: Bed temperature (80).
- MESH: Name of the bed mesh to load. If empty, no mesh is loaded. If it doesn’t exist, a new mesh will be created ("").
- FORCE_LEVELING: Force bed leveling (False).
- SKIP_LEVELING: Skip bed leveling under any conditions. Overrides FORCE_KAMP and FORCE_LEVELING (False).
-
FORCE_KAMP: Build an adaptive bed mesh (False). Recommended to also set
SAVE_ZMOD_DATA CLEAR=LINE_PURGE
to use the purge area for mesh calibration. - Z_OFFSET: Set Z offset (0.0).
- SKIP_ZOFFSET: For native screen printing, do not set Z offset (True for native screen / False for headless mode).
- INTERNAL: For Pro versions in headless mode: 0 = external airflow, 1 = internal recirculation (1).
Notes:
- Any calibration (FORCE_KAMP or FORCE_LEVELING) triggers CLEAR_NOZZLE.
- During START_PRINT, ZSSH_RELOAD restores SSH connections if needed.
Example for Orca with native screen: Replace the start G-code with:
START_PRINT EXTRUDER_TEMP=[nozzle_temperature_initial_layer] BED_TEMP=[bed_temperature_initial_layer_single]
M190 S[bed_temperature_initial_layer_single]
M104 S[nozzle_temperature_initial_layer]
Example for Orca in headless mode:
START_PRINT EXTRUDER_TEMP=[nozzle_temperature_initial_layer] BED_TEMP=[bed_temperature_initial_layer_single]
To display layer count correctly in Fluidd, add to the start G-code:
SET_PRINT_STATS_INFO TOTAL_LAYER=[total_layer_count]
And add to the layer change G-code:
SET_PRINT_STATS_INFO CURRENT_LAYER={layer_num + 1}
Global Flags (set via SAVE_ZMOD_DATA):
- PRECLEAR: Enable nozzle pre-cleaning in CLEAR_NOZZLE (0 = off, 1 = on).
- CLEAR: Nozzle purge method (LINE_PURGE).
- PRINT_LEVELING: Always build a bed mesh before printing (0 = off, 1 = on).
- USE_KAMP: Use adaptive mesh (KAMP) instead of full mesh (0 = off, 1 = on).
- DISABLE_PRIMING: Disable priming extrusion (0 = off, 1 = on).
- FORCE_MD5: Verify file MD5 checksums (1 = enabled by default).
- DISABLE_SKEW_CORRECT: Disable skew correction (1 = disabled).
- AUTO_REBOOT: Auto-reboot after print (0 = off, 1 = reboot, 2 = firmware restart).
- CLOSE_DIALOGS: Auto-close dialogs post-print (0 = off, 1 = slow, 2 = fast).
- STOP_MOTOR: Disable motors 25 seconds after print (1 = on).
- MIDI_START/END: Play MIDI files at print start/end ("").
Replaces the native end G-code.
Global Flags (set via SAVE_ZMOD_DATA):
- AUTO_REBOOT: Auto-reboot after print (0 = off, 1 = reboot, 2 = firmware restart).
- CLOSE_DIALOGS: Auto-close dialogs post-print (0 = off, 1 = slow, 2 = fast).
- STOP_MOTOR: Disable motors 25 seconds after print (1 = on).
- MIDI_END: Play MIDI at print end ("").
Adaptive bed leveling with nozzle cleaning.
- EXTRUDER_TEMP: Extruder temperature (240).
- BED_TEMP: Bed temperature (80).
Recommended: Use START_PRINT with SAVE_ZMOD_DATA PRINT_LEVELING=1 USE_KAMP=1
.
Full bed calibration with nozzle cleaning.
- EXTRUDER_TEMP: Extruder temperature (230).
- BED_TEMP: Bed temperature (80).
- PROFILE: Mesh profile name (auto).
Print a file with native screen bed leveling.
- FILENAME: File to print.
Requires enabling "Local Network Only" in printer settings.
Abort the current print.
Nozzle cleaning (native method).
- EXTRUDER_TEMP: Extruder temperature (230).
- BED_TEMP: Bed temperature (80).
Enable pre-cleaning via SAVE_ZMOD_DATA PRECLEAR=1
.
Turn on LED lighting.
Turn off LED lighting.
Set LED brightness.
- S: Brightness percentage (50).
Pause the print.
Resume the print.
Play a MIDI file.
-
FILE: Filename (e.g.,
For_Elise.mid
). Files are stored inmod_data/midi/
.
Reboot the printer.
Slowly close dialogs on the native screen (may cause freezes).
Quickly close dialogs on the native screen. Requires enabling "Local Network Only".
Save Klipper configuration without freezing the screen (experimental).
Resume print after power loss or errors. Disabled when using the native screen.
Bed screw adjustment using probe.
- EXTRUDER_TEMP: Extruder temperature (240).
- BED_TEMP: Bed temperature (80).
Reset strain gauge weight.
PID calibration for the bed.
- TEMPERATURE: Target temperature (80).
PID calibration for the extruder.
- TEMPERATURE: Target temperature (245).
- COOLER: Fan speed (255).
Input shaper calibration. Graphs are saved in mod_data/
.
Belt resonance analysis.
- SPECTROGRAM: Generate spectrogram (1 = enabled).
Detects part detachment or nozzle collision with the bed.
Emergency printer shutdown if weight limit is exceeded.
WEIGHT - weight in grams (1500)
Settings persist after reboot.
Set NOZZLE_CONTROL WEIGHT=0
to disable this feature.
Control is disabled until the first macro call.
When using the stock screen, executing the macro reboots the printer.
When operating without the stock screen, it restarts Klipper since configuration files are modified.
Everything works automatically, but the following macros are also available for use in Gcode:
-
ZCONTROL_ON
- activate monitoring -
ZCONTROL_OFF
- deactivate monitoring -
ZCONTROL_STATUS
- check function status -
ZCONTROL_PAUSE
- trigger pause on detection (pause executes only after command queue clears; avoid enabling on first layers) -
ZCONTROL_ABORT
- trigger KLIPPER shutdown on detection
To enable nozzle monitoring on first layers, add ZCONTROL_PAUSE
via the slicer at the layer where pause should replace abort.
Pause/trigger macro on the next layer.
- ENABLE: 0 = off, 1 = on (1).
-
MACRO: Macro to execute (
PAUSE
).
Pause/trigger macro at a specific layer.
- ENABLE: 0 = off, 1 = on (1).
-
MACRO: Macro to execute (
PAUSE
). - LAYER: Layer number (0).
Cold pull nozzle cleaning. Follow on-screen instructions.
Filament change.
AD5X only: Filament type/color management (native screen required).
Enable alternate camera.
- WIDTH: Resolution width (640).
- HEIGHT: Resolution height (480).
- FPS: Framerate (20).
-
VIDEO: Camera device (
video0
). - FS: Fix frame size for unstable cameras (0 = off).
Disable alternate camera.
Restart alternate camera.
View current ZMOD parameters.
Save global ZMOD parameters (persistent after reboots).
Usage:
SAVE_ZMOD_DATA PARAMETER=value
Example:
SAVE_ZMOD_DATA CLOSE_DIALOGS=2
Play MIDI at print start (""). Use 0
to disable.
Example: SAVE_ZMOD_DATA MIDI_START=Pain-Shut-your-mouth.mid
Enable nozzle pre-cleaning in CLEAR_NOZZLE.
-
0
= Disabled (default) -
1
= Enabled Example:SAVE_ZMOD_DATA PRECLEAR=0
Always build a bed mesh before printing (using the native screen if enabled).
-
0
= Disabled (default) -
1
= Enabled *To use native screen bed leveling, enable "Local Network Only" in printer settings:Settings
→WiFi icon
→Network Mode
→ Toggle "Local Network Only.* **Example:**
SAVE_ZMOD_DATA PRINT_LEVELING=1`
Use adaptive bed mesh (KAMP) instead of full mesh where possible.
-
0
= Disabled (default) -
1
= Enabled Recommended to setSAVE_ZMOD_DATA CLEAR=LINE_PURGE
to use the purge area for mesh calibration. Example:SAVE_ZMOD_DATA USE_KAMP=1
Test bed mesh before printing.
-
0
= Disabled -
1
= Enabled (default) Probes the bed to verify the loaded mesh matches the physical setup. Triggers a warning if deviations exceed ±0.21mm. Example:SAVE_ZMOD_DATA MESH_TEST=0
Validate file integrity using MD5 checksums. Corrupted files are deleted.
-
0
= Disabled -
1
= Enabled (default) Add addMD5.bat (Windows) or addMD5.sh (Linux) to post-processing scripts in your slicer. Example:SAVE_ZMOD_DATA FORCE_MD5=1
Disable skew correction.
-
0
= Loadskew_profile
(default) -
1
= Disabled Learn more Example:SAVE_ZMOD_DATA DISABLE_SKEW_CORRECT=1
Load saved Z-offset from SET_GCODE_OFFSET
.
-
0
= Disabled -
1
= Enabled (default) How Z-offset works Example:SAVE_ZMOD_DATA LOAD_ZOFFSET=0
Disable nozzle priming extrusion.
-
0
= Enabled (default) -
1
= Disabled Example:SAVE_ZMOD_DATA DISABLE_PRIMING=0
Select nozzle purge method:
-
_CLEAR1
: Orca-style (may scratch bed with KAMP) -
_CLEAR2
: FF group variant 1 (may scratch bed) -
_CLEAR3
: FF group variant 2 (may scratch bed) -
_CLEAR4
: Top-right to bottom-left wipe -
_CLEAR_TRAP
: Brush-assisted wipe (top-right) -
LINE_PURGE
: KAMP purge (default) Custom purge macros can be added tomod_data/user.cfg
. Example:SAVE_ZMOD_DATA CLEAR=LINE_PURGE
Play MIDI at print end (""). Use 0
to disable.
Example: SAVE_ZMOD_DATA MIDI_END=Pain-Shut-your-mouth.mid
Auto-close print completion dialogs.
-
0
= Disabled (default) -
1
= Slow close -
2
= Fast close Enable "Local Network Only" for fast closing. Example:SAVE_ZMOD_DATA CLOSE_DIALOGS=2
Disable motors 25 seconds after print/cancel.
-
0
= Disabled -
1
= Enabled (default) Example:SAVE_ZMOD_DATA STOP_MOTOR=1
Auto-reboot after print:
-
0
= Disabled (default) -
1
= Full reboot (REBOOT
) -
2
= Firmware restart (FIRMWARE_RESTART
for headless mode) Example:SAVE_ZMOD_DATA AUTO_REBOOT=0
Use filament motion sensor instead of filament runout sensor.
-
0
= Disabled (default) -
1
= Enabled Disable native filament sensor on the screen. Example:SAVE_ZMOD_DATA MOTION_SENSOR=1
Correct square_corner_velocity in shaper graphs.
-
0
= Stock value (5
, default) -
1
= Use value frommod_data/user.cfg
Recommended: Addsquare_corner_velocity: 9
tomod_data/user.cfg
for better print quality. Example:SAVE_ZMOD_DATA FIX_SCV=1
This is an experimental parameter
Global causes of E0011 error:
- Host did not respond within allotted time (0.025 sec)
- MCU did not respond within allotted time (0.025 sec)
Specific causes:
- Frozen Nations MCU mainboard or eboard (
Lost communication with MCU 'mcu'
). Fix: Reboot. Replace mainboard (mcu
) or extruder board (eboard
). - Host processor overload (shaper calculations/graph generation).
- EMMC overload (git operations, backups, large file uploads during printing).
- Insufficient RAM. Fix: Re-solder CPU and upgrade RAM to 256 MB.
- Damaged extruder cable. Fix: Replace/adjust cable.
- Extruder head board connector issues. Fix: Replace extruder board.
- SWAP data loading (SWAP on EMMC with 10 MB/s speed; SWAP usage during shaper generation reaches 25 MB).
Fix: Disable SWAP if using 256 MB RAM:
SAVE_ZMOD_DATA USE_SWAP=0
. - MCU firmware failure. Fix: Reflash MCU via factory reset or use mod UPDATE_MCU.
Fix E0011 and Communication timeout during homing
:
Printer reboots when changing parameter. 0=No, 1=Yes (default: 0)
-
0
keeps stock value: 0.025 -
1
sets value to: 0.05
Example: SAVE_ZMOD_DATA FIX_E0011=1
About Communication timeout during homing
:
Occurs due to high latency between host and MCUs. Round-trip time should consistently stay below 10 ms. Short latency spikes can cause homing failures.
TRSYNC_TIMEOUT (Klipper parameter):
- Stock value:
0.025
sec (file:/opt/klipper/klippy/mcu.py
) - Patched value:
0.05
sec
Stock firmware fix:
- Format USB as FAT32.
- Save to USB flash:
- Power off printer.
- Insert USB into printer.
- Power on printer (loud beeping will occur).
- Wait for reboot.
- Remove USB.
- Reprint problematic file — E0011 should resolve.
Manual stock firmware fix:
- Install root.
- Connect via WinSCP over SSH.
- Edit
/opt/klipper/klippy/mcu.py
. - Find line:
TRSYNC_TIMEOUT = 0.025
. - Replace with:
TRSYNC_TIMEOUT = 0.05
. - Save file.
- Reboot printer.
Fix E0017 error - printer will reboot when changing parameter. 0=No, 1=Yes (1)
In file /opt/klipper/klippy/toolhead.py
:
Stock parameter LOOKAHEAD_FLUSH_TIME = 0.5
, original Klipper uses LOOKAHEAD_FLUSH_TIME = 0.250
.
Our modification works well with LOOKAHEAD_FLUSH_TIME = 0.150
- 0 sets parameter to stock value
- 1 sets parameter to 0.150
Example: SAVE_ZMOD_DATA FIX_E0017=1
Stock firmware fix:
- Format USB as FAT32
- Save to USB flash:
- Adventurer5M-e0017-4.tgz for FlashForge 5M
- Adventurer5MPro-e0017-4.tgz for FlashForge 5M Pro
- Power off printer
- Insert USB into printer
- Power on printer
- Printer will beep loudly
- Wait for automatic reboot
- Remove USB flash
- Reprint problematic file - E0017 error should be resolved
Manual stock firmware fix:
- Install root
- Connect via WinSCP over SSH
- Edit file
/opt/klipper/klippy/toolhead.py
- Find line:
LOOKAHEAD_FLUSH_TIME = 0.5
- Replace with:
LOOKAHEAD_FLUSH_TIME = 0.150
- Save file to printer
- Reboot printer
LED brightness at startup (50%).
Example: SAVE_ZMOD_DATA LED=50
Play MIDI at printer startup (""). Use 0
to disable.
Example: SAVE_ZMOD_DATA MIDI_ON=Pain-Shut-your-mouth.mid
Use non-freezing SAVE_CONFIG
for PID calibration.
-
0
= Disabled (default) -
1
= Enabled Example:SAVE_ZMOD_DATA NEW_SAVE_CONFIG=0
Enable swap memory:
-
0
= Disabled (requires 256MB RAM) -
1
= Use EMMC (default) -
2
= Prefer USB flash Example:SAVE_ZMOD_DATA USE_SWAP=1
Enable Chinese cloud services: 0=No, 1=Yes (default: 0)
Example: SAVE_ZMOD_DATA CHINA_CLOUD=0
Disabling Chinese clouds (recommended)
Important:
Even if all cloud-related options are disabled via the printer interface, the device may still attempt to send photos, videos, and telemetry to Chinese servers. Setting this parameter to 0
partially blocks these manufacturer-background activities.
- Re-enable cloud services:
SAVE_ZMOD_DATA CHINA_CLOUD=1
- Reboot the printer
- Perform firmware update
- Format USB drive as FAT32
- Download file: flashforge_init.sh (disable cloud)
- Copy the file to the USB drive
- Power off the printer
- Insert USB into the printer
- Power on the printer
- Wait for 1 reboot cycle
- Remove USB drive
- Format USB drive as FAT32
- Download file: flashforge_init.sh (enable cloud)
- Copy the file to the USB drive
- Follow steps 4-8 above
Set Klipper process priority (1-40, higher = more resources). Default: 20
.
Example: SAVE_ZMOD_DATA NICE=20
Native screen timeout in headless mode (seconds). Default: 180
.
Example: SAVE_ZMOD_DATA DISPLAY_OFF_TIMEOUT=120
Auto-poweroff timer for FF5M Pro (minutes). 0
= Disabled.
Example: SAVE_ZMOD_DATA PRO_POWEROFF_TIMEOUT=10
Custom macro button layouts:
-
0
= Use ZMOD defaults (default) -
1
= Allow user-defined layouts Example:SAVE_ZMOD_DATA SAVE_MOONRAKER=1
Remove zmod.
-
FULL: 0 – keep the
/opt/config/mod_data
folder, 1 – delete the/opt/config/mod_data
folder (0)
The /opt/config/mod_data
folder stores configurations for zmod
, fluidd
, moonraker
, and mainsail
.
By default, it is not deleted because users often accidentally run the REMOVE_ZMOD
macro.
Reboot into the original system without launching zmod.
Disables configuration files for ZMOD, Moonraker, and Fluidd.
The following remain active:
- Alternative camera
- SSH
Enable native screen.
Disable native screen (saves RAM).
Show memory usage.
Test EMMC/USB/SWAP performance.
Clear logs/GCODE.
Show current time.
Set system time.
Switch between Fluidd and Mainsail.
Configure timezone.
Backup logs and configs.
Restores configuration files from the config.tar
archive
The archive must be loaded in 'Configuration' -> 'mod_data' -> config.tar
Update ZMOD via USB.
Stop Moonraker/Fluidd.
Start Moonraker/Fluidd.
Validate file checksums.
Update MCU firmware.
Verify OS file integrity.
Enable SSH server.
- SSH_SERVER: SSH server IP.
- SSH_PORT: SSH port.
- SSH_USER: SSH username.
- VIDEO_PORT: Camera port.
- MOON_PORT: Moonraker port.
Disable SSH server.
Restart SSH server.
Reload SSH configuration.
Add your SSH public key to authorized_keys
on the printer.
Run ZSSH_ON
on the printer.
Power off the printer.
Uninstall ZMOD.
-
FULL=0
: Keep/opt/config/mod_data
(default). -
FULL=1
: Delete all configs.
Reboot into stock firmware (disables ZMOD services).
Enable native screen and reboot.
Disable native screen to save RAM.
-
GUPPY=0
: Disable GuppyScreen. -
GUPPY=1
: Enable GuppyScreen (default).
Show memory usage.
Test storage performance.
-
SIZE
: Data size in MB (100). -
SYNC
: Sync mode (1 = enabled). -
FLASH
: Test target (0
=EMMC,1
=USB,2
=RAM). -
RANDOM
: Use random data (0
=off).
Clear logs/files.
-
LOG=1
: Clear logs (default). -
ANY=1
: Clear all non-log files.
Show current time.
Set system time (format: YYYY.MM.DD-HH:MM:SS
).
Example: DATE_SET DT=2024.01.01-00:00:00
Switch between Fluidd and Mainsail.
Set timezone.
Example: SET_TIMEZONE ZONE=Asia/Yekaterinburg
Backup configs to mod_data/config.tar
.
Update ZMOD via USB.
Stop Moonraker/Fluidd services.
Restart Moonraker/Fluidd.
Validate G-code MD5 checksums.
-
DELETE=yes
: Delete corrupted files.
Experimental - Update MCU firmware (Klipper v12).
Verify OS file integrity.
-
RESTORE=1
: Auto-repair files.
Enable SSH tunneling to remote server.
-
SSH_SERVER
: Server IP/hostname. -
SSH_PORT
: SSH port (22). -
SSH_USER
: Remote username. -
VIDEO_PORT
: Camera port (8080). -
MOON_PORT
: Moonraker port (7125). -
REMOTE_RUN
: Command to execute on server (e.g.,./ff5m.sh bot1
).
Disable SSH tunneling.
Restart SSH tunnel.
Reload SSH config (called automatically during prints).
Due to the printer's limited hardware resources (slow CPU and low RAM), running moonraker-telegram-bot directly on the printer is impractical. Instead, the bot is deployed on an external server.
Requirements:
- A server (physical/virtual) accessible via SSH from the printer.
Automatic SSH Key Generation: ZMOD automatically creates SSH keys for passwordless authentication:
- Public key:
/mod_data/ssh.pub.txt
→ Add to server's~/.ssh/authorized_keys
. - Private key:
/mod_data/ssh.key
→ Used by the printer for SSH connections.
Setup via Macro: Use the ZSSH_ON macro with these parameters:
-
SSH_SERVER
: Server IP/hostname. -
SSH_PORT
: SSH port (usually 22). -
SSH_USER
: Server username. -
VIDEO_PORT
: Camera stream port (default: 8080). -
MOON_PORT
: Moonraker API port (default: 7125). -
REMOTE_RUN
: Command to execute on the server (e.g.,./ff5m.sh bot1
).
Note: SSH consumes ~300KB of memory. If the printer and server are on the same LAN, SSH tunneling is optional. Configure directly via telegram.conf (located in mod/telegram/
on the printer).
- Visit @BotFather on Telegram.
- Send
/newbot
. - Choose a display name (e.g., "My Printer Bot").
- Choose a bot username ending with
_bot
(e.g.,ff5msuper_bot
). - Copy the provided
bot_token
for server configuration.
Run as root
:
bash <(wget --cache=off -qO- https://github.com/ghzserg/zmod_ff5m/raw/1.5/telegram/telegram.sh)
Script Actions:
- Installs Docker.
- Downloads
docker-compose.yml
andtelegram.conf
- Creates
tbot
user. - Guides through bot setup (requires
bot_token
andchat_id
). - Installs ff5m.sh.
Manually add the SSH public key from mod_data/ssh.pub.txt
to the server.
- Install Docker:
apt update && apt install docker.io docker-compose apparmor -y
- Create bot directory:
mkdir bot1 && cd bot1
- Add docker-compose.yml and telegram.conf.
- Configure
telegram.conf
with yourbot_token
andchat_id
. - Start the bot:
docker-compose up -d
- Create a dedicated user:
useradd tbot && usermod -aG docker tbot
- Switch to
tbot
user:su - tbot
- Add public key:
mkdir -p .ssh echo "PASTE_PUBLIC_KEY_HERE" > .ssh/authorized_keys
Run the ZSSH_ON macro on the printer with your server details. SSH tunnels automatically restart 3 minutes after reboots.
Example:
ZSSH_ON SSH_SERVER=192.168.1.100 SSH_USER=tbot VIDEO_PORT=8080 MOON_PORT=7125 REMOTE_RUN="./ff5m.sh bot1"
- Главная страница | Home Page
- История версий | Version History
- Часто задаваемые вопросы | Frequently Asked Questions
- Рекомендации по повышению стабильности работы принтера | Recommendations for Improving Printer Stability
- Список Макросов | List of Macros
- Установка/Обновление/Удаление мода/Восстановление загрузки | Installation/Update/Removal/Boot Recovery
На развитие мода | Support Mod Development: BTC 17wXTd9BqYp1K3zCLTxVyGLEXUDjf7XNLL