Frequency Counter

Discussion in 'General Electronics Chat' started by tejasdj12, Feb 9, 2013.

  1. tejasdj12

    Thread Starter New Member

    Jul 11, 2010
    20
    0
    I'm making a Frequency Counter. It should work for Sine, Triangle and Square waves. The amplitude of the input signal can be anything (any non-zero value) and should also work for μVolts.

    This is what I thought of. The counting circuit is digital. This means, I need to convert the signal into digital pulses (5V Square Wave). This is where I was stuck. The amplitude can be anything. But my output should be 5V only.

    I used Voltage Comparator LM393N. The Inverting pin is Grounded and the signal is passed through a High Pass filter (removing DC component) and applied to the Non-inverting terminal. The comparator will act as a Zero Cross detector and when the amplitude is greater than 0, it will give a High output.

    Here is the circuit:
    [​IMG]
    EDIT: I've missed the Pull-up resistor at the output. But in my real circuit, I've connected one.

    So my question is whether this circuit is fine? Or any changes are necessary? Will it work for above 1MHz (the LM393N datasheet does not say anything about Maximum Frequency)?

    I tested it using my Function Generator. Seems it works well, at least for a few Hertz. I dont have a CRO or Frequency Counter, so I can't test it for Higher Frequencies.
     
  2. BillO

    Well-Known Member

    Nov 24, 2008
    985
    136
    The spec sheet says the large signal response time is 300ns, which is cutting it kind of thin for operation at 1mHz. The small signal response time is 1.2us, which will not get you to 1mHz. I'd say if operation in the mHz range is important you'd need to find a faster device.
     
  3. tejasdj12

    Thread Starter New Member

    Jul 11, 2010
    20
    0
    So, I need a High speed comparator. You know any other?
    Apart from Maximum Frequency, is the circuit okay?
     
  4. BillO

    Well-Known Member

    Nov 24, 2008
    985
    136
    The circuit should work except at really low frequencies.

    There are many, many high speed comparators. Just google "high speed comparator". You'll get all you could ever need.
     
  5. Audioguru

    New Member

    Dec 20, 2007
    9,411
    896
    The maximum input bias current for an LM393 is 0.25uA. Then your 1M input resistor causes the input voltage of some LM393 ICs to be +0.25V then it will not be sensitive to less peak input voltage.

    Your 1pF input capacitor value is EXTREMELY low. Stray capacitance (maybe 10pF?) will create a voltage divider then the circuit will have very poor sensitivity.
     
  6. tejasdj12

    Thread Starter New Member

    Jul 11, 2010
    20
    0
    How about 0.1μF and 10kΩ?

    I found this one:
    TLV3501 - http://www.ti.com/lit/ds/symlink/tlv3501.pdf
    Never heard of this IC before. I guess, it will be hard to find this one in my area.
    Other ICs, which I found, needed Dual Power Supplies.
     
  7. Audioguru

    New Member

    Dec 20, 2007
    9,411
    896
    Then the comparator will be extremely sensitive and its output will probably be its own noise that is amplified.
    Simple arithmatic shows that 0.1uF and 10k reduces the signal level for frequencies below 160Hz.

    Comparators are almost always used with some hysteresis as mentioned in the datasheet for the LM393. Then they do not amplify their own noise and they do not oscillate. Your circuit does not have hysteresis.
     
  8. tubeguy

    Well-Known Member

    Nov 3, 2012
    1,157
    197
    If the input amplitude can be 'anything' it would be a good idea to add a resistance in series with the signal input for over voltage current limiting as recommended on pg 7, fig.3 of the TI datasheet.
     
  9. BillO

    Well-Known Member

    Nov 24, 2008
    985
    136
    Looking at the input circuit of the LM393, I am not sure why this would happen. I think you could do without the the resistor entirely.

    Yes, agreed. This would also further reduce high frequency performance.

    @tejasdj12, Use as large a cap as you can. A 1uF ceramic might be a good choice.
     
  10. tejasdj12

    Thread Starter New Member

    Jul 11, 2010
    20
    0
    Yup, I thought about that too. But, I don't think that I would ever apply a signal of more than 10V. When I said 'anything' I meant to make its operation independent of the signal amplitude.

    When I removed that resistor (1MΩ), it didn't work. Voltage didn't drop below 0V and output was always HIGH. And I think a High Pass filter has a Capacitor in series and a Resistor in Parallel.

    If I use a High Capacitance value, wouldn't the charging and discharging time cause any trouble (larger Capacitance, more time, more problems with High Frequencies)? Moreover, Capacitor Reactance is what I thought of while deciding the capacitor value.
     
  11. BillO

    Well-Known Member

    Nov 24, 2008
    985
    136
    Here is a good reference for designing a stable comparator circuit.

    Sounds like noise is an issue. With capacitor coupling, the input should go negative at the comparator. However, as Audioguru suggest, a properly designed circuit will work better for you. See the document I linked to.

    No, this should not be an issue. The ac component will pass through the capacitor. any DC component will charge the cap, but will be blocked from affecting the input of the comparator.
     
  12. BillO

    Well-Known Member

    Nov 24, 2008
    985
    136
    Stray capacitance after the 1pF cap will tend to attenuate the high frequencies.
     
  13. tubeguy

    Well-Known Member

    Nov 3, 2012
    1,157
    197
    The absolute maximum input voltage is V supply + 0.3v (5.3 V) in this case and the below Gnd max is only - 0.3V so with no series resistance and a 10V max input signal there could be trouble.
     
    Last edited: Feb 9, 2013
  14. tubeguy

    Well-Known Member

    Nov 3, 2012
    1,157
    197
    When using AC coupling you need the 1M resistor as a reference point for the cap to charge/discharge.
     
  15. MrChips

    Moderator

    Oct 2, 2009
    12,421
    3,356
    LM311 comparator has shorter rise time and will get you above 1MHz.
     
  16. tejasdj12

    Thread Starter New Member

    Jul 11, 2010
    20
    0
    Didn't know that there was something like Maximum Input Voltage :rolleyes:
    So it isn't safe for voltages above 5V? How about 1kΩ. But if I add a Resistor here, then there would be some drop across it, which is not good if the signal voltage is very small.

    Okay, I'll add 1μF Ceramic disc. But the circuit doesn't work without 1MΩ, even if use 1μF Cap.

    Nice link :) I will think about Hysteresis when dealing with Noise reduction. I'll be getting access to a CRO soon (in my College Laboratory).
     
  17. tejasdj12

    Thread Starter New Member

    Jul 11, 2010
    20
    0
    Oh man! That's the thing I was searching for. Low Current and Low Voltage Offset. Should work perfectly up to a minimum of about 10mV p-p input signal voltage.
     
  18. Audioguru

    New Member

    Dec 20, 2007
    9,411
    896
    No.
    The input needs a resistor to 0V to establish a 0V input reference.
    The inputs are PNP transistors so if the resistor is missing then the input will float as high as it can go then the comparator WILL NOT WORK.
     
  19. BillO

    Well-Known Member

    Nov 24, 2008
    985
    136
    Right, go it. I missed the part where he was using a single supply as well. I should've given my head a shake.

    Edit: I so rarely use ac coupled op-amps these days. It's amazing what you forget over time. I always revert to "ideal" in those cases.
     
    Last edited: Feb 10, 2013
  20. tejasdj12

    Thread Starter New Member

    Jul 11, 2010
    20
    0
    Okay guys! I'm going to finalize this design. But I thought of another way to do it. Instead to directly applying the signal to the Comparator, I can use an amplifier and attenuator with Automatic Gain Control to provide maximum amplitude of 5V p-p. This would eliminate the Low Voltage limit.

    But the most difficult part is the Automatic Gain control for which I don't have any idea for a practical circuit. If the signal is small (< 5Vp-p), it will automatically amplify it upto 5V. If it's more than 5V, it should automatically attenuate it to 5V. This appears more superficial, but if it works, it would be flawless.
     
Loading...