Linear Hall-effect ICs are magnetic sensor devices designed to respond to magnetic fields to produce a proportionate amount of electrical output.
It thus becomes useful for measuring the strength of magnetic fields, and in applications that require an output switched through magnetic triggers.
The modern hall effect ICs are designed with immunity to most mechanical stressful conditions such as vibrations, jerks, shocks and also against moisture and other atmospheric pollutions.
These devices are also immune to ambient temperature variations which otherwise could make these components vulnerable to heat producing incorrect output results.
Typically, modern linear Hall Effect ICs can work optimally over a temperature range of -40 to +150 degree Celsius.
Basic Pinout Diagram
Ratiometric Specified Functioning
Many standard linear Hall-effect ICs such as A3515/16 series from Allegro or DRV5055 from ti.com are “ratiometric” by nature, wherein the devices quiescent output voltage and sensitivity vary in accordance with the supply voltage and ambient temperature.
The quiescent voltage could be typically half the supply voltage. As an example if we consider the supply voltage to the device to be 5V, in the absence of a magnetic field its quiescent output would normally be 2.5V and would vary at a rate of 5mV per Gauss.
In case the supply voltage was to increase to 5.5V, the quiescent voltage would also correspond to 2.75V, with the sensitivity reaching the 5.5mV/gauss.
What is Dynamic Offset
Linear Hall-effect ICs such as the A3515/16 BiCMOS incorporate a proprietary dynamic offset cancellation system with the help of an in-built high frequency pulse so tat the residual offset voltage of the Hall material is controlled appropriately.
The residual offset could arise normally due to over-molding of the device, temperature discrepancies or due to other relevant stressful situations.
The above feature renders these linear devices with a significantly stable quiescent output voltage, well immune to all types of external negative impacts on the device.
Using a Linear Hall-effect IC
The Hall-effect IC may be connected with the help of the given connections, where the supply pins must go to the respective DC voltage terminals (regulated).The output terminals may be connected to an appropriately calibrated voltmeter having a sensitivity matching the Hall output range.
Connecting a 0.1uF bypass capacitor directly across the ICs supply pins is recommended in order to safeguard the device from externally induced electrical noise or stray frequencies.
After powering up, the device may require a few minutes of stabilization period during which it must not be operated with a magnetic field.
Once the device gets internally temperature-stabilized, it may be brought under the influence of a external magnetic field.
The voltmeter should immediately register a deflection corresponding to the strength of the magnetic field.
Identifying Flux Density
For identifying the flux density of the magnetic field, the devices output voltage may be plotted and located over the Y-axis of a calibration curve, the intersection of the output level with the calibration curve would confirm the corresponding flux density on the X-axis curve.
Linear Hall Effect Application Areas
- Linear Hall-effect Devices could have diverse application areas, a few of them are presented below:
- Non-Contact Current sensing meters for sensing current externally passing through a conductor.
- Power sensing meter, identical to the above (watt-hour metering) Current trip-point detection, where an external circuitry is integrated with a current sensing stage for monitoring and tripping a specified over current limit.
- Strain gauge meters, where the strain factor is magnetically coupled with the Hall sensor for providing the intended outputs.
- Biased (magnetically) sensing applications Ferrous metal detectors, where the Hall effect device is configured to detect the ferrous material through relative magnetic induction strength detection Proximity sensing, same as the above application, the proximity is sensed by approximating the relative magnetic strength over the Hall device.
- Joy-stick with intermediate position sensing Liquid-level sensing, another relevant sensing application of the Hall device. Other similar application which involve magnetic field strength as the main medium along with the Hall effect device are: Temperature/pressure/vacuum sensing(with bellows assembly) Throttle or air valve position sensing Non-contact potentiometers.
Circuit Diagram using Hall Effect Sensor
The hall effect sensor explained above can be quickly configured through a few external parts for converting magnetic field into electrical toggling pulses for controlling a load. The simple circuit diagram can be seen below:
In this configuration, the hall effect sensor will convert a magnetic field within a specified proximity and will convert it into a linear analogue signal across its "out" pin.
This analogue signal can be easily used for driving a load or for feeding any desired switching circuit.
How to Increase Sensitivity
The sensitivity of the above basic hall effect circuit could be increased by adding an additional PNP transistor, with the existing NPN, as shown below:
Using Opamp
The DRV5055 hall effect sensor can be also integrated with an operational amplifier for getting the switch ON results in response to a magnetic proximity with the hall effect device.
Here the inverting input of the op amp is set to fixed reference of 1.2 V using two series 1N4148 diodes, while the non-inverting input of the op amp is configured with the output of the hall effect for the intended detection.
The 1k preset is used for setting up the switching threshold at which the op amp is supposed to switch, depending on the strength and the proximity level of the magnetic filed around the hall effect.
In the absence of a magnetic field, the hall effect sensor output remains below the set threshold of the op amp inputs.
As soon as the output from the hall effect goes above the non-inverting threshold of the op amp, as set by the preset and the reference level of the inverting input, the output of the op amp turn high, causing the LED to switch ON. The LED could be replaced by another circuit stage for a switching ON some other desired load.
TETRA says
Great site!
You are an excellent teacher. Creative and patient.
Thanks for all the shared knowledge.
Swagatam says
Thanks, I appreciate your kind feedback.
İbrahim Ceviz says
Hi Swagatam,
I want to control the brightness of a 3W power LED using a hall effect sensor. The circuit will work with a 3.7 v Li-Ion battery. The LED current will vary between 600mA-1A. When the magnet approaches the sensor, the brightness of the LED will increase, and when it moves away it will decrease. I would be very happy if you could help me design this circuit.
It works well.
Swagatam says
Hi Ibrahim,
I think you can try the following circuit diagram, with some modifications:
https://www.homemade-circuits.com/wp-content/uploads/2020/11/hall-effect-compressed.jpg
Remove the load (LED) from the collector side and put it between the emitter and ground of the transistor.
For the transistor use TIP122.
The 1K preset may not be needed, you can remove it.
Let me know if you any more doubts.
CB Chapman says
How do I find the part number of a Hall Effect Sensor with TO-92 case 0V out at zero mag field, 2.5V out at 50% mag field, 5V out at full mag field ? Similar to 49E series. I do not know how to find the part number and there are 30,000 data sheets to look through.
Swagatam says
I understand your problem, however the challenge is as difficult for me too. I am too having difficulty figuring out the exact part number, I may have to scan many datasheets which I find quite difficult.
Mark says
Hello, I have a solar DC coupled inverter and battery – myenergi only uses AC CTs but I would like to trick the system by matching the outputs. i.e. if there is 2kW of power being sent from the solar to the battery what is the output of the hall effect sensor (is this measured in 0-5volt?) for the sam amount of power in an AC circuit what is the output of the CT (is this measured in 4-20mA) is ther a way to convert the hall effect to output to match the equivelent AC CT output. therefor the system will see the amount of power – I also need to know if this can be directional (dual sensor?)
Swagatam says
Sorry Mark, I can’t figure it out, looks difficult to understand and solve.
Riley Grieb says
Reversible Turns Counter
I have a (approximately) 25 turn roller inductor in my antenna matching device. The inductor is adjusted my turning a hand knob on its 1/4 inch shaft to obtain the desired impedance. My intent is create a digital readout of turns (1/2 turns actually using 2 narrow tape magnet strips) that will decrease count when the knob is turned in reverse.
I know I need a dual-hall sensor (looking at TI TMAG5111) and wish to combine it with my obtained Digiten GDD7949AT-P24V-BU counter, which is a PCB attached to a nice 4 segment display. The PCB has 2 directional contacts: one for incrementing the count up (BROWN) and another for decrementing the count down (BLUE wire).
I’m not an engineer, so I need recommendations on
* the dual-hall sensor
* small breadboard to mount the sensor and bolt to chassis
* a switching circuit from OUT2 of the sensor to utilize either BROWN or BLUE wire to connect to OUT1 of the sensor
Would you please help me with this?
Swagatam says
Sorry, I could not understand your application, so it is difficult for me to answer your questions.
Todd Twenter says
This is great information for a problem I’m having with a Harley Davidson motorcycle throttle. The throttle actually uses two hall effect sensors. One circuit is setup to provide a 0-5V signal increasing in voltage and the other provides a 5-0V signal decreasing (as the throttle is turned). They sum the outputs and check that they are about 5V as a safety to prevent runaway acceleration.
On my motorcycle I can measure the 5-0V decreasing signal but I cannot get a value from the output of the 2nd sensor. My guess is that the output circuit is “open” between the sensor and the Electronic Control Module (broken wire, bad connector, failed ECM module). Do you agree that I’m in the correct direction.
thank you
Swagatam says
I agree, your assumption may be correct, however it can be verified only after a practical checking.
Peter says
Hi Could you help me design a hall effect circuit board capable of powering an attractive electromagtic holding a 40-50lb load?
Swagatam says
Hi, can you please explain the role of the hall effect sensor, how it would be implemented to function.
Peter says
Thanks for your reply! I want to use the hall sensor to hold a 40-50 lb weight, attached to a permanent magnet in levitation below the electromagnet. Plan to use a permanent electromagnet that uses current to neutralize the magnetic field instead of create it.
Swagatam says
OK, you can try the following design:
https://www.homemade-circuits.com/wp-content/uploads/2022/10/hall-effect-levitation-circuit.jpg
Safoor Ramjan says
Interesting information. Regards and Good luck
Swagatam says
Thank you!
Emejakpor Emmanuel says
Can I use the last circuit which has opamp to sense overload current to switch off inverter during overload condition? If possible, how can I connect it to sense the overload? Thanks
Swagatam says
You can try the following circuit instead. Replace the “battery” with your inverter and connect Vs with your battery positive:
https://www.homemade-circuits.com/wp-content/uploads/2020/03/battery-charger-circuit.png
Emejakpor Emmanuel says
Good morning Sir. Thanks for your response. I have some questions and observation.
[1] Should I Connect drain of irf540 to inverter negative and battery negative terminal to ground of the circuit?
[2] is this correct for 1000w inverter, to get shunt for the referred circuit?
P=IV
700w=I×12v
I=58.33A
Then R=3/58.33, R=0.05ohm
That is 1/R=(1/r1)+(1/r2)
I/R= 1/0.1+ 1/0.1
R=0.05ohms when using two 0.1ohm in parrallel.
[3] will the circuit function for 24v or 48v input inverter?
[4] In case for higher power like 5kw, will I change any components apart from the shunt resistor and addition of voltage regulator to protect the IC?
[5] I studied the circuit and is like the overload shutdown will be fluctuating like ‘on’ ‘off’ ‘on’ ‘off’……. Until the heavy load is removed. It will not shutdown permanently like SCR as in the case of low battery shutdown.
Swagatam says
Hi Emmanuel,
Your [1] and [2] points are correct. You can also replace the 3V zener with a 1N4148 diode (cathode towards ground) and replace the 3 value in the formula with 0.6. The wattage of the resistor can be calculated using the formula = 3 x 58 or 0.6 x 58. The wattage will be huge because the current is huge. Instead of using this setup I would recommend using the shut down feature that may be available in your oscillator IC of the inverter
3) If 741 opamp is used then it will not work 24V and above. In that case you may connect a 10K resistor across pin7 and positive line, and also connect a 12V zener diode across pin7 and ground.
4) For 5kw you will have to mainly upgrade the mosfet power and the shunt resistor power appropriately.
5) Yes that’s correct, the opamp will keep switching ON/OFF during the overload thresholds
There’s one modification that needs to be done so that the circuit works for the inverter overload application. You must swap the +/- input pins of the op amps with each other,, meaning now the + input will go to the zener diode and the – input will go to the Rs shunt resistor.
To make the circuit latch during overloads you can add a 1N4148 diode between the + input and the output terminal of the op amp, cathode will go to the output of the opamp and anode to the + input pin.
Ken says
Hello again,
Do all Hall sensors sense a magnetic field the same way? Do they have to sense the south pole as shown in your circuit? Does one side of the sensor sense south, and the other north. Or does it just go high or low depending on the pole?
Thanks again!
Swagatam says
Hello Ken,
According to me the all the hall effect sensor will sense the difference in magnetic poles, but their output response may be different. For analogue hall effect the output will be gradual and exponential, for digital it will be in the form of ON or OFF.
No I don’t think the hall effect device itself has a polarity, the response will be the same no matter from which side the magnet is introduced.
Zipora says
because it is normally the face that is marked with the part number (the datasheet for each device indicates the active area depth from the branded face). To optimally operate the switch, the magnetic flux lines must be oriented to cross perpendicularly through the active area (the branded face of planar Hall devices, or the sensitive edge of vertical Hall devices), and must have the correct polarity as it crosses through. Because the active area is closer to the branded face than it is to the back side of the case, and is exposed on the branded-face side of the chip, using this orientation produces a cleaner signal.
ROMEO JR. G DITCHON says
Hi Mr. Swagatam sir,
On the above hall circuit diagram can used it to drive a solenoid coil of 12v dc.
Regards,
Romeo
Swagatam says
Hi Romeo, yes you can use a solenoid coil…
ROMEO JR. G DITCHON says
Thank you Sir,
How much would it cost to make 5 pcb circuits with voltage
variable from 3 to 12 or 3 to 24 volts can please give me quotation for 5 pcb.
Swagatam says
Romeo, sorry we don’t sell electronic items from this website…
ROMEO JR. G DITCHON says
Hi Sir
Can you help find the website and i want your circuit to be the same.
Thank you
Romeo
Swagatam says
Presently I do not know any website that will help you to get PCBs for my designs…
ROMEO JR. G DITCHON says
Hi Sir,
Can i copy your design to be used for magnetic coil (solenoid)
Thanks
Romeo
Swagatam says
Yes you can…
Curtis Silver says
I am an automotive technician and instructor desperately trying to better understand the operation of hall effect sensors. In your linear hall effect sensor diagrams I have two questions. First and probably the most important, is the actual direction of current (electron) flow on the schematics from ground to power? Second question, why is the 1K resistor required between the 12V power and the base of the PNP transistor. It’s really difficult trying to explain how circuits work without a true understanding of them.
Swagatam says
The movement of electron will be from negative to the positive, but for ease of representation and understanding schematics, the conventional direction is considered to be from positive to negative. The positive side resistor ensures that the base of the PNP is at the positive potential and perfectly switched off and never floating with an undefined voltage level, whenever the NPN is in the OFF state.
Ron says
Hello,
I am not an electronics type guy at all.
I am attempting to build a current limiting device for use on 120VAC. The plan is to be able to shut down the AC power at either 5 amps or 10 amps until the load has been reduced below the 5 or 10 amp limit.
I know I would need to have two separate circuits that would be selected depending on which current limit value is required. I have been looking at the Allegro ACS723 (xLLCTR-5AB and xLLCTR-10AB) devices and they look promising. I’m just not sure about implementing these devices to control a relay in order to open the AC power wires. I ran across your circuit on this project and was wondering if I might substitute the output of the ACS723 device in place of the A1321 device output? Or would that be too easy? My existing circuit has +28VDC and I can add a +5VDC and/or a +12VDC if required.
Swagatam says
hello, A hall effect sensor is no way related to a current limiting application, and therefore it cannot be used.
Instead you can see the concept explained in the following article:
https://www.homemade-circuits.com/mains-over-load-protector-circuit-for/
Ron says
Hello again,
I might not have explained myself correctly or fully.
https://www.digikey.com/en/datasheets/allegromicrosystemsllc/allegro-microsystems-llcacs723datasheetashx
The ACS723 is a current sensor that uses a built in Hall sensor to track the amount of current flow from the supply to the load. As the load current increases the voltage output of the device increases. My plan is to use this device to monitor the load and if the desired current setting is exceeded the output would be used to toggle a logic circuit (TBD) and subsequently to open a relay and shut off the power to the load.
I have thrown together a very rough sketch of my idea if I can send it to you somehow.
Regards,
Ron
Swagatam says
Hello, I went through the details in the datasheet, and have come up with the following simple design as per your desired specifications:
The load could be wired through the relay contacts and and in series with the input AC coupled with the IC.
In order to latch the relay you can additionally connect the pin2 of the IC with the the collector of the transistor via a 1N4148 diode.
Ron says
Hi,
This looks really good. Three more questions please.
#1: I have a switched ground that is presently controlling the relay such that a ground keys the relay and supplies the 120VAC to the load. Can this be connected to the circuit so that the relay is energized and provides the 120VAC to the load unless the load hits the maximum current? At the maximum current limiting point the relay de-energizes and stays open until the load is either removed or the current falls below the maximum limit at which point the relay will energize again?
#2: Is the LED used to provide a visual indication of the relay status?
#3: My relay coil is driven by +28VDC. If I am reading the specifications correctly for the BC547 I should be able to use 28VDC instead of +12VDC with no other changes?
Thank you so much,
Ron
Swagatam says
Hi, this circuit also uses a ground to switch the relay via BC547, so everything looks fine.
However, when the relay switches, the current will be removed which will prompt the relay to switch again, and this may cause rapid chattering of the relay at the thresholds. To avoid this, a latching feedback will be necessary. Also make sure to add a 47uF/25V capacitor across base/emitter of the transistor to ensure a delay effect on the relay switching.
28V can be used with BC547, but the relay coil current must be within 60 mA
Swagatam says
….the red LED indicates the cut off action and also prevents the leakage offset voltage from the op amp output to reach the transistor base
Ron says
Thank you again. I will get these parts on order to breadboard and test it all out.
Ron says
Hi again,
I bread boarded this up and was not getting the results we were looking for. I made some changes and I believe I have it functioning now. I have not gotten into the accuracy and fine adjustments but but it appears to be operating. Is there a way of attaching a pdf or some other type of file for your review? I just want to make sure it is correct.
Regards,
Ron
Swagatam says
Hi, you can send it through Google drive, make sure to enable the sharing option for the link.
Ron says
I hope this works. I’ve never used this before.
https://drive.google.com/file/d/1GI_7cPJDO7IC8k6F6B3U8zBZ5z7L_G97/view?usp=sharing
Swagatam says
Hi, the diagram drawn by me is technically the correct diagram and it has to work. The modified diagram drawn by you looks OK but not fully correct technically. Anyway if it is working then you carry on with it.
The minimum that you can do is connect a 12v zener diode across pin7 and pin4 of the IC.
Ron says
Hi Swagatam,
Thanks for looking it over and please help me out on this.
My plan is to use a regulated +15VDC supply for the LM741 +V input rather than the +28V with the resistors. Would I still need the zener diode across V+ and V- ?
The only difference I see between our drawings is the 10K resistor omitted in series with the 1K preset resistor and the higher voltage input to the LM741. The nominal input voltage for the LM741 specs is +/-15VDC. It is currently running at 17.4V with the resistors I had around. I was unable to get the circuit to operate consistently at the +5VDC input voltage with the 10K resistor.
So I played with the circuit and got it to work with my changes. If I am violating some design principles please let me know as I want this to be correct.
I really appreciate your guidance.
Ron
Swagatam says
Hi Ron, the basic working of a compartaor op amp as shown in my diagram is very simple. The output pin 6 will be around 0 V as long as pin 3 voltage is lower than pin 2 voltage. The moment pin 3 voltage exceeds pin 2 voltage even by 0.3V will turn pin 6 high and equal to the supply voltage.
Since the hall effect output voltage increases slowly upwards in response to increasing current, you have to set the pin 2 preset such that its level is just lower to the voltage at pin 3 which determines the cut off AC current.
It is fine to remove the 10 k from pin 3.
15V regulated is also fine, although 12V is the recommend voltage for IC 741.
Before connecting the op amp you must first confirm the rising equivalent voltage at Vout of the hall effect and check the level that corresponds the maximinum cut off current limit. Then adjust the pin2 preset so that the pin2 voltage is set at this threshold level.
The LED at pin 6 is very important otherwise the relay will stay permanently ON
Ron says
Hi again Swagatam,
I forgot to add that the LM741 maximum input voltage is equal to the supply voltage when supply voltage is less than +-15V.
Once I increased the supply voltage above 15V I was able to get the LED and relay to operate. The preset potentiometer had no effect on the trip level until I removed the 10K resistor.
Ron
Swagatam says
Hi Ron, it seems something is not right with your op amp or your configuration. The inputs of the opamp will respond even to 0.3 v, it is the difference between the pin2 and pin3 that matters not the supply voltage.
The iC 741 should work fine even at 5 V supply, and with input difference of as low as 0.3 V
The 10k should have no effect on the op amp preset setting, unless your hall effect output is already too high in the beginning. I am assuming the hall effect output to begin from zero and upwards in response to increase in current.
Ron says
Hi Swagatam,
Okay I will go back and review all of this. More questions/comments below.
#1. I was asking about the 12 volt zener diode you said should be installed across LM741 pin 7 and pin 4. Do I need that if I use a regulated 12 volt supply?
#2. The hall sensor output is not zero volts with a zero current input. It is Vcc X 0.5 which in this case is 2.5 VDC. The output increases very little. At 5 amps load on the input monitor it rises to 2.54 VDC. This is in line with the spec of 400 mV/A.
#3. Is there a chance we are expecting too much from our circuit due to the small voltage change we are looking at for the transition point?
Regards,
Ron
Swagatam says
Hi, Ron, if you regulate the supply to 12V using a 7812 ic or by any other means then the 12v zener will not be necessary.
if the initial output from the IC is 2.5 V and this increases by 400 mv per Amp, in that case the default pin2 preset setting will need to be higher than 2.5 v, depending on exactly what output voltage from the hall effect you want the op amp output to change state. The pin2 must be set 200mV lower than the pin3 voltage which determines the cut off threshold.
I think even 200mV should be quite enough for the IC to be able to detect the difference between the input pins and toggle the output state.
shandor says
Hello Swagatam,
Thanks for this article, it is very interesting and possibly will point me in the direction I am looking to go. My electronics is very basic and I am on a huge learning curve.
I am trying to build a discrete magnetic field detection application.
I made a prototype using a reed switch (nc) and a pnp transistor. It worked but the reliability of the reed switch is not consistent.
I like the idea of a Halls effect sensor as this is more robust and reliable.
My question is, using the diagram (allegro linear hall effect sensor pintout wiring details above) can it be made more sensitive? ie detect a magnetic field 4-6 inches? I am not sure if this would involve changing the A1321 Hall effect sensor and upgrading the resistor from 1k to something higher? Would the supply voltage, being a 9v battery be too great for the Hall effect sensor?
the load (box) after the transistor (pnp?) can that drive a buzzer or some other ‘alarm’ device. I really need to keep the device as simple and as robust as possible. The magnetic field is generated by a 18v DC electromagnet.
I sincerely thank you for your opinion and help on this.
Swagatam says
Hello Shandor, I have the updated the required design at the end of the above post, this should increase the sensitivity to a great extent.
The supply to the hall must be 5 V, so you may need to regulate the 9V to 5V through an IC 7805 or simply using a 1K, 4.7 V zener network.
The load can e replaced with a alarm or a relay.
raj says
hi, Swagatam,
i am working on a anemometer using linear hall effect sensor, but i need to transmit the output signal to 20 feet from my roof top to my house, can you suggest any idea on how to do so ,as the voltage is getting droped.
Swagatam says
Hi Raj, I think you can convert the output to 220V AC through a transformer, and then convert it back to the required DC at the end of the 20 feet wire. 220V AC will have lower loss through the 20 feet wire compared to DC
Richard says
Hi Swagatam,
I don’t have a pull up resistor on the Vout pin of the LM293P and thanks for the explanation. Given the output of 2.5V, that’s perfect for me as I don’t have to mess around will voltage level changers given the max input pin voltage on the Pi is 3.3V.
Swagatam says
Hi Richard,
Without a pull up resistor the output should be zero volts permanently, 2.5 V is not normal. It means your opamp could be malfunctioning. With a pull up resistor it will be either 0V or 5V. This 5V then can be converted to 3.3V
Richard says
Hi Swagatam,
Making my hall circuit, I’ve seen a few things that may be of interest to others.
1. Using the analogue hall sensor, when I placed it directly next to the cat flap magnet to make the back bias and the iron slug on the bottom of the flap door is next to it, I get 0v shown on the comparator Vout. If the flap is barely opened, I get fluctuating values from 0.5v and up. If the flap is moved completely open, I get 0v again.
Now measuring when the flap is open and closed is more tricky if you get 0v when it is both fully open AND closed, so I put the sensor about a quarter inch from the magnet so still 0v when flap closed but the voltage now only starts to go up when the flap is open about and inch and stays up even when fully open and returns to 0v when closed. So good.
2. I’m a bit confused by the voltage level, taking it from 5v down to 3.3v so the Pi input GPIO pin won’t fry. From what I read about comparators, they will check the input of two separate sample voltages and will output the Vcc voltage powering the comparator itself on the Vout. I’ve got 5V powering the comparator, Vin+ is 2.50v and Vin- is 0.5mv, yet when the flap is open I see 2.50v max on Vout and not 5v. 2.50v is fine for the Pi as it’s over 1.65v which the pin will see as a digital HIGH which I can code as “flap open”. Does the LM293P only output the largest voltage seen?
Swagatam says
Hi Richard,
Did you connect the output of the compartaor with a pull-up resistor? The LM393 or 293 have their output connected to an open transistor collector internally.
You will have to connect a 1K or any resistor upto 10K from this output to the +5V line. Then the output will be either +5V or 0V depending on the input conditions, anything between this could indicate a fault in the comparator.
For more info you can refer to the LM311 example in this article:
https://www.homemade-circuits.com/comparators-using-ic-741-ic-311-ic-339/
Richard says
Hi Swagatam,
I hope you can help because I can’t seem to find the answers / experts elsewhere and your explanation of hall sensors here is great.
The problem.
I have a Raspberry Pi (I can’t use an Arduino for other reasons) and I want to be able to detect when a cat flap door opens. There is a slug of iron crimped onto the bottom of the flap door and that is attracted to a neodymium magnet inside the flap, underneath the slug.
In a nutshell, I want to put a hall sensor between the magnet and the iron slug and when the slug disturbs the magnetic field, I get a voltage or flag change that I can use in code to say “the flap has been used”.
Effectively a back biased magnet setup. The magnet is mounted horizontally with N facing outside the house and S facing in.
I bought an A17301 analogue sensor and APS11700/60 digital magnetic switches. All three connected and detected when a magnet was brought close to them but did not show any change when then I moved the iron slug near them. I’m guessing the digital switches are preset and I need a $2000 sensor programmer to set it to what I need.
So then I saw this guy make a ferrous detector with a hall sensor (he doesn’t say which sensor he’s using but has to be analogue). That would be fine, replace coin with iron slug and bingo but I’m sure the A17301 already has an opamp in it.
http://www.youtube.com/watch?v=JSQ_q0_9emY
So I’m stuck.
Do I then…
A. Buy a basic linear omni polar analogue hall sensor, make this ferrous circuit and work out the output with a simple ADC to connect to the Pi.
B. Is there an all in one hall sensor that I can use with the existing magnet which will give me a 0 or 1.
C. Is there another hall sensor option?
I can’t imagine it’s this hard, it’s not detecting a camshaft rotating, it’s a cat flap. 🙂
TIA
Richard
Swagatam says
Hi Richard, the application you are trying to implement looks too basic to have any problems. At first I thought may be I was missing something, but after reading your explanation a few times I still couldn’t find anything complex in it.
However my first question is why do you wish to use an iron slug for the detection? Why not fix the magnet itself on the cat flap door and use it for triggering the hall sensor.
Secondly, did you check the output from your Hall sensor separately with a meter and with the iron slug disturbance?
Remember, only an external op amp would be able to detect a difference of even a 0.2V when the iron slug is brought near the sensor. I would recommend a LM393 op amp, for building the op amp circuit.
So if you are seeing a difference at the output even by a 0.2V or 0.5V that would be enough to force the external op amp to toggle its output.
Hope this solves your problem!
Richard says
Hi,
Thanks for getting back to me so quickly.
The reason for not attaching a magnet directly to the flap door is two fold.
1. I wanted to keep the flap as stock as possible and not attach anything to the flap door otherwise I would have gone for a reed switch solution.
2. The magnet and the iron slug have been matched by the flap manufacturer and it’s unlikely I would find the same crimped mounting for a magnet on the door which wouldn’t change the dynamic of the swing, plus the cat knows how much weight to push against it now and doesn’t like change. Nuts, yes.
For testing I put a 5V VCC feed in and measured the VOUT. The sensor has self calibration and gave a solid 0 when a magnet was brought close.
It was more of a sanity check if the saturation of the back bias magnet would be zeroed out with the sensors internal calibration and be close enough that the difference with moving the iron slug would throw some voltage back from the VOUT. Clearly I misunderstood that. 🙂
I’ve got some LM393s so I’ll make up the circuit with the existing A17301 and see what the result is.
Thanks again.
Richard
Swagatam says
That sounds great! will wait to see how it goes!
Richard says
So… all good.
I made the circuit up as per the ferrous detector link but I swapped out the op amp for a LM293P comparator. I tested it with a 5V Arduino using the builtin LED for high and low.
Held the A 7301 hall sensor next to the cat flap magnet with flap door closed, LED went off. Opened the flap, LED came on.
Will solder it up on a perma-proto board already in the project adding some 5V to 3.3V level shifting before adding connecting it to the Pi.
BTW the project is The Integrated Cat Flap, a ML flap with all the components inside the flap. If the flap detects prey in the cat’s mouth, it will issue an audio warning and servo lock the flap. Now with the hall sensor I can detect if the flap is moved before the camera sees the cat, the cat is going out and if the camera sees the cat first, then the flap is moved, the cat is coming in.
http://www.raspberrypi.org/forums/viewtopic.php?t=172114
Thanks for the help.
Richard
Swagatam says
Awesome! Glad you could do it so quickly! I love cats too! Have many of them playing in my backyard!