Skip to content

Commit

Permalink
v5.0.0 #181 from Frix-x/develop
Browse files Browse the repository at this point in the history
v5.0.0
  • Loading branch information
Frix-x authored Dec 30, 2024
2 parents 66f5e32 + ba6541d commit 74364d7
Show file tree
Hide file tree
Showing 36 changed files with 3,794 additions and 3,078 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,18 @@ jobs:
klipper_repo:
- klipper3d/klipper
- DangerKlippers/danger-klipper
klipper_version:
- master
- v0.12.0
python_version:
- '3.9' # Debian Bullseye default
- '3.11' # Debian Bookworm default
# Below disabled - Greenlet upstream version not compatable with py 3.12
# - '3.12' # Latest Released as of 2024/9
steps:
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Checkout shaketune
uses: actions/checkout@v4
with:
Expand All @@ -23,11 +34,11 @@ jobs:
with:
path: klipper
repository: ${{ matrix.klipper_repo }}
ref: master
ref: ${{ matrix.klipper_version }}
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y build-essential gcc-avr avr-libc
- name: Build klipper dict
run: |
pushd klipper
Expand All @@ -50,7 +61,7 @@ jobs:
run: |
pushd klipper
mkdir ../dicts
cp ../klipper/out/klipper.dict ../dicts/linux_basic.dict
cp ../klipper/out/klipper.dict ../dicts/atmega2560.dict
../klippy-env/bin/python scripts/test_klippy.py -d ../dicts ../shaketune/ci/smoke-test/klippy-tests/simple.test
lint:
runs-on: ubuntu-latest
Expand Down
7 changes: 7 additions & 0 deletions MAINTNENCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## When a new stable version of klipper is released:

In `.github/workflows/test.yaml`, update `jobs.klippy_testing.strategy.matrix.klipper_version` to include the new version.

## When a new version of python becomes supported by klipper

In `.github/workflows/test.yaml`, update `jobs.klippy_testing.strategy.matrix.python_version` to include the new version.
46 changes: 35 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,42 @@ Follow these steps to install Shake&Tune on your printer:
```
[shaketune]
# result_folder: ~/printer_data/config/ShakeTune_results
# The folder where the results will be stored. It will be created if it doesn't exist.
# number_of_results_to_keep: 3
# The number of results to keep in the result_folder. The oldest results will
# be automatically deleted after each runs.
# keep_raw_csv: False
# If True, the raw CSV files will be kept in the result_folder alongside the
# PNG graphs. If False, they will be deleted and only the graphs will be kept.
# Path where the processed results will be stored. If the folder doesn't exist,
# it will be automatically created. You can change this if you'd like to store
# results in a different location.
# number_of_results_to_keep: 10
# This setting defines how many results you want to keep in the result folder.
# Once the specified number is exceeded, older results will be automatically deleted
# to free up space on the SD card and avoid cluttering the results folder.
# keep_raw_data: False
# If set to True, Shake&Tune will store both the processed graphs and the raw accelerometer
# .stdata files in the results folder. This can be useful for debugging or archiving purposes.
# Please always attach them when reporting any issues on GitHub or Discord.
# show_macros_in_webui: True
# Mainsail and Fluidd doesn't create buttons for "system" macros that are not in the
# printer.cfg file. If you want to see the macros in the webui, set this to True.
# timeout: 300
# The maximum time in seconds to let Shake&Tune process the CSV files and generate the graphs.
# Mainsail and Fluidd doesn't create buttons for system commands (macros that are not part
# of the printer.cfg file). This option allow Shake&Tune to inject them into the webui at runtime.
# If set to False, the macros will be hidden but still accessible from the console by typing
# their names manually, which can be useful if you prefer to encapsulate them into your own macros.
# timeout: 600
# This defines the maximum processing time (in seconds) to allows to Shake&Tune for generating
# graphs from a .stdata file. 10 minutes should be more than enough in most cases, but if you have
# slower hardware (e.g., older SD cards or low-performance devices), increase it to prevent timeouts.
# measurements_chunk_size: 2
# Each Shake&Tune command uses the accelerometer to take multiple measurements. By default,
# Shake&Tune will write a chunk of data to disk every two measurements, and at the end of the
# command will merge these chunks into the final .stdata file for processing. "2" is a very
# conservative setting to avoid Klipper Timer Too Close errors on lower end devices with little
# RAM, and should work for everyone. However, if you are using a powerful computer, you may
# wish to increase this value to keep more measurements in memory (e.g., 15-20) before writing
# the chunk and avoid stressing the filesystem too much.
# max_freq: 200
# This setting defines the maximum frequency at which the calculation of the power spectral density
# is cutoff. The default value should be fine for most machines and accelerometer combinations and
# avoid touching it unless you know what you're doing.
# dpi: 300
# Controls the resolution of the generated graphs. The default value of 300 dpi was optimized
# and strikes a balance between performance and readability, ensuring that graphs are clear
# without using too much RAM to generate them. Usually, you shouldn't need to change this value.
```

Don't forget to check out **[Shake&Tune documentation here](./docs/README.md)**.
38 changes: 4 additions & 34 deletions ci/smoke-test/klipper-smoketest.kconfig
Original file line number Diff line number Diff line change
@@ -1,34 +1,4 @@
CONFIG_LOW_LEVEL_OPTIONS=y
# CONFIG_MACH_AVR is not set
# CONFIG_MACH_ATSAM is not set
# CONFIG_MACH_ATSAMD is not set
# CONFIG_MACH_LPC176X is not set
# CONFIG_MACH_STM32 is not set
# CONFIG_MACH_HC32F460 is not set
# CONFIG_MACH_RP2040 is not set
# CONFIG_MACH_PRU is not set
# CONFIG_MACH_AR100 is not set
CONFIG_MACH_LINUX=y
# CONFIG_MACH_SIMU is not set
CONFIG_BOARD_DIRECTORY="linux"
CONFIG_CLOCK_FREQ=50000000
CONFIG_LINUX_SELECT=y
CONFIG_USB_VENDOR_ID=0x1d50
CONFIG_USB_DEVICE_ID=0x614e
CONFIG_USB_SERIAL_NUMBER="12345"
CONFIG_WANT_GPIO_BITBANGING=y
CONFIG_WANT_DISPLAYS=y
CONFIG_WANT_SENSORS=y
CONFIG_WANT_LIS2DW=y
CONFIG_WANT_LDC1612=y
CONFIG_WANT_SOFTWARE_I2C=y
CONFIG_WANT_SOFTWARE_SPI=y
CONFIG_NEED_SENSOR_BULK=y
CONFIG_CANBUS_FREQUENCY=1000000
CONFIG_INITIAL_PINS=""
CONFIG_HAVE_GPIO=y
CONFIG_HAVE_GPIO_ADC=y
CONFIG_HAVE_GPIO_SPI=y
CONFIG_HAVE_GPIO_I2C=y
CONFIG_HAVE_GPIO_HARD_PWM=y
CONFIG_INLINE_STEPPER_HACK=y
# Base Kconfig file for atmega2560
CONFIG_MACH_AVR=y
CONFIG_MACH_atmega2560=y
CONFIG_CLOCK_FREQ=16000000
82 changes: 79 additions & 3 deletions ci/smoke-test/klippy-tests/simple.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,85 @@
# Test config with a minimal setup to have kind
# of a machine ready with an ADXL345 and an MPU9250
# to have the required the resonance_tester section
# and allow loading and initializing Shake&Tune into Klipper

[stepper_x]
step_pin: PF0
dir_pin: PF1
enable_pin: !PD7
microsteps: 16
rotation_distance: 40
endstop_pin: ^PE5
position_endstop: 0
position_max: 200
homing_speed: 50

[stepper_y]
step_pin: PF6
dir_pin: !PF7
enable_pin: !PF2
microsteps: 16
rotation_distance: 40
endstop_pin: ^PJ1
position_endstop: 0
position_max: 200
homing_speed: 50

[stepper_z]
step_pin: PL3
dir_pin: PL1
enable_pin: !PK0
microsteps: 16
rotation_distance: 8
endstop_pin: ^PD3
position_endstop: 0.5
position_max: 200

[extruder]
step_pin: PA4
dir_pin: PA6
enable_pin: !PA2
microsteps: 16
rotation_distance: 33.5
nozzle_diameter: 0.500
filament_diameter: 3.500
heater_pin: PB4
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PK5
control: pid
pid_Kp: 22.2
pid_Ki: 1.08
pid_Kd: 114
min_temp: 0
max_temp: 210

[heater_bed]
heater_pin: PH5
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PK6
control: watermark
min_temp: 0
max_temp: 110

[mcu]
serial: /tmp/klipper_host_mcu
serial: /dev/ttyACM0

[printer]
kinematics: none
kinematics: cartesian
max_velocity: 300
max_accel: 300
max_accel: 3000
max_z_velocity: 5
max_z_accel: 100

[adxl345]
cs_pin: PK7
axes_map: -x,-y,z

[mpu9250 my_mpu]

[resonance_tester]
probe_points: 20,20,20
accel_chip_x: adxl345
accel_chip_y: mpu9250 my_mpu

[shaketune]
2 changes: 1 addition & 1 deletion ci/smoke-test/klippy-tests/simple.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DICTIONARY linux_basic.dict
CONFIG simple.cfg
DICTIONARY atmega2560.dict

G4 P1000
6 changes: 6 additions & 0 deletions docs/is_tuning_generalities.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ While you should usually try to focus on the toolhead/belts mechanical subsystem
1. **Diagnosis phase**: Begin with the nozzle tip mount to identify and troubleshoot mechanical issues to ensure the printer components are healthy and the assembly is well done and optimized.
1. **Filter selection phase**: If the graphs are mostly clean, you can transition to a mounting point near the toolhead's center of gravity for cleaner data on the main resonance, facilitating accurate Input Shaping filter settings. You can also consider the CANBus integrated accelerometer for its simplicity, especially if the toolhead is particularly rigid and minimally affected by wobble.

### Should I use the sweeping or pulse-only test?

The "sweeping" test superimposes a slow motion sweep on top of the usual back-and-forth pulses of the original test. This causes the toolhead (and stepper motors) to pass through multiple positions, rather than getting stuck on the same motor steps, rotor angle, and kinematic position. The added benefit is that it can help filter out some of the random motor and mechanical noise in the measurement, especially on less rigid machines, which can be problematic with the original test. This can help focus on only the "toolhead on belts" resonance peak, which is the most important one, and prevent the recommendation results from being muddled by extra vibration and noise you might have on the graph. It can be seen as a complementary solution to placing your accelerometer right at the center of gravity of the toolhead: you'll end up with a cleaner signal.

On the other hand, if you're looking for mechanical problems (like a wobbly toolhead, binding axis, loose belts, or other gremlins), the pulse-only mode can actually be more revealing. In fact, because the sweep mode smooths things out, it can hide some of the problems you want to find and fix. So if you're in full diagnostic mode, my advice is to use the pulse-only test and try placing the accelerometer in different places, like the nozzle tip, to better see the problems and fix them. Once everything is fixed, if there's still a bit of noise on your graphs, you can switch back to sweep mode for one last nice, clean reading.


## Theory behind it

Expand Down
6 changes: 6 additions & 0 deletions docs/macros/axes_shaper_calibrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ Then, call the `AXES_SHAPER_CALIBRATION` macro and look for the graphs in the re
|MAX_SMOOTHING|None|max smoothing allowed when calculating shaper recommendations|
|TRAVEL_SPEED|120|speed in mm/s used for all the travel movements (to go to the start position prior to the test)|
|Z_HEIGHT|None|Z height wanted for the test. This value can be used if needed to override the Z value of the probe_point set in your `[resonance_tester]` config section|
|MAX_SCALE|None|Maximum energy value to scale the input shaper graph. Useful for comparing multiple consecutive tests by forcing the same energy scale|


> **Note**
>
> If you are wondering wether you should use sweeping or not, have a read on the [dedicated section here](../is_tuning_generalities.md#should-i-use-the-sweeping-or-pulse-only-test).
![](../images/shaper_graphs/shaper_graph_explanation.png)

Expand Down
5 changes: 5 additions & 0 deletions docs/macros/compare_belts_responses.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ Then, call the `COMPARE_BELTS_RESPONSES` macro and look for the graphs in the re
|ACCEL_PER_HZ|None (default to `[resonance_tester]` value)|accel per Hz value used for the test|
|TRAVEL_SPEED|120|speed in mm/s used for all the travel movements (to go to the start position prior to the test)|
|Z_HEIGHT|None|Z height wanted for the test. This value can be used if needed to override the Z value of the probe_point set in your `[resonance_tester]` config section|
|MAX_SCALE|None|Maximum energy value to scale the belts graph. Useful for comparing multiple consecutive tests by forcing the same energy scale|

> **Note**
>
> If you are wondering wether you should use sweeping or not, have a read on the [dedicated section here](../is_tuning_generalities.md#should-i-use-the-sweeping-or-pulse-only-test).
![](../images/belts_example.png)

Expand Down
16 changes: 14 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
USER_CONFIG_PATH="${HOME}/printer_data/config"
MOONRAKER_CONFIG="${HOME}/printer_data/config/moonraker.conf"
KLIPPER_PATH="${HOME}/klipper"
KLIPPER_VENV_PATH="${HOME}/klippy-env"
KLIPPER_VENV_PATH="${KLIPPER_VENV:-${HOME}/klippy-env}"

OLD_K_SHAKETUNE_VENV="${HOME}/klippain_shaketune-env"
K_SHAKETUNE_PATH="${HOME}/klippain_shaketune"
Expand Down Expand Up @@ -124,7 +124,19 @@ function add_updater {
update_section=$(grep -c '\[update_manager[a-z ]* Klippain-ShakeTune\]' $MOONRAKER_CONFIG || true)
if [ "$update_section" -eq 0 ]; then
echo -n "[INSTALL] Adding update manager to moonraker.conf..."
cat ${K_SHAKETUNE_PATH}/moonraker.conf >> $MOONRAKER_CONFIG
cat <<EOF >>$MOONRAKER_CONFIG
## Klippain Shake&Tune automatic update management
[update_manager Klippain-ShakeTune]
type: git_repo
origin: https://github.com/Frix-x/klippain-shaketune.git
path: ~/klippain_shaketune
virtualenv: ${KLIPPER_VENV_PATH}
requirements: requirements.txt
system_dependencies: system-dependencies.json
primary_branch: main
managed_services: klipper
EOF
fi
}

Expand Down
11 changes: 0 additions & 11 deletions moonraker.conf

This file was deleted.

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ matplotlib==3.8.2
numpy==1.26.2
scipy==1.11.4
PyWavelets==1.6.0
zstandard==0.23.0
Loading

0 comments on commit 74364d7

Please sign in to comment.