Home arrow Semiconductor Information arrow A Signal Generator Project Based on Single Chip Microcomputer 89C51

arrow left

arrow right

A Signal Generator Project Based on Single Chip Microcomputer 89C51

Author: Apogeeweb
Date: 25 Jan 2018
 14056
low frequency signal generator

 

Warm hints: The word in this article is about 2800 and reading time is about 14 minutes.

Summary

In this article, it will mainly introduce a low frequency function signal generator project based on single chip microcomputer 89C51. By adopting the technology of digital waveform synthesis and through the combination of hardware circuits and software programs, the signal generator can output custom waveform, such as sine wave, square wave, triangle wave,  trapezoid wave and other arbitrary waveform.

 

The frequency and amplitude of waveform can be changed arbitrarily in a certain range. The change of waveform and frequency is controlled by software, and the change of amplitude is realized by hardware. The principle of waveform generation, the design principle of hardware circuit and software will also be introduced in this article.This system can produce the waveform of 798.6HZ. It has the advantages of small size, low price, stable performance and complete function.

 

 


Catalog

Ⅰ Abstract

Ⅱ Signal Generator Basics

Ⅲ Tasks and Requirements

  3.1 Basic Requirements

  3.2 Scheme

  3.3 Operational Principle

Ⅳ Signal Generator Circuit Design and Analysis

  4.1 The Main Circuit

  4.2 Digital-to-analog Conversion Circuit

  4.3 Operational Amplifier Circuit and Low Pass Filter Circuit

  4.4 Serial Communication Circuit

Ⅴ The Design of System Software

Ⅵ Installation, Debugging and Measurement Data Analysis

  6.1 Debugging Process

  6.2 Frequency Measurement Data and System Simulation Waveforms

  6.3 Effect Analysis and Measuring Apparatus

Ⅶ Summary

Ⅷ Signal Generator Attachment

  8.1 The Whole Circuit Diagram

  8.2 Source Program

Ⅸ FAQ

 

 

 


Ⅰ Abstract

By adopting the technology of digital waveform synthesis and through the combination of hardware circuits and software programs, the signal generator can output custom waveform, such as sine wave, square wave, triangle wave,  trapezoid wave and other arbitrary waveform. The frequency and amplitude of waveform can be changed arbitrarily in a certain range. The change of waveform and frequency is controlled by software, and the change of amplitude is realized by hardware. The principle of waveform generation, the design principle of hardware circuit and software will also be introduced in this article.This system can produce the waveform of 798.6HZ. It has the advantages of small size, low price, stable performance and complete function.

 

Keywords: signal generator project; Single Chip Microcomputer; low frequency signal generator; single chip microcomputer(SCM); D / A conversion; 

 

 


Ⅱ Signal Generator Basics

A signal generator is a device that provides a variety of frequency, waveform, and output level electrical signals. When measuring the amplitude characteristics, frequency characteristics, transmission characteristics and other electrical parameters of various telecommunication systems or telecommunication equipments, and measuring the characteristics and parameters of components, they are used as signal sources or excitation sources for testing. It also known as signal source or oscillator, is widely used in the field of production and science and technology.

 

All kinds of waveform curves can be expressed by the trigonometric function equation. A circuit that produces a variety of waveforms, such as triangular waves, sawtooth waves, rectangular waves (including square waves), and sinusoidal waves, is called a function signal generator.

English Name Signal Generator Overview An instrument for generating an electrical test signal for the required parameters
Waveform Type Triangular;sawtooth  or rectangular wave, etc. Signal Sources An instrument for generating test signals

 

 


Ⅲ Tasks and Requirements

The task is to design a signal generator controlled by a single chip microcomputer. Using MCU system  to control and generate various kinds of waveforms, which include square wave, triangle wave, sawtooth wave, sinusoidal wave, etc. The frequency and amplitude of the waveform generated by the signal generator can be adjusted, and the waveform of the signal can be arbitrarily changed by software.

3.1 Basic Requirements

  • 1.Produce more than three kinds of waveforms, such as sinusoidal wave, triangle wave, rectangle wave, etc.

  • 2. The maximum frequency is no less than 500 Hz, and the frequency can be adjusted according to a certain law, such as the change according to the period of 1T,2T,3T,4T or 1T,2T,4T,8T.

  • 3. The amplitude is adjustable and the peak value varies from 0 to 5 V.

Extension requirements: generate more frequencies and waveforms.

Before we start, you can first watch the video to learn more about signal generator, which will help you in the following design: 

 

This video is about the function Generator Tutorial and Signal Generator / Function Generator basic

3.2 Scheme

  • General Scheme

The scheme is to use AT89C51 single-chip microcomputer and DAC0832 digital-to-analog converter to generate the waveform, and a low-pass filter is added to generate purer waveform.  Its characteristics are that it can generate arbitrary waveform, the frequency is easy to adjust, and the frequency can reach 500 Hz or more.High performance, good stability in low frequency range, easy operation, small volume and less power consumption.

 

This scheme can not only meet the basic requirements of curriculum design, but also give full play to its advantages, such as simple circuit, easy control and cost-effective.

  • Range Changing Scheme

Amplify the output voltage through an operational amplifier.The advantage is that the amplitude can be continuously adjustable. 

 

3.3 Operational Principle

A digital signal can be converted into an analog signal by a digital-to-analog converter. Therefore, by generating digital signals and converting them into analog signals, we can obtain the required waveform. 89C51 MCU itself is a complete microcomputer, having all each part of the microcomputer: central processor CPU, random access memory (RAM), read-only memory (RAM), I / O interface circuit, timer / counter, serial communication interface and so on. As long as 89C51 is reconfigured with keyboard, digital-to-analog conversion, waveform output, amplifier circuit and so on, the needed waveform generator can be constructed. The system block diagram of the signal generator is shown in the following figure: 

The system block diagram of the signal generator--A Signal Generator Project Based on Single Chip Microcomputer 89C51

89C51 is the core part of the whole waveform generator. It generates a variety of signals and receives data through the programming and execution of the program. Data is received from the keyboard and then conversion of various functions and adjustment of signal amplitude are carried out. When the digital signal circuit arrives at the conversion circuit, it is converted into the analog signal, which is the required output waveform.

 

The waveform ROM table is to separate the signal into 64 points at equal intervals and stored in the single chip computer RON. The concrete ROM table is generated by MATLAB, such as sinusoidal table. The program generated by MATLAB is as follows:

x=0:2*pi/64:2*pi; y=round(sin(x)*127)+128

 

 

 


Ⅳ Signal Generator Circuit Design and Analysis

4.1 The Main Circuit

In the design, we mainly adopt STC89C51 microcontroller, which has the following advantages: 

  • 1)Has perfect external extension bus, through which the peripheral unit can be expanded conveniently. 

  • 2)The MCU has 4K-byte FLASH ROM program memory space and 256-byte RAM data storage space, which can fully meet the requirements of the program. Because the chip can be electrically erased, it can be reused. If you want to change the content of the program, you can take down the chip and program it again. 

  • 3)The MCU is compatible with the instruction set and output pin of the industrial standard MCS-51 machine.

The interrupt system is set up so that the processor has the ability to handle external asynchronous events. When the CPU is processing something and an emergency occurred outside, it will request the CPU to suspend the current work and start to deal with the emergency.

 

In the waveform generator, two switches are directly connected to the pins of the external interrupt 0 and the external interrupt 1, wherein the S1 switch is used to change the waveform and S2 switch to change the frequency. In the main function of the program, we write a dead loop that will always output a default waveform. When S1 or S2 is pressed and lifted, the program will temporarily jump out of the dead loop and enter the interrupt system, thus changing the waveform and frequency.

 

Clock circuit. Because the delay time at each point of triangle wave, sinusoidal wave, square wave and other waves is several microseconds at a higher frequency, so delay time must be added to the instruction time to obtain the waveform of the specified frequency. The circuit uses 11.0592MHz crystal oscillator.

Signal Generator Clock circuit--A Signal Generator Project Based on Single Chip Microcomputer 89C51

4.2 Digital-to-analog Conversion Circuit

Because the single-chip produces the digital signal, in order to get the needed waveform, it is necessary to convert the digital signal into the analog signal. Therefore, here we choose the digital-to-analog converter DAC0832 which is with low cost, simple interface, easy conversion control and 8-bit resolution. DAC0832 is mainly composed of 8-bit input registers, 8-bit DAC registers, 8-bit DPA converter and the input control circuit. But actually, the output of the DAC0832 is not really continuously adjustable, it increases or decreases in absolute resolution, which is a quasi analog output. DAC0832 is a current-mode output. When applied, an op amplifier is plugged in to make it a voltage-mode output.

 

According to the different control mode of DAC0832 data latch and DAC register, DAC0832 has three working modes: Straight-through mode, single-buffer mode and double-buffer mode. In this article, we choose straight-through mode. 

 

The data port of DAC0832 is connected with the P0 port of the MCU.

 

CSDA:  Chip select signal input line (Strobe data latch), active low;

WR: Data Latch Strobe Input Lines, Negative pulse (pulse width greater than 500ns) validity. LE1 is generated by the logical combination of ILE, CS and WR1. When the LE1 is high, the input data is latched when the data latch state transforms. 

Digital-to-analog conversion circuit--A Signal Generator Project Based on Single Chip Microcomputer 89C51

4.3 Operational Amplifier Circuit and Low Pass Filter Circuit

Operational amplifier circuit and low pass filter circuit--A Signal Generator Project Based on Single Chip Microcomputer 89C51

The LM324's pin 5 is connected to the DAC0832's (IOUT2C) pin 12 and the LM324's pin 6 is connected to the DAC0832's (IOUT1C) pin 11. The LM324's pin 7 is connected to the DAC0832's (REF) pin 9.

 

The function of the first stage operational amplifier is to convert the current signal from DAC0832 to voltage signal V1, and the function of the second stage operational amplifier is to convert V1 through the reverse amplifier circuit.

 

It is required that the output voltage be adjustable at 0-5V, while the V1 voltage is about 5V, so R1 selects 5K resistor and R2 selects 10K potentiometer. The maximum output voltage is 5*(10/2)=10 and the minimum voltage is 0, which can achieve 0-5 V as required.

 

A low-pass filter is connected to the output of the second operational amplifier. Without the low-pass filter, the waveform can still be generated, but there are a lot of burrs in the generated signal. A low-pass filter can not only act as a filter, but also acts as a smoother in this circuit. The cutoff frequency of the low-pass filter is F=1/(2*pi*R3*C6). Here, we choose 100 ohms resistance as R3 and 104 capacitance as C6, and the cutoff frequency is F=16KHZ. The experimental results show that the output waveform is good at this time.

4.4 Serial Communication Circuit

UART (Universal Asynchronous Transceiver) is a kind of serial interface, which is usually included in general microprocessor. Asynchronous serial interface provides a simple way for two devices to communicate without sharing the same clock signal. If add an appropriate level converter MAX232, the serial port can be used in RS232, RS485 and other networks to achieve communication, or to connect with the computer's COM port. The serial port can be implemented only with two signal lines (RX and TX), and as long as both devices have the same bit format and baud rate, then they don't need any other information about each other. The data can be transferred successfully.

Serial communication circuit--A Signal Generator Project Based on Single Chip Microcomputer 89C51

Ⅴ The Design of System Software

Software design will divided into several modules programming according to the function: main program module, external interrupt 0 module, external interrupt 1 module.

  • Main program module

The main program first does some initialization work, and then enter the corresponding while loop according to the waveform sign a,b,c,d and e. The advantage of this writing is that the output waveform frequency can be more than 790 HZ. In the while loop, the single chip microcomputer constantly looks up the table according to the address flag bit, then assigns the value to the data port of the DAC0832, and then add 1 to the address flag bit, determine whether the address flag bit is equal to 64. If it is, then set 0 and make further execution. If not, then directly keep on the execution. And then the corresponding delay is carried out according to the frequency mark bit. The Main program flow chart is as following:

Main program flow chart--A Signal Generator Project Based on Single Chip Microcomputer 89C51

  • Interrupt service program

In this program, two external interrupts play the role of control waveform and frequency respectively. It is also add dithering elimination in the program. 

Interrupt service program--A Signal Generator Project Based on Single Chip Microcomputer 89C51

 

 


Ⅵ Installation, Debugging and Measurement Data Analysis

6.1 Debugging Process

  • 1. No power, use multimeter according to circuit diagram to carefully check whether the connection of each line is normal.

  • 2. First of all, debugging the MCU. DA and operational amplifier chip is not connected. Program under Serial Port with STC_ISP_V483 Software. See if it can be normally programmed.

  • 3., When you can normally program, program the 51 MCU to input 0 to I/0 ports, delay, and then output 1, and so on. Use multimeter to measure the voltage of each I/O port, and see whether it is high or low for a while.

  • 4. Install DA and operational amplifier chip, give a test program of output sine wave of single chip microcomputer, see if output is normal by oscilloscope.

  • 5.Write a complete program to the MCU. Respectively press S1, see whether the waveform changes. Press S2, see whether the frequency changes.

6.2 Frequency Measurement Data and System Simulation Waveforms

Period

T

2T

3T

4T

5T

6T

7T

8T

Theoretical value

798.6

399.3

266.2

199.7

159.7

133.1

114.1

99.8

Actual value

798.6

399.6

266.5

199.9

159.9

133.3

114.2

99.9

System simulation waveforms is as following:

Square waveSawtooth wave (STW)Sinusoidal wave

6.3 Effect Analysis and Measuring Apparatus

From the theoretical and practical values of Frequency measurement data , it can be seen that the frequency error is very small at T,2T,3T,4T,5T,6T,7T,8T. The final waveform output effect is also very good. The measuring apparatus is as following:

  • Oscilloscope (OSC)

  • DC regulated power supply 

  • Multimeter

 


Ⅶ Summary

The design of signal generator based on single chip microcomputer involves a typical control process in the design of the signal generator. A single chip microcomputer controls an analog-to-digital converter (DAC0832) to generate the required current. Then the current output of the operational amplifier LM324 can be linearly converted into the voltage output, and then the voltage can be amplified by the operational amplifier to obtain a signal of sufficient amplitude. Through controlled by the program, a series of regular waveforms can be generated. Such a signal generator has a wide range of applications in the field of control.

 

 


Ⅷ Signal Generator Attachment

8.1 The Whole Circuit Diagram

whole circuit--A Signal Generator Project Based on Single Chip Microcomputer 89C51

8.2 Source Program

#include<reg51.h>

#define uchar unsigned char

#define uint unsigned int

sbit csda=P2^2;

sbit wr=P2^1;

sbit s1=P3^2;

sbit s2=P3^3;

uchar k=0,p=0,delay=0;

uchar bxxz=0;pinglv=0;

uchar a=1,b=0,c=0,d=0,e=0;

uchar code sin[64]={

135,145,158,167,176,188,199,209,218,226,234,240,245,249,252,254,254,253,251,247,243,237,230,222,213,204,193,182,170,158,

146,133,121,108,96,84,72,61,50,41,32,24,17,11,7,3,1,0,0,2,5,9,14,20,28,36,45,55,66,78,90,102,114,128

};

uchar code juxing[64]={

255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,

255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

};

uchar code juchi[64]={

0,4,8,12,16,20,24,28,32,36,40,45,49,53,57,61,65,69,73,77,81,85,89,93,97,101,105,109,113,117,121,125,130,134,138,142,

146,150,154,158,162,166,170,174,178,182,186,190,194,198,202,206,210,215,219,223,227,231,235,239,243,247,251,255

};

uchar code tixing[64]={

0,13,26,39,52,65,78,91,104,117,130,143,156,169,182,195,208,221,234,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,

247,247,247,247,247,247,247,242,229,216,203,190,177,164,151,138,125,112,99,86,73,60,47,34,21,8

};

uchar code sanjiao[64]={

0,8,16,24,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152,160,168,176,184,192,200,208,216,224,232,240,248,

248,240,232,224,216,208,200,192,184,176,168,160,152,144,136,128,120,112,104,96,88,80,72,64,56,48,40,32,24,16,8,0

};

void delay1()

{

int a,b;

for(a=1;a>0;a--)

for(b=122;b>0;b--);

}

void int0() interrupt 0

{

EX0=0;

delay1();

if(s1==0){

bxxz++;

if(bxxz==5)

bxxz=0;

switch(bxxz)

{

case 0 :

{a=1,b=0,c=0,d=0,e=0;}

break;

case 1 :

{a=0,b=1,c=0,d=0,e=0;}

break;

case 2 :

{a=1,b=0,c=1,d=0,e=0;}

break;

case 3 :

{a=0,b=0,c=0,d=1,e=0;}

break;

case 4 :

{a=0,b=0,c=0,d=0,e=1;}

break;

}

delay1();

while(!s1);

}

while(!s1);

EX0=1;

}

void int1() interrupt 2

{

EX1=0;

delay1();

if(s2==0){

p++;

if(p==8)

   p=0;

switch(p)

{

case 1 :

pinglv=3;

break;

case 2 :

pinglv=6;

break;

case 3 :

pinglv=9;

break;

case 4 :

pinglv=12;

break;

case 5 :

pinglv=15;

break;

case 6 :

pinglv=18;

break;

case 7 :

pinglv=21;

break;

default :

pinglv=0;

break;

}

delay1();

while(!s2);

}

while(!s2);

EX1=1;

}

void main()

{

csda=0;

wr=0;

EA=1;

IT0=1;

EX0=1;

IT1=1;

EX1=1;

while(1)

{

while(a)

{

 delay=pinglv;

P0=sin[k];

k++;

if(k==64)

k=0;

while(delay)            

    delay--;

}

while(b)

{

 delay=pinglv;

P0=juxing[k];

k++;

if(k==64)

k=0;

while(delay)           

    delay--;

}

while(c)

{

 delay=pinglv;

P0=juchi[k];

k++;

if(k==64)

k=0;

while(delay)            

    delay--;

}

while(d)

{

 delay=pinglv;

P0=tixing[k];

k++;

if(k==64)

k=0;

while(delay)            

    delay--;

}

while(e)

{

 delay=pinglv;

P0=sanjiao[k];

k++;

if(k==64)

k=0;

while(delay)            

    delay--;

}

}

}

 


Ⅸ FAQ

1. How does a signal generator work?

The signal generator generates the tone, waveforms in digital patterns, and arbitrary. Once the signal generates an unmodulated signal, then these are known for producing continuous wave signals. So it generates a square wave modulated signal, complex and triangular waves, etc.

 

2. What is an audio signal generator?

Signal generator, electronic test instrument that delivers an accurately calibrated signal at frequencies from the audio to the microwave ranges. It is valuable in the development and testing of electronic hardware.

 

3. What are the types of signal generators?

Types of signal generators:

• Waveform or function generators.

• Arbitrary function generator.

• Arbitrary waveform generator.

• RF signal generator.

• RF vector signal generator.

 

4. What is the difference between a signal generator and a function generator?

A signal generator can generate simple waveforms (usually just sine wave, although some may generate a square wave, triangle wave). ... A function generator has the capability to generate the above waveforms but also custom shapes, which in some cases can be created and loaded into the generator using the software.

 

5. What should I look for in a signal generator?

RF signal generator specifications fundamentally break down to an assessment of the quality of the output signal, this includes the range, resolution, and accuracy of the frequency and power outputted, as well as switching time, and spectral purity.

 

6. What is the difference between the signal generator and oscillator?

The term oscillator is generally used for an instrument that provides only a sinusoidal output signal. and the term generator is applied to an instrument that provides several output waveforms, including sine wave, square wave, triangular wave, and pulse trains as well as amplitude modulation of the output signal.

 

7. Can a signal generator change phase?

Signal generators are also often called signal sources or simply, sources. A signal generator allows you to output signals with various frequencies, amplitudes, and time durations. Many signal generators even allow you to modulate frequency, amplitude, and phase signals.

 

8. What is a standard signal generator?

A standard signal generator produces known and controllable voltages. It is used as a power source for the measurement of gain, signal to noise ratio (S/N), bandwidth, standing wave ratio and other properties. It is extensively used in the testing of radio receivers and transmitters.

 

9. Is signal generator AC or DC?

Signal generators produce alternating currents (and voltages) or AC and signal generators play the role of batteries for AC circuits. Oscilloscopes are basically voltmeters to measure alternating voltages.

 

10. Is Cro a signal generator?

The CRO is the vacuum tube and the main function of this device is to change the signal from electrical to visual. This tube includes the electron gun as well as the electrostatic deflection plates. The main function of this electron gun is used to generate a focused electronic ray that speeds up to high frequency.

 


 

Book Recommendation

  • Know your signal generators, (A Howard W. Sams photofact publication)

--Robert Gordon Middleton (Author)

  • How to use AF & RF signal generators Hardcover – 1977

--George deLucenay Leon  (Author)

 


Relevant information about "A Signal Generator Project Based on Single Chip Microcomputer 89C51"

About the article "A Signal Generator Project Based on Single Chip Microcomputer 89C51", If you have better ideas, don't hesitate to  write your thoughts in the following comment area. You also can find more articles about electronic semiconductor through Google search engine, or refer to the following related articles.

 

 

Best Sales of diode

Photo Part Company Description Pricing (USD)

Alternative Models

Part Compare Manufacturers Category Description

Ordering & Quality

Image Mfr. Part # Company Description Package PDF Qty Pricing (USD)

Related Articles

pinglun

Leave a Reply

Your email address will not be published.

 
 
   
 
code image
Rating: poor fair good very good excellent

# 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z