# Optical Sensor Probe Project

**URL:** https://forum.lulzbot.com/t/optical-sensor-probe-project/6784
**Category:** Hardware
**Created:** [July 4, 2019, 3:12pm UTC](https://forum.lulzbot.com/t/optical-sensor-probe-project/6784 "2019-07-04T15:12:47Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Rp1030](https://avatars.discourse-cdn.com/v4/letter/r/e99b99/32.png) [@Rp1030](https://forum.lulzbot.com/u/Rp1030)
#### Post date: [July 4, 2019, 3:12pm UTC](https://forum.lulzbot.com/t/optical-sensor-probe-project/6784/1 "2019-07-04T15:12:47Z")

</div>

Hey everyone. I’ve been mentioning this project for a little bit and I was thinking that it’s time to start posting my results. Hope you all like it!

Proximity Sensors are nice, but how accurate are they?

We have the Capacitive sensor that can be used on anything with a current, which is good, however it detects electrical current which means different readings for different print bed temperatures. This type of probe can also have different readings based on the ambient temperature in the room and may be affected by dust in the air…

We have the inductive sensor which is limited to metal print beds, is also affected by the amount of current running through its sensing area, can also be affected by ambient temperature and dust as well, and is at least 3x the cost

and we have the mechanical sensors that can be as simple as a microswitch or as complex as the BL Touch sensor (also 3x the cost of the capacitive sensor) . They can sense on any surface but are they really accurate?  
With no experience, I can’t say anything about the BL Touch, but the common microswitch was highly inaccurate, and was also affected by the temperature of my print bed…

So, here’s my solution!  
 ![Optical Sensor.jpeg](https://us1.discourse-cdn.com/flex020/uploads/lulzbot/original/2X/a/a940ec8662db0b56dd389b8881548e866859867d.jpeg)  
An optical sensor!  
This uses a LM393 Dual Differential Comparator IC and will output in Digital and/or Analog

This type of sensor with my probe design can detect distance on any surface with high speed and accuracy, and is not affected by current, print bed temperature, ambient temperature, dust, or humidity.  
I’ve designed this to be used as a Z stop probe, however this can be used as an endstop with the simple implementation of a spring and a design tweek.

So now the fun stuff:

List of Parts:  
 ![Parts.jpg](https://us1.discourse-cdn.com/flex020/uploads/lulzbot/original/2X/e/ed489212aad53943fd1f8a9b3f387c5281040c28.jpeg)  
1x Optical Sensor  
1x Step down Buck converter  
2x M3 x 12mm screw  
1x M3 x 15mm screw  
1x small washer  
1x #14 gauge body piercing (one end chucked into a drill and sanded down to form a cylinder)  
Jumper Cable Pin Header Connectors  
Wires  
you will need All printed parts from this post

Also you will need this equipment:  
A Soldering Iron  
Solder  
Electrical Tape  
Wire Cutters and maybe Wire Strippers  
Heat Shrink Tubing  
Digital Multimeter

And when you’re finished it should look something like this:  
 ![SensorAttached.jpg](https://us1.discourse-cdn.com/flex020/uploads/lulzbot/original/2X/e/ed4d0e3135182a741c794bbe9e95f441279e7e80.jpeg)  
I even have a video found here: (I am having serious problems uploading files to this forum)

---

<div class="post-metadata">

### Author: ![Rp1030](https://avatars.discourse-cdn.com/v4/letter/r/e99b99/32.png) [@Rp1030](https://forum.lulzbot.com/u/Rp1030)
#### Post date: [July 4, 2019, 3:17pm UTC](https://forum.lulzbot.com/t/optical-sensor-probe-project/6784/2 "2019-07-04T15:17:01Z")

</div>

Front:

 ![Case Back.png](https://us1.discourse-cdn.com/flex020/uploads/lulzbot/original/2X/d/d492e2be987e1053d93a7ac2d5f0c7d91babf7b8.png)  
[CaseFront\_Healed.stl](https://forum.lulzbot.com/uploads/short-url/A3HiDdo7eyxxXHo7PQWjcQiGFYm.stl) (570 KB)  
Back:  
 ![Case Front 2.png](https://us1.discourse-cdn.com/flex020/uploads/lulzbot/original/2X/9/9251323c61de157582e7fcfb00280ecd7f7fc4b9.png)  
[Holder2.stl](https://forum.lulzbot.com/uploads/short-url/2i1ZULKcd5c7g3niudb6OTiR7Il.stl) (274 KB)  
Holder  
 ![Case Holder.png](https://us1.discourse-cdn.com/flex020/uploads/lulzbot/original/2X/d/d26255220e3f7e806af60b5263edc66d383a69c2.png)  
[New Back.stl](https://forum.lulzbot.com/uploads/short-url/duYGc6cmaM9brXXYxDZwUeudakZ.stl) (45.2 KB)  
Probe Screw  
 ![Probe Screw.png](https://us1.discourse-cdn.com/flex020/uploads/lulzbot/original/2X/1/1b9a4b0dc619a82e777f7359e5eb1b50033ebabd.png)  
[Screw W Hole.stl](https://forum.lulzbot.com/uploads/short-url/eTdHNW1LJrkR5rGVsK203l0hPjV.stl) (570 KB)  
New Activator Bar (this one works better)  
[Activator Bar.stl](https://forum.lulzbot.com/uploads/short-url/p9Xt86yiqQ3pFl0taAtqyjYi0s6.stl) (11.6 KB)

---

<div class="post-metadata">

### Author: ![Rp1030](https://avatars.discourse-cdn.com/v4/letter/r/e99b99/32.png) [@Rp1030](https://forum.lulzbot.com/u/Rp1030)
#### Post date: [July 4, 2019, 3:18pm UTC](https://forum.lulzbot.com/t/optical-sensor-probe-project/6784/3 "2019-07-04T15:18:59Z")

</div>

Firmware adjustments needed:

* * *

Your Z\_MIN\_ENDSTOP\_INVERTING within your firmware needs to be set to False

(Here are my offsets (using the mount adapted to the X-rails mod)  
X\_PROBE\_OFFSET\_FROM\_EXTRUDER -14  
Y\_PROBE\_OFFSET\_FROM\_EXTRUDER 127  
Z\_PROBE\_OFFSET\_FROM\_EXTRUDER 0 (I use my gcode to set this offset)

Gcode

* * *

This is my current gcode, subject to change in the future.

G21 ; set units to millimeters  
M107  
G28 ; home all axes  
G1 Z10 F5000 ; lift nozzle \<----  
M203 X192 Y208 Z4 ; set max rapid rates mm per sec  
G91; set to incremental motion  
G1 Z5 F11520; raise Z  
G90; set to absolute motion  
G28 X0 Y0; home X and Y axes  
G1 X276 F11520; go to probe deployment position  
G1 X289 F350; deploy probe  
G1 X138 Y62 F11520; go to probing spot  
G28 Z0; Home Z axes  
G29; probe bed  
G1 Z5 F11520; raise probe off bed  
G1 X10 F11520; go to probe retract position  
G1 X0 F350; retract probe  
G1 X1 F350; move away from limit switch  
G92 Z7.5; Set actual location \<\<-------(This is important when you’re setting your z-hight from the print bed)  
G92 E0 ;zero the extruded length  
G1 F200 E3 ;extrude 3mm of feed stock  
G92 E0 ;zero the extruded length again  
G1 F{travel\_speed}  
M117 Printing… ;Put printing message on LCD screen

---

<div class="post-metadata">

### Author: ![jimbalny](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.lulzbot.com/jimbalny/32/9837_2.png) [@jimbalny](https://forum.lulzbot.com/u/jimbalny)
#### Post date: [October 14, 2019, 8:07pm UTC](https://forum.lulzbot.com/t/optical-sensor-probe-project/6784/4 "2019-10-14T20:07:14Z")

</div>

This is awesome! Nice work! I’m curious though how the toolhead moves rapidly towards home and nicely slows down before hitting the endstop, I’ve never seen that behavior before.

---

<div class="post-metadata">

### Author: ![Rp1030](https://avatars.discourse-cdn.com/v4/letter/r/e99b99/32.png) [@Rp1030](https://forum.lulzbot.com/u/Rp1030)
#### Post date: [October 15, 2019, 1:46am UTC](https://forum.lulzbot.com/t/optical-sensor-probe-project/6784/5 "2019-10-15T01:46:07Z")

</div>

> [@](#):
>
> This is awesome! Nice work! I’m curious though how the toolhead moves rapidly towards home and nicely slows down before hitting the endstop, I’ve never seen that behavior before.

Thanks. All of the movement outside of the G29 command is done with my start Gcode.  
I’ve highlighted in red where my movement speed goes from 11520 mm/m down to 350 mm/m in the Gcode  
  
  
G21 ; set units to millimeters  
M107  
G28 ; home all axes  
G1 Z10 F5000 ; lift nozzle \<----  
M203 X192 Y208 Z4 ; set max rapid rates mm per sec  
G91; set to incremental motion  
G1 Z5 F11520; raise Z  
G90; set to absolute motion  
G28 X0 Y0; home X and Y axes  
G1 X276 F11520; go to probe deployment position  
G1 X289 F350; deploy probe  
G1 X138 Y62 F11520; go to probing spot  
G28 Z0; Home Z axes  
G29; probe bed  
G1 Z5 F11520; raise probe off bed  
G1 X10 F11520; go to probe retract position  
G1 X0 F350; retract probe  
G1 X1 F350; move away from limit switch  
G92 Z7.5; Set actual location \<\<-------(This is important when you’re setting your z-hight from the print bed)  
G92 E0 ;zero the extruded length  
G1 F200 E3 ;extrude 3mm of feed stock  
G92 E0 ;zero the extruded length again  
G1 F{travel\_speed}  
M117 Printing… ;Put printing message on LCD screen

---

<div class="post-metadata">

### Author: ![Rp1030](https://avatars.discourse-cdn.com/v4/letter/r/e99b99/32.png) [@Rp1030](https://forum.lulzbot.com/u/Rp1030)
#### Post date: [April 30, 2020, 3:24am UTC](https://forum.lulzbot.com/t/optical-sensor-probe-project/6784/7 "2020-04-30T03:24:37Z")

</div>

New Servo Mount that sits under the X AXIS Liner Rail Plate

 ![Screen Shot 2020-04-29 at 10.05.45 PM](https://us1.discourse-cdn.com/flex020/uploads/lulzbot/original/2X/d/d2cdc5f269472758241570221beccbb4be246493.jpeg) ![Screen Shot 2020-04-29 at 10.06.22 PM](https://us1.discourse-cdn.com/flex020/uploads/lulzbot/original/2X/6/656aeb7f7725c39d40e8f12e3bef24ccebb43666.jpeg)

I will follow up in a few days with the files and more pictures. I’m going to bed 😴
