Connect with us

AVR comparator

Discussion in 'Electronic Design' started by Scott Ronald, Nov 5, 2007.

Scroll to continue with content
  1. Scott Ronald

    Scott Ronald Guest


    So if I go with the AVR's internal comparator for reading in a sine wave
    is there a common way to handle hysteresis for this module?

    As for hooking up the circuit on an Atmega88 does the following sound right?

    AIN0 - 0 to 5 volt (dc offset sine wave)
    AIN1 - GND

    Bit4 ACI: - this is the flag set when the comparator event occurs.
    Bit 3 ACIE: interrupt enable for the module
    Bits 1, 0 – ACIS1, ACIS0: set to 11 for rising edge triggering

    Bit 1, 0 – AIN1D, AIN0D: AIN1, AIN0 Digital Input Disable so the digital
    inputs dont interfere with the comparator

    Now I would just handle the timer interrupt and take the inverse of the
    elapsed time to recover frequency.

  2. Unfortunately, no. The output of the comparator is not connected to the
    outside of the chip, therefore you can't make a hysteresis using a resistor.
    What you have to do is suppressing the transition ripples in the software.
    I.e. ignore a state of the input if it lasts for less then X microseconds.

    Vladimir Vassilevsky
    DSP and Mixed Signal Consultant
  3. Guest

    What if he uses an output pin that replicates the state of the
    Can't he tie a resistor network to that pin?
    There would be a delay but I don't think it matters for his speed, I
    believe it was a 50Hz sine wave.
  4. It certainly can be done in that way, however it is not going to help
    much. The internal comparator is connected to the input capture hardware
    directly, so the input capture register will be updated several times by
    triggering on the noise during the transition. There is some noise
    reduction circuitry on the chip, however it is not going to help if the
    incoming signal is dirty.

    Vladimir Vassilevsky
    DSP and Mixed Signal Design Consultant
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day