Using AD7008 to construct a programmable sine wave signal generator
[Copy link]
Using AD7008 to construct a programmable sine wave signal generator [Date: 2006-5-11 ] | Source: MCU and Embedded System Application | In many electronic systems, a sine wave signal with adjustable frequency and amplitude is often needed as a reference or carrier signal. Sine wave signals are mainly generated by analog circuits or DDS (Direct Digital Synthesis). Compared with analog circuits, DDS has many advantages such as phase continuity, high frequency resolution, fast conversion speed, and stable signal. Therefore, DDS has been widely used in radar, communication, testing, instrumentation and other fields.
1 System composition The core component of the system is AD7008, which is a highly integrated DDS frequency synthesizer launched by ADI. First, the single-chip microcomputer sends the frequency control word to AD7008, and the required sine signal can be obtained at the output port of AD7008. In order to make the frequency of the output signal more stable, the output signal is filtered through a center frequency adjustable bandpass filter composed of MAX262. The center frequency of MAX262 is set by the single-chip microcomputer according to the output frequency of AD7008. The function of DAC0832 is to control the amplitude of the output signal. The system composition block diagram is shown in Figure 1. 2 Main hardware circuits The main hardware circuits of the system are shown in Figure 2. It mainly consists of three parts: the interface between AD7008 and the single-chip microcomputer, the programmable filter, and the amplitude control. They are introduced separately. 1.2.1 Interface between AD7008 and the single-chip microcomputer AD7008 can form two parallel or serial interfaces with the peripheral MPU, and the parallel interface can be divided into 8-bit and 16-bit. Since the system uses an 8-bit single-chip microcomputer, considering the response speed, an 8-bit parallel interface is used. When the single-chip microcomputer sends data to the PO port. If a negative pulse appears on the WR pin of AD7008 (connected to P1.0 of the single-chip microcomputer), the data of the PO port is sent to the parallel register of AD7008. If a positive pulse appears on the LOAD pin of AD7008 (connected to Pl.1 of the microcontroller), the data in the parallel register of AD7008 will be sent to the on-chip command register, frequency register 0, frequency register 1 or phase register according to the logical relationship of TC3~TC0 (connected to PO.3~PO.0 of the microcontroller). In this way, the sinusoidal signal generated by AD7008 is controlled. The output pins lOUT and IOUT of AD7008 are grounded through a resistor, and the output current is converted into a voltage, which is then passed through a subtraction circuit composed of an operational amplifier to generate a sine wave. 2.2 Design of programmable filter In order to improve the quality of the output signal, the sinusoidal signal generated by AD7008 must be filtered. Since the signal generator is used in electrical measuring instruments, the frequency requirement for the sinusoidal signal is 40Hz~5kHz. The author selected MAX262 with an operating frequency of 1Hz~140kHz to form a bandpass filter with programmable center frequency. MAX262 has three programmable parameters: center frequency , Q value and working mode. All programmable parameters are input through data pins DO and D1. Address pins A3~A0 control the input data to enter different registers. When the frequency of the AD7008 output signal is determined, the center frequency and Q value of MAX262 can be set. In this way, a programmable bandpass filter is formed to filter the output signal of AD7008. 2.3 Amplitude Control The amplitude control of the sinusoidal signal is realized by the D/A converter DAC0832. The filtered sinusoidal signal is connected to the reference voltage pin VREF of DAC0832. The eight-bit data input pin of DAC0832 is connected to the P0 port of the microcontroller, and the chip select signal CS (connected to PI.2 of the microcontroller) determines whether the input data is selected. As shown in Figure 2, DAC0832 works in a single buffer register mode, that is, when CS is low, the data sent by the DO~D7 data line is directly D/A converted. According to the working principle of D/A conversion, we have: Substituting into, we have: The first-stage operational amplifier converts current into voltage output, then: Substituting the expression into, we get the second-stage operational amplifier plays a reverse amplification role, and the relationship between its input and output voltage is: Substituting the expression into, we finally get the following relationship: Since , after the input voltage passes through the circuit, its output is attenuated by digital control. When R changes the value of DO~D7, the output voltage also changes accordingly, that is, the amplitude control of the sine wave signal is realized. 3 Software Design After the microcontroller is powered on and reset, the AD7008 and MAX262 are initialized first. Then the peripheral input unit is detected. When there is a frequency setting input, the frequency control word is sent to the AD7008, and then the center frequency and Q value of the MAX262 are set according to the signal frequency. When there is an amplitude setting input, the amplitude control word is sent to the DAC0832. The program flow chart is shown in Figure 3. Conclusion This signal generator has been successfully used in an electrical measurement system with good results. Due to the actual needs of the system, the full advantages of DDS technology have not been fully utilized. DDS can also be applied to other fields such as frequency hopping communication and digital modulation. Especially in applications that require high frequency accuracy and short conversion time, the use of DDS technology has incomparable advantages over other frequency synthesis technologies. Due to the advantages of DDS itself, it will be widely used in the field of frequency synthesis with high performance requirements.
|