1
\$\begingroup\$

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:

schematic

simulate this circuit – Schematic created using CircuitLab

low pass filter

Here is a screenshot from my scope while it's making false counts: 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?

\$\endgroup\$
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Transistor Apr 1 '16 at 23:39
  • \$\begingroup\$ @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. \$\endgroup\$ – GisMofx Apr 2 '16 at 2:05
  • \$\begingroup\$ 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. \$\endgroup\$ – Transistor Apr 2 '16 at 9:36
  • \$\begingroup\$ @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. \$\endgroup\$ – GisMofx Apr 2 '16 at 16:03
  • \$\begingroup\$ 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? \$\endgroup\$ – Transistor Apr 2 '16 at 16:48
2
\$\begingroup\$

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.

schematic

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.
\$\endgroup\$
  • \$\begingroup\$ This works! But what about the low pass filter? \$\endgroup\$ – GisMofx Apr 4 '16 at 20:55
  • \$\begingroup\$ 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? \$\endgroup\$ – Transistor Apr 4 '16 at 21:34
  • \$\begingroup\$ 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. \$\endgroup\$ – GisMofx Apr 4 '16 at 21:44
  • \$\begingroup\$ 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. \$\endgroup\$ – Transistor Apr 4 '16 at 22:08
  • \$\begingroup\$ 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. \$\endgroup\$ – GisMofx Apr 4 '16 at 22:41
3
\$\begingroup\$

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:schematic

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: revised schematic

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – GisMofx Apr 2 '16 at 19:00
  • \$\begingroup\$ 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. \$\endgroup\$ – GisMofx Apr 4 '16 at 0:15
  • \$\begingroup\$ try using a pin with internal schmitt trigger or use software debounce \$\endgroup\$ – ElectronS Apr 4 '16 at 1:39
  • \$\begingroup\$ 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. \$\endgroup\$ – GisMofx Apr 4 '16 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.