# Adding Low Pass Filter to Open Collector Hall Sensor

I'm using a gear tooth sensor to create pulses when a metal object passes the sensor. There's a lot of noise on the signal so I decided a simple low pass filter would suffice(f-cutoff = appx.400hz).

The sensor is an open collector type, so the mcu pin is using the internal pull-up to keep it at 3.3v. And falling edges are triggering my mcu timer.

The sensor is connected to the resistor and the other side of the resistor is connected to the mcu pin and the cap. The cap then goes to ground. Like this:

simulate this circuit – Schematic created using CircuitLab

Here is a screenshot from my scope while it's making false counts:

Updated circuit at bottom: When the LP filter is connected to the input of the Shmitt Trigger Opto-islator(H11L1M) The output does not seem to work. Without the LP filter, it output side works. I've tested these with LEDs. When the hall sensor is triggered, both LEDs should go off. The output LED never comes on to begin with. Is the LP filter affecting the current through the IC?

• You can remove R2 and just let R1 and C1 do the job. When the sensor turns on it will discharge the capacitor to ground. When it switches of the capacitor will charge up to +5 V at a rate determined by R1.C1. So for a 400 Hz cutoff the pulse rate is $\frac {1}{400} = 2.5 ms$ and, assuming it is on for 50% of the time that makes the pulse width about 1 ms. Try it with RC = 1 ms. $R = \frac {\tau}{0.1 \mu} = \frac {1m}{0.1\mu} = 10k$ which you already have. Apr 1, 2016 at 23:39
• @transistor it's probably closer to 10%-15% duty cycle. The sensor is picking up bolt heads on a spinning hub. There are 5 bolts. In my amateurism, I've never though about it in terms of Tau. Now it makes sense! So, actually, 4.7K seems like it would work for me Fcutoff=appx 319hz. That's ok for testing. I'm going to put a scope on it, because I was testing it like the circuit in my question and was still getting some noise which was affecting the MCU input capture. Apr 2, 2016 at 2:05
• Expect to see different time-constants for charge and discharge then. Discharge at 4.7 k; charge at 14.7 k. Also when running the scope check how low the signal goes. You may find that it's tending to oscillate around a DC value. Apr 2, 2016 at 9:36
• @transistor I still seem to be getting some noise. I plugged in my scope, but it's not sensitive enough to pick up the noise. Although, my counter in the MCU is making false counts which is throwing off my measurement. Apr 2, 2016 at 16:03
• I don't know how you're getting any counts with figure 2. Your MCU input is connected directly to +5 V. (1) Are you missing counts or getting extra counts? Apr 2, 2016 at 16:48

You have a bundle of problems with your third circuit.

• There is a +5 V supply permanently powering the opto-isolator. No matter what happens the Hall sensor the opto will never turn off.
• You have quite a high resistance in the circuit to the opto-isolator LED. It may not be turning on.
• You have the MCU input connected between the LED and it's current limiting resistor instead of to the Schmitt-trigger output directly. If everything else was working the MCU input could only switch between 1.8 V and 3.3 V.

Let's start again with the bare minimum.

simulate this circuit – Schematic created using CircuitLab

Figure 1. Modified circuit.

• Wire up the opto, R7 and LED1 to the Hall sensor as shown.
• Test it. Make sure that the LED blinks as the screw-heads pass the sensor. (You don't explain where the magnetic field is coming from in your setup. The Hall sensor needs to detect a change in magnetic field strength. It won't "just detect metal". This may be another problem.)
• Next connect up the output as shown. You should see LED2 blink as you test.
• If all is well hook up to the MCU.
• This works! But what about the low pass filter? Apr 4, 2016 at 20:55
• You shouldn't need it if your Hall sensor is working reliably. A cleanly switching on-off signal should work perfectly. (The low-pass filter wouldn't have been my choice and I originally addressed it because you had specified it.) Run a scope trace between 0 V and the sensor output and let's see how it looks. Any little bit of noise left should be sorted out by the Schmitt trigger. Out of curiosity, where is the magnetic field for the gear-wheel coming from? Apr 4, 2016 at 21:34
• Not sure what you mean about the magnetic field? I'm using this sensor which picks up ferrous objects as they pass by. Since this sensor is used near an IC engine and I think there's some noise from the ignition system or probably the power supply that might be making it's way into the Hall Sensor wires. I'll run a scope with the engine running again and post a pic. Apr 4, 2016 at 21:44
• Hall effect sensors detect magnetic fields. Your gear wheel is not magnetised so there must be a magnet in the sensor which reacts with the passing ferrous teeth and disturbs the field in the Hall sensor built into the switch. The way you have it wired now is a nice low-impedence circuit - effectively a current driven circuit. Noise will be much less of a problem. Apr 4, 2016 at 22:08
• Thanks! I just did some testing and it's working well! Yes, it's a convenient sensor, the magnet and hall sensor are combined together in one unit. Apr 4, 2016 at 22:41

your revised circuit is not what " transistor " recommended , he said remove R2 and leave R1 , so this way the circuit will be something like this:

you also are better disabling the micro-controller internal pull up of the micro-controller and use a voltage divider if micro is 3.3v and sensor is 5v as shown in the schematic , instead pull up the sensor to 3.3v because this is the whole point of using open collector , even if the sensor is supplied by 5v , the output can be interfaced to 3.3v or 12v or whatever you want , the circuit will be like:

• Thanks! I will disable internal pull up and try 3.3v like your second circuit. I will change the 10k to 4.7k based on Tau I need for filter. I'll let you know how this works. Apr 2, 2016 at 19:00
• I tried the second circuit like you show and removed the internal pull up on the pins. I'm still getting false counts on the circuit. I added a screenshot from my scope..I'm not sure the scope is telling. Apr 4, 2016 at 0:15
• try using a pin with internal schmitt trigger or use software debounce Apr 4, 2016 at 1:39
• Don't have one available, but I added an external shmitt trigger IC and updated my circuit. The LP filter does not yield any output on the shmitt trigger. I don't know why. Apr 4, 2016 at 15:55