diff options
author | Chris Thompson <chris@hypocrite.org> | 2023-03-27 18:38:26 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-27 20:38:26 -0400 |
commit | e93f39444c47e9a2ba7f3b7cfa942d9b87fd0a0b (patch) | |
tree | 87d6c468c0c3f7829db134aa0f0a9518cce25375 | |
parent | 16f54c820007e03e8d29c99bf3d341be3a72a629 (diff) | |
download | kutter-e93f39444c47e9a2ba7f3b7cfa942d9b87fd0a0b.tar.gz kutter-e93f39444c47e9a2ba7f3b7cfa942d9b87fd0a0b.tar.xz kutter-e93f39444c47e9a2ba7f3b7cfa942d9b87fd0a0b.zip |
docs: Document how to connect ADXL345 to Pico then on to Pi. (#5996)
This is based on documentation from:
https://klipper.discourse.group/t/raspberry-pi-pico-adxl345-portable-resonance-measurement/1757
Signed-off-by: Christopher Thompson <chris@hypocrite.org>
-rw-r--r-- | docs/Measuring_Resonances.md | 89 | ||||
-rw-r--r-- | docs/img/adxl345-pico.png | bin | 0 -> 514492 bytes | |||
-rw-r--r-- | docs/img/flash_rp2040_FLASH_DEVICE.png | bin | 0 -> 17043 bytes | |||
-rw-r--r-- | docs/img/klipper_pico_menuconfig.png | bin | 0 -> 6030 bytes |
4 files changed, 88 insertions, 1 deletions
diff --git a/docs/Measuring_Resonances.md b/docs/Measuring_Resonances.md index 63b61394..d09c3054 100644 --- a/docs/Measuring_Resonances.md +++ b/docs/Measuring_Resonances.md @@ -39,6 +39,7 @@ SCLK+CS ##### ADXL345 +###### Direct to Raspberry Pi **Note: Many MCUs will work with an ADXL345 in SPI mode(eg Pi Pico), wiring and configuration will vary according to your specific board and available pins.** @@ -60,6 +61,31 @@ Fritzing wiring diagrams for some of the ADXL345 boards:  +###### Using Raspberry Pi Pico + +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: @@ -164,6 +190,65 @@ probe_points: It is advised to start with 1 probe point, in the middle of the print bed, slightly above it. +#### 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 MPU-6000/9000 series With RPi Make sure the Linux I2C driver is enabled and the baud rate is @@ -228,7 +313,9 @@ 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. diff --git a/docs/img/adxl345-pico.png b/docs/img/adxl345-pico.png Binary files differnew file mode 100644 index 00000000..77bce31b --- /dev/null +++ b/docs/img/adxl345-pico.png diff --git a/docs/img/flash_rp2040_FLASH_DEVICE.png b/docs/img/flash_rp2040_FLASH_DEVICE.png Binary files differnew file mode 100644 index 00000000..7687811e --- /dev/null +++ b/docs/img/flash_rp2040_FLASH_DEVICE.png diff --git a/docs/img/klipper_pico_menuconfig.png b/docs/img/klipper_pico_menuconfig.png Binary files differnew file mode 100644 index 00000000..478ee4a1 --- /dev/null +++ b/docs/img/klipper_pico_menuconfig.png |