Reed switch vs. Hall effect sensor

Reed switch vs. Hall effect sensor

Two years ago, we told you about reed switches, especially to warn you about the difficulties that you can encounter when you want to use them to build a rev counter. But we had somewhat forgotten to tell you about Hall effect sensors, which can be a welcome substitute.





The idea of a rev counter based on a reed switch is to rotate a disc equipped with a magnet that generates an impulse each time it passes in front of the contact. You then only need to count the number of pulses per second to know the rotation speed. The Yocto-PWM-Rx does that very well.


Issues with reed switches

A small reed switch (MITI-7-15-20 de Littelfuse) and a tiny magnet able to trigger it
A small reed switch (MITI-7-15-20 de Littelfuse) and a tiny magnet able to trigger it


As a reminder, reed switches are small glass bulbs ending with two legs. Inside, there are two metal strips, which come together in the presence of a magnetic field, and end up touching each other, thus creating an electrical contact between the two legs. These bulbs behave exactly like switches, so it's very easy to wire them. Note that the magnet doesn't need to be very large. In this post, we used a 2x2mm cylindrical neodymium magnet.

Wiring a reed switch with a Yocto-PWM-rx, don't forget the pull-up
Wiring a reed switch with a Yocto-PWM-rx, don't forget the pull-up



However, this technology has some problems:

  • the bulb must be installed in parallel to the axis of the magnetic field which controls it, and at the correct distance. Too close and you obtain three pulses for each revolution, too far and it doesn't work.
  • being based on mechanical contacts, the strips can generate significant rebounds and a rebound doesn't need to be very big to count as a pulse.


Signal generated by a reed switch (5ms per division)
Signal generated by a reed switch (5ms per division)


The same signal but at a 50ums per division scale
The same signal but at a 50ums per division scale


On the scope capture above, we are at 62.5 Hz, but even the oscilloscope detects double the frequency because of the high rebound

You can naturally work around these rebounds by using the debounce parameter of the Yocto-PWM-Rx. In the example above, a 1ms debounce solves the issue without difficulty. But if you increase the speed, the size of the pulse is going to diminish and if it becomes inferior to the minimal duration for the debounce, you won't have a measure anymore. Note that this rebound issue is important to measure fast and repetitive movements. If you only want to detect the opening of a window or of a door, you can very well ignore the phenomena.

The Hall effect sensor

The basic use of Hall effect sensors is to measure magnetic fields. Electronic compasses are based on this type of component. But there is a much simpler version of this type of sensors which behave as if they closed a circuit when in presence of a magnetic field.

An NPN Hall effect sensor, the SS441A by Honeywell
An NPN Hall effect sensor, the SS441A by Honeywell



In terms of benefit/disadvantage ratio, they are the exact opposite of reed contacts: they don't generate any rebound which enables them to go very fast.

Signal generated by a Hall effect sensor (2ms per division)
Signal generated by a Hall effect sensor (2ms per division)


The same signal, 50ums per division,  no rebound :-)
The same signal, 50ums per division, no rebound :-)



They are also easy to install: you are either in the right direction and close enough to the magnet and it works, or it doesn't work at all. No need to use an oscilloscope to be sure that everything happens as expected.

However, these sensors must be powered, which makes wiring slightly more complex. In the case of the SS441A which can work in 5V, you can take 5V from the contacts located behind the USB connector. Don't forget to put in common the USB ground with the sensor ground. Note that this has for effect to neutralize the isolation of the Yocto-PWM-Rx.

Wiring of an NPN Hall effect sensor with a Yocto-PWM-rx
Wiring of an NPN Hall effect sensor with a Yocto-PWM-rx



You probably noticed that this sensor is an NPN sensor, which means that you can also use it with a Yocto-IO, a Yocto-Maxi-IO-V2, or even a Yocto-Knob.

Conclusion

If you want to detect a mechanical motion in a fast and reliable way, a Hall effect sensor and a tiny magnet could very well make your life easier without too much expense, as long as you can power it.

Add a comment No comment yet Back to blog












Yoctopuce, get your stuff connected.