C source programming of AT89C51 single chip frequency meter

This article is based on the AT source of the AT89C51 microcontroller frequency meter. The main functions of the frequency meter are as follows:

C source programming of AT89C51 single chip frequency meter

Test function

It shows that all the test functions of the digital frequency meter generally include frequency measurement, period, cumulative pulse number, frequency ratio, time interval and self-comparison function.

2. Measurement range

It shows the effective measurement range for different functions. When the frequency is measured, the measurement range is that the digital frequency meter is under normal working conditions, and the frequency range of the signal to be measured is generally expressed by the upper and lower limits of the frequency. Most of the low end starts from 10 Hz; the high end is due to different frequency meters. different. Therefore, the high-end frequency is the basis for determining the low, medium, and high-speed counters. In the measurement cycle, the measurement range is expressed by the maximum value and the minimum value of the common cycle.

3. Input characteristics

Digital frequency meters generally have 2~3 input channels. When testing different items, the measured signals can be input to the instrument through different channels. The input characteristics are a set of characteristic parameters indicating that the digital frequency meter is connected to the signal source under test, and usually include the following aspects.

(1) Input sensitivity. Usually refers to the rms value of the minimum input voltage at which the instrument can operate normally. The sensitivity of commonly used digital frequency meters is around 100mV.

(2) Maximum input voltage. Refers to the maximum input voltage value that the instrument can allow. If the measured signal exceeds this value, the instrument cannot guarantee normal operation or even damage.

(3) Input coupling method. The instrument sets two coupling modes, AC and DC. When AC is coupled, the signal to be measured is input through a DC blocking capacitor. When DC coupling, the signal under test directly enters the input circuit. AC coupling is suitable for measuring signals with DC level, DC coupling is suitable for measurement of low frequency pulses or step square wave signals.

(4) Input impedance. In order to reduce the load of the signal source, the digital frequency meter generally uses a high frequency input impedance. The input impedance consists of two parts, the input resistor and the input capacitor.

4. Display and working methods

It indicates what can be displayed, the number of digits displayed, the display device used, and the duration of the measurement that is displayed after one measurement. Some also indicate that the electronic counter is a "no memory" display mode or a "memory" display mode.

5. Output

There are several standard frequency signals that the instrument can directly output, and it can indicate the encoding mode and output level of the output measurement data.

C language program

#include

#include

#define uchar unsigned char

#define uint unsigned int

Uchar temp[8]={0,0,0,0,0,0,0,0};

Uchar temp1[8]={0,0,0,0,0,0,0,0};

Uchar T1count, TImecount, T1count1, TImer, yushu, yushu1;

Long fre,frx;

Float zhou;

Bit flag;

Bit flag1;

Void delay(uchar);

Bit result;

Sbit ird=P1^1;

Sbit id=P1^0;

Sbit clr=P1^2;

Sbit en=P1^5;

Sbit rw=P1^6;

Sbit rs=P1^7;

Sbit rd=P3^7;

Sbit kb=P1^3;

Sbit kx=P1^4;

Sbit A0=P3^6;

Sbit A1=P3^7;

Bit start;

Uchar code tab1[]=“fre: ”;

Uchar code tab2[]=“frx: ”;

Void delay(uchar z)

{

Uchar x,y;

For(x=z;x"0;x--)

For(y=110;y"0;y--);

}

Panduan_bz()

{

Rs = 0;

Rw = 1;

En = 1;

Result = (bit)(P2&0x80);

En = 0;

Return(result);

}

Void write_com(uchar com)

{

While(panduan_bz());

Rs = 0;

Rw = 0;

En = 0;

P2=com;

Delay(5);

En = 1;

Delay(5);

En = 0;

}

Void write_dat(uchar dat)

{

While(panduan_bz());

Rs = 1;

Rw = 0;

En = 0;

P2=dat;

Delay(5);

En = 1;

Delay(5);

En = 0;

}

Void init()

{

Uchar num;

En = 0;

Write_com(0x38);

Write_com(0x0c);

Write_com(0x06);

Write_com(0x01);

Write_com(0x80);

For(num=0;num

Wireless Charger Car Phone Holder

Wireless Charger Car Phone Holder,In Car Phone Holder Wireless Charger,Car Phone Holder And Charger,Phone Car Mount With Wireless Charger

Ningbo Luke Automotive Supplies Ltd. , https://www.car-phone-holder.com