Single chip microcomputer STM32L151CCU6
Crystal oscillator
Quartz Oscillator 3225 20M OSC

In recent years, with the rapid development of science and technology, especially the rapid development of related integrated circuit production technologies such as single-chip microcomputers, the rapid development of instrumentation and home appliance industry has been promoted, and the complexity of hardware circuits has been simplified with program code. Constantly moving towards a small size, low price, more diversified functions and intelligent direction. Full-featured, low-priced products are increasingly favored by people. Of course, the development of technology is the first to benefit from the frontier science and technology research personnel. For them, a good measuring device will be their research work. It also brings a lot of burden while bringing convenience. For the time being, many high-end instruments and equipment rely on imports. Researching and manufacturing high-end instruments and equipment belonging to our own country will be the direction we have been working hard, and it has very broad development prospects.

1 hardware circuit design

The design mainly consists of a signal acquisition circuit, an amplification shaping circuit, a frequency dividing circuit, a signal processing circuit, a power supply circuit and a display circuit. After the collected signal is shaped into a rectangular wave of moderate amplitude after being amplified by the shaping circuit, the corresponding frequency dividing circuit is selected according to the frequency of the frequency to perform appropriate frequency division processing, and then the frequency-divided signal is transmitted by the single-chip microcomputer. The frequency measurement is performed, and after the processing, the result is sent out, the digital frequency information outputted by the display circuit is driven, and the corresponding range is indicated, thereby realizing automatic measurement and display of the frequency. The overall working principle block diagram of the frequency meter is shown in Figure 1.

AT89C51单片机的量程自切换频率计算方法介绍0

1.1 Design of the amplification shaping circuit

9013 is an NPN-structured triode with a maximum voltage of 25 V between the collector and the emitter, a maximum voltage of 45 V between the collector and the base, and a maximum voltage of 5 V between the emitter and the base. The maximum current of the collector is 0.5 A; the maximum dissipated power of the triode is 0.625 W, the highest junction temperature is 150 ° C, and its characteristic frequency is 150 MHz; the magnification range is 40 times to 110 times; the operating temperature range -55 ~ +150 ° C; 74LS14 is a dual in-line package with a six-inverter Schmitt trigger, its working maximum power supply voltage is 7 V, the working temperature range is 0 ~ 70 ° C; The amplification shaping circuit formed by the triode 9013 and the Schmitt trigger 74LS14 can effectively amplify and shape the signals of the square wave, the sine wave, the rectangular wave, the triangle wave, etc., and can stably output, has a strong driving capability, and can satisfy This topic requires a frequency range from 0 Hz to 20 MHz. The amplification shaping circuit formed by the transistor 9013 and the Schmitt trigger 74LS14 is as shown in FIG.

AT89C51单片机的量程自切换频率计算方法介绍1

1. 2 signal division part circuit design

The 74LS161 is a binary synchronous counter with functions such as synchronous presets, asynchronous clearing, and hold. Reasonable application of the clear function and set function of the counter, a 74LS161 can be composed of any hexadecimal frequency divider below hexadecimal; 74LS151 is a 8-to-1 data selector with strobe input and complementary output, data selection end ( ABC) is binary coded to select one of the required data from 8 data (D0 to D7).

The frequency dividing circuit formed by the data selector 74LS151 and the counter 74LS161 can conveniently complete the frequency division processing of the signal, and the frequency selector of the counter is controlled by the data selector, thereby realizing effective division of frequency signals of different orders of magnitude. Frequency processing; provide the necessary guarantee for the smooth operation of subsequent circuits. The circuit diagram of the signal divider module is shown in Figure 3.

AT89C51单片机的量程自切换频率计算方法介绍2

1. 3 signal processing part of the circuit design

The expansion of microcontroller systems is usually based on a minimal system. The signal processing module mainly relies on the minimum system of the single chip microcomputer. The minimum system is a truly useful microcontroller minimum configuration system. For the AT89C51 microcontroller, because the program memory is included in the chip, the minimum system is formed by externally connecting the reset circuit and the crystal oscillator circuit. The XTAL1 and XTAL2 pins of the microcontroller are used to connect to the crystal oscillator circuit. XTAL1 is connected to one end of the external crystal and trimming capacitor. It is the input terminal of the internal clock working circuit and the inverting amplifier of the oscillator. XTAL2 is connected to the external crystal and trimming capacitor. At one end, on the chip it is the output of the oscillator's inverting amplifier. RST is the reset end of the MCU, connected to the reset circuit. When this pin is high, the MCU can be reset and returned to the initial state. The reset circuit mainly includes a reset switch, a reset resistor, and a reset capacitor. The minimum system of the microcontroller is shown in Figure 4.

AT89C51单片机的量程自切换频率计算方法介绍3

1.4 Display part of circuit design

In this design system, as long as the signal frequency and range are displayed, a 4-digit common anode digital tube is selected to dynamically display the measured frequency, and red, yellow and green LEDs are selected to indicate the corresponding range. , corresponding to the MHz, kHz, Hz files. Since the operating current of the LED is small, generally about 10 mA, in order to ensure the normal operation of the LED, a current limiting resistor of 200 Ω must be added thereto. The four digits are used to display the measured value of the frequency. When the frequency is between 0 and 9999 Hz, the B position indicator (green) lights up; when the frequency is between 10 and 999.9 kHz, the K position indicator (yellow light) ) Lights up; when the frequency is between 1 and 20 MHz, the M gear indicator (red light) lights up. A display circuit composed of four common anode digital tubes and three color light emitting diodes is shown in FIGS. 5 and 6.

AT89C51单片机的量程自切换频率计算方法介绍4

1.5 power part circuit design

In this design, a 5 V DC power supply is used to supply power to each module. The 220 V AC power is stepped down by a transformer to obtain an AC voltage of 9 V. The rectified AC voltage is rectified by the rectifier bridge to become DC. The voltage is filtered by the capacitor to filter out the high-frequency interference signal. Finally, the voltage regulator 7805 is connected in series to the rectified and filtered DC voltage, and the heat sink aluminum sheet is added to the 7805 to ensure its normal heat dissipation and operation. Therefore, the output of the stable +5 V DC voltage is supplied to each module. The theoretical calculation shows that the power of the whole system is within the rated power of the Zener tube, thus ensuring the normal operation of the entire system. The schematic diagram of the power supply circuit is shown in Figure 7.

AT89C51单片机的量程自切换频率计算方法介绍5

2 software design

In the development process of single-chip application system, C language is the most widely used. C language can not only directly operate the hardware of the computer, but also has flexible language, good program structure, high code efficiency and good portability.

2.1 System General Flow Chart

Flowchart analysis: When the power is turned on, the system initializes and the system starts to run. The internal frequency of the microcontroller begins to judge the frequency of the input signal. The frequency division is calculated in order from high to low to obtain the appropriate frequency division coefficient to control the data selector. The frequency division processing is implemented, and the corresponding range indicator light is determined according to the high and low frequency range of the frequency, and the number of digits to be displayed is determined. Finally, the multiplied result is displayed on the four-digit digital tube through the dynamic scanning display mode. The corresponding measurement results are displayed. The general flow chart of the system is shown in Figure 8.

AT89C51单片机的量程自切换频率计算方法介绍6

2.2 Program flow chart of range display

Flowchart analysis: After the system determines the range, the range indicator lights of different colors according to different range ranges: when the frequency range is 0~9999Hz, the green LED lights up; when the frequency range is 10~999.9kHz The yellow LED is lit; when the frequency is in the range of 1 to 20 MHz, the red LED is lit. The program flow chart of the display range is shown in Figure 9.

AT89C51单片机的量程自切换频率计算方法介绍7

3 circuit debugging and results

The debugging of the system mainly starts from two aspects of software debugging and hardware debugging. Of course, everything is aimed at achieving the established tasks. Software debugging and hardware debugging process are closely related and coordinated. This frequency meter design focuses on debugging software programs.

When the sinusoidal signal is input to the function signal generator at 279 Hz, the result of the digital tube is observed. The results are shown in Figure 10.

AT89C51单片机的量程自切换频率计算方法介绍8

When the square wave signal input to the function signal generator is 680 kHz, the result is as shown in Fig. 11.

AT89C51单片机的量程自切换频率计算方法介绍9

When the input signal waveform of the function signal generator is 2.76 MHz, the result of the digital tube is observed. The results are shown in Figure 12.

AT89C51单片机的量程自切换频率计算方法介绍10

When the triangular signal of the input signal generator is 583 Hz, the result of the digital tube is observed. The results are shown in Figure 13.

AT89C51单片机的量程自切换频率计算方法介绍11

4 Conclusion

The design was debugged in the Proteus software after being debugged by Keil software, and the physical frequency test was carried out to measure the frequencies of the square wave, triangle wave, sawtooth wave and sine wave. It has the characteristics of automatic switching and indicating range, high precision and large measuring range, which is in line with the development trend of electronic instruments and has certain practical value.


Laptop Stand

aluminium laptop stand amazon,vertical laptop stand india,vertical laptop stand multiple

Shenzhen ChengRong Technology Co.,Ltd. , https://www.dglaptopstandsupplier.com