Fast 3D Printing with Raspberry Pi — But Not How You Think


Although we tend to think of 3D printers as high-tech toys, most of them are not especially powerful in the brain department. There are some exceptions, but most 3D printers run on either an 8-bit Arduino or some Arduino variant with a lot of I/O. There are a few 32-bit boards, but if you grab a random 3D printer, its brain is going to be an 8-bit AVR running something like Marlin or Repetier. It isn’t uncommon to see a Raspberry Pi connected to a printer, too, but — again, in general — it is a network interface that handles sending G-code to the 8-bit controller that runs the stepper motors. Would it make more sense to do things like parse G-code, map out curves, and set accelerations in the relatively powerful Raspberry Pi and relegate the 8-bit AVR to just commanding motors and heaters? [KevinOConnor] thinks so, and he wrote Klipper to prove it.

Klipper is mostly written in Python and it does most of the functions of traditional 3D printing firmware. It communicates with the onboard microprocessor by providing a schedule of when to do what tasks. The microprocessor then handles the timing and things like motion control for the axes and extruder. Klipper can control multiple microprocessors with no trouble and keeps them in synchronization, so you could have a processor for your extruder and one for each stepper, for example. You can use Klipper with a Cartesian machine, a delta, or a Core XY-style printer.

The host computer doesn’t even have to be a Raspberry Pi. The BeagleBone will work and — in theory, at least — so will any Linux computer. There’s a small bit of firmware you program on the microcontroller that speaks a lightweight protocol to the host computer. As for user interface, that’s easy. The host can talk to Octoprint and you can run that on the same Raspberry Pi that runs Klipper.

The microcontroller firmware only has a handful of commands. Most of those are related to something to do at a given time: operating a stepper motor or setting a PWM output. Because it is simple, you could have a small CPU and you could possibly get much faster rates. Of course, that assumes your hardware can handle a faster rate.

Features

Klipper touts several “compelling features”:

Each stepper event is scheduled with a precision of 25 microseconds or better. The software does not use kinematic estimations (such as the Bresenham algorithm).  It calculates precise step times based on the physics of acceleration and the physics of the machine kinematics. More precise stepper movement translates to quieter and more stable printer operation.

Since the microcontroller firmware is very simple, it is easy to reconfigure things in Klipper just by changing a file on the host computer. The firmware is simple and in C so it can support many microprocessors including common 8-bit and 32-bit CPUs found in 3D printers.

Klipper is able to achieve precise high stepping rates. An older AVR can apparently achieve rates of over 175,000 steps per second and rates up to 500,000 per second are possible.  Higher stepper rates enable higher print velocities.

At high print speeds, oozing can be a problem. Klipper implements a “pressure advance” algorithm for extruders. When properly tuned, pressure advance reduces extruder ooze, possibly allowing faster printing. You can see a video, below, of [Bradley Muller] printing at 100 mm/s using Klipper.

If that’s not fast enough, check out this cube at 150 mm/s (wait for the first layer to finish) from [lenne 0815]:

There’s also a novel “stepper phase endstop” algorithm that can improve the accuracy of typical endstop switches. This is especially important for the Z endstop since that can lead to a more precise first layer height and improve print quality and adhesion.

Tuning

Some of these features do require tuning. The pressure advance algorithm, for example, requires a machine-specific constant. Here’s some text from the document describing the software’s kinematics:

The “pressure advance” system attempts to account for this by using a different model for the extruder. Instead of naively believing that each cubic mm of filament fed into the extruder will result in that amount of cubic mm immediately exiting the extruder, it uses a model based on pressure. Pressure increases when filament is pushed into the extruder (as in Hooke’s law) and the pressure necessary to extrude is dominated by the flow rate through the nozzle orifice (as in Poiseuille’s law). The key idea is that the relationship between filament, pressure, and flow rate can be modeled using a linear coefficient.

You can find that value experimentally by printing a test square and finding the lowest number that gives a good-looking corner. For example, below is a mistuned corner on the left and a correctly tuned one on the right.

The endstop feature utilizes the phases of the stepper motor driver. For example, a stepper driver with 16 microsteps has 64 distinct phases. Instead of homing with one step resolution, you can home to the resolution of the stepper motor.

Barrier to Entry

What’s stopping you from trying Klipper? You probably have a Raspberry Pi hanging around. Klipper’s firmware probably works with your current printer’s CPU (just be sure you know how to flash code on it and have a copy of your current firmware).

We couldn’t help but think that if you could field this on a Linux laptop, you could just have a kind of super control panel for your printer. Of course, you could do that anyway, but you’d be leaving even more computing horsepower on the table if you used a laptop to just hook into Octoprint.

From a hacking point of view, being able to make changes in the 3D printing algorithms over ssh using Python without having to flash a microcontroller ought to open up a lot of experimenting possibilities. If you have an interesting fork, be sure to send us a tip and we’ll cover it here.

 



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *