Skip to main content

Accelerometer Usage

Usage Tutorial

Accelerometer Testing and Calibration

Installing Dependencies

Notes
  • If the device is running the FlyOS-FAST system, the required dependencies are pre-installed. You can skip this step.
  • If using a non-FLY host computer, please ensure to complete the following installation steps.
  • It is recommended to use SSH tools like MobaXterm or PuTTY to connect before proceeding.
  • This tutorial is based on a 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 be patient until completion.
  3. If the device's RAM is insufficient, 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 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 before obtaining accelerometer data.

Common Issue Troubleshooting

Power Off Operation

Before inspecting, reconnecting, or replacing the accelerometer wiring, completely turn off the printer and disconnect the power supply. Do not plug or unplug ADXL/LIS2DW/MPU/ICM modules or touch exposed pins while powered on.

  1. First execution failure: Some Klipper versions may have command recognition delays. If no data is returned on the first try, re-execute the same command.
  2. Command not recognized: If the command is still unknown after multiple attempts, it may be due to an outdated Klipper version. It is recommended to:
    • Update Klipper to the latest version
    • Or reflash with the latest system version (e.g., FlyOS-FAST latest)
  3. Invalid adxl345 id: If prompted with Invalid adxl345 id (got xx vs e5), 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 customers to re-solder or repair solder joints themselves.
  4. Invalid lis2dw / mpu / icm id: If using LIS2DW, MPU9250, ICM20948 sensors, ensure the configuration section name, communication bus, and chip model match the actual hardware.
  5. Unable to obtain response / timeout: This usually indicates a communication issue between the host computer and the accelerometer MCU. Check USB/CAN connections, [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 measurements can be performed.
  • Error output: If a timeout, no data, or communication error is indicated, check the following in order:
    1. Disconnect power and confirm the accelerometer wiring is secure.
    2. Verify the sensor configuration and SPI settings in the configuration file are correct.
    3. Prioritize diagnosing power/communication issues by replacing the finished cable, adapter board, or sensor module.
Loading...

Common Resonance Test Errors

Error MessageCommon CauseSolution
No data received from accelerometerAccelerometer not connected, SPI/I2C wiring sequence error, power supply anomalyFirst execute ACCELEROMETER_QUERY to confirm communication is normal, then re-test
Insufficient axis data for shaper calibrationMovement range too small, acceleration too low, excessive sensor reading noiseIncrease the test range or accel_per_hz, check if the accelerometer is firmly attached
Frequency range too narrowBelt too loose, machine mechanical resonance frequency outside measurement rangeCheck belt tension and mechanical structure tightness; if necessary, lower max_freq or increase accel_per_hz
Resonance graph is all noise, no clear peakSensor not firmly attached, fan vibration interference, cable swayDisconnect power, re-secure the sensor; turn off fans during testing; route signal cables separately from motor cables
SHAPER_CALIBRATE executes with no output or exits with errorMissing Python dependencies (numpy/matplotlib), insufficient memoryInstall missing dependencies as per the installation steps at the beginning of this article; large resonance graph calculations may require more memory
Cannot test Z axis together with other axesTEST_RESONANCES specifies Z axis along with X/Y axisThe Z axis needs to be tested separately; do not mix it with X/Y
Invalid POINT parameterIncorrect POINT= coordinate format, or missing x,y,z three valuesFill in the format like POINT=100,100,20
Invalid NAME parameterOutput name is empty, contains special characters, or does not match command requirementsUse English letters, numbers, underscores, or hyphens for naming
No accelerometer measurements foundNo valid accelerometer data was collected during the testFirst execute ACCELEROMETER_QUERY, then check sensor attachment and communication
Unsupported outputThe OUTPUT= parameter specifies an unsupported typeUse the supported output types in Klipper; common is resonances

If ACCELEROMETER_QUERY is normal but the resonance test consistently fails, prioritize troubleshooting in this order:

  1. Disconnect power and ensure the accelerometer surface is tightly attached to the component under test, without any cushioning material or loose double-sided tape.
  2. Temporarily turn off model cooling fans, hotend fans, and chamber fans during the test.
  3. Ensure no cables are tugging on the sensor or being caught by the moving axes during the test.
  4. Increase the test amplitude: In [resonance_tester], gradually increase accel_per_hz from the default of 75 to 100–150.
  5. If using an accelerometer on a toolhead board (USB/CAN), confirm the communication cables are not running close to motor or heated bed cables.

Accelerometer Calibration

Calibration Steps

  1. Ensure the printer has 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 vigorously during calibration. If the vibration is excessive, immediately press the emergency stop button or send the M112 command to halt.

Adjusting Vibration Intensity

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

[resonance_tester]
accel_per_hz: 50

Note: The above steps apply to most Klipper-based 3D printer resonance compensation configurations. Please adjust according to your actual hardware and system environment.

Loading...