Sonic 3D Printer Auto Bed Leveling Makes a Swoosh

3D Printering: the final frontier. These are the voyages of another 3D printer hack. Its mission: to explore strange new ways of leveling a print bed.

So far, we’ve had servo probes, Allen key probes, Z-sled probes, inductive and capacitive contactless switches, just to name a few. All of them allow a 3D printer to probe its print bed, calculate a correction plane or mesh, and compensate for its own inherent, time variant, inaccuracies.

conductive pads by Zortrax
Build plate with conductive pads by Zortrax

These sensors are typically mounted somewhere on the print head and introduce their own sensor offset, which has to be precisely calibrated for the whole thing to work. To eliminate these offsets – and a large part of costly EOL testing and calibration – the Polish 3D printer manufacturer Zortrax uses a smarter approach: Conductive pads on the build plate. During the leveling procedure, the printing nozzle makes contact with these pads, which practically turns the nozzle itself into the probe — offset-free. Makerbot patented a contact sensing solution based on force sensors located in the print head, although similar builds based on limit switches were known before. Other DIY builds use force sensitive resistors (FSR) underneath the build plate to achieve the same. All these techniques are based on the detection of a brief contact between the printing nozzle and the build plate, and are therefore offset-free.

Compelled by the idea of eliminating the last manual calibration step, I wanted to make Zortrax’s method of contact sensing compatible with non-conductive PEI, Garolite and glass build plates. I didn’t want to interfere with the Makerbot patent, and force sensitive resistors would not survive the temperatures of a heated bed. I figured that I could just strap a sufficiently heat resistant piezo sensor to the print bed to sense the little knock the nozzle would make when it collides with the print bed. However, not much sound energy is released when a nozzle runs into a build plate at blazing 1 mm/s. A first test revealed that the knocking sound was too weak to be reliably distinguished from other vibrations in the machine.

Visaton EX 45s structure-borne sound exciter (image source)

To fix this, I acquired a 10 W structure-borne sound exciter and attached it to the extruder. The exciter allowed me to actively inject a white noise signal into the nozzle. If it was strong enough, this signal would travel through the entire printer and could be picked up by the piezo discs in the print bed, far above the printer’s own noise level. I assumed, that when the nozzle touches the print bed, the transfer function between the exciter and the piezo sensor must change rapidly due to the direct transfer of sound between the two. This change would then lead to a rapid change in the amplitude spectrum the piezo picks up. A little DSP could process the piezo signal, detect these rapid changes in the amplitude spectrum and give back a trigger signal to indicate the collision.

For the required realtime DSP, I hooked up the piezo discs to a plain Teensy Audio Shield equipped with a Teensy 3.1, which practically completed the hardware portion of this project in one step. Using Paul Stoffregen’s amazing DSP library, it took only a few lines of code to run a 256 point FFT on the input signal and a few more to generate a time-averaged amplitude spectrum. The little sketch compares this averaged “frequency fingerprint” of commonly present vibrations to the current spectrum, calculates an overall energy difference between the two, and if that difference exceeds a certain threshold, the Teensy pulls an output pin low, telling the 3D printer controller that the nozzle just touched the build plate. I later added an OLED display and rotary encoder, basically for plotting the signals and for being able to adjust the threshold.

sonic_probing_teensy

This turned out to work quite well, while submersing the whole printer in a pleasant swoosh noise, but it added quite a bit of additional weight the extruder assembly. Also, these exciters aren’t particularly cheap, and an additional audio amp would be required, too. It wasn’t really it.

It took a while for me to figure out what I would do with the whole project. And then, just when I was about to send it into project-limbo, I had another idea: To save cost and weight, I could use the extruder’s stepper motor as the exciter, the stepper motor driver as the amplifier, and stick with the cheap piezo discs attached to the print bed as microphones. In theory, the 3D printer controller could both generate the noise signal and process the sound signal from the piezos, so the only additional component would be the preamp and the piezo discs.

sonic_extruder
“Extruder, you’re a speaker now.” – “K, boss.”

Yet, it was still unclear if the stepper motor would adapt to become some sort of speaker, so that’s the first thing that needed testing. I hacked together a little noise injector board that would go between the 3D printer controller and the stepper driver. This little hack utilizes an Arduino Pro Mini clone to switch between two modes: A bypass-mode, where it just passes through the signals from the 3D printer controller, and a noise mode, where it streams a pseudo-random sequence of forward and backward micro steps to the motor driver. This, I hoped, would cause the stepper motor to oscillate and produce a noise signal. And well, it did. I turned it on and the extruder motor swooshed with a strong noise, very similar to the exciter I used before, although the extruder’s gears rattled quite a bit.

sonic_probing_noise_injector
Noise injector with Pololu DRV8825 driver (right), plain Pololu DRV8825 driver (left)

I tweaked the random sequence to make sure that the stepper motor would never perform an actual full step as a random accumulation of micro steps. Besides that, everything worked surprisingly well. The probing is accurate to a level where it becomes really hard to tell how accurate it actually is. If the nozzle touches down to a sheet of paper and stops once it senses the touch, the paper will slide easily and consistently between the nozzle and the build plate without being stuck. Since then I’ve been using this for several prints, and it works just like regular auto bed leveling probes, although with fewer advantages than expected: It eliminates the offset calibration, but also introduces a threshold value for the touch detection.

From an economical view, this is still a nightmare. On current Arduino-style 3D printer platforms, it takes an additional DSP, DAC, a preamp and the noise injection adaptor to implement this sort of sonic auto bed leveling. Even if the piezo discs are virtually free, everything adds up to about 5 times the cost of a decent capacitive distance switch.

It might make more sense in the not so distant future. We’re beginning to see a new generation of 3D printer controllers that feature a more powerful 32 bit MCU, ideally we want one that supports DSP instructions. Given the availability of cheap STM Nucleo boards with powerful, DSP-enabled ARM Cortex-M4 MCUs, my bet is that insanely powerful 3D printer controller electronics, capable of tricks like this one, are bound to happen rather soon. For now, enjoy the following video of an early test of the sonic auto bed leveling:

39 thoughts on “Sonic 3D Printer Auto Bed Leveling Makes a Swoosh

    1. Yea, you could float the plate on a sea melted gallium. When you want to level it, heat up the gallium until it melts (29.76 degrees Celsius) Let it float level and then let the gallium cool and harden. You are now level with a solid foundation. The next challenge is keeping the heated bed from melting the gallium again. Not too useful since this does not compensate for irregularities in the building surface, levelness of the xyz motion system, and simply being at the right level. Its good to brainstorm, though.

  1. analog band pass filter tuned to the frequency of the oscillation of the extruder. If we can play music on an extruder we can have a band pass that picks up only that one note and triggers…you might even be able to do it with a single cheap op-amp…digital isn’t always the solution – although it can usually be an answer.

    1. I’d love to see a purely analog implementation of this. Although an oscillation of only a single frequency transmits very few energy compared to white noise. Also, they create standing wave nodes on the plate, so it would be quite an effort to get a uniform sensitivity across the entire build plate.

      1. Wouldn’t the greatest signal strength would be at the resonant frequency of the piezo, so why not use a piezo mounted to the heatsink fins on the hotend as the exciter? Physical contact of the nozzle would increase the received amplitude greatly, no?

        If you were concerned about standing waves at a single frequency, surely an array of piezos as you have on the bed would be able to detect this. The Arduino Knock sketch has a principle of reading the voltage when piezo is touched (vibrated at resonant frequency in this case) and a high value resistor is between the piezo terminals. Could this be the basis for a digital input to the controller, perhaps with op amp? With ATMEGA/RAMPS/MARLIN, you could use a pin to enable the sound excitation (custom G/M code required?) and just link the piezo array input to the probe pin.

        The haptic motors would also be a good approach, as already suggested, if you didn’t want to use highly audible frequencies but I wonder if the amplitude of the bed during vibration would make this low frequency imprecise.

        Finally, any thoughts on whether the response of an electret microphone would make them suitable? What’s the leap in detectable signal between an air gap and physically touching? Would they work over a greater range of frequencies?

  2. You’re eventually going to chew up your Z-axis mechanism this way.
    Why not excite the bed with a broadband acoustic signal, and look for the impedance change when the print head contacts it?

  3. As an aside, Zortrax patented the conductive bed pads approach. I think it’s a BS patent but it’s still a patent. If you’re just doing it for yourself you’re reasonably safe (if still technically violating modern patent laws, but probably too low profile to be a concern to them), but if you want to sell the parts or the machines to do this, you might run into trouble.

    One of the ways to avoid z-wobble is avoid over constraining the screws, several designs use isolators that “float” the X gantry, so the method in this article won’t work for them.

    1. In any case, it pretty much sucks for a 3d-printer anyway. The nozzle coats itself in non-conductive plastic *by design*, so getting a reliable electrical contact is a non starter.

  4. Use a small vibration motor to create the noise, cheap and easy to control. The amplitude is dependent on the motor speed. It should have a very distinct signature that would be easy to detect.

  5. I don’t quite get why you need the complexity of white noise. Surely you could just modify the pattern of steps the controller uses as it approaches the bed, in a Up-Down-Up-Down-Up-Down-Down kind of way so that when it reaches the critical height it’s tapping the bed like a woodpecker at high speed. What’s with the white noise requirement?

    1. Yeah, I tried the woodpecker tapping. It works better at high speeds, but the accuracy is terrible. You really need to smash the nozzle into the build plate to get a well-defined transient signal that lies above the general noise level. White noise transmits the maximum energy within a given bandwidth and also isn’t affected by standing wave nodes in the build plate.

  6. Another posibility: Just send steps at a rate that’s too high for the stepper (e.g. x khz * microsteps) after making sure it’s definitely not moving (no steps for y ms). The stepper will not be able to accelerate fast enough and therefore miss steps at a certain frequency. Then, use the technique described by [restrictedayerspace] above to detect the signal.
    If done properly, the stepper should vibrate less then a step, therefore limiting the amount of damage it could do to the mechanics.
    Part of this, I already tested (accidentally), while working on a very basic step generator in verilog. My clock divider was not working as expected and sent step signals at about 120khz. Since I used 16 microsteps, that should be a bit more than 7 khz. The stepper was not strong anough to accelerate that fast, instead, it started whining.

  7. Very cool idea & good writeup, however ‘im with’ some of the people here saying your sorta messing up your gears/belts/etc, i liked the approach with the ‘structure-borne sound exciter’ more, but understand what your saying about cost, however, what about a simple pager motor? those can be had for cheap afaik, and that should be detectable/destinguishable too

    1. Thanks! Haven’t messed ’em up yet, but the fizz is gone. A pager motor won’t produce white noise (at least if not driven with the same trick I’m using with the stepper motor). The noise is necessary, since monofrequent oscillations carry too few energy at a given bandwidth/amplitude and also create standing wave nodes on the build plate. At these nodes, the sensitivity is practically zero.

  8. “structure-borne sound exciter” = fancy name for a speaker that bolts to things. Figure out a way to mount a small speaker to the extruder so it’s quick to remove for printing.

    1. Making it detachable is a great idea. Although it’s more a fancy name for what it actually is. SBSEs don’t have membranes, instead, they have a piece of mass. A regular speaker won’t really work here.

  9. Couldn’t you get the same effect as the Zortrax setup by just using a sheet of aluminum foil you place on the bed for levelling purposes, then take off for printing? Or better yet, combine the Zortrax system and the servo-switch system, but with a curved bit of foil instead of the switch, and the servo swings it down under the nozzle, ready to be sandwiched between the nozzle and glass.

  10. I’ve tried the conductive pad solution once, it was alright, but not perfect. The nozzle has plastic remainings all over, and isn’t a very good conductor. This resulted in the extruder squishing the bed before making actual contact, so that the leveling would be inaccurate. This is with the extruder heated to printing temp, otherwise it isn’t working at all.

    1. Why not move the conductive pads to a different location? Say at the Z rods/rails? When the nozzle contacts the bed, the conductive pads on the Z rails/rods open, telling the printer the nozzle is at Z0.

  11. Seems like a defined modulated audio tone would be enough to pick out of the noise if you could strap a microphone to the bed and adjust the threshhold to cancel out the vibrations delivered through the structure. I think you would have to FFT the resulting speaker output and compare to the known tone or tones. I know I’ve seen steppers used as speakers before. (http://makezine.com/2009/06/23/stepper-motor-music/) As an added bonus it could say things like “autolevel complete” through stepper vibrations which hopefully could be more audible with the nozzle in contact with the bed. I def. don’t know how to do any of that though, so maybe I’m a bad person for suggesting anything. As long as we’re spitballing here, I think the right answer is to have a bed that is gimbled and has steppers on lead screws to level itself.

  12. I have tried a number of methods using piezoelectric disks including transmitted sound – from a pager vibrator motor in my case. The biggest problems I found were dead areas on the plate where standing waves cancelled out. You may also run into some problems with the limited usable temperature range with the PZT ceramics used on these disks I did find that the simple click of contact can be detected although I settled on detecting reduction of force on a set of three disks. Details of this at http://forums.reprap.org/read.php?1,635075,page=1 and http://www.thingiverse.com/thing:1399512

    Mike

  13. “Sonic 3D” is what I saw first in the title. And then I realized it has nothing to do with SEGA products. :-)

    I’m glad to see someone using sound for pseudo-bed-leveling. (To me bed leveling means adjusting the bed to make it level, not measuring the nonconformity) I had no idea anyone would take it to this extreme. :-) (FFT and all) I imagined someone simply setting up a high gain amplifier between detector on head and sound source on bed (or reverse) such as to create a wicked feedback loop when touching. Then slowly lift until the feedback stops and then you’ve measured the point.

  14. There is no need for either wicked feedback nor even high gain – 2 is close enough to “very high” with piezo transducers as long as the amplifier has a decently high input impedance – You would be amazed quite how large an output you get from a piezo disk used as a sensor.

    Mike

    1. Makes sense to me that the piezo element already has high gain built in. :-) Anyone who has ever shocked themselves on the igniter trigger on their gas water-heater knows they can be substantial. :-)

  15. Aren’t we ignoring the transferability of the Zortrax shortcoming that people have pointed out here? If filament deposits on the nozzle below the lowest point of the metal, this sensor technique appears to be fooled into thinking that the nozzle is in contact with the bed when it is a potentially significant distance above. Yes, the relative distance between bed probing points will be unaffected but your all-important first layer might be.

  16. Deposits on the nozzle along with particles picked up from the build stage can be a problem but there are various workarounds. Using the nozzle hot after extruding a small amount of hot filament then retracting the filament and wiping the nozzle on an unused part of the bed goes a long way. Doing a sanity check to check that the measurement is about what it should be and repeating until it looks safe should also help. The sound transmission technique should also give a better idea than force-contact measurements as there will be attenuation of higher frequencies even with a thin layer of soft extrudate.

    Mike

  17. have you tried a pager motor (boy does that date me!) or a disc motor, spinning at a rough harmonic of your piezeo pickup? orient it so that it”s effective motion is in the vertical plane..IE: shove it between the fins of the extruder heatsink :-} you should be able to provide power 1 to 3 volts, and control through your detection circuit good luck JB

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s