Skip to main content

Accelerometer Usage

Usage Tutorial

Accelerometer Testing and Calibration

Dependency Package Installation

Notes
  • If the device is running the FlyOS-FAST system, the required dependencies are pre-installed, this step can be skipped.
  • If using a non-FLY host computer, please be sure to complete the following installation.
  • It is recommended to connect using SSH tools such as MobaXterm or PuTTY before proceeding.
  • This tutorial is based on the Raspberry Pi; other platforms are for reference only.

Installation Steps

  1. Execute the following commands sequentially to install the dependency packages.
  2. The installation time depends on CPU performance and network conditions, typically taking 10–20 minutes. Please wait patiently until the installation is complete.
  3. If the device's RAM is too small, installation may fail.

Step 1: Install system dependency packages

sudo apt install python3-numpy python3-matplotlib libatlas-base-dev

Step 2: Install Klipper virtual environment dependency packages

~/klippy-env/bin/pip install matplotlib numpy

Accelerometer Testing

Prerequisites

  • The printer has performed the Homing operation.
  • Ensure that the accelerometer is correctly enabled in the Klipper configuration file.

Test Commands

Enter the following command in the Klipper console:

ACCELEROMETER_QUERY

If multiple accelerometers are connected, you can specify the chip for testing:

ACCELEROMETER_QUERY CHIP=<ADXL Chip Name>

Replace <ADXL Chip Name> with the actual accelerometer identifier (e.g., adxl345).

Tip

Some older versions of Klipper require executing ACCELEROMETER_QUERY twice to obtain accelerometer data.

Common Problem Handling

Power-off Operation

Before checking, re-plugging, or replacing the accelerometer wiring, fully shut down the printer and disconnect the power supply. Do not plug or unplug the ADXL/LIS2DW/MPU/ICM module or touch exposed pins while powered on.

  1. First execution fails: Some Klipper versions may have command recognition delays. If the first execution returns no data, execute the same command again.
  2. Command not recognized: If the command is still unknown after multiple executions, the Klipper version may be too old. It is recommended to:
    • Update Klipper to the latest version
    • Or reflash the system to the latest version (e.g., latest FlyOS-FAST)
  3. Invalid adxl345 id: If prompted with Invalid adxl345 id (got xx vs e5), first immediately re-execute ACCELEROMETER_QUERY once; if the error persists, prioritize replacing the finished accelerometer cable, adapter board, or sensor module for cross-testing. It is not recommended for users to perform soldering or repair solder joints themselves.
  4. Invalid lis2dw / mpu / icm id: If using LIS2DW, MPU9250, ICM20948 sensors, verify that the configuration section names, communication bus, and chip model match the actual hardware.
  5. Unable to obtain response / timeout: This usually indicates a communication anomaly between the host computer and the accelerometer MCU. Please check the USB/CAN connection, [mcu] ID, cs_pin, spi_bus, or i2c_bus.

Result Interpretation

  • Normal Output: If a continuous data stream is returned (as shown in the figure below), the accelerometer is working correctly, and resonance compensation measurement can be performed.
  • Error Output: If a timeout, no data, or communication error is indicated, check in sequence:
    1. After powering off, confirm the accelerometer wiring is secure
    2. Verify the sensor configuration and SPI/SPI bus in the config file
    3. Prioritize determining power/communication issues by replacing the finished cable harness, adapter board, or sensor module
Loading...

Common Resonance Test Errors

Error MessageCommon CauseSolution
No data received from accelerometerAccelerometer not connected, SPI/I2C wiring order incorrect, power supply anomalyFirst execute ACCELEROMETER_QUERY to confirm normal communication, then retest
Insufficient axis data for shaper calibrationMovement range too small, acceleration too low, excessive sensor readout noiseIncrease test range or accel_per_hz, check if the accelerometer is securely fixed
Frequency range too narrowBelt too loose, machine mechanical resonance frequency outside measurement rangeCheck belt tension, mechanical structure tightness; if necessary, lower max_freq or increase accel_per_hz
Resonance graph full of noise, no obvious peaksSensor not securely fixed, fan vibration interference, cable harness swayingAfter power-off, re-secure the sensor, turn off fans during testing, route signal cables separately from motor cables
SHAPER_CALIBRATE executes but no output or exits with errorsMissing Python dependencies (numpy/matplotlib), insufficient memoryInstall missing dependencies following the steps at the beginning of this article; calculating large resonance graphs may require more memory

If ACCELEROMETER_QUERY works normally but resonance testing consistently fails, prioritize troubleshooting in the following order:

  1. After power-off, ensure the accelerometer surface is firmly attached to the component under test, without loose cushioning material or double-sided tape.
  2. Temporarily turn off the model cooling fan, hotend fan, and chamber fan during the test.
  3. Ensure no cable harnesses are pulling on the sensor or being snagged by moving axes during the test.
  4. Increase the test amplitude: In the [resonance_tester] section, gradually increase accel_per_hz from the default 75 to 100–150.
  5. If using an accelerometer on a toolhead board (USB/CAN), ensure the communication cable is not routed near the motor cables or heated bed cables.

Accelerometer Calibration

Calibration Steps

  1. Ensure the printer is homed.

  2. Enter the following command in the console to start automatic calibration of the X and Y axes:

    SHAPER_CALIBRATE
  3. After calibration is complete, save the configuration:

    SAVE_CONFIG

Single Axis Calibration

To calibrate only a single axis, use:

SHAPER_CALIBRATE AXIS=X

Or replace X with Y.

Safety Tip

The printer may vibrate violently during the calibration process. If the vibration is too severe, immediately press the emergency stop button or send the M112 command to stop urgently.

Adjusting Vibration Intensity

If the vibration is too strong during the test, you can appropriately lower the accel_per_hz parameter value (default 75):

[resonance_tester]
accel_per_hz: 50

Note: The above steps apply to the resonance compensation configuration of most Klipper-based 3D printers. Please adjust according to the actual hardware and system environment.

Loading...