This documentation is a copy from https://miscsolutions.wordpress.com/mini-height-sensor-board
A differential modulated IR height sensor. The sensor detects the target height by looking for the reflected light from two separate LEDs to be equal. The two LEDs are positioned such that they reflect light into the sensor at slightly different heights. This allows the sensor to be used most any bed surfaces.
- A high degree of immunity from sunlight, incandescent artificial light, and other background sources of IR.
- Unlike capacitive and inductive sensors, the sensor measures the height to the top surface of a glass bed, not the distance to a backing plate.
- A red LED indicates when the head is at or below target height.
- Automatic selection of a 4-level analog output for printer electronics that support it (e.g Duet), or a digital output for other printer electronics.
- Power: 5V or 3.3V
- Maximum current draw: 20mA @ 5V, or 12mA @ 3.3V
- Size: 18mm high x 24mm wide x 10mm deep
- Weight: 2g (board and 3-way header, excluding socket)
- Trigger height to 3mm glass target on top of black paper: between 2.5mm and 3.5mm
- Reproducibility of repeated probing at same spot: approx. 0.01mm
Mounting the board
The board needs to be mounted with the two fixing holes at the top, and the bottom edge of the board (where the infrared components are mounted) facing the bed and at right angles to it. The sensing area is approximately in the middle of the bottom edge of the board, below the cylindrical capacitor. In order to minimise the effect of any tilt of the hot end as it moves in the XY plane, this area should be as close to the nozzle as reasonably possible, without being so close that the board or the components on it get hot. Mounting it with the back facing the nozzle is recommended, because it reduces the chance of the optical components getting contaminated by extruded filament, and shields the optical components from the heat of the nozzle.
The bottom edge of the board should be no more than 2mm higher than the tip of the nozzle, to ensure that it will trigger before the nozzle touches the bed. To avoid the risk of the board fouling on the print, we suggest that the bottom edge is at least 1mm higher than the tip of the nozzle. So aim for 1.5mm.
Very important! Check that there is no possibility of the board shorting against anything (e.g. the printer frame or the nozzle heating block), even if the head moves outside the normal printing range. Note that the heater block on E3Dv6 and similar hot ends is liable to rotate about the heat break! If the back of the sensor is close to the heater block, you should trim any protruding wire stubs and header pins on the back of the board, and put at least two layers of Kapton tape or alternative high-temperature electrical insulation on the back of the board. It is also a good idea to fit a silicone sock over the heater block, because this will provide additional electrical and thermal insulation. E3D now includes silicone socks with their hot ends, and they can supply socks to retrofit to earlier hot ends that were supplied without them.
Note for delta printer owners: It is important that the effector does not change its tilt relative to the horizontal as it moves in the XY plane. Otherwise, the height difference between the tip of the nozzle and the bottom of the sensor board will vary with XY position, giving rise to calibration errors when you use the sensor to auto-calibrate your printer. If you are using Duet electronics then you can compensate for effector tilt in the bed.g file, but it is better to avoid it in the first place.
For best results, the sensor needs to sense the reflection from the top surface of the bed. There is a potential problem when the sensor is used with a transparent bed material that reflects infrared light weakly and there is a surface below the transparent material that reflects IR much more strongly. Here is a guide to using the sensor with different print surfaces:
- Glass (with or without coatings such as hairspray, PVA or Kapton tape): works as-is if placed directly on a PCB bed heater or other surface that does not reflect strongly. If there is an aluminium heat spreader or bed plate underneath the glass, then either paint the aluminium surface matt black (see below), or put a sheet of matt black paper between the glass and the aluminium. Coatings on the glass affect the trigger height slightly.
- PEI: this is highly transparent to IR. Paint the underside matt black (see below) before using adhesive sheet to attach it to the bed plate. Changes to the surface finish affect the trigger height slightly. We have a report that as an alternative to painting the underside black you can sand the top surface with very fine grit sandpaper until it has a dull matt appearance, but we have not confirmed this.
- BuildTak: the dark grey variant works well with the sensor. I have not tested the white variant, but it should work too.
- PrintBite: early samples were found to be opaque to IR, but more recent samples are transparent to IR. This means that it needs to be painted black on the underside in order to work well with the IR sensor. However, this is not practical if the PrintBite sheet has the adhesive already attached.
- Anodised aluminium, with or without a thin PEI coating: suitable if the finish is matt or semi-matt
- Bright aluminium: not suitable
- Mirror: not suitable
If you need to paint the top of an aluminium heat spreader or the underside of a PEI sheet matt black, then I recommend using spray-on barbecue & stove paint. It needs to be cured at an elevated temperature to harden. I have found 2 hours at 170C in a domestic electric fan oven works well. Caution: the temperature in a domestic oven without a fan will vary greatly in different parts of the oven.
Connecting the board
Looking at the board from the component side, with the mounting holes at the top and the cylindrical capacitor at the bottom, the pads for the 3-pin connector are near the top. These pads are labelled from left to right on the front of the board as follows:
- OUT: this is the output from the board to the printer electronics.
- GND: this must be connected to signal ground on your printer electronics.
- VCC: this must be connected to the +3.3V rail of your 3.3V printer electronics, or the +5V rail if you have 5V printer electronics.
There are also pads for a 6-pin connector, on the right of the board looking at it from the component side. Ignore those pads – they are used for programming only.
Duet 0.8.5 and Duet WiFi electronics: wire the sensor to the 4-pin PROBE connector. Connect sensor GND and VCC pins to Duet GND and 3V3 pins respectively. The OUT pin of the sensor should be connected to the AD12 or IN pin on the probe connector. Leave the AD14 or PC10 or MOD pin on the probe connector unconnected.
Testing and commissioning the board
Testing with Duet electronics
In your config.g file, use probe type P1 in your M558 command and trigger threshold P500 in your G31 command.
Start with the hot end and sensor some distance above the bed. Power up the Duet using USB power only. About 4 seconds after power is applied, the LED on the sensor should flash four times, indicating that the board has started in analog output mode. If it does not flash, check the power connections to the board.
Connect to the Duet from a PC using the web interface. On the Control page you can see a continuous readout of the Z probe reading.
Send M558 P1 to the Duet, then send G31 P500 Z1.0.
Move a suitable target (e.g. white paper or glass) up underneath the sensor. Check that you get the following readings:
- With the sensor a long way above any surface, the reading should be close to zero.
- With the sensor close to a surface but slightly further away than the trigger height, the reading should be about 465.
- With the sensor slightly closer to a surface, the reading should be about 535 and the red LED on the sensor board should illuminate.
- If you place a surface right up against the sensor board, then the reading may drop to near zero again. This is normal.
- If you see a reading of around 1000, or if the LED flashes rapidly, this means that there is too much ambient IR for the sensor to function correctly. This normally happens only when direct bright sunlight is reflected from the bed into the sensor, or when you place a highly reflective surface below the sensor such as aluminium foil.
If you get the expected readings, then you can apply 12V power and continue with commissioning. If not, check your wiring.
With 12V power applied, send M558 P1 followed by G31 P500 Z1.0 to the Duet again. Note: if your printer does not use the Z probe to home any axes, you also need to add parameters X0 Z0 to the M558 P1 command.
To calibrate the sensor for Z homing and bed probing, home X and Y, then position the head over the centre of the bed. With the nozzle at operating temperature, lower the head so that it is just touching the bed or just gripping a sheet of paper, then send G92 Z0 to define that position as Z=0. Raise the head 5mm and remove the paper. Then send command G30 S-1 to probe the bed at that point without adjusting the Z height setting. Read off the Z height in the “Head Position” box in Duet Web Control, or from the Z coordinate shown on the Control page of PanelDue, or send M114 to retrieve the head position if using a USB host program on a PC. It should be in the range 0.5 to 2.5mm. Use that value for the Z parameter in your G31 command in config.g. Please note:
- The S-1 parameter may not be supported in the official RepRapFirmware release. It is supported in my fork and dcnewman’s fork.
- Always use a P value of 500. When the probe is triggered, the Z probe reading will be about 535. When it is slightly higher than the trigger height, the reading will be about 465. With a P value of 500, when the Duet sees the reading of about 465, it knows it is getting close to target height and it will slow down the Z motor.
- If you are using my (dc42) fork of RepRapFirmware, then the G31 command in config.g must come after the M558 P1 command. This is because the firmware supports different G31 values for different sensor types.
- After turning your printer on, do not perform any operation that uses the sensor (e.g. X homing on some printers) for 5 seconds, until after the LED has done its 4 flashes.
LED illuminates (more dimly than normal) as soon as the board is connected. This usually means that you have plugged the 3-pin connector the wrong way round on the board, thereby transposing the Vcc and Out connections. Turn the power off and check your wiring.
LED turns on/off to indicate triggering, but the printer firmware does not recognise whether or not it is triggered. Check that you are getting the correct number of flashes from the LED after power up (4 if you are using Duet electronics or RADDS electronics running RepRapFirmware, 2 for other electronics). If you are getting 4 flashes but expecting 2, then either the sensor output pin is not connected to your electronics correctly, or the pullup resistor is not enabled in your printer firmware, or the pullup resistor has too high a value. If you are getting 2 flashes but the firmware always indicates that the sensor is triggered even when it is not, then the value of the pullup resistor may be too low – see the note for Smoothieboard users above.
Trigger height relative to nozzle varies with XY position. This may mean that there is a large variation in the surface of your print bed, or (if it is a glass bed) in the reflectivity of the surface underneath the glass. Check that the bed surface is the same everywhere you are probing. Another common cause is that the print head is tilting slightly by an amount that depends on XY position (this is common on delta printers). Mounting the sensor close to the nozzle will reduce the effect of any such tilt.
If you cannot eliminate the variation of trigger height with XY position, then if you are using Duet electronics running my fork of RepRapFirmware version 1.09e or later, you can compensate for differences in trigger height using the H parameter on the G30 commands in the bed.g file.
Trigger height too low. This usually means that you have mounted the board too high. The bottom edge of the board should be between 1mm and 2mm higher than the tip of the nozzle. This should give you a trigger height between 0.5mm and 1.5mm. Another possibility is that you are using a glass or PEI bed and the surface underneath the glass is reflective – you should use a black surface underneath the glass or PEI.
Board dimensions and mounting holes
If the bottom left corner of the board is position (0, 0) then other points on the board are at the following (X, Y) coordinates, in mm:
Top right corner (24.0, 17.62)
Mounting hole centres (2.70, 14.92) and (21.11, 14.92)
Mounting hole diameter 2.8