Motor synchronization on printers with QuadXY kinematics (AWD) - altzbox/motors_sync GitHub Wiki
The project also moved to a real programmer :).
https://github.com/MRX8024/motors-sync
The script adjusts the position of the shaft on the X1/Y1 motor and uses an accelerometer to measure "impacts" when X/Y motor activated.
- Installing the script on a host with Klipper:
Create a directory:
mkdir scripts
Copy the script files motors_sync.py and motors_sync.sh into this directory.
In the motors_sync.py file in line 13return np.sqrt(accel_x**2 + accel_y**2 + accel_z**2)it is necessary to exclude the accelerometer axis perpendicular to the ground in order to reduce the accelerometer noise level. For example, if the Z axis of the accelerometer is perpendicular to the ground, then the line should look like thisreturn np.sqrt(accel_x**2 + accel_y**2).
Go to the scripts directory:
cd scripts
Grant execution permissions:
chmod +x motors_sync.py
chmod +x motors_sync.sh
Install the necessary libraries:
sudo apt update
sudo apt install python3-scipy python3-pandas python3-numpy
- Install the macro in Klipper.
To run the script from Klipper, you need the G-Code Shell Command Extension, which is installed through KIAUH in the Advanced section.
Copy the file motors_sync.cfg to the directory with printer.cfg.
Add the following lines to printer.cfg:
[include motors_sync.cfg]
[force_move]
enable_force_move: True
[respond]
default_type: echo
default_prefix:
Pay attention to the paths in motors_sync.sh and motors_sync.cfg. Yours may be different.
If the macro does not run, then running "sh /home/klipper/scripts/motors_sync.sh" from the host console will help to detect the problem.
-
Mount the accelerometer on the print head. It is assumed that synchronization will be carried out before the start of each print.
-
Motor synchronization:
Run the MOTORS_SYNC macro and wait for the process to complete.
Notes:
- Synchronization accuracy - 1/16 step.
- The more desynchronized the motors are, the longer the synchronization takes. In the worst case I spent 4 minutes.
- It is possible to speed up the process by reducing the number of iterations, but first I need feedback from users.
- It is possible to run the macro at the beginning of printing while the bed is heating up. To do this you need to change the pause macro. Example:
[gcode_macro PAUSE]
rename_existing: BASE_PAUSE
gcode:
{% set sync_motors = params.SYNC_MOTORS|default(0)|int %}
SET_IDLE_TIMEOUT TIMEOUT=43200
{% if sync_motors == 1 %}
G1 X10 Y10 Z10 F16500
SAVE_GCODE_STATE NAME=PAUSESYNC
BASE_PAUSE
MOTORS_SYNC
{% else %}
_Your pause macro_
{% endif %}
[gcode_macro RESUME]
rename_existing: BASE_RESUME
gcode:
{% set sync_motors = params.SYNC_MOTORS|default(0)|int %}
SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout}
{% if sync_motors == 1 %}
RESTORE_GCODE_STATE NAME=PAUSESYNC MOVE=1 MOVE_SPEED=275
BASE_RESUME
{% else %}
_Your resume macro_
{% endif %}
And at the beginning of the print start macro, set:
M140 S[bed_temperature_initial_layer_single] ;set bed temp
G28
PAUSE SYNC_MOTORS=1
G28
M190 S[bed_temperature_initial_layer_single] ; wait for bed temp to stabilize
Here is my pause and resume macros.
- Do not turn on the hotend heating during synchronization. In my case, when the hotend heating was turned on, the accelerometer noise level increased. Vibrations in the electronics compartment (power supply fans, etc.) can also affect the accelerometer.