1. raghavendraa@myw.ltindia.

    Thread Starter New Member

    Oct 19, 2010
    4
    0
    I am using MSP430F247 controller which is having internal 12 bit ADC.so , i want to know the logic how to measure the variable analog frequecy i.e in the range from 50 - 60Hz +/- 2%. Please suggest some logics as earliest.
     
  2. DonQ

    Active Member

    May 6, 2009
    320
    11
    First, if what you want to do is measure frequency, do not do it with an ADC! Do it with a zero-crossing detector and some sort of time interval. That would be some high-speed counter, or perhaps some sort of 'capture' device if that controller has one.

    ADC is for measuring voltage, and although you can, with some hardware, and some software, eventually extract frequency info, it is not worth the effort when there are built-in things meant to do exactly that. Frequency is 1/time. Once you know the time between zero crossings, you know the frequency, regardless of the voltage.

    You will still need the code to initialize the hardware, but not nearly as much as trying to do it with an ADC.
     
  3. guitarguy12387

    Active Member

    Apr 10, 2008
    359
    12
    Whats wrong with doing zero crossing detection in software? Seems like it would just be a few if statements...
     
  4. DonQ

    Active Member

    May 6, 2009
    320
    11
    Nothing is wrong, but needless. It is like reading a push-button switch with an ADC, sure you can do it, but why? You are not looking for analog information, so why do you want to do things analog. All you want is the moment of the zero crossings. This is a digital event so it seems obvious to do it digital.

    Doing it analog, you need to scale/condition the signal, ADC conversion including waiting for the conversion to complete, and then software and memory to store current and previous values to get the zero-crossing. (You say "a few if statements". How long does that take? That becomes your sample rate.) All this, just to get the information that is directly available with a simple opto-coupler input at a much higher resolution. The resolution of the ADC version is dependent on the ADC conversion time plus the time each set of 'ifs' takes. The opto-coupler zero-crossing detector resolution is essentially infinite since it is detecting the zero-crossing as an analog value and converting it into a digital edge.

    Then you still have to determine the time between zero crossings. The opto-coupler input could go straight to an input-capture hardware arrangement if the controller has one (if not, an interrupt that reads a free-running counter). These generally have a resolution equal to the system clock speed, on some systems this is 4 times the single instruction execution rate. This is so, so much more than you will ever be able to get from an ADC based zero crossing detector and is so simple that you can spend the extra time doing important stuff.

    Other than that, I can't think of any reasons.
     
  5. guitarguy12387

    Active Member

    Apr 10, 2008
    359
    12
    Ahhh makes sense. Thanks for the tips!
     
Loading...