在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<abbr id="27omo"></abbr>

<menu id="27omo"><dl id="27omo"></dl></menu>
    • <label id="27omo"><tt id="27omo"></tt></label>

      新聞中心

      EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 頻率計(jì)數(shù)器電路

      頻率計(jì)數(shù)器電路

      作者: 時(shí)間:2023-08-09 來源:電子產(chǎn)品世界 收藏

      在本項(xiàng)目中,我將設(shè)計(jì)并演示一個(gè)簡(jiǎn)單的電路,可用于測(cè)量信號(hào)的。本項(xiàng)目基于 8051 微控制器,不過您也可以設(shè)計(jì)非微控制器版本。

      本文引用地址:http://www.biyoush.com/article/202308/449422.htm

      Frequency Counter Circuit Image 1

      簡(jiǎn)介

      計(jì)是一種用于測(cè)量信號(hào)頻率的儀器。在科學(xué)術(shù)語中,頻率是指信號(hào)每秒的周期數(shù)。通俗地說,信號(hào)的頻率表示信號(hào)在一定時(shí)間內(nèi)的出現(xiàn)率。頻率基本上是一種簡(jiǎn)單的計(jì)數(shù)系統(tǒng),其計(jì)數(shù)時(shí)間有限。

      在這里,我們使用兩個(gè)定時(shí)器和兩個(gè)設(shè)計(jì)了一個(gè)簡(jiǎn)單的頻率計(jì)數(shù)器系統(tǒng)。其中一個(gè)定時(shí)器集成電路用于產(chǎn)生時(shí)鐘信號(hào),另一個(gè)用于產(chǎn)生一秒的限時(shí)信號(hào)。

      頻率計(jì)數(shù)器電路工作原理

      該電路基于頻率的簡(jiǎn)單定義,即每秒的周期數(shù)?;旧希讲òl(fā)生器電路用于產(chǎn)生簡(jiǎn)單的脈沖波。這些脈沖被輸入 8051 微控制器的定時(shí)器/計(jì)數(shù)器,并對(duì)脈沖數(shù)進(jìn)行計(jì)數(shù)。

      在進(jìn)行一些簡(jiǎn)單計(jì)算后,得到的頻率將以赫茲為單位顯示在 16X2 液晶顯示屏上。

      需要注意的一點(diǎn)是,我使用 Arduino UNO 作為方波源。您既可以使用 Arduino,也可以使用 555 定時(shí)器 IC 將其配置為可控多頻振蕩器,從而完全建立自己的方波發(fā)生器。

      頻率計(jì)數(shù)器電路圖

      Frequency Counter Circuit Circuit Diagram

      頻率計(jì)數(shù)器電路設(shè)計(jì)

      由于我使用 Arduino 來產(chǎn)生方波,因此只需要幾行代碼和訪問一個(gè)數(shù)字 I/O 引腳。但是,如果你打算使用 555 定時(shí)器 IC 構(gòu)建方波發(fā)生器電路,請(qǐng)理解下面的解釋。

      555 定時(shí)器電路的主要要求是產(chǎn)生占空比約為 99% 的振蕩信號(hào),使輸出信號(hào)的低電平時(shí)間值小于高電平時(shí)間值。 由于占空比只取決于閾值和放電電阻的值,因此可以通過選擇適當(dāng)?shù)碾娮柚祦碚{(diào)整占空比。


      Schematic of IC 555 as Astable Multivibrator

      占空比的計(jì)算公式為 D = (R1+R2)/(R1+2R2)

      將 D 值代入 0.99,可得 R1 的值是 R2 值的 98 倍。因此,R2 的值為 100Ω,R1 的值為 9.8KΩ。實(shí)際上,R1 的值為 10KΩ。

      電路設(shè)計(jì)的下一步是設(shè)計(jì)計(jì)數(shù)器電路。我們的要求是測(cè)量幾千赫茲的頻率。如電路原理所述,我將使用 8051 的定時(shí)/計(jì)數(shù)器。事實(shí)上,我將同時(shí)使用 8051 微控制器的定時(shí)器 0 和定時(shí)器 1。

      我將使用定時(shí)器 0 產(chǎn)生延時(shí),使用定時(shí)器 1 計(jì)數(shù)來自脈沖發(fā)生器的脈沖。定時(shí)器 0 在模式 1 中配置為定時(shí)器,而定時(shí)器 1 在模式 1 中配置為計(jì)數(shù)器。

      代碼

      以下是使用 8051 微控制器的頻率計(jì)數(shù)器電路代碼。

      #include<reg51.h>

      #define lcd P1

      sbit rs=P3^0;

      sbit e=P3^1;


      unsigned long z=0;

      void delay (int);

      void display (unsigned char);

      void cmd (unsigned char);

      void init (void);

      void string (char *);

      void intro (void);

      char i=0;


      void delay (int i)

      {

      int j=0;

      for(j=0;j<i;j++)

      {

      TMOD=0x51;

      TH0=0xFC;

      TL0=0x66;

      TR0=1;

      while(TF0==0);

      TR0=0;

      TF0=0;

      }

      }


      void cmd (unsigned char c)

      {

      lcd=c;

      rs=0;

      e=1;

      delay(10);

      e=0;

      }

      void display (unsigned char c)

      {

      lcd=c;

      rs=1;

      e=1;

      delay(10);

      e=0;

      }

      void string (char *c)

      {

      while(*c)

      {

      display(*c++);

      }

      }

      void init (void)

      {

      cmd(0x38);

      cmd(0x01);

        cmd(0x0c);

      cmd(0x80);

      }

      void intro (void)

      {

      cmd(0x80);

      string("  Electronics  ");

      cmd(0xc0);

      string("      Hub      ");

      delay(2000);

      cmd(0x01);

      cmd(0x80);

      string("   Frequency   ");

      cmd(0xc0);

      string("    Counter    ");

      delay(2000);

      cmd(0x01);

      cmd(0x80);

      }


      void main()

      {

      unsigned int temp=0;

      unsigned int temp1=0;

      unsigned int frequency;

      init();

      intro();

      delay(100);

      while(1)

      {

        TMOD=0x51;

      TH1=0;

      TL1=0;

      TR1=1;

      delay(100);

      TR1=0;

      frequency=(TH1*256)+TL1;

      frequency=frequency*10;

       

      ////////////////////////////////////////////////////////////////////////////////////////////////////////////

      if(i==0)

      {

      string("Frequency In Hz");

      i++;

      }

          cmd(0xc5);

      if((frequency>=1) && (frequency<10))

      {

      string("    ");

        temp=frequency*10000;

        temp1=((temp/10000)+48);

        display(temp1);

        }

        else if((frequency>=10) && (frequency<100))

      {

      string("   ");

      temp=frequency*1000;

        temp1=((temp/10000)+48);

        display(temp1);

      temp1=(((temp/1000)%10)+48);

        display(temp1);

      }

      //////////////////////////////////////////////////////////////////////

      else if((frequency>=100) && (frequency<1000))//1234

      {

      string("  ");

      temp=frequency*100;

        temp1=((temp/10000)+48);

        display(temp1);

      temp1=(((temp/1000)%10)+48);

        display(temp1);

      temp1=(((temp/100)%10)+48);

      display(temp1);

      }

      else if((frequency>=1000) && (frequency<10000))//1234

      {

      string(" ");

      temp=frequency*10;

        temp1=((temp/10000)+48);

        display(temp1);

      temp1=(((temp/1000)%10)+48);

        display(temp1);

      temp1=(((temp/100)%10)+48);

      display(temp1);

      temp1=(((temp/10)%10)+48);

      display(temp1);

      }

      else if((frequency>=10000) && (frequency<100000))//12345

      {

      temp=frequency*1;

        temp1=((temp/10000)+48);

        display(temp1);

      temp1=(((temp/1000)%10)+48);

        display(temp1);

      temp1=(((temp/100)%10)+48);

      display(temp1);

      temp1=(((temp/10)%10)+48);

      display(temp1);

      temp1=((temp%10)+48);

      display(temp1);

      }

      else

      {

      string("    0");

      }

      delay(500);

       }

      while(1);

      }

      view rawFrequency_Counter_Circuit_8051.c hosted with ? by GitHub

      頻率計(jì)數(shù)器電路操作

      按照電路圖進(jìn)行連接,將 Arduino 產(chǎn)生的脈沖輸入端口 3 引腳 P3.5,即定時(shí)器 1 引腳。由于我已將定時(shí)器 1 配置為計(jì)數(shù)器,因此使用 TCON 位 TR1,我將通過將 TR1 設(shè)置為高電平和低電平來計(jì)數(shù)持續(xù)時(shí)間約為 100 毫秒的脈沖。脈沖計(jì)數(shù)存儲(chǔ)在定時(shí)器 1 中,即 TH1 和 TL1 寄存器中。

      要獲得頻率值,必須使用以下公式。

      frequency=(TH1*256)+TL1;

      為了將頻率值轉(zhuǎn)換為赫茲(即每秒周期數(shù)),需要將結(jié)果值乘以 10。然后,通過一些簡(jiǎn)單的數(shù)學(xué)運(yùn)算將結(jié)果值格式化,以便在 16X2 LCD 顯示屏上輕松顯示結(jié)果。

      Frequency Counter Circuit Image 2

      該電路的應(yīng)用

      使用 8051 微控制器的頻率計(jì)數(shù)器電路可用于精確測(cè)量信號(hào)的頻率。

      由于我們對(duì)脈沖進(jìn)行計(jì)數(shù),因此只能測(cè)量方波及其導(dǎo)數(shù)(占空比不同)的頻率。



      關(guān)鍵詞: 計(jì)數(shù)器 頻率

      評(píng)論


      相關(guān)推薦

      技術(shù)專區(qū)

      關(guān)閉