# Hall effect switches

Sometimes you find a non-contact switch is very useful in sensing presence and speed. Take car speedometer for example, you need to know how many turns the wheel makes per second to find the car’s speed. You could use a mechanical system to find out the speed of the wheel but a mechanical system is prone to failure. You need a non-contact measurement of the rotation of the wheel. In quantum physics, there exists no way that would measure something without changing the one being measured so no real non-contact measurement exists. But when everyday measurement is concerned, lots of ways constitute non-contact measurement. One can use a photo gate to tell speed. On the other hand, mud can also get into the system and prevents a photo sensor from working properly. An alternative is to use magnets and magnetic sensors. If you attach a magnet to the moving part of your wheel, then attach a magnetic sensor to a non-moving part of your car, close to the moving magnet, you can detect the presence of the magnet every time the wheel brings the magnet close to the sensor. If you keep your count and work out the relation between counts and angular speed, then angular speed and linear speed, you can display it on the speedometer.

So the sensor that we are going to use is a Hall effect switch, which is a digital element that outputs HIGH and LOW under different conditions. Here is the principle:

From physics, magnetic field affects charged particles. Inside a semiconductor, the charge carriers can be either positive or negative. Say you pass positive charge from left to right at a constant rate (current is constant). Then the magnetic field will affect the charge carriers and deflect them towards the side. The deflected charges are deposited on the side of the semiconductor, which set up an electric field. The electric field does just the opposite what the magnetic field does, deflecting the charges the other way around. Once there are enough deflected charges, the electric field will exert enough force to the moving charges to completely cancel the force from the magnetic field. At this point, the deflection stops and charge carriers flow through in a straight line. The stronger the magnetic field, the more charges need to be deposited and the greater the electric field. You can measure the field in terms of voltages, and deduce the amount of magnetic field strength, which is proportional to the voltage.

Here is a Hall effect switch:

There are three pins, 5V, ground, and signal.

For this particular one, bringing in North pole to it will result it to switch to HIGH. Then removing the north pole will not return the switch to LOW until the south pole is brought close to it. It will output LOW. A switch that retains its state until a different condition is met is called a latch. When north pole is brought near, the switch latches to HIGH, until when a south pole is brought in and the switch is latched to LOW.

Another type of sensor is not latched so if it senses north pole, it will switch to HIGH, then if north pole switch is removed, it switches to LOW. To find the switch that fits you, you should read the spec sheets on the logic behaviors.

Here is the link to the latching switch sold at sparkfun.com