Simulation and Design of a Waveform Generator Based on DDS Technology Qun Sun 1*, Zhenmin Ge 1, Chao Li 2, Linlin Chen 1, Chong Wang 1 1 School of Mechanical and Automotive Engineering, Liaocheng University, Liaocheng 252059,China 2 College of Mechanical Engineering and Applied Electronics Technology Beijing University of Technology, Beijing 100124. * Corresponding author: sunxiaoqun97@163.com Abstract - Waveform generators employed in college laboratories are often purchased instruments with ultra precision, which may cause unnecessary expenditure since the prices are often high whilst some functionalities are not required. By analyzing the principle of existing products, a simple waveform generator based on DDS (direct digital synthesis) technology has been developed using AT89S52 single chip microcomputer combined with DDS chip AD9851, which can produce square wave, sine wave and triangular wave signals. While meeting the requirements of college laboratories, surplus functionalities were avoided to limit the cost. In addition to advantages such as small size, simple structure and easy operation, experiments showed that the generated waveforms are of high precision. Keywords - DDS technology, wave generator, AT89S52 microcomputer I. INTRODUCTION Waveform generators are widely used in scientific research, engineering education and production practice. Square waves and sine waves are extensively utilized signals, often as the standard signals in electronic circuit performance test or parameter measurement [1-3]. In addition, many testing instruments also need standard sine wave and square wave signals to detect some physical quantities. The Direct Digital Synthesis (DDS) technology has been dramatically developed in recent years for several advantages such as very high resolution, continuous phase of frequency conversion, easy synthesis and convenient extension [4-8]. Waveform generators in many laboratories at present are mainly purchased instruments with ultra precision and high costs, which could cause waste of resources since not all the functionalities can be fully utilized[9-15]. For the above reason, a simplified waveform generator has been developed using single chip microcomputer combined with integration of DDS chip to achieve high precision, small volume, simple structure and easy operation. It can produce square wave, sine wave and triangle wave to meet the requirements of laboratories in colleges and universities, whilst other functionalities not commonly used are removed to limit the cost. II. THE OVERALL DESIGN OF WAVE GENERATOR A. System Design Requirement and Module Construction The requirements of system design are to achieve the basic functions of a waveform generator, i.e., ready to configure the output signal waveform types, numerically control output signal amplitude and frequency, ensure the output frequency to reach as high as 6 MHz, operate through the keyboard and display frequency and amplitude etc. The block diagram of the system construction is shown in Figure 1, including a human-computer interface module, a micro-computer controller module, a signal generating module and a signal processing module. The signal processing module includes operational amplifier circuit and filter circuit. Figure 1. The block diagram of wave generator The frequency values are typed through a keyboard and sent to the micro-computer control unit to judge whether it is beyond the frequency range. If it is within the scope, then the frequency control code is generated and sent parallel to the DDS chip, which synthesizes the frequencies required by the users and produces sine wave and square wave signals, and shows on the LCD display through programming. The waveform signals are processed through filter and operational amplifier circuits, and the amplitudes can be adjusted by a slide rheostat. DOI 10.5013/IJSSST.a.17.32.24 24.1 ISSN: 1473-804x online, 1473-8031 print
B. Selection of System Main Components The human-machine interface module consists of a keyboard and LCD1602 display. The controller module is based on an AT89S52 single chip microcomputer that controls other modules, and the signal generating module is an AD9851 chip that produces the signal. The signal processing module is a LM224 amplifier that processes signals after these are produced. In the -12V voltage generating circuit, a 10uF bypass capacitor was added between pin CAP+ and pin CAP- to avoid pressure drop attenuation, and a 10uF capacitor was added to pin VOUT to introduce filter effect. This circuit is a voltage inversion circuit, which outputs -12V voltage through the stabilized +12V input voltage, as shown in Figure 4. III. HARDWARE DESIGN OF THE WAVE GENERATOR A. The Design of stabilized Voltage Supply The power supply module provides voltage to the whole circuit so that the voltage source condition determines the performance of the circuit to a great extent. This design employs three voltage source types including +5V and ±12V. It would be very inconvenient if all the required voltages are external inputs, therefore a single +12V input voltage was chosen as the power supply and the other two voltages were obtained from conversion of +12V. The single chip microcomputer in the control module needs +5V voltage power supply, which can be obtained from a three-terminal voltage regulator LM7805. The signal processing module LM224 needs ±12V power supply, where +12V voltage can be obtained directly, and the -12V voltage is obtained by CMOS voltage converter ICL7662CPA. The principle of the power unit is shown in Figure 2. Figure 4. The circuit of generating -12V voltage. B. Design of the Signal Generating Module Signal generation is made through an AT89S52 single chip microcomputer and a DDS chip AD9851. Users send the frequency values through keyboard to the single chip microcomputer (SCM), where the frequency values can be processed into control word, and finally the control word is sent to the DDS chip that can generate frequency controllable waveform signals. The circuit scheme of AT89S52 and AD9851 is shown in Figure 5. Figure 2. The principle of stabilized voltage supply The 12V input produces +5V voltage after a filtering circuit and the voltage regulator 7805 circuit. It needs to use a 100uF capacitor and a 0.1uF capacitor before power supply voltage input for the purpose of filtering, and to add a 100uF capacitor and a 0.1uF capacitor at the voltage output for the purpose of filtering and damping. A light emitting diode is connected at the end of the output and cascaded with a 1kΩ resistance to indicate the voltage. The 5V voltage regulator circuit is shown in Figure 3. +12V U1 VCC 1 V V 2 IN OUT GND C3 Cap 0.1uF 3 C4 78L05 Cap Pol2 100uF GND C7 Cap 0.1uF C8 Cap Pol2 100uF Figure 3. +5V voltage regulator circuit R2 Res2 1K D1 LED0 Figure 5. The circuit scheme of AT89S52 and AD9851. C. Design of the Controller Module AT89S52 MCU is advantageous in its low power consumption and has 8k internal storage capacity. The XTAL1 and XTAL2 pins of the MCU are connected to a 12M crystal oscillator and 30pF capacitors before grounding. The clock circuit can be set up as shown in Figure 6. DOI 10.5013/IJSSST.a.17.27.23 23.2 ISSN: 1473-804x online, 1473-8031 print
The square wave amplifier circuit adopts inverting input and the in-phase input was grounded. The input signal connects with a 5kΩ resistor and then to the inverting input terminal, while a 10kΩ slide rheostat was linked between inverting input end and the output end. The amplification factor ranges from 0 to 2 and the square wave amplifier circuit is shown in Figure 9. Figure 6. The clock circuit The RST pin connects to a switch button and VCC, with a 10uF capacitor in parallel connection, grounded via a 10K resistor. This constitutes a reset circuit as shown in Figure 7. Figure 9. The square amplifier circuit Figure 7. The reset circuit D. Design of the Human-Machine Interface Module LCD1602 with 2 16 characters, internal font,and adjustable character brightness is chosen as LCD display module. The 8-line data cables of the LCD module are connected to the microcontroller Port 0, while pin RS, pin RW, pin E respectively link to P3.5, P3.6 and P3.7 of the MCU, with a slide rheostat used to adjust the brightness of the display. The LCD interface circuit is shown in Figure 8. The sine wave amplifier circuit adopts inverting input and the in-phase input was grounded. The input signal connects with a 5kΩ resistor and then to the inverting input terminal, while a 10kΩ slide rheostat was linked between inverting input end and the output end. The amplification factor ranges from 0 to 10 and the sine wave amplifier circuit is shown in Figure 10. Figure 10. The sinusoidal amplifier circuit Compared with the inverting circuit, a 0.1uF capacitor was used to replace the resistor as the feedback element, so as to construct an integral arithmetic circuit. Its role is to convert square wave signals into triangle wave signals, as shown in Figure 11. Figure 8. The LCD interface circuit. E. The Design of Signal Processing Module Op-Amp LM224 was chosen within amplifying circuit and integral circuit for signal processing, and the amplitude was adjusted by a slide rheostat. Figure 11. The circuit of generating triangular wave DOI 10.5013/IJSSST.a.17.27.23 23.3 ISSN: 1473-804x online, 1473-8031 print
The triangle wave amplifier circuit adopts inverting input and the in-phase input was grounded. The input signal connects with a 1kΩ resistor and then to the inverting input terminal, while a 10kΩ slide rheostat was linked between inverting input end and the output end. The amplification factor ranges from 0 to 10 and the square wave amplifier circuit is shown in Figure 12. modes are detected, the program moves into different subfunctions. Figure 12. The triangular amplifier circuit F. The Anti-Interference Design The anti-interference circuit adopts an elliptic filter as shown in Figure 13. Since this signal generator is a hybridsystem of digital and analogue circuits with very high operating frequency, much attention should be paid to the PCB anti-interference design. The PCB separates the layer out and wiring of digital circuit and analogue circuit, while the digital signal ground and analogue signal ground are separated but grounded at one point. The crystal oscillator is close to the pins of the DDS chip. The wires of the crystal oscillator and the power supply were thickened. Figure 13. The filtering circuit IV. THE SOFTWARE DESIGN OF WAVE GENERATOR A. The Main Program Design The software is based on the idea of structured and modular design, and the flow diagram is shown in Figure 14. The initialization program mainly writes in several special function registers, and sets the working modes and initial values of each module. If the reset source is watchdog or the clock looses detector, the latest working condition will be restored. The keyboard scanning is controlled by the T0 timer, and after different waveform Figure 14. The main program flow chart B. The design of DDS Controller The DDS control flow chart is shown in Figure 15. Programming the DDS chip will make the DDS chip produce square wave or sine wave signals that are of the corresponding frequencies. The D/A output voltage of MCU can be adjusted according to the input amplitude, so as to control the amplitude of the square wave and sine wave, and store the frequency and amplitude values into MCU internal flash to avoid losing data. If the reset source is watchdog or the clock looses detector, the frequency and amplitude values saved in the last working cycle is restored. DOI 10.5013/IJSSST.a.17.27.23 23.4 ISSN: 1473-804x online, 1473-8031 print
Start Input the Frequency The requency is beyond the scope? No Convert the frequency into control word Send control word, writing enabled End Yes conditions. The oscilloscope is a selected DS1102E digital oscilloscope. Statistical method has been used for the sampling test, mainly to see whether or not a waveform has distortion. The data collection procedures of three waveforms are the same. Firstly, the frequency is fixed at 1Hz to detect the waveform ranging from 1V to 10V using 1V step. Then the frequency is fixed at 10Hz to detect the waveform ranging from 1V to 10V using 1V step. The tests are carried on using this method by gradually increasing the frequency. A. The Square Waveform Testing In order to make waveform more accurate, some improvements to the original amplifier circuit has been made by adding a voltage comparator to the circuit. UR is the reference voltage added to the in-phase input end and the input voltage U1 is added to the inverting input end. The operational amplifier works in an open loop condition. Because of high voltage in open-loop amplification and a tiny difference can lead to output saturation voltage, an ideal square wave only exists in a saturated zone. The actual square wave experiment is shown in Figure 16. Figure 15. The DDS flow gram C. The key Scanning Program The keyboard is firstly initialized and anti-shake program is added to prevent detection error during key scanning. If key 1 is pressed, the LCD cursor moves to the right. Pressing key 2 increases the frequency value, and pressing key 3 reduces the frequency value. If key 4 is pressed, the microcontroller will reset and the program will restart. D. The LCD display The display module is a LCD1602 panel that can display two lines and each line can display 16 characters. Firstly initialize LCD1602 and then set the position of the first line and display the contents of the first line. In order to ensure that the control command can be received completely, time delay is added in the program. The second line is configured after completion of the first line of data transmission, using the same approach as for the first line. V. EXPERIMENTAL ANALYSIS AND IMPROVEMENT OF THE WAVE GENERATOR Figure 16. The measured drawing of square wave B. The Sinusoidal Waveform Testing The sinusoidal wave is output directly by the AD9851, by adjusting the slide rheostat to adjust the amplitude. For sinusoidal wave with any arbitrary frequency and amplitude, the test found that the waveform is ideal. The actual experiment of sinusoidal wave is shown in Figure 17. Because this design is for laboratory in colleges and universities, therefore there are not very strict requirements for environmental conditions. The scope of the room temperature ranging from 10 to 35 have been provided, and relative humidity is no more than 80% under the testing DOI 10.5013/IJSSST.a.17.27.23 23.5 ISSN: 1473-804x online, 1473-8031 print
Figure 17. The measured drawing of sinusoidal wave. C. The Triangular Waveform Testing Triangle wave generating circuit is actually an integral circuit, which is integral of the square wave output of AD9850, resulting in a triangle wave. Because the triangular wave is obtained by square wave, the quality of the square wave directly affects the quality of the triangular wave. Therefore, in order to get ideal triangle wave, it is essential to firstly ensure the quality of the square wave. The actual experiment of triangular wave is shown in Figure 18. (A)Before improvement;(b)after improvement;(c)frequency control word Figure 19.The experimental data of frequency testing E. The Improvement of System Amplitude-Frequency Characteristics Before nonlinear compensation, the D/A output voltage is linear and its input amplitude is fixed at 306mV. The system amplitude-frequency characteristics are those characteristics of the operational amplifiers. The amplitudefrequency characteristic curve is shown in Figure 20, where the signal attenuation is 0dB within the low frequency band and the actual output amplitude is consistent with the configured range. When the frequency is 80 khz, the amplitude begins to decay, the higher the frequency the greater the decay. The amplification factor decreases when the input signal frequency is increased. Figure 18. The measured drawing of triangular wave. D. Improvement of the System Frequency Performance Frequency synthesis adopts a ROM look-up table. From the perspective of the application, the frequency control word determines the output frequency and sampling points, which can either increase the frequency decreasing the sampling points, or decrease the frequency and increase sampling points. Due to variations of output frequency, the output waveform signal distortion also changes, as shown in Figure 19. Figure 20. The comparison of the amplitude-frequency characteristics of before and after non-linear compensation. DOI 10.5013/IJSSST.a.17.27.23 23.6 ISSN: 1473-804x online, 1473-8031 print
Figure 21. The developed waveform generator. VI. CONCLUSION The lost cost waveform generator has been developed with several advantages such as high precision, small size, simple structure and easy operation. It can produce square wave, sine wave and triangle wave signals to satisfy the requirements of laboratories in colleges and universities. At the same time, some rarely used functions have been removed to reduce costs. Under the control of the MCU, waveform signals with adjustable frequency and amplitude can be directly synthetized by the DDS device. According to the sampling theorem, the frequency of the output sine signal can reach 6MHz when the DDS chip uses a 125MHz reference clock. However due to restrictions of the operational amplifier, the waveform quality becomes poor when the output frequency increases to 10MHz. [6] Yifan TAO. Design of a Signal Generator Based on AD9854[J]. Control & Automation, 2006(02Z): 241-243. [7] Guoguang ZHANG. Research of DDS-based high-precision multichannel signal generation system[j]. Electronic Measurement Technology,2014,37(4):125-129. [8] Qun SUN, Qing SONG. Portable signal generator based on direct digital synthesis[j]. Instrument Technique and sensor.2009,4(4):67-70. [9] Jianqing LIAO. Design of Phase Adjustable Signal Generator Based on DDS[J].Journal of Luoyang Normal University, 2014,33(2):29-32. [10] Zhengjiao CAO. Design of DDS Signal Generator Based on FPGA[J].Computer Measurement & Control, 2011,19(12):3175-3177,3186. [11] Yingying SUN, Jingyang LU, Sijiu LIU, Hongqi BEN. Design of sinusoidal signal generator based on AD9833 and potentiometer[j].electrical Measurement & Instrumentation, 2012,7:93-96. [12] Dawei YANG, Xiufang YANG, Jianghong CHEN. Design and implementation of direct digital frequency synthesis [13] Chuansheng ZHANG. Visualization Versatile Waveform-generator Based on S3C2440 [J].Chinese Journal of Liquid Crystals and Displays, 2014, 29(6):939-943. [14] Shou.Y.Z, Zhang.H, Ge.Y.H. Design and Implementation of DDS Signal Generator Based on FPGA[J]. Journal of Jimei University (Natural Science), 2014, 19(5):393-400. [15] ZHANG Genxuan,WU Zihuai. Design of Signal Generator Based on AT89S52 Microcontroller[J]. Journal of Hunan Institute of Engineering, 2010, 20(3): 18-20. ACKNOWLEDGEMENT This project is founded by Shandong Province special funding to upgrade technology research of large scientific instruments (ID: 2013SJGZ26) and national college students innovation and National Training Programs of Innovation and Entrepreneurship for Undergraduates (ID: 201510447034). REFERENCES [1] Xiaoling XIA. The design of waveform generator based on FPGA and MCU[J]. Electronic Technology & Software Engineering. 2015, 06:141. [2] Haibo WANG, Weitao REN, Xu LIU. Simulative HPM Pulse Generation Based on Arbitrary Waveform Generator[J]. Modern Applied Physics, 2015,01: 66-69. [3] Shuming LAI, Zhuoxin YANG, Lijuan ZHANG. A new type of digital development of high frequency signal generator[j]. Digital Technology and Application, 2015, 02: 60-61. [4] Kaiyan LI. Multi-functional signal generator[j]. Journal of Tianjin University of Commerce, 2006,26(3):69-71. [5] Wenting LI, Shaobo LIU, Zhaozhi LONG. Calculated performance analysis of impulse measurement software[j]. Electrical Measurement & Instrumentation, 2015,01:64-69. DOI 10.5013/IJSSST.a.17.27.23 23.7 ISSN: 1473-804x online, 1473-8031 print