Accelerometer Usage
Usage Tutorial
Accelerometer Testing and Calibration
Dependency Package Installation
- 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
- Execute the following commands sequentially to install the dependency packages.
- The installation time depends on CPU performance and network conditions, typically taking 10–20 minutes. Please wait patiently until the installation is complete.
- 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).
Some older versions of Klipper require executing ACCELEROMETER_QUERY twice to obtain accelerometer data.
Common Problem Handling
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.
- First execution fails: Some Klipper versions may have command recognition delays. If the first execution returns no data, execute the same command again.
- 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)
- Invalid adxl345 id: If prompted with
Invalid adxl345 id (got xx vs e5), first immediately re-executeACCELEROMETER_QUERYonce; 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. - 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.
- 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, ori2c_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:
- After powering off, confirm the accelerometer wiring is secure
- Verify the sensor configuration and SPI/SPI bus in the config file
- Prioritize determining power/communication issues by replacing the finished cable harness, adapter board, or sensor module
Common Resonance Test Errors
| Error Message | Common Cause | Solution |
|---|---|---|
No data received from accelerometer | Accelerometer not connected, SPI/I2C wiring order incorrect, power supply anomaly | First execute ACCELEROMETER_QUERY to confirm normal communication, then retest |
Insufficient axis data for shaper calibration | Movement range too small, acceleration too low, excessive sensor readout noise | Increase test range or accel_per_hz, check if the accelerometer is securely fixed |
Frequency range too narrow | Belt too loose, machine mechanical resonance frequency outside measurement range | Check belt tension, mechanical structure tightness; if necessary, lower max_freq or increase accel_per_hz |
| Resonance graph full of noise, no obvious peaks | Sensor not securely fixed, fan vibration interference, cable harness swaying | After 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 errors | Missing Python dependencies (numpy/matplotlib), insufficient memory | Install 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:
- After power-off, ensure the accelerometer surface is firmly attached to the component under test, without loose cushioning material or double-sided tape.
- Temporarily turn off the model cooling fan, hotend fan, and chamber fan during the test.
- Ensure no cable harnesses are pulling on the sensor or being snagged by moving axes during the test.
- Increase the test amplitude: In the
[resonance_tester]section, gradually increaseaccel_per_hzfrom the default75to100–150. - 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
-
Ensure the printer is homed.
-
Enter the following command in the console to start automatic calibration of the X and Y axes:
SHAPER_CALIBRATE -
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.
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.