Monday, April 15, 2013

Optical distance sensors

I've been looking for a good solution to automatic bed leveling, Nophead did some work on this a couple of years ago using a sensor that was deployed during a calibration phase. I've also seen a solution using a metal bed and the hotend itself as a probe.

The idea is simple enough measure 3 points to get the plain of the bed, adjust the incoming GCode to print parallel to it.

The same approach could be taken to auto calibrate a delta printer, though in this case you'd adjust the arm positions to all have the same step value at the same height. It's actually a little more complicated that this because the measurement point would be offset from the center of the head, but it's still relatively simple.

My original idea was similar to Nophead's, have a deployable probe and use a mechanical switch for the measurements, using a system where the head would be moved into a physical obstacle somewhere in the build envelope to deploy/retract the probe.

However a friend of mine pointed me at optical distance switches, used in robotics for obstacle detection.

After reading the datasheet, they are really pretty inaccurate, but in this application accuracy is irrelevant, all you need is 3 values relative to each other, so what matters is repeatability. Of course there is no information on that in the data sheet, so I ordered one from Pololu.

I spent most of the weekend writing a TCP stack for the LPC1768 board, but I did get a change to wire up the sensor and do some rough testing.
I attached it temporarily with some tape to me RostockMax's carriage, and jogged to turn the proximity LED on and off.

I wasn't expecting much, but it turns out it's remarkably repeatable. I would estimate in the 0.02mm range and certainly better than 0.05mm.
So now I have another project to get back to when I have some time...


  1. I've been thinking hard about ways to auto level the rostockMax as well .. I was thinking that three of these placed @ the edge of the onyx print bead and a routine that would drop, slowly touch etc... they are kind of spendy, but with the known thickness and ability to sense actual force you should be able to get a very true reading.

    1. I looked at those , I was going to put them in the hotend mount, but they require a fair amount of force to get a significant resistance change and they are very temperature sensive.

  2. Hi Marcio,
    I think he is using the sharp sensor GP2Y0D810Z0F .

  3. oops, my fault, only the package is the same, the datasheet shows it is a 1bit 10cm sensor. I think the sensor Rob used is a substitute for GP2Y0AH01K0F but I didn't discover what is it.

  4. hurrah, I was right, he used GP2Y0D810Z0F from this module: Unfortunately it is not so accurate like the GP2Y0AH01K0F, but this one is obsolete...

  5. Hey great post, I truly enjoyed reading it! Thanks for the cool informative post.Print Shop in Irvine

  6. It's realy an informative post. I like the design as well. website Design Laguna Niguel
    Thanks for sharing.

  7. Same day Sticker Printing London Same Day Printing in London YES, Our average turnaround time is only 3 hours. We are one of the fastest turnaround printer in London. If you have been let down by some printer or have urgent requirements for tight deadline then you came on right place. Same day printing is available on:A BoardsAnnual ReportsAprons printBackdrop PrintingBadgesBags