<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 嵌入式系統 > 設計應用 > 頻率計數器電路

頻率計數器電路

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

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

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

Frequency Counter Circuit Image 1

簡(jiǎn)介

計是一種用于測量信號頻率的儀器。在科學(xué)術(shù)語(yǔ)中,頻率是指信號每秒的周期數。通俗地說(shuō),信號的頻率表示信號在一定時(shí)間內的出現率。頻率基本上是一種簡(jiǎn)單的計數系統,其計數時(shí)間有限。

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

頻率計數器電路工作原理

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

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

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

頻率計數器電路圖

Frequency Counter Circuit Circuit Diagram

頻率計數器電路設計

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

555 定時(shí)器電路的主要要求是產(chǎn)生占空比約為 99% 的振蕩信號,使輸出信號的低電平時(shí)間值小于高電平時(shí)間值。 由于占空比只取決于閾值和放電電阻的值,因此可以通過(guò)選擇適當的電阻值來(lái)調整占空比。


Schematic of IC 555 as Astable Multivibrator

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

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

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

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

代碼

以下是使用 8051 微控制器的頻率計數器電路代碼。

#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ìn)行連接,將 Arduino 產(chǎn)生的脈沖輸入端口 3 引腳 P3.5,即定時(shí)器 1 引腳。由于我已將定時(shí)器 1 配置為計數器,因此使用 TCON 位 TR1,我將通過(guò)將 TR1 設置為高電平和低電平來(lái)計數持續時(shí)間約為 100 毫秒的脈沖。脈沖計數存儲在定時(shí)器 1 中,即 TH1 和 TL1 寄存器中。

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

frequency=(TH1*256)+TL1;

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

Frequency Counter Circuit Image 2

該電路的應用

使用 8051 微控制器的頻率計數器電路可用于精確測量信號的頻率。

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



關(guān)鍵詞: 計數器 頻率

評論


相關(guān)推薦

技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>