For the limit switches on a custom 3D printer I’m designing, I want to try out some contactless sensors. I have chosen to use hall effect sensors, which are sensitive to a magnetic field.
There are three different types of these sensors available. First, there’s the omnipolar hall sensor, which turns on when a magnet comes in its vicinity. Next is the unipolar one, which turns on as long as a specific magnetic pole is close enough, which pole depends on the sensor. Finally, there’s the bipolar hall effect sensor, which latches on when one pole comes close and only turns off when it senses the other pole.
The sensors that I am using for my circuit is an Allegro A3144, an unipolar sensor. These are no longer manufactured, however eBay is chock full of them and they can be had for less than €0.20 each. They come in a miniature TO-92-like package, as seen in the picture below.
As a visual indication of the sensor’s status, I want two LEDs, one each for the triggered and off state. Since the A3144 has an open collector output, driving a LED from the output is only possible when the sensor is triggered. In order to drive both LEDs either a buffer or an inverter is required. One option is to use an N-channel MOSFET for the off LED and connect the triggered LED straight to the A3144’s output. Apart from the MOSFET, this would also require a resistor to the MOSFET’s gate. A alternative which uses less parts is the versatile 74LVC1G58. This is a configurable logic chip with 3 inputs, which has ±24 mA output drive and comes in a tiny SOT23-6 package. Best of all: when configured as an inverter, the pins are grouped together such that the chip can be soldered on a standard breadboard. You can find the schematic for my simple hall effect switch below.
I used SMD components for everything, except the hall effect sensor and the connector. Although tiny, all of the SMD components can be soldered without any problem on a standard breadboard. The dual LED comes in a 1210 SMD package, all resistors and capacitors are 0603 format. The connector is a tiny JST ZH and had to be cut up a bit, so that the leads could be forced into the breadboard. I didn’t bother with a custom board, due to the small number of components. Connections are made with solid core 30 AWG (≈0.25 mm diameter) PTFE coated wire. I really like the PTFE coating for SMD work, since it won’t melt when heated by a soldering iron, so you don’t get accidental short circuits. In the middle of the board is a mounting hole for an M3 bolt. The final board size is 19 mm x 14 mm. For fun I routed a custom two-layer layout (all components on the top layer) which came out to 17 mm x 11.5 mm, so this breadboard layout is pretty close to the minimum area. Below is a picture of the board on a 50c coin for size comparison.
The circuit triggers very reliably for a handful of magnets I have lying around. The A3144 has build-in hysteresis, which is really nice. Without it, the output would oscillate when a magnet is just at the trigger distance. Although not necessary in this case, the 74LVC1G58 has Schmitt-trigger inputs, so you could use an analog output hall sensor instead of the A3144 and would also get hysteresis on the output without having to change anything else. See the image below for the circuit both in off and triggered state.