Sine to square wave using op-amp

Discussion in 'General Electronics Chat' started by Tobias, Jan 24, 2009.

  1. Tobias

    Thread Starter Active Member

    May 19, 2008
    158
    0
    I am wanting to measure wheel speed on a vehicle. Each axle has a variable reluctance sensor. I am sharing this signal with the ECM. I am using a LM-2902-Q1. The data sheet is attached along with a schematic and output from the circuitry.

    The rear axle output is really nice. As soon as the sensor voltage is positive, the output goes high to 5v and stays there until the sensor voltage is negative. Then the output goes to 0V.

    The front axle isn't right. I drew up the scope data on AutoCad so it isn't exact, mainly to give you an idea as to what is happening. The yellow trace is the output of the circuit. The white is the output of the sensor. As you will notice, the output starts off right, but goes to 0V when it should stay high.

    Any ideas?
    Thanks in advance
    Toby
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Are you powering the opamp with 5V and ground?

    hgmjr
     
  3. Tobias

    Thread Starter Active Member

    May 19, 2008
    158
    0
    yes, pin 4 is to 5v and pin 11 to GND.

    Also both front axles look the same and the two rears look alike. So its not a sensor problem.
     
  4. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Is it possible that the voltage output from the sensor is greater that +5 volts?

    hgmjr
     
  5. Tobias

    Thread Starter Active Member

    May 19, 2008
    158
    0
    The sensor signal is the white sine wave in the scope.pdf file. The rear axle sensor's output voltage is actually higher than the front and the rear is all good.
     
  6. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    It sure looks like the opamp is exhibiting foldback. Some opamps have a tendency for their output to foldback when the voltage applied to the input is greater than the positive supply voltage.

    hgmjr
     
  7. Tobias

    Thread Starter Active Member

    May 19, 2008
    158
    0
    ok, thats interesting. I have two options then. First is go to a different op-amp, can you suggest one? Or I can power the op-amp with 12v. I am just concerned with the output then being higher than 5v and smoking the PIC chip inputs. Can I use diodes to not let the voltage out of the amp not go over 5v?
    Thanks again
    Toby
     
  8. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    The easiest thing to do is try a diode that would clamp the positive input so that it would not go more positive than the positive power supply rail.

    hgmjr
     
  9. Tobias

    Thread Starter Active Member

    May 19, 2008
    158
    0
    Here is a cell phone pic of the scope data while testing the 12v supply to the amp. The blue trace is the wheelspeed sensor pulse and the yellow is the circuit output.

    Notice that the two spikes at the 'zero-crossing'
     
  10. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    I suggest you try putting a diode to prevent the positive input of the opamp from going below ground more than a diode drop as well as the one that clamps the input from going above the positive supply rail by a diode drop.

    If you have a schottky diode that would be perferred over a standard diode.

    I would also use a couple of 1K resistors to create a 2.5V reference and then tie the 100K resistor that now goes from the negative input and ground to this 2.5V reference.

    hgmjr
     
  11. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    The voltage on the inputs can't be allowed to go lower than -0.3v; that's right in the absolute maximum ratings of the IC.

    You might use a 4.7v or 5.1v Zener diode to clamp each input to Vcc. Even Schottky diodes won't have a low enough Vf to clamp the input to ground; about the lowest Vf you'll find is 0.32v, which exceeds the opamp's specifications.
     
  12. Wendy

    Moderator

    Mar 24, 2008
    20,766
    2,536
    I'm coming in late on this one.

    What is Vss, ground?

    Have you thought of a simple transistor version, or is there a reason you're going with op amps?

    [​IMG]
     
    • amp.GIF
      amp.GIF
      File size:
      1.5 KB
      Views:
      244
  13. eblc1388

    Senior Member

    Nov 28, 2008
    1,542
    102
    An active clamp would clamps the input voltage to about zero voltage on its negative excursion.

    [​IMG]
     
  14. Audioguru

    New Member

    Dec 20, 2007
    9,411
    896
    EDIT: I didn't see the entire schematic and inputs because the schematic is sideways.
    The input goes to a negative voltage that is higher than the absolute max allowed voltage of -0.3V.
    The opamps would work if they are inverters with a voltage gain of about 0.74V because the output will have a max high voltage of only 3.8V (not 5V).
     
    Last edited: Jan 25, 2009
  15. Wendy

    Moderator

    Mar 24, 2008
    20,766
    2,536
    I think I like yours better than mine. Took me a second to figure out, but it is simple enough.
     
  16. Tobias

    Thread Starter Active Member

    May 19, 2008
    158
    0
    I need the op-amp because I need a high impendence circuit. The first time I connected to the vehicle, the ECM didn't like me sharing the wheelspeed sensor signal and gave an ABS error. Attached is the schematic for the wheelspeed signal
     
  17. Audioguru

    New Member

    Dec 20, 2007
    9,411
    896
    The quad opamp you used is an LM324 that is spec'd for a car's temperature range.
    The datasheet for the LM324 explains that its output goes high when its input voltage is more than 0.3V below its negative supply which is 0V in your circuit.

    If the opamp is made to be inverting then when its output is its max of +3.8V when the supply is only 5V then its input can go down to -3.8V and the input voltage of the opamp is fine at 0V.
    If the inverting opamp has a gain of 0.74 then a -5V input makes an output of +3.7V and the input voltage of the opamp is 0V.
     
  18. Tobias

    Thread Starter Active Member

    May 19, 2008
    158
    0
    I am pretty new to this op-amp deal. Its pretty interesting for sure. Could you suggest an op-amp package that would work better?
    Thanks to all who have replied
     
  19. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Here's a modification of your circuit - not real pretty, as I just kind of threw it together.

    It's using LM2903 dual comparators instead of LM2902 quad opamps. They both have the same -0.3 limit for input voltages and are both qualified for automotive temperature ranges.

    Since what you're trying to do is square up a sinewave, comparators are more appropriate than opamps; comparators are designed to be operated with their outputs in constant saturation, whereas opamps are not.

    Note the 1N751 diodes; these are Zener diodes with a breakdown of 5.1V. Connected from the comparator's inputs to Vcc, that will prevent the inputs from falling lower than Vcc-5.1v, or -0.1v. It will also clamp the inputs to Vcc+0.7v (approximately) - but since the current will be so limited by the 100k resistors, it will actually be less than that.

    The 220k Ohm resistors provide for hysteresis; this makes switching between on/off states much more stable.

    The 1.5k resistors are pull-up resistors. Comparators generally have open-collector outputs; pull-up resistors are required. The 1.5k value means that the comparator outputs will sink a maximum of 3.33mA, which is a good target range.

    Note that the input sinewaves look somewhat distorted; that is due to the effects of clamping and hysteresis.

    The output of the comparators should range from about 90mV to Vcc, with the transitions being quite rapid.
     
  20. Tobias

    Thread Starter Active Member

    May 19, 2008
    158
    0
    I tested the circuit on my bench and it worked great. I hooked it up to my vehicle and it worked great there too except for one thing. The output of the sensor when not moving is not stuck to ground, its a bit noisy. So I get a trigger from the output of the comparator output often while its not moving. It works pretty good when the vehicle is moving.

    I read up some more on comparators and thought I would try applying 0.400v to the GND pin. From what I have learned I thought it would trigger the output of the comparator when the IN+ went above 0.400v. So I found a 150k and a 30k resistor and made a little voltage divider and tied them to the GND pin. It doesn't do anything on the output. What am I missing?
    Thanks again
    Toby
     
Loading...