Accelerometer Usage
Usage Tutorial
Accelerometer Testing and Calibration
Installing Dependencies
- 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
- 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 be patient until completion.
- 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).
Some older versions of Klipper require executing ACCELEROMETER_QUERY twice before obtaining accelerometer data.
Common Issue Troubleshooting
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.
- 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.
- 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)
- Invalid adxl345 id: If prompted with
Invalid adxl345 id (got xx vs e5), 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 customers to re-solder or repair solder joints themselves. - 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.
- 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, 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 measurements can be performed.
- Error output: If a timeout, no data, or communication error is indicated, check the following in order:
- Disconnect power and confirm the accelerometer wiring is secure.
- Verify the sensor configuration and SPI settings in the configuration file are correct.
- Prioritize diagnosing power/communication issues by replacing the finished cable, 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 sequence error, power supply anomaly | First execute ACCELEROMETER_QUERY to confirm communication is normal, then re-test |
Insufficient axis data for shaper calibration | Movement range too small, acceleration too low, excessive sensor reading noise | Increase the test range or accel_per_hz, check if the accelerometer is firmly attached |
Frequency range too narrow | Belt too loose, machine mechanical resonance frequency outside measurement range | Check belt tension and mechanical structure tightness; if necessary, lower max_freq or increase accel_per_hz |
| Resonance graph is all noise, no clear peak | Sensor not firmly attached, fan vibration interference, cable sway | Disconnect 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 error | Missing Python dependencies (numpy/matplotlib), insufficient memory | Install 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 axes | TEST_RESONANCES specifies Z axis along with X/Y axis | The Z axis needs to be tested separately; do not mix it with X/Y |
Invalid POINT parameter | Incorrect POINT= coordinate format, or missing x,y,z three values | Fill in the format like POINT=100,100,20 |
Invalid NAME parameter | Output name is empty, contains special characters, or does not match command requirements | Use English letters, numbers, underscores, or hyphens for naming |
No accelerometer measurements found | No valid accelerometer data was collected during the test | First execute ACCELEROMETER_QUERY, then check sensor attachment and communication |
Unsupported output | The OUTPUT= parameter specifies an unsupported type | Use 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:
- Disconnect power and ensure the accelerometer surface is tightly attached to the component under test, without any cushioning material or loose double-sided tape.
- Temporarily turn off model cooling fans, hotend fans, and chamber fans during the test.
- Ensure no cables are tugging on the sensor or being caught by the moving axes during the test.
- Increase the test amplitude: In
[resonance_tester], gradually increaseaccel_per_hzfrom the default of75to100–150. - 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
-
Ensure the printer has 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 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.