I am trying to use a hall-effect sensor to trigger an interrupt. There are different sensors available. Some use a puill up resistor, some are "2-wire" and you measure the voltage across a load. Therefore some have 0-5 volt square wave signals. Others have 8-9 volt square wave signals.
I want to have one technique to measure the transitions on the sensor without having to change the circuit to fit the sensor.
I originally had a level-based circuit using an inverting schmitt trigger gate. Obviously this will not do the trick.
I then thought I could use a comparator (something like a LM339) (running on 12v) with the signal going to both the inverting and non-inverting inputs. The two inputs have different low-pass filters, and the edge of the sensor transition is measured in this manner. It will be reasonably independent of the actual voltage of the signal.
I was thinking that there would be a 47K resistor to each input. One would have a 0.01uF cap, and the other would have a 0.001uF cap. The feedback to the non-inverting input would be 470K.
Does this sound reasonable? I have heard that the input resistance should be kept low (like 10-20K) and the feedback should be lower than 100K in order to minimize the issues of offset voltages. Would this be a problem for me in this circuit?
The LM339 output would use a 2.2K pullup resistor to +5v. This would be the same voltage running the ZX. Would the 8 to 9 volts on the input, running through the input resistor and the feedback resistor cause a problem for the 5V system? I am caution about using a larger input resistor because of the offset considerations.
Is there a better way to detect the edge and have it compatible with up to 18V, and have it reasonably independent of voltage, and able to detect 1v transitions?
-Tony
how to get comparator to reject "common-mode"
Re: how to get comparator to reject "common-mode"
Depending on the characteristics of the 9 volt signal, it may be sufficient to just clip it to +5 using a circuit like that below. The resisitor should be large enough to limit the current to a reasonable level when the input signal is at its maximum value but small enough enough to handle the input current to the gate without too much voltage drop.spamiam wrote:I want to have one technique to measure the transitions on the sensor without having to change the circuit to fit the sensor.
- Attachments
-
- clip.jpg (7.36 KiB) Viewed 5388 times
- Don Kinzer
Re: how to get comparator to reject "common-mode"
Hmmm, I had considered the possibility of clipping the signal, and/or a voltage divider, but these did not seem to be sufficiently "universal".dkinzer wrote:Depending on the characteristics of the 9 volt signal, it may be sufficient to just clip it to +5 using a circuit like that below. The resisitor should be large enough to limit the current to a reasonable level when the input signal is at its maximum value but small enough enough to handle the input current to the gate without too much voltage drop.
I think I was not very clear about the voltage responses of the various sensors that people might want to use:
Type 1 (Hall effect): ON = 0V, OFF = 5V (measured)
Type 2 (proximity): ON = 9V, OFF = 8V (measured)
Type 3 (proximity): ON = 5V, OFF = 6V (measured)
Type 4 (proximity): ON = 2V, OFF = 8V (estimated)
I _think_ that the clipping circuit you give would result in 5V at all times for type 2 and 3 sensors.
So, I need to be able to use the same circuit to detect the transitions on all 4 types of sensors with no modifications, nor external components. It may not actually be possible....
Here is the circuit I described earlier. It does seem to come close to the goal. It works OK for signals in the 0 thru 5v range, even with small voltage changes (0.8v). This is the "simple" version without provision to deal with offset voltages at the inputs.
-Tony
- Attachments
-
- Common_mode.jpg (74.23 KiB) Viewed 5384 times
I did some breadboarding. In order to make the circuit fully compatible with the 5 volt circuits of the ZX (essentially to avoid worrying about the direction of current flow when the input voltage to the non-inverting comparator pin which then connects to the output of the comparator thru the feedback resistor), I added a voltage divider to the input.
I then did some adjustments to the resistors and got something that works with a signal varying between 0 and 5v. It also works with a signal varying between 8 and 9 volts. I also found that it works better without R3. In the spice program, it seemed to like having R3, but my mockup of the real thing, using an LM339 instead of the LT comparator in the spice.
Also, it works properly with a signal tested from 0.1Hz to several KHz. I was not interested in higher frequencies than that, so I did not test them.
I am attaching the circuit.
Any comments on how to do this better?
-Tony
ADDENDUM:
I find that the circuit works better if the two capacitors are switched. For some reason the greater degree of filtering on the side with the feedback works more smoothly. When set up this way, then R3 does not add any extra functionality, and can be deleted.
I then did some adjustments to the resistors and got something that works with a signal varying between 0 and 5v. It also works with a signal varying between 8 and 9 volts. I also found that it works better without R3. In the spice program, it seemed to like having R3, but my mockup of the real thing, using an LM339 instead of the LT comparator in the spice.
Also, it works properly with a signal tested from 0.1Hz to several KHz. I was not interested in higher frequencies than that, so I did not test them.
I am attaching the circuit.
Any comments on how to do this better?
-Tony
ADDENDUM:
I find that the circuit works better if the two capacitors are switched. For some reason the greater degree of filtering on the side with the feedback works more smoothly. When set up this way, then R3 does not add any extra functionality, and can be deleted.
- Attachments
-
- Functioning edge detector
- Comparator-1.jpg (46.81 KiB) Viewed 5353 times