Loading ...
Sorry, an error occurred while loading the content.

Bls: [booksbybibin,www.booksbybibin.tk] reading frequency of an ac signal by atmega8

Expand Messages
  • miftahul muhid
    before u read frequency of AC, must turn down voltage until micro can read that. u can use voltage divide. ________________________________ Dari: danial_1000
    Message 1 of 4 , Jul 27 6:09 AM
    • 0 Attachment
      before u read frequency of AC, must turn down voltage until micro can read that. u can use voltage divide.



      Dari: danial_1000 <danial_1000@...>
      Kepada: booksbybibin@yahoogroups.com
      Terkirim: Ming, 25 Juli, 2010 21:15:15
      Judul: [booksbybibin,www.booksbybibin.tk] reading frequency of an ac signal by atmega8

       

      i m newbie to avr progarmming i wana read a frequency of a ac signal by atmega8 plz any help will be appreciated .
      regards
      dany


    • danial_1000
      i know that and do the same by impleminting a transistor buffer and voltage divider at the input of the transistor gate to switch the vcc at the mcu ICP @
      Message 2 of 4 , Aug 7, 2010
      • 0 Attachment
        i know that and do the same by impleminting a transistor buffer
        and voltage divider at the input of the transistor gate to switch the vcc at the mcu ICP @ input signal frequency and its ok i having problem with the code .i although do it by using the external interrupt and calculate the exact frequency but i wana do it by using ICP.
        my code which i written for reading the frequency by using the ICP is here.plz any help will be appreciated to calculate the exact frequency.
        /*******************************************************************/
        uint32_t time_in_milliseconds=0;
        uint32_t rising_edge,falling_edge;
        uint32_t pulse_clock;
        uint32_t ov_counter++;

        int main(void)
        {

        TIMSK1=(1<<ICIE1)|(1<<TOIE1);//input capture and timer overflow interrupt enable

        /*Noise canceller, prescaler/8, rising edge*/

        TCCR1B=(1<<ICNC1)|(1<<CS11)|(1<<ICES1);

        while(1) //loop forever
        {

        //do nothing the
        }
        return 0;
        }
        /*****************************************************************/
        ISR(TIMER1_OVF_vect)
        {

        ov_counter++;

        }

        ISR(TIMER1_CAPT_vect)
        {

        /*This subroutine checks was it start of pulse (rising edge)

        or was it end (fallingedge)and performs required operations*/

        if (ICP) //if high level

        {

        //save start time
        ICR1=0X00;
        rising_edge=ICR1;

        //set to trigger on falling edge

        TCCR1B^=ICES1;

        //reset overflow counter

        ov_counter=0;

        }

        else

        {

        //save falling time

        falling_edge=ICR1;

        //rising edge triggers next

        TCCR1B^=ICES1;

        pulse_clock=(uint32_t) falling_edge-(uint32_t) rising_edge +(uint32_t)ov_counter*0x10000;
        time_in_milliseconds= pulse_clock/1000;

        }

        }


        --- In booksbybibin@yahoogroups.com, miftahul muhid <azil_man@...> wrote:
        >
        > before u read frequency of AC, must turn down voltage until micro can read that.
        > u can use voltage divide.
        >
        >
        >
        >
        >
        > ________________________________
        > Dari: danial_1000 <danial_1000@...>
        > Kepada: booksbybibin@yahoogroups.com
        > Terkirim: Ming, 25 Juli, 2010 21:15:15
        > Judul:[booksbybibin,www.booksbybibin.tk] reading frequency of an ac signal by
        > atmega8
        >
        >
        > i m newbie to avr progarmming i wana read a frequency of a ac signal by atmega8
        > plz any help will be appreciated .
        > regards
        > dany
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.