mirror of
https://github.com/QIDITECH/klipper.git
synced 2026-01-31 16:08:42 +03:00
plus4的klipper版本
This commit is contained in:
@@ -1,55 +1,182 @@
|
||||
# Measuring Resonances
|
||||
|
||||
Klipper has built-in support for ADXL345 accelerometer, which can be used to
|
||||
measure resonance frequencies of the printer for different axes, and auto-tune
|
||||
[input shapers](Resonance_Compensation.md) to compensate for resonances.
|
||||
Note that using ADXL345 requires some soldering and crimping. ADXL345 can be
|
||||
connected to a Raspberry Pi directly, or to an SPI interface of an MCU
|
||||
board (it needs to be reasonably fast).
|
||||
Klipper has built-in support for the ADXL345, MPU-9250 and LIS2DW compatible
|
||||
accelerometers which can be used to measure resonance frequencies of the printer
|
||||
for different axes, and auto-tune [input shapers](Resonance_Compensation.md) to
|
||||
compensate for resonances. Note that using accelerometers requires some
|
||||
soldering and crimping. The ADXL345/LIS2DW can be connected to the SPI interface
|
||||
of a Raspberry Pi or MCU board (it needs to be reasonably fast). The MPU family can
|
||||
be connected to the I2C interface of a Raspberry Pi directly, or to an I2C
|
||||
interface of an MCU board that supports 400kbit/s *fast mode* in Klipper.
|
||||
|
||||
When sourcing ADXL345, be aware that there is a variety of different PCB
|
||||
board designs and different clones of them. Make sure that the board supports
|
||||
SPI mode (small number of boards appear to be hard-configured for I2C by
|
||||
pulling SDO to GND), and, if it is going to be connected to a 5V printer MCU,
|
||||
that it has a voltage regulator and a level shifter.
|
||||
When sourcing accelerometers, be aware that there are a variety of different PCB
|
||||
board designs and different clones of them. If it is going to be connected to a
|
||||
5V printer MCU ensure it has a voltage regulator and level shifters.
|
||||
|
||||
For ADXL345s/LIS2DWs, make sure that the board supports SPI mode (a small number of
|
||||
boards appear to be hard-configured for I2C by pulling SDO to GND).
|
||||
|
||||
For MPU-9250/MPU-9255/MPU-6515/MPU-6050/MPU-6500s there are also a variety of
|
||||
board designs and clones with different I2C pull-up resistors which will need
|
||||
supplementing.
|
||||
|
||||
## MCUs with Klipper I2C *fast-mode* Support
|
||||
|
||||
| MCU Family | MCU(s) Tested | MCU(s) with Support |
|
||||
|:--:|:--|:--|
|
||||
| Raspberry Pi | 3B+, Pico | 3A, 3A+, 3B, 4 |
|
||||
| AVR ATmega | ATmega328p | ATmega32u4, ATmega128, ATmega168, ATmega328, ATmega644p, ATmega1280, ATmega1284, ATmega2560 |
|
||||
| AVR AT90 | - | AT90usb646, AT90usb1286 |
|
||||
|
||||
## Installation instructions
|
||||
|
||||
### Wiring
|
||||
|
||||
An ethernet cable with shielded twisted pairs (cat5e or better) is recommended
|
||||
for signal integrity over a long distance. If you still experience signal
|
||||
integrity issues (SPI/I2C errors):
|
||||
|
||||
- Double check the wiring with a digital multimeter for:
|
||||
- Correct connections when turned off (continuity)
|
||||
- Correct power and ground voltages
|
||||
- I2C only:
|
||||
- Check the SCL and SDA lines' resistances to 3.3V are in the range of 900
|
||||
ohms to 1.8K
|
||||
- For full technical details consult [chapter 7 of the I2C-bus specification
|
||||
and user manual UM10204](https://www.pololu.com/file/0J435/UM10204.pdf)
|
||||
for *fast-mode*
|
||||
- Shorten the cable
|
||||
|
||||
Connect ethernet cable shielding only to the MCU board/Pi ground.
|
||||
|
||||
***Double-check your wiring before powering up to prevent
|
||||
damaging your MCU/Raspberry Pi or the accelerometer.***
|
||||
|
||||
### SPI Accelerometers
|
||||
|
||||
Suggested twisted pair order for three twisted pairs:
|
||||
|
||||
```
|
||||
GND+MISO
|
||||
3.3V+MOSI
|
||||
SCLK+CS
|
||||
```
|
||||
|
||||
Note that unlike a cable shield, GND must be connected at both ends.
|
||||
|
||||
#### ADXL345
|
||||
|
||||
##### Direct to Raspberry Pi
|
||||
|
||||
**Note: Many MCUs will work with an ADXL345 in SPI mode (e.g. Pi Pico), wiring
|
||||
and configuration will vary according to your specific board and available
|
||||
pins.**
|
||||
|
||||
You need to connect ADXL345 to your Raspberry Pi via SPI. Note that the I2C
|
||||
connection, which is suggested by ADXL345 documentation, has too low throughput
|
||||
and **will not work**. The recommended connection scheme:
|
||||
|
||||
| ADXL345 pin | RPi pin | RPi pin name |
|
||||
|:--:|:--:|:--:|
|
||||
| 3V3 (or VCC) | 01 | 3.3v DC power |
|
||||
| 3V3 (or VCC) | 01 | 3.3V DC power |
|
||||
| GND | 06 | Ground |
|
||||
| CS | 24 | GPIO08 (SPI0_CE0_N) |
|
||||
| SDO | 21 | GPIO09 (SPI0_MISO) |
|
||||
| SDA | 19 | GPIO10 (SPI0_MOSI) |
|
||||
| SCL | 23 | GPIO11 (SPI0_SCLK) |
|
||||
|
||||
An alternative to the ADXL345 is the MPU-9250 (or MPU-6050). This
|
||||
accelerometer has been tested to work over I2C on the RPi at 400kbaud.
|
||||
Recommended connection scheme for I2C:
|
||||
|
||||
| MPU-9250 pin | RPi pin | RPi pin name |
|
||||
|:--:|:--:|:--:|
|
||||
| 3V3 (or VCC) | 01 | 3.3v DC power |
|
||||
| GND | 09 | Ground |
|
||||
| SDA | 03 | GPIO02 (SDA1) |
|
||||
| SCL | 05 | GPIO03 (SCL1) |
|
||||
|
||||
|
||||
Fritzing wiring diagrams for some of the ADXL345 boards:
|
||||
|
||||

|
||||
|
||||
##### Using Raspberry Pi Pico
|
||||
|
||||
Double-check your wiring before powering up the Raspberry Pi to prevent
|
||||
damaging it or the accelerometer.
|
||||
You may connect the ADXL345 to your Raspberry Pi Pico and then connect the
|
||||
Pico to your Raspberry Pi via USB. This makes it easy to reuse the
|
||||
accelerometer on other Klipper devices, as you can connect via USB instead
|
||||
of GPIO. The Pico does not have much processing power, so make sure it is
|
||||
only running the accelerometer and not performing any other duties.
|
||||
|
||||
In order to avoid damage to your RPi make sure to connect the ADXL345 to 3.3V
|
||||
only. Depending on the board's layout, a level shifter may be present, which
|
||||
makes 5V dangerous for your RPi.
|
||||
|
||||
| ADXL345 pin | Pico pin | Pico pin name |
|
||||
|:--:|:--:|:--:|
|
||||
| 3V3 (or VCC) | 36 | 3.3V DC power |
|
||||
| GND | 38 | Ground |
|
||||
| CS | 2 | GP1 (SPI0_CSn) |
|
||||
| SDO | 1 | GP0 (SPI0_RX) |
|
||||
| SDA | 5 | GP3 (SPI0_TX) |
|
||||
| SCL | 4 | GP2 (SPI0_SCK) |
|
||||
|
||||
Wiring diagrams for some of the ADXL345 boards:
|
||||
|
||||

|
||||
|
||||
### I2C Accelerometers
|
||||
|
||||
Suggested twisted pair order for three pairs (preferred):
|
||||
|
||||
```
|
||||
3.3V+GND
|
||||
SDA+GND
|
||||
SCL+GND
|
||||
```
|
||||
|
||||
or for two pairs:
|
||||
|
||||
```
|
||||
3.3V+SDA
|
||||
GND+SCL
|
||||
```
|
||||
|
||||
Note that unlike a cable shield, any GND(s) should be connected at both ends.
|
||||
|
||||
#### MPU-9250/MPU-9255/MPU-6515/MPU-6050/MPU-6500
|
||||
|
||||
These accelerometers have been tested to work over I2C on the RPi, RP2040 (Pico)
|
||||
and AVR at 400kbit/s (*fast mode*). Some MPU accelerometer modules include
|
||||
pull-ups, but some are too large at 10K and must be changed or supplemented by
|
||||
smaller parallel resistors.
|
||||
|
||||
Recommended connection scheme for I2C on the Raspberry Pi:
|
||||
|
||||
| MPU-9250 pin | RPi pin | RPi pin name |
|
||||
|:--:|:--:|:--:|
|
||||
| VCC | 01 | 3.3v DC power |
|
||||
| GND | 09 | Ground |
|
||||
| SDA | 03 | GPIO02 (SDA1) |
|
||||
| SCL | 05 | GPIO03 (SCL1) |
|
||||
|
||||
The RPi has buit-in 1.8K pull-ups on both SCL and SDA.
|
||||
|
||||

|
||||
|
||||
Recommended connection scheme for I2C (i2c0a) on the RP2040:
|
||||
|
||||
| MPU-9250 pin | RP2040 pin | RP2040 pin name |
|
||||
|:--:|:--:|:--:|
|
||||
| VCC | 36 | 3v3 |
|
||||
| GND | 38 | Ground |
|
||||
| SDA | 01 | GP0 (I2C0 SDA) |
|
||||
| SCL | 02 | GP1 (I2C0 SCL) |
|
||||
|
||||
The Pico does not include any built-in I2C pull-up resistors.
|
||||
|
||||

|
||||
|
||||
##### Recommended connection scheme for I2C(TWI) on the AVR ATmega328P Arduino Nano:
|
||||
|
||||
| MPU-9250 pin | Atmega328P TQFP32 pin | Atmega328P pin name | Arduino Nano pin |
|
||||
|:--:|:--:|:--:|:--:|
|
||||
| VCC | 39 | - | - |
|
||||
| GND | 38 | Ground | GND |
|
||||
| SDA | 27 | SDA | A4 |
|
||||
| SCL | 28 | SCL | A5 |
|
||||
|
||||
The Arduino Nano does not include any built-in pull-up resistors nor a 3.3V
|
||||
power pin.
|
||||
|
||||
### Mounting the accelerometer
|
||||
|
||||
@@ -92,14 +219,18 @@ of time, up to 10-20 minutes. Be patient and wait for the completion of
|
||||
the installation. On some occasions, if the board has too little RAM
|
||||
the installation may fail and you will need to enable swap.
|
||||
|
||||
Afterwards, check and follow the instructions in the
|
||||
#### Configure ADXL345 With RPi
|
||||
|
||||
First, check and follow the instructions in the
|
||||
[RPi Microcontroller document](RPi_microcontroller.md) to setup the
|
||||
"linux mcu" on the Raspberry Pi.
|
||||
"linux mcu" on the Raspberry Pi. This will configure a second Klipper
|
||||
instance that runs on your Pi.
|
||||
|
||||
Make sure the Linux SPI driver is enabled by running `sudo
|
||||
raspi-config` and enabling SPI under the "Interfacing options" menu.
|
||||
|
||||
For the ADXL345, add the following to the printer.cfg file:
|
||||
Add the following to the printer.cfg file:
|
||||
|
||||
```
|
||||
[mcu rpi]
|
||||
serial: /tmp/klipper_host_mcu
|
||||
@@ -115,9 +246,91 @@ probe_points:
|
||||
It is advised to start with 1 probe point, in the middle of the print bed,
|
||||
slightly above it.
|
||||
|
||||
For the MPU-9250, make sure the Linux I2C driver is enabled and the baud rate is
|
||||
#### Configure ADXL345 With Pi Pico
|
||||
|
||||
##### Flash the Pico Firmware
|
||||
|
||||
On your Raspberry Pi, compile the firmware for the Pico.
|
||||
|
||||
```
|
||||
cd ~/klipper
|
||||
make clean
|
||||
make menuconfig
|
||||
```
|
||||

|
||||
|
||||
Now, while holding down the `BOOTSEL` button on the Pico, connect the Pico to
|
||||
the Raspberry Pi via USB. Compile and flash the firmware.
|
||||
```
|
||||
make flash FLASH_DEVICE=first
|
||||
```
|
||||
|
||||
If that fails, you will be told which `FLASH_DEVICE` to use. In this example,
|
||||
that's ```make flash FLASH_DEVICE=2e8a:0003```.
|
||||

|
||||
|
||||
##### Configure the Connection
|
||||
|
||||
The Pico will now reboot with the new firmware and should show up as a serial
|
||||
device. Find the pico serial device with `ls /dev/serial/by-id/*`. You can
|
||||
now add an `adxl.cfg` file with the following settings:
|
||||
|
||||
```
|
||||
[mcu adxl]
|
||||
# Change <mySerial> to whatever you found above. For example,
|
||||
# usb-Klipper_rp2040_E661640843545B2E-if00
|
||||
serial: /dev/serial/by-id/usb-Klipper_rp2040_<mySerial>
|
||||
|
||||
[adxl345]
|
||||
cs_pin: adxl:gpio1
|
||||
spi_bus: spi0a
|
||||
axes_map: x,z,y
|
||||
|
||||
[resonance_tester]
|
||||
accel_chip: adxl345
|
||||
probe_points:
|
||||
# Somewhere slightly above the middle of your print bed
|
||||
147,154, 20
|
||||
|
||||
[output_pin power_mode] # Improve power stability
|
||||
pin: adxl:gpio23
|
||||
```
|
||||
|
||||
If setting up the ADXL345 configuration in a separate file, as shown above,
|
||||
you'll also want to modify your `printer.cfg` file to include this:
|
||||
|
||||
```
|
||||
[include adxl.cfg] # Comment this out when you disconnect the accelerometer
|
||||
```
|
||||
|
||||
Restart Klipper via the `RESTART` command.
|
||||
|
||||
#### Configure LIS2DW series
|
||||
|
||||
```
|
||||
[mcu lis]
|
||||
# Change <mySerial> to whatever you found above. For example,
|
||||
# usb-Klipper_rp2040_E661640843545B2E-if00
|
||||
serial: /dev/serial/by-id/usb-Klipper_rp2040_<mySerial>
|
||||
|
||||
[lis2dw]
|
||||
cs_pin: lis:gpio1
|
||||
spi_bus: spi0a
|
||||
axes_map: x,z,y
|
||||
|
||||
[resonance_tester]
|
||||
accel_chip: lis2dw
|
||||
probe_points:
|
||||
# Somewhere slightly above the middle of your print bed
|
||||
147,154, 20
|
||||
```
|
||||
|
||||
#### Configure MPU-6000/9000 series With RPi
|
||||
|
||||
Make sure the Linux I2C driver is enabled and the baud rate is
|
||||
set to 400000 (see [Enabling I2C](RPi_microcontroller.md#optional-enabling-i2c)
|
||||
section for more details). Then, add the following to the printer.cfg:
|
||||
|
||||
```
|
||||
[mcu rpi]
|
||||
serial: /tmp/klipper_host_mcu
|
||||
@@ -132,6 +345,46 @@ probe_points:
|
||||
100, 100, 20 # an example
|
||||
```
|
||||
|
||||
#### Configure MPU-9520 Compatibles With Pico
|
||||
|
||||
Pico I2C is set to 400000 on default. Simply add the following to the
|
||||
printer.cfg:
|
||||
|
||||
```
|
||||
[mcu pico]
|
||||
serial: /dev/serial/by-id/<your Pico's serial ID>
|
||||
|
||||
[mpu9250]
|
||||
i2c_mcu: pico
|
||||
i2c_bus: i2c0a
|
||||
|
||||
[resonance_tester]
|
||||
accel_chip: mpu9250
|
||||
probe_points:
|
||||
100, 100, 20 # an example
|
||||
|
||||
[static_digital_output pico_3V3pwm] # Improve power stability
|
||||
pins: pico:gpio23
|
||||
```
|
||||
|
||||
#### Configure MPU-9520 Compatibles with AVR
|
||||
|
||||
AVR I2C will be set to 400000 by the mpu9250 option. Simply add the following
|
||||
to the printer.cfg:
|
||||
|
||||
```
|
||||
[mcu nano]
|
||||
serial: /dev/serial/by-id/<your nano's serial ID>
|
||||
|
||||
[mpu9250]
|
||||
i2c_mcu: nano
|
||||
|
||||
[resonance_tester]
|
||||
accel_chip: mpu9250
|
||||
probe_points:
|
||||
100, 100, 20 # an example
|
||||
```
|
||||
|
||||
Restart Klipper via the `RESTART` command.
|
||||
|
||||
## Measuring the resonances
|
||||
@@ -154,10 +407,15 @@ Recv: // adxl345 values (x, y, z): 470.719200, 941.438400, 9728.196800
|
||||
```
|
||||
|
||||
If you get an error like `Invalid adxl345 id (got xx vs e5)`, where `xx`
|
||||
is some other ID, it is indicative of the connection problem with ADXL345,
|
||||
is some other ID, immediately try again. There's an issue with SPI
|
||||
initialization. If you still get an error, it is indicative of the connection
|
||||
problem with ADXL345,
|
||||
or the faulty sensor. Double-check the power, the wiring (that it matches
|
||||
the schematics, no wire is broken or loose, etc.), and soldering quality.
|
||||
|
||||
**If you are using a MPU-9250 compatible accelerometer and it shows up as
|
||||
`mpu-unknown`, use with caution! They are probably refurbished chips!**
|
||||
|
||||
Next, try running `MEASURE_AXES_NOISE` in Octoprint, you should get some
|
||||
baseline numbers for the noise of accelerometer on the axes (should be
|
||||
somewhere in the range of ~1-100). Too high axes noise (e.g. 1000 and more)
|
||||
@@ -233,7 +491,7 @@ or you can choose some other configuration yourself based on the generated
|
||||
charts: peaks in the power spectral density on the charts correspond to
|
||||
the resonance frequencies of the printer.
|
||||
|
||||
Note that alternatively you can run the input shaper autocalibration
|
||||
Note that alternatively you can run the input shaper auto-calibration
|
||||
from Klipper [directly](#input-shaper-auto-calibration), which can be
|
||||
convenient, for example, for the input shaper
|
||||
[re-calibration](#input-shaper-re-calibration).
|
||||
@@ -245,10 +503,11 @@ of the accelerometer between the measurements for X and Y axes: measure the
|
||||
resonances of X axis with the accelerometer attached to the toolhead and the
|
||||
resonances of Y axis - to the bed (the usual bed slinger setup).
|
||||
|
||||
However, you can also connect two accelerometers simultaneously, though they
|
||||
must be connected to different boards (say, to an RPi and printer MCU board), or
|
||||
to two different physical SPI interfaces on the same board (rarely available).
|
||||
Then they can be configured in the following manner:
|
||||
However, you can also connect two accelerometers simultaneously, though the
|
||||
ADXL345 must be connected to different boards (say, to an RPi and printer MCU
|
||||
board), or to two different physical SPI interfaces on the same board (rarely
|
||||
available). Then they can be configured in the following manner:
|
||||
|
||||
```
|
||||
[adxl345 hotend]
|
||||
# Assuming `hotend` chip is connected to an RPi
|
||||
@@ -265,6 +524,30 @@ accel_chip_y: adxl345 bed
|
||||
probe_points: ...
|
||||
```
|
||||
|
||||
Two MPUs can share one I2C bus, but they **cannot** measure simultaneously as
|
||||
the 400kbit/s I2C bus is not fast enough. One must have its AD0 pin pulled-down
|
||||
to 0V (address 104) and the other its AD0 pin pulled-up to 3.3V (address 105):
|
||||
|
||||
```
|
||||
[mpu9250 hotend]
|
||||
i2c_mcu: rpi
|
||||
i2c_bus: i2c.1
|
||||
i2c_address: 104 # This MPU has pin AD0 pulled low
|
||||
|
||||
[mpu9250 bed]
|
||||
i2c_mcu: rpi
|
||||
i2c_bus: i2c.1
|
||||
i2c_address: 105 # This MPU has pin AD0 pulled high
|
||||
|
||||
[resonance_tester]
|
||||
# Assuming the typical setup of the bed slinger printer
|
||||
accel_chip_x: mpu9250 hotend
|
||||
accel_chip_y: mpu9250 bed
|
||||
probe_points: ...
|
||||
```
|
||||
[Test with each MPU individually before connecting both to the bus for easy
|
||||
debugging.]
|
||||
|
||||
Then the commands `TEST_RESONANCES AXIS=X` and `TEST_RESONANCES AXIS=Y`
|
||||
will use the correct accelerometer for each axis.
|
||||
|
||||
@@ -473,9 +756,9 @@ supplying `AXIS=` parameter, like
|
||||
SHAPER_CALIBRATE AXIS=X
|
||||
```
|
||||
|
||||
**Warning!** It is not advisable to run the shaper autocalibration very
|
||||
**Warning!** It is not advisable to run the shaper auto-calibration very
|
||||
frequently (e.g. before every print, or every day). In order to determine
|
||||
resonance frequencies, autocalibration creates intensive vibrations on each of
|
||||
resonance frequencies, auto-calibration creates intensive vibrations on each of
|
||||
the axes. Generally, 3D printers are not designed to withstand a prolonged
|
||||
exposure to vibrations near the resonance frequencies. Doing so may increase
|
||||
wear of the printer components and reduce their lifespan. There is also an
|
||||
|
||||
Reference in New Issue
Block a user