High-precision frequency regulator based on AVR microcontroller

Publisher:幸福如意Latest update time:2006-07-10 Source: 电子产品世界 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Introduction
In modern industrial production and high-precision testing, we need quite precise frequencies to help judge equipment performance indicators. And we want to be able to fine-tune that frequency. The frequency obtained by using a voltage-controlled oscillator is not accurate enough, and the steps to fine-tune the frequency are cumbersome and time-consuming. Therefore, some test items limit the use of voltage-controlled oscillators.

The Mega series of microcontrollers have been launched by Atmel since 2002. This AVR enhanced microcontroller has many advantages such as fast speed, strong anti-interference ability, and low price. In order to speed up the software compilation of AVR microcontrollers, Atmel and third parties provide a variety of development tools, making program development convenient and effective. The internal FLASH structure of the microcontroller has flexible functions and is difficult to decrypt after being locked, which can protect intellectual property rights to the maximum extent. AVR microcontrollers can be widely used in communications, field testing, automotive electronics, medical equipment and other fields, and are suitable for various low voltage and low power consumption occasions. ?

This article proposes a method based on the AVR microcontroller, using the AD9850 to provide a frequency signal accurate to 1Hz. It can generate not only sine waves, but also square waves, thus solving problems for companies that require high frequency accuracy. It uses Atmel's AVR microcontroller Atmega16L as the core and can control the output frequency conveniently and accurately. Since the AVR microcontroller is online programmable, the design steps are greatly simplified and the design process is accelerated. At the same time, the chip will not be burned or burned, thus saving costs. ?

Figure 1 shows the overall design block diagram of the frequency regulator. The user sets the frequency value through the 4×4 keyboard, and the AVR microcontroller uses the I/O port to scan and read the frequency value. Then the AVR microcontroller controls the AD9850 to adjust to the frequency required by the user. The output of the AD9850 can be connected to a voltage comparator to shape it into a square wave, or it can limit the bandwidth through a low-pass filter to output a sine waveform. The AVR microcontroller also controls the LCD module to display the current frequency in real time.

Figure 1. Overall block diagram of frequency regulator

2. Control core and frequency generation technology
2.1. Control core
This design uses Atmel's AVR microcontroller Atmega16L as the control core. The single-cycle instructions of the AVR microcontroller can ensure high execution efficiency and low cost, and it is a high-performance device in the reduced instruction set CPU. The AVR microcontroller can provide an execution time of up to 16 MIPS, has a programmable Flash memory of 128K bytes, and has a static RAM of 4096 bytes. The AVR microcontroller comes with a watchdog timer, which can prevent the program from running away under strong electromagnetic interference conditions. The Atmega16L used in this design also has the following features:
·???Contains a hardware multiplier internally to speed up the multiplication operation; the number of I/O port pins is up to 32; ··
???Supports online programmable functions, There is no need to frequently plug and unplug chips from the circuit board; it has a programmable UART port that supports synchronous transmission;
·????Supports three-wire transmission SPI port; it has a convenient I2C bus port that can be directly connected to the Philips chip;
·?? ?Supports JTAG boundary scan circuit; has BOD low voltage detection function;
·???There are 8-channel 10-bit A/D converters inside; 4 PMWs can work collaboratively or individually;
·??Internal real-time clock Circuit; operating frequency up to 16MHz.

2.2? AD9850 frequency generation technology
??? AD9850 is a low-power direct digital frequency synthesizer chip launched by AD Company. It can generate wide frequency signals from DC to 62.5MHz. It has been used in radar systems and low-power systems since it was put on the market. consumption frequency source. Its good frequency synthesis function is suitable for application in high-precision testing. This design uses AD9850 as the waveform generator, which has the advantages of small size and low power consumption.

?? In the control process, the AVR microcontroller calculates the frequency control word for the AD9850 and writes the frequency control word into it. Combined with the "+1Hz" key and the "-1Hz" key on the small keyboard, this design allows the frequency to be adjusted accurately to a step of 1Hz. It can generate square waves and sine waves. When users require the generation of sine waves, we design a low-pass filter to filter out the high-frequency components of the signal. This low-pass filter can also be implemented using a fifth-order elliptical filter. Figure 2 shows the AD9850 circuit design diagram of this system. PC2-PC5 can also be used as an I2C bus port.

Figure 2 AD9850 circuit design

3. Input device and output device
3.1. Keyboard input device and corresponding software
???
This design uses a 4×4 keyboard as the frequency input device. Since the number of buttons is small, only 16, and it needs to represent a wide range of frequencies from 1Hz to 10MHz, the AVR microcontroller scanning method is used in the software design. Use all 8 I/O pins of port A as a scanning keyboard. In addition to a total of 10 numbers from 0 to 9, the keyboard definition also defines the "backspace" key, "delete all" key, "enter" key, "+1Hz" key and "-1Hz" key, so that you can Dadi facilitates users to modify the frequency and fine-tune the frequency at any time. When reading the frequency value input by the user, a delay anti-shake and anti-interference software program is used. The initial value of the scan variable is set to 0xFE, and the scan is implemented by changing the low level to 0. The C code scanned by the keyboard of this microcontroller is as follows:
??????????sccode=0xFE;/*every?scan?initiative?value,11111110*/
?????????? ??while(sccode!=0xEF)/*sccode?is?not?11101111,follow;or?return?0*/
?????????{
???????? ???????PORTA=sccode;/*send?scan?code?11111110?to?portA*/
?????????????PORTA=sccode;/*send? scan?code?11111110?to?portA*/
????????????????if((PINA&0xF0)!=0xF0)/*read?portA,if?high?4?bits? are?not?1111,key?pressed?in?this?line*/
????????????????{
???????????????? ????recode=(PINA&0xF0)|0x0F;/*portA?high?4?bits?reserved,low?4?bits?are?1111*/
????????????? ????while((PINA&0xF0)!=0xF0)
????????????????{};
????????????? ???????/*read?portA,if?portA?high?4?bits?are?not?1111,key?pressed,
??????????????????? ???if?key?pressed,we?must?wait,wait?for?key?released*/
?????????????????????return((~sccode) +(~recode));/*return?row+column*/
????????????????}
?????????????else
???????????????{
???????????????????sccode=(sccode<<1)|0x01;
?? ???????????????/*scan?code?left?shift?1?bit,?add?1?to?right,11111101*/
?????? ??????????}
??????????}
????The scan result finally returned includes the row value and column value of the key. The judgment step is: first record the high 4 bits of port A in the scan variable recode, and set the low 4 bits to 1111. Read the high 4 bits of port A again to determine whether the button is released. When the user has not released the button, there is a low level 0 in the high 4 bits. At this time, the user can only wait in a loop. Only when the user releases the button, the high 4 bits and the low 4 bits are bitwise inverted and combined to form the final returned scan result. If no key press is detected, the scan variable sccode is shifted to the left by 1 bit and continues to the next scan.

3.2?LCD display module
??? After users perform input frequency and "+1Hz" and "-1Hz" fine-tuning many times, they focus on observing the impact of signal output on the next-level circuit, and often forget the output frequency of the current system. This leads to the fact that when fine-tuning is required during precise testing, it is not known whether to adjust it high or low. In order to inform the user of the current frequency of the system, we have expanded the LCD module to realize the real-time display of the current frequency on the LCD module. The LCD module occupies the PD0-PD7 of the single-chip computer Atmega16L as the data interface, and uses the PB0-PB4 of the single-chip computer as the control port. Figure 3 shows the circuit diagram of the liquid crystal display module and controller circuit design.
The PB0 pin selects the data memory or command memory of the LCD module. The PB1 pin indicates whether the operation is
to read or write the LCD module. PB2 constitutes the rising edge and falling edge to complete the reading and writing sequence. PB3 is responsible for selecting the left half of the LCD module, and PB4 is responsible for selecting the right half. Usually, PB3 and PB4 are both set to 1. It should be noted that after the data or instructions are ready, let PB2 change the level, otherwise reading and writing errors will occur.

?? This design uses the large-capacity program memory of the microcontroller Atmega16L to store the font lattice of English letters and several Chinese characters as an array into the program memory of the microcontroller. When a certain character needs to be displayed, the array is called directly, thus simplifying the design and realizing the display of English, Chinese characters and graphics. This design has a friendly display interface and strong operation controllability.

Figure 3 - LCD module and controller circuit design

4? Conclusion
??? In order to facilitate modern industrial production and accurate frequency testing, we designed a high-precision frequency regulator based on AVR microcontroller. In this design, you can use the "+1Hz" key and "-1Hz" key on the small keyboard to easily adjust the frequency accurate to 1Hz. This frequency regulator is small in size but powerful in function. It uses Atmel's AVR microcontroller Atmega16L as the control core. The user can adjust the system output frequency at any time. A 4×4 keyboard is used to input the frequency value set by the user, which occupies a small space and is highly efficient. The AVR microcontroller is programmed to scan and obtain the frequency, eliminating the need for a dedicated keyboard interface chip 8279. The LCD display module can display the current frequency in real time, with a friendly display interface and strong operation controllability. This system can generate square waves and sine waves.

?? The hardware and software of this design have been applied in a certain frequency test production line. Industrial production and test use show that this design simplifies the frequency adjustment process, is user-friendly, and has the characteristics of power saving, low cost, strong anti-interference ability, high frequency control accuracy and fast speed.

References
[1]?Atmel?Corporation.?8-bit?AVR?Microcontroller?with?16K?Bytes?In-System?Programmable?Flash?Atmega16L?data?sheet.?Atmel?Corporation,?2003:?3- 18.
[2]?Atmel?Data?Sheets.?http://www.atmel.com/dyn/products/devices.asp?family_id=607%20
[3]?Atmel?Application?Note.?http:/ /www.atmel.com/dyn/products/app_notes.asp?family_id=607

Reference address:High-precision frequency regulator based on AVR microcontroller

Previous article:Design of USB/PS2 MOUSE using 4BIT OTP microcontroller
Next article:Intelligent temperature control meter with communication port based on 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号