Design of equal-precision frequency measurement based on STM32 and CPLD

Publisher:EnigmaticCharmLatest update time:2011-12-15 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
In electronic engineering, resource exploration, instrumentation and other related applications, frequency measurement is one of the most basic and common measurements in electronic measurement technology, and frequency meter is also an indispensable measurement tool for engineering technicians. However, traditional frequency measurement methods have great limitations in practical applications. The measurement accuracy of frequency meters based on traditional frequency measurement principles will change with the change of the frequency of the measured signal. The measurement accuracy of the traditional direct frequency measurement method will decrease with the decrease of the measured signal frequency, and the measurement accuracy of the period measurement method will decrease with the increase of the measured signal frequency. This paper proposes a design of a wide-band digital frequency meter based on ARM and CPLD, using the microcontroller STM32 as the core control chip and the CPLD programmable logic device to achieve equal-precision frequency measurement of gate measurement technology.

Technical indicators of this design:

Frequency measurement range: 1Hz~200MHz, resolution is 0.1Hz, relative error of frequency measurement is one millionth.
Period measurement: signal measurement range and accuracy requirements are the same as those of frequency measurement function.
Duty cycle measurement: accuracy is 99%.
Counting range: 0~1000000000, can be manually paused and reset.
Power consumption: 5V×250mA=1.25W.

Principle of equal-precision frequency measurement

Common direct frequency measurement methods mainly include frequency measurement method and period measurement method. The frequency measurement method is to record the number of change cycles (or pulses) Nx of the measured signal within a certain gate time Tw, then the frequency of the measured signal is: fx=Nx/Tw. The period measurement method requires the frequency fs of the standard signal. Within a period Tx of the measured signal, the number of periods Ns of the standard frequency is recorded, then the frequency of the measured signal is: fx=fs/Ns. The count values ​​of these two methods will produce ±1 word error, and the test accuracy is related to the value Nx or Ns recorded in the counter. In order to ensure the test accuracy, the period measurement method is generally used for low-frequency signals, and the frequency measurement method is used for high-frequency signals. However, due to the inconvenience of testing, the equal-precision frequency measurement method is proposed. The equal-precision frequency measurement method is developed on the basis of the direct frequency measurement method. Its gate time is not a fixed value, but an integer multiple of the period of the measured signal, that is, it is synchronized with the measured signal. The control timing diagram of the equal-precision frequency measurement system is shown in Figure 1.

Figure 1 Control timing diagram of equal-precision frequency measurement system

During the measurement process, two counters count the standard signal and the measured signal simultaneously. First, the gate opening signal (preset gate rising edge) is given. At this time, the counter does not start counting, but waits until the rising edge of the measured signal arrives before the counter actually starts counting. Then, when the preset gate closing signal (falling edge) arrives, the counter does not stop counting immediately, but waits until the rising edge of the measured signal arrives before ending the counting and completing a measurement process. It can be seen that the actual gate time r is not strictly equal to the preset gate time r1, but the difference does not exceed one cycle of the measured signal. Assume that in an actual gate time r, the counter counts the measured signal as Nx, the counts the standard signal as Ns, and the frequency of the standard signal is fs. The frequency of the measured signal is as shown in formula (1).
(1)

Figure 2 is a logic block diagram of equal-precision frequency measurement. CNT1 and CNT2 are two controllable counters. The standard frequency signal fs is input from the clock input terminal CLK of CNT1, and the shaped measured signal fx is input from the clock input terminal CLK of CNT2. The CEN input terminal in each counter is the clock enable terminal, which controls the clock input. When the preset gate signal is high (the preset time starts), the rising edge of the measured signal passes through the output terminal of the D flip-flop, and the two counters start counting at the same time; similarly, when the preset gate signal is low (the preset time ends), the rising edge of the measured signal passes through the output terminal of the D flip-flop, and the counter counts are turned off at the same time.

Figure 2 Logic block diagram of equal-precision frequency measurement

System hardware design

The frequency meter is designed using ST's 32-bit processor STM32F103C8 as the main control chip and the high-reliability programmable logic device EPM240T100C5.

The functional features of STM32F103C8 are as follows: (1) The maximum frequency can reach 72MHz, with 128/64KB FLASH, 1.25DMIPS/MHz, and can access the memory with 0 wait cycles. (2) The power supply voltage range is 2.0~3.6V, with an embedded 8MHz high-speed crystal oscillator, and can also be supplied by an external clock. This system uses CPLD clock division supply. (3) The download mode can use the serial wire debug (SWD) interface and JTAG interface. This system uses the JTAG download interface.

The functional features of EPM240T100C5 are as follows: (1) Supports internal clock frequency of 300MHz. This system uses an active crystal oscillator with a frequency of 50MHz. (2) The on-chip voltage regulator supports 3.3V, 2.5V or 1.8V power input. This system uses a 3.3V voltage supply. (3) The download mode uses a 10-pin JTAG interface.

1 System hardware structure block diagram

The system controls the internal logic unit by controlling the STM32F103C8 microcontroller and sending data and commands to the CPLD chip EPM240T100 via the SPI bus. EPM240T100 uses an external active crystal oscillator 50MHz supply, and 12.5MHz is divided by 4 as the input clock of the CPU. The hardware structure of the system is shown in Figure 3. It includes the main control chip module, JTAG download module, reset circuit module, host computer display module, and measured input module.

Figure 3 System block diagram


2 Digital circuit design of the system

The principle of the microcontroller is shown in Figure 4. The processor of this system uses STM2F103C8, and the clock is divided by CPLD to supply the CPU. The data and commands are transmitted to CPLD via SPI, and then sent to the host computer for display via serial port RS232.

Figure 4 Schematic diagram of microcontroller

Reference address:Design of equal-precision frequency measurement based on STM32 and CPLD

Previous article:Research on Direct Sequence Spread Spectrum and Its Implementation on FPGA
Next article:Research on Dynamic Elastic Modulus Measurement Based on Mallat Algorithm

Recommended ReadingLatest update time:2024-11-16 20:47

Getting Started with STM32 BIT_BAND Bit Band Alias ​​Area
1. What is a bit segment and bit band alias area? 2. What are its benefits? Answer 1: Yes, remember MCS51? MCS51 has bit operation, which takes one bit (BIT) as the data object.       MCS51 can simply operate the second bit of P1 port independently: P1.2=0;P1.2=1; just like this, the third pin (BIT2) of P1 port
[Microcontroller]
Getting Started with STM32 BIT_BAND Bit Band Alias ​​Area
Multi-channel temperature acquisition system circuit and design based on CPLD
K-type thermocouple is a temperature sensor commonly used in current industrial production and scientific experiments. It can directly measure the temperature of liquid vapor, gas medium and solid surface in the range of 0 to 1,300°C in various production processes. Due to its measurement range and high cost perform
[Test Measurement]
Multi-channel temperature acquisition system circuit and design based on CPLD
Mapping C library function printf in STM32
1. MDK settings MicroLib in the project's Target 2. Add the following compiled code before the main function: #define COM USART1 //Serial port selection initialization, USART1 is serial port 1, USART2 is serial port 2 #ifdef __GNUC__     #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) #else   #define PUTCHAR_PR
[Microcontroller]
Mapping C library function printf in STM32
STM32 simple traffic light design (timing adjustable)
// Button key1 sets the red light time.   Button key2 sets the green light time.   Button key3 sets the yellow light time.   #include stm32f10x_lib.h #include "sys.h"   #include "delay.h" #include "usart.h" #include "stdlib.h"   static int G=0,R=0,Y=0; //Set the green, red and yellow light time
[Microcontroller]
STM32 simple traffic light design (timing adjustable)
stm32 learning notes (I) lighting up the LED
#include "stm32f10x.h" #include "delay.h"  void Delay(u32 count)  {   u32 i=0;   for(;i count;i++);    }      int main(void)  {   GPIO_InitTypeDef  GPIO_InitStructure;     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //Enable PA   delay_init();       GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; //LED0-- PA.8
[Microcontroller]
stm32 learning notes (I) lighting up the LED
How to build a circuit system using 51 microcontroller and CPLD chip
I. Introduction The single-chip microcomputer market can be described as a giant. Among them, the 51 single-chip microcomputer has more users. There is no need for more introduction to the 51 single-chip microcomputer. It must be emphasized here that as long as you are proficient in the 51 single-chip microcomputer, y
[Microcontroller]
How to build a circuit system using 51 microcontroller and CPLD chip
stm32 infrared remote control
HS0038B http://www.51hei.com/stm32/3589.html The infrared remote control I use uses the NEC protocol, which uses PWM to modulate the information sent.     The NEC protocol has the following characteristics:  1. 8-bit address and 8-bit instruction length;  2. Address and command are transmitted twice (to ensure relia
[Microcontroller]
stm32 infrared remote control
Designing finite impulse response filters using programmable logic devices
  1 Introduction     An analog integrated operational amplifier implements a second-order Filters, high-order filters can be formed by connecting second-order filters in series. However, passive components Achieving a filter with an error value of 1.5% or higher requires improved component performance. The typical d
[Analog Electronics]
Latest Embedded Articles
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号