Parameter Analysis of Frequency Signal Measurement Using Single Chip Microcomputer

Publisher:太白山人Latest update time:2011-12-28 Keywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Introduction

Regardless of the type of signal, continuous or discrete, regular or irregular, for a computer control system, it must first be conditioned through the forward channel so that the signal can be detected by the machine: the range of high and low levels, timing coordination, whether latching is required, whether frequency division is required, etc.

Frequency signals are generally used for speed measurement, V/I measurement, phase measurement, etc., especially in industrial control. Many transmitters such as voltage, power, and travel transmitters have frequency signal or pulse signal outputs. Frequency signals have good anti-interference performance and are suitable for long-distance transmission. In addition, the interface required for frequency signals is simple and occupies less resources. Generally, it only occupies one counter interface for direct counting or one interrupt source input interface to count pulses in the interrupt service program. Of course, external counting devices can also be used to input several general I/O interfaces.

In short, the measurement of frequency signals has a flexible input method, which is of great significance to the measurement of various parameters of frequency signals. Frequency parameters mainly include period, duration of high and low levels, and duty cycle.

2. Cycle measurement

Because cycle = number of pulses/time, in order to calculate the number of pulses per unit time, a time reference must be firstly provided. If the timer of a single-chip microcomputer is used for timing, the highest frequency of the signal directly connected to the single-chip microcomputer depends on the crystal oscillator frequency. Since the high and low levels of each pulse of the measured signal must last for at least one machine cycle, its cycle must not be higher than 2 times the machine cycle; on the other hand, one machine cycle is equal to 6 state cycles, and one state cycle is equal to 2 crystal oscillator cycles. Therefore, T to be measured <= 24*T crystal oscillator.

2.1 Measurement of low-frequency signal period The wiring diagram is shown in Figure 1. The front end belongs to the signal conditioning circuit. The working principle is: use a counter and a timer to accumulate the number of pulses within the set time; another method is one timer and one interrupt port, the interrupt is triggered by the falling edge, and counting is performed in the interrupt program.

Obviously, the count value obtained by the above method will be affected by the timing error; in situations where high accuracy is required, this error can be avoided by using an external precision pulse source. That is, when using external pulses for comparative counting, there is no error caused by timing reasons. See Figure 2. At this time, the following relationship will be obtained: F to be measured * COUNT standard = F standard * CONNT to be measured

2.2 Measurement of high frequency signal period. Figure 3 is a typical circuit.

The functions of each part of this circuit are described as follows:

AD9686: Converts non-TTL level signals to TTL level and is a forward conditioning circuit.

The accumulator is a binary counter, the purpose is to divide the signal, MR is the clear terminal. Two counters with different performance are used here, namely 74LS197 and 74LS93. Among them, LS197 is a four-bit binary counter with a maximum counting frequency of 100MHz. It can be divided by 16. If the divided frequency calculated according to the main frequency of the microcontroller is still higher than the measurable frequency, it is necessary to continue dividing. Of course, the maximum operating frequency requirement of the subsequent dividing chip can be reduced. The output of each pin is:

Output of 74LS197: Output of 74LS93:
Q1: Fin divided by 2 Q2: Fin divided by 4 Q1: Fin divided by 32 Q2: Fin divided by 64
Q3: Fin divided by 8 Q1: Fin divided by 16 Q3: Fin divided by 128 Q1: Fin divided by 256

This circuit uses hardware control. When the gate position is "1", 74LS00 is turned on, and the pulse to be tested and the reference pulse enter the external hardware counter for counting at the same time. After a certain delay, the gate position is 0 and the counting stops. According to the count value at this time, we have the following relationship: COUNT to be tested/F to be tested = COUNT reference/F reference. According to needs, only the corresponding frequency division pin can be connected to the microcontroller for counting, or the I/O port can be used to read all the frequency division pins. From the structure of the circuit, we know that this circuit has the advantage of modularity.

3 Measurement of pulse high level duration

3.1 When the pulse frequency is high and the high level time of each cycle is short, in order to ensure accuracy, the time values ​​of N high levels need to be averaged. The wiring and flow diagram are as follows:

3.2 When the pulse frequency is low, it means that the high level lasts longer. At this time, the gating method of T0 or T1 can be used for direct counting. In order to prevent counting from starting from point B in Figure 5, there are two ways to reduce the error: using software method: the signal to be measured is connected to the interrupt port through a non-gate, and the timing of the gating method is turned on in the interrupt program at the same time, thereby ensuring that counting starts from the rising edge of the pulse; hardware method can also be used to ensure that it starts from point A. This method is explained as follows. Using the JK trigger circuit of Figure 6, when the falling edge of Fin arrives, the potential at point C is high, and the potential sent to INT0 is low.

If the high level time in the above method exceeds 65535 count values, the TF0 mark should be identified to expand the counting range.

Obviously, as long as the pulse signal is inverted, we can get the measurement method of its low-level duration, which is not elaborated here.

4 Application of 8098 series microcontroller

Use the timer to count and measure the pulse width. This method is similar to the above: turn on the interrupt by detecting the pin's upward jump, and record the time value T1 at the same time; turn off the interrupt by detecting the pin's downward jump, and record the time value T2 at that moment. T2 minus T1 plus the time corresponding to the number of interrupts recorded is equal to the duration of the high level in one cycle.

The unique feature is the use of the HSI component (high-speed input channel) in 8098. Pulse signals are input through the pins, and the time of the event can be recorded in four working modes at the same time: positive jump, negative jump, positive and negative jump, and trigger every 8 positive jumps, without occupying CPU time. Since the time of the event is based on timer T1, T1 is counted once every 8 states, and each state cycle is 3 times the crystal oscillator cycle, the duration of the positive and negative levels should be greater than 12 times the crystal oscillator cycle. When the frequency is too high, the frequency can be measured by 8 divisions. When the frequency can be measured directly, the same signal can be input through two HIS pins to record the positive jump, negative jump time and the number of cycles respectively, so as to calculate the pulse cycle, positive level time, negative level time, and further calculate the duty cycle.

5 Conclusion

The key to frequency measurement with a single-chip microcomputer lies in frequency division, synchronization, and counting range. In the aforementioned method, the counting port and the external interrupt port can be used interchangeably, but the counting is implemented differently, which requires a corresponding change in the input method. By measuring the high and low potential time of the pulse signal, the duty cycle can be measured using the calculation function of the single-chip microcomputer.

Keywords:MCU Reference address:Parameter Analysis of Frequency Signal Measurement Using Single Chip Microcomputer

Previous article:Application of TOPSwitch-FX series single chip switching power supply
Next article:Application of LCD Module DMF-50081 in Single Chip Microcomputer System

Recommended ReadingLatest update time:2024-11-16 17:40

Haisuxin 8-bit MCU-TM52F1376 is used in electric shavers
An electric shaver is composed of a stainless steel grille, an inner blade, a micro motor and a casing. The main control aspect controls key switches, motor drive, power management, etc. To ensure performance, an electric shaver needs to use an MCU with good stability. . This article will recommend Haisuxin’s high-per
[Microcontroller]
Design and implementation of bus CAN bus lighting node based on μPD780822 single chip microcomputer
1 Introduction CAN (Controller Area Network) was first proposed by Bosch of Germany. It is the most popular and commonly used bus in the automotive controller area network. Its main features are: CAN bus is a multi-master bus. Each node can actively send information to other nodes on the network at any time,
[Microcontroller]
Design and implementation of bus CAN bus lighting node based on μPD780822 single chip microcomputer
51 MCU pin description
When we get a single-chip microcomputer chip, we see so many "thighs". What are they used for? Now that we know the origin of the 51 family, let's learn about their "legs". You must learn well, this is very important. If you can't even distinguish between hands and legs, it's like building a house out of thin air to le
[Microcontroller]
51 MCU pin description
STM8L15x series MCU determines the level of the specified I/O pin
/**   * @brief Reads the specified GPIO input data pin.   * @param GPIOx: Select the GPIO peripheral number (x = A to I).   * @param GPIO_Pin: Specifies the pin number.   * This parameter can be one of the following values:   * @arg GPIO_Pin_0: Pin 0   * @arg GPIO_Pin_1: Pin 1   * @arg GPIO_Pin_2: Pin 2   * @arg GPIO_
[Microcontroller]
Metal detector based on 51 single chip microcomputer
1. Hardware Solution The metal detector designed in this paper is made based on the principle of electromagnetic induction. When a metal is placed in a changing magnetic field, eddy currents will be generated inside the metal according to the principle of electromagnetic induction. The magnetic field generated by the
[Microcontroller]
Metal detector based on 51 single chip microcomputer
C language program using DS18B20 temperature sensor in single chip microcomputer (reference 2)
/*--------------------------------------------------------------------------------------------------- Function: Read DS18B20 Principle: Single bus protocol Note: The single bus protocol has strict requirements on delay. This program uses a 11.0592M crystal oscillator. If you use other crystal oscillators, please m
[Microcontroller]
Lesson 15: MCU bit operation instructions
In the previous routines of running lights, we are used to "bits". One bit is the on and off of a light, but the instructions we learned are all introduced with "bytes": byte movement, addition, subtraction, logical operations, shifting, etc. Using bytes to handle some mathematical problems, such as controlling the te
[Microcontroller]
MCU program memory ROM
  The English abbreviation of single-chip program memory is ROM. The data stored in ROM is generally written in advance before being installed in the whole machine. It can only be read out during the operation of the whole machine, and it cannot be quickly and conveniently rewritten like random access memory. The data
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号