If you're reading this it's likely because you've noticed that your MK4 xBuddy Controller has a port reserved for an accelerometer and wondered "Hmmm. I wonder if that works."
I'm happy to report that the answer is "Yes." I found it to be reliable and working just fine, but in response to my demo, Josef Prusa himself responded "Hi! Please note the code is not tested on MK4 so you shouldn't count on it's results. There will be an official implementation but not ETA yet." Source here.
This repository contains information, designs, and tools for using an accelerometer with the Prusa MK4 3D Printer.
This primary document is focused on being a quick start guide, while other documents in the repository contain more in-depth technical information about other aspects of the project.
Here's a roadmap of a few simple tasks that I'd like to accomplish with this project.
Q: Does this void my warranty?
A: Probably.
You can read the official Prusa Warranty on their website here. Quote "This warranty is voided by: ... Upgrades or add-ons that are not officially supported."
This modification does not require you to compile or upload any custom firmware to work. The release firmware directly from Prusa supports these boards, so this is purely a hardware addition. That said, I will include thorough warnings where appropriate to ensure that nothing goes wrong, should you follow the instructions correctly.
Here is a list of tools that will be needed to add an accelerometer board at the moment.
For this section, I will document the soldering procedure for the generic purple Chinese LIS2DH boards, as that is the first board I confirmed to be working.
Identify the first wire to solder. If you did step two, the top side that you marked is pin 6 on the Prusa Schematics and Connector documentation. (See the Diagram below). On the Digikey cable assembly, they use tape in the middle of the cables to group them to together. We have two options:
a) Cut the tape and visually trace the cables.
b) Leave the tape intact and use a multimeter to buzz out which cable is connected to each connector pin. This can be done by switching to continuity mode, touching one lead to a cable of your choice, and the other to small pad on the back of the connector.
Here is a reference table for the Prusa Connector Pins and the breakout board. Prusa's documentation supporting this is found here.
Connector | Pin (Prusa) | Pin (Accel Board) | Type | Function | GPIO | Limitations |
---|---|---|---|---|---|---|
J29 (ACCELEROMETER) | 1 | CS | open drain output | SPI2 CS | PA10 | Max 3.3V/5mA |
J29 (ACCELEROMETER) | 2 | SCL | input/output | SPI2 SCL | PB10 | Max 5V/5mA |
J29 (ACCELEROMETER) | 3 | SDA | input/output | SPI2 SDI | PC3 | Max 5V/5mA |
J29 (ACCELEROMETER) | 4 | SDO | input/output | SPI2 SDO | PC2 | Max 5V/5mA |
J29 (ACCELEROMETER) | 5 | VCC | 3V3 | Power | x | Max 50mA |
J29 (ACCELEROMETER) | 6 | GND | GND | Power | x | x |
Board Name | Testing Status | Source | Notes |
---|---|---|---|
NOYITO LIS2DH12TR Development Board | WORKING | https://a.co/d/4UiPgB6 | This board is very generic and can be found many places ranging from $4 to $13. They likely all come from the same place. |
Sparkfun SPX-15760 LIS2DH12 (Qwiic) | FAIL | https://www.sparkfun.com/products/retired/15760 | This board is hard wired for I2C, while the Prusa MK4 expects an SPI compatible device, so this will not work. |
Adafruit LIS3DH Triple-Axis Accelerometer (Recommended) | WORKING | https://www.adafruit.com/product/2809 | The LIS3DH has a few more features we won't be using, however I confirmed it to work similarly. Since Adafruit has a solid supply chain, this is likely the best all around choice. Minor Con: The breakout board has pins on both sides, requiring cables to be on both sides, so it is a little messier. |
If you are hoping to get useful values out of the accelerometer, emphasize doing any pending maintenance first. Lube the smooth rods/bearings. Check for scratches. Check belt tension, etc. Each of these factors will change these results if you fix them later, so just do them now to avoid retesting. See Prusa's official docs for recommended regular maintenance here.
M593
command with no arguments. This will return the existing Input Shaping (IS) parameters. An example of my output can be found below. If you want to see all my Input Shaping testing results, see Testing.
Send: M593
Recv: echo:axis X type=MZV freq=50.700001 damp=0.100000 vr=20.000000
Recv: echo:axis Y type=MZV freq=40.599998 damp=0.100000 vr=20.000000
Recv: echo:axis Z disabled
Recv: echo:weight_adjust y freq_delta=-20.000000 mass_limit=800.000000
Recv: ok
M959 X F40.0 G60.0 N10
. This tests the X-Axis starting at 40Hz and ending at 60Hz, with a very quick sample size. The results this produces should not be used. It is provided here purely as a way to quickly test that you wired up the sensor correctly.M959 X F65.0 G85.0 H0.5
. See below for a list of parameters to the M959 command.Once you are satisfied with the results and think you have a consistent number, we will save the values. See the official documentation for the M593
command here. Assuming I got the following results Recv: ZV shaper selected Recv: Frequency: 79.00 damping ratio: 0.17444
a) To do this temporarily (until you shut off the printer), run the following command M593 X D0.17444 F79.00 T0
. Note the lack of the W
parameter, the parameter to save it to the EEPROM.
b) To save it permanently, run the following command M593 X D0.17444 F79.00 T0 W
.
The M959
command does all the heavy lifting in our testing. It's parameters are only listed in the source code, so I've copied them here for convenience.
/\*\*
\* u/brief Tune input shaper
\*
\* - X<direction> Vibrate with X motor, start in direction 1 or -1
\* - Y<direction> Vibrate with Y motor, start in direction 1 or -1
\* - Z<direction> Vibrate with Z motor, start in direction 1 or -1
\* - K select Klipper tune algorithm
\* - KM select Klipper Marek modified tune algorithm
\* - F<Hz> Start frequency
\* - G<Hz> End frequency
\* - H<Hz> Frequency step
\* - A<mm/s-2> Acceleration
\* - N<cycles> Number of excitation signal periods
\* of active measurement.
\*/