This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Frequency counter

Other Parts Discussed in Thread: MSP430F5418

Hi all..........

i want to count the frequency 0 to 25 mhz...also i use to divide by two stage  for  25mhz so it will give me the 12.5 MHz out put. I have to use  the Timer b Capture/compare pin fo timerB & iuse capture resister to take the external events to count the frequency. so please suggest how it is implemented to count  the frequency  range 0 to 25 mhz.....

  • You could use the Timer capture function to measure the time between rising (or falling) edges to determine the period and therefore the frequency using the time stamps provided. See the User's Guide for more info on how to set this up at www.ti.com/msp430

    What specific MSP430 will you be using?

    Please note that only the latest 5xx devices operate at 25MHz, and since this is the upper limit of the device's operating frequency it may be very difficult to set up the timer capture feature to detect & process your incoming signal at higher frequencies if you are dealing with a time dependent operation.

  • I am not sure, but I think both the OP and Brandon are talking about using a known clock source for the Timer and try to capture the edges of the unknown clock.

    Unknown = Known / Count;

    This will work if the known clock source of the Timer is much higher than that of the unknown signal.

    When the unknow clock is much faster then the known clock, the above will not work. But you can use the unknown clock as the clock source of the Timer and try to capture the edges of a known clcok to comput the frequency:

    Unknown = Known * Count;

  • thank you..

              i m using MSP430f5418 ..

    my i/p frequency is  25 / (2     (used divide by two  hardware)     )          =12.5mhz max   ...min   0Hz,

    my crystal frequency =16mhz  external crystal. is it  ok

     

  • You could use that i/p frequecy (12.5MHz) as the clock source of one of the Timer. Use an external watch crystal (32768Hz) to generate ACLK=4096Hz, And try to capture the ACLK with that Timer.

    <i/p frequency> 4096 * <captured counts>

  • with ref to m lst post..

     

    (Hi all..........

    i want to count the frequency 0 to 25 mhz...also i use to divide by two stage  for  25mhz so it will give me the 12.5 MHz out put. I have to use  the Timer b Capture/compare pin fo timerB & iuse capture resister to take the external events to count the frequency. so please suggest how it is implemented to count  the frequency  range 0 to 25 mhz.....)

     

    i used captur & compare technique for frequency counting.....here i capture cycles (count) between one(first ) cycle rising edge to next rising edge .& calculate the frequency. my crystal freq=16mhz .

     

    problem: when i/p frequency reaches 243hZ it counts wrong & shows random count 

     & when i/p frequency goes 290khz it stop counting & display (lcd 16 x2)shwos no counting ....

    please help................

  • Hi,
         with reference to old_cow_yellow Statements:-
        You could use that i/p frequecy (12.5MHz) as the clock source of one of the Timer. Use an external watch crystal     (32768Hz) to generate ACLK=4096Hz, And try to capture the ACLK with that Timer.

        <i/p frequency> 4096 * <captured counts>
       
        it has to work if not, check http://en.wikipedia.org/wiki/Logic_level
        controllers works on TTL levels so if ur frequency pulse voltage is not in TTL logic high range it wont detect as a pulse

  • Hi ,

     

    Was this problem of yours solved? I am also planning to design frequency counter using MSP430.I would like to know the display routine for LCD that you have written? Can you please share me the code?

     

    Thanks,

    Shilpa

  • Hi Shilpa,

    if your're looking for some code to access a standard 16x2 LCD module you can find it into 'My Files' http://e2e.ti.com/members/1371069/files/default.aspx. It drives the LCD in 8bit mode; 4bit mode will need some minor modifications.

    Rgds
    aBUGSworstnightmare

  • Hi aBUGSworstnightmare,

    I would like to know the first part of it i.e. the frequency is given as an input to one of the timers in MSP430.Now,I would like to know the routine for converting this frequency in such a way that it can be displayed on the LCD. I understand that the incoming frequency is in binary form i.e. it will look something like this 010110101001111 .... I would like to know how to display this value on LCD? Have I need to convert this into BCD? Please let me know the exact procedure for the same.One of my friends told me this procedure:

    1)binary value need to be converted into Unpacked BCD,

    2) Unpacked BCD ------->string

    3)A small routine to reverse this string and then this string can be displayed on LCD

    Please let me know if this long procedure is right? Waiting for your valuable inputs.

    Thanks,

    Shilpa

     


  • Hi Shilpa,

    you need to take care of your frequency measurement yourself! If this is done, you have i.e. an integer giving you the frequency in Hz.

    Then you can take this (integer, char) value and have it printed to the LCD using the LCD_output_result()-function. This function takes a (max) 4digit number, splits it into single chars (using modulo operator), converts the digits to ASCII and prints them to the LCD.

    If you have a string to be displayed you can use LCD_string(), for a single char you can use LCD_char().

    Rgds
    aBUGSworstnightmare

  • Hi,

    Thanks for the mail.This means that I need to convert the incoming binary values into integer and pass on this value to the LCD_Output_Result function as the rest will be taken care by this function?

    Can you please confirm to me.It would be great if someone could just tell me also to how to calculate frequency from the timer?

    Waiting for your inputs.

    Thanks,

    Shilpa

     

     

  • Hi Shilpa,

    Hi, I don't understand what you mean when talking about 'incoming binary values', so I will give you another example.

    Let's say you're using the AD converter for sampling an value coming from a trimmer. You pass the AD result to a variable with a name i.e. ad_result. ad_result is of type unsigend int (integer); with a 10-bit resolution the value for it can be 0 (trimmer connected to ground) or 1023 (trimmer connected to VCC).

    So, you simply need to take the variable (ad_result for this example) and pass it over to the LCD_output_result()-function (i.e. the LCD_output_result(ad_result); ).

    Rgds
    aBUGSworstnightmare

  • Hi  aBUGSworstnightmare,

    Thanks for the info.Speaking w.r.t our example, i can calculate the frequency from the timer this way:

    df = st_TMR1L+(st_TMR1H<<8)+(st_TMR1_ovfl<<16);

    with variables declared this way:

    unsigned short st_TMR1L       ; // Store Timer 1 low byte (after calced).
    unsigned short st_TMR1H       ; // store Timer 1 high byte time.
    unsigned long  st_TMR1_ovfl=0 ; // store timer 1 overflows - multiples of 65536.
    unsigned long  df = 0         ; // display frequency value to use.

    I will now pass this df  value to LCD_output_result function where in the conversion of this decimal number to string will be taken care by this function.Can you throw some light upon this issue?

    Regards,

    Shilpa

     

  • Hi Kshatriya,

    I am just starting to work in a project where i need to measure multiple sources of frequency, is there a way to have multiple channels for frequency measurements using any of the launchpad boards (MSP430, Stellaris or Piccolo)?

    Could you please point me to the right direction?

    Thanks in advance.

**Attention** This is a public forum