diff --git a/.gitignore b/.gitignore index c66668c..efc73b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ klippy-env *_history out -*.bkp \ No newline at end of file +*.bkp +resonances \ No newline at end of file diff --git a/README.md b/README.md index 0fd4551..ee63052 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,38 @@ docker compose --profile up -d ``` ## Advanced Topics +### Input Shaper Calibration +Note: +>Running a host_mcu process on a RaspberryPi to access its GPIO pins is currently not possible when running in Docker. +Feel free to contribute if you have a Solution for this. + +Using input shaper requires an accelerometer that is directly connected to your printers mainboard. Follow the Docs on [Measuring Resonances](https://www.klipper3d.org/Measuring_Resonances.html), to set up your Printer accordingly. + +After running `TEST_RESONANCES` or `SHAPER_CALIBRATE`, Klipper generates csv output in /tmp. To further analyze this data, it has to be extracted from the running klipper container. +``` +mkdir ./resonances + +docker compose exec klipper ls /tmp + resonances_x_20220708_124515.csv resonances_y_20220708_125150.csv + +docker compose cp klipper:/tmp/resonances_x_20220708_124515.csv ./resonances/ +docker compose cp klipper:/tmp/resonances_y_20220708_125150.csv ./resonances/ +``` + +`docker-compose.calibrate-shaper.yaml` is set up to run `calibrate_shaper.py`, so any options supported by the script can also be used with the container. +Set an alias to save yourself from typing the the docker compose command multiple times. The generated Images are located besides the csv files in `./resonances` +``` +alias calibrate_shaper="docker compose -f docker-compose.calibrate-shaper.yaml run --rm calibrate_shaper" + +calibrate_shaper resonances_x_20220708_124515.csv -o cal_x.png + [...] + Recommended shaper is ei @ 90.2 Hz + +calibrate_shaper resonances_y_20220708_125150.csv -o cal_y.png + [...] + Recommended shaper is mzv @ 48.2 Hz +``` + ### Change Execution Options The Entrypoint for all Docker Images within this Repo are the actual Applications, which are run at container execution time. This makes it possible to set command line Arguments for the Apps as Docker Command. diff --git a/docker-compose.calibrate-shaper.yaml b/docker-compose.calibrate-shaper.yaml new file mode 100644 index 0000000..6ad82f7 --- /dev/null +++ b/docker-compose.calibrate-shaper.yaml @@ -0,0 +1,7 @@ +services: + calibrate_shaper: + image: mkuf/klipper:${TAG:-latest}-mcu + entrypoint: python3 /opt/klipper/scripts/calibrate_shaper.py + working_dir: /opt/resonances + volumes: + - ./resonances:/opt/resonances \ No newline at end of file diff --git a/docker/klipper/Dockerfile b/docker/klipper/Dockerfile index e0d50cd..f78dc62 100644 --- a/docker/klipper/Dockerfile +++ b/docker/klipper/Dockerfile @@ -12,6 +12,7 @@ RUN git clone ${REPO} klipper \ RUN virtualenv -p python2 venv \ && venv/bin/pip install -r klipper/scripts/klippy-requirements.txt \ + && venv/bin/pip install numpy \ && venv/bin/python -m compileall klipper/klippy \ && venv/bin/python klipper/klippy/chelper/__init__.py @@ -40,6 +41,7 @@ WORKDIR /opt COPY --from=build /opt/klipper ./klipper COPY --from=build /opt/venv ./venv +ARG DEBIAN_FRONTEND=noninteractive RUN apt update \ && apt install -y \ virtualenv python-dev libffi-dev build-essential \ @@ -48,6 +50,7 @@ RUN apt update \ avrdude gcc-avr binutils-avr avr-libc \ stm32flash libnewlib-arm-none-eabi \ gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0 \ + python3-numpy python3-matplotlib \ && apt clean ## Build klipper.elf for Simulavr and Simulavr itself