当前位置:网站首页>MCU function signal generator, output four kinds of waveforms, adjustable frequency, schematic diagram, simulation and C program
MCU function signal generator, output four kinds of waveforms, adjustable frequency, schematic diagram, simulation and C program
2022-04-23 14:25:00 【Jiang Yuzhi】
The design requirements
-
With MCS-51 Series single chip microcomputer is the control device , use C Language for program development , Combined with peripheral electronic circuits , Design a function signal generator system ;
-
Can produce a sine wave 、 square wave 、 Triangular wave and sawtooth wave 4 Kinds of waveform ;
-
Extended keyboard input circuit , Used to switch the waveform type 、 Set the frequency size and step value ;
-
LCD1602 The display circuit displays the current waveform type in real time 、 Frequency value and other information ;
-
Adjustment range of waveform frequency value :10~100Hz;
-
Frequency step value adjustment range :0.1~10Hz;
System Overview
This article is based on 51 Function signal generator system designed by single chip microcomputer , Can produce a sine wave 、 square wave 、 Triangular wave and sawtooth wave 4 Kinds of waveform , And the waveform frequency is adjustable , The adjustment range is 10~100Hz.
System consists of 5V Power supply module 、AT89C51 Minimum system of single chip microcomputer 、DAC0832 A / D conversion circuit 、LM358 Amplification circuit 、LCD1602 LCD circuit 、 Key circuit and LED The indicator circuit consists of .
The system framework is as follows :

Working principle is : Digital signal generated by single chip microcomputer , the DAC0832 Convert to analog signal , Re pass LM358 After the operation circuit is amplified , Output 4 A waveform with adjustable frequency .
The type and frequency value of the waveform are determined by LCD Liquid crystal display (LCD) , The switching of waveform and the adjustment of frequency are controlled by keys . meanwhile ,4 A different color LED As indicator lights of different waveforms .
Simulation circuit diagram


Schematic diagram

Analysis of simulation results
Open the function signal generator simulation file , Double click the MCU to load Signal.hex file ( be located C In the program folder ), Run the simulation , give the result as follows .
LCD1602 The first line of LCD shows Wave:Sine, The second line shows Freq:10.0Hz. Indicates that the current initialization waveform is 10Hz The sine wave of , At the same time, the green corresponding to the sine wave LED The light is on .
Besides , The system will pop up the oscilloscope window automatically , Display the waveform . In this system , The signal output terminal is connected to the... Of the oscilloscope A passageway .


Simulation runtime , If the oscilloscope window is accidentally closed or does not pop up , Right click the oscilloscope , Click... In the drop-down menu Digtal Oscilloscope Can be restored .
In the system , Four keys are used to control the switching of waveform types 、 Increase or decrease of frequency value and increase or decrease of frequency step value .
Click on “ Switch ” key , Sine wave can be realized 、 square wave 、 Triangular wave and sawtooth wave 4 Switching back and forth between waveforms ;
In waveform frequency display mode ,“ increase ” and “ Reduce ” Key is used to increase or decrease the frequency of the current waveform , The default frequency step value of the system is 0.1, Press once “ increase ” or “ Reduce ” key , The change of frequency is 0.1Hz.
for example , We switch the waveform to square wave , Set its frequency to 14.5Hz, give the result as follows . here , Red corresponding to square wave LED The light is on .


When pressed “ Stepping ” Post key , The system enters the step adjustment mode , As shown in the figure below .LCD Show Step value:0.1, Indicates that the current step value is 0.1Hz. here ,“ increase ” and “ Reduce ” key , Used to change the size of the step value .

for example , We set the frequency step value to 3Hz, The results are shown below . After setting , Press again “ Stepping ” key , The system exits the step adjustment mode , Return to frequency display mode . At this time , Press down “ increase ” or “ Reduce ” key , The change amplitude of the frequency value is 3Hz.
below , We set the system output frequency to 50Hz Triangular wave sum 80Hz The square wave , give the result as follows .




in summary , The operation effect of the function signal generator simulation circuit meets the design requirements , Verify success .
part C Code
void keyscan() // Key scan function
{
if(s1==0) // Whether the frequency plus key is pressed
{
EA=0; // Turn off interrupt
delay(2); // Delay chattering
if(s1==0) // Judge again
{
while(!s1); // Release the button
pinlv+=bujin; // The frequency increases in steps
if(pinlv>1000) // The frequency value is maximum 100Hz
{
pinlv=100;
}
display();
/* The minimum frequency value is 10Hz,pinlv The value of is 100( Because you want to display one decimal place ),150000/100=1500, This 1500 That's what the timer needs to count , The unit is us,65536-1500 What you get is the initial value of the timer , Regardless of the initial value , Look at the timing first ,1500us, The period of a waveform is determined by 64 Composed of two timing , therefore , A waveform period is 64*1500us=96000, That is to say 96ms, Appointment etc On 100ms, That is to say 10Hz The frequency of */
m=65536-(150000/pinlv); // Calculate the frequency
a=m/256; // Assign the initial value of the timer to the variable
b=m%256;
EA=1; // Turn on the interrupt master switch
}
}
if(s2==0) // Whether the frequency reduction key is pressed
{
delay(5);
if(s2==0)
{
EA=0;
while(!s2);
pinlv-=bujin;
if(pinlv<100)
{
pinlv=1000;
}
display();
m=65536-(150000/pinlv);
a=m/256;
b=m%256;
EA=1;
}
}
if(s3==0) // Whether the waveform switching key is pressed
{
delay(5);
if(s3==0)
{
EA=0;
while(!s3);
boxing++;
if(boxing>=4)
{
boxing=0;
}
display();
EA=1;
}
}
}
Resource content
(1) be based on 51 MCU function signal generator design paper complete version ;
(2)Keil C Program ;
(3)Proteus Simulation ;
(4) Schematic file ;
(5)Visio Flow chart file ;
(6) List of components ;
(7) Reference material ;
Resource screenshot






Say the important thing again !!!
Because the design of function signal generator is my original design , Get a full set of information ,
WeChat search for my official account : Jiaoyuan Xiaozhi
版权声明
本文为[Jiang Yuzhi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231412471782.html
边栏推荐
- Tongxin UOS php7 2.3 upgrade to php7.0 two point two four
- Wechat applet rotation map swiper
- 矩阵交换行列
- Pass in external parameters to the main function in clion
- 翻牌效果
- 字节面试编程题:最小的K个数
- 1分钟看懂执行流程,永久掌握for循环(附for循环案例)
- Five ways of using synchronized to remove clouds and fog are introduced
- A table splitting implementation scheme of MySQL and InnoDB, MyISAM and MRG_ Introduction to MyISAM and other engine application scenarios
- 关于在vs中使用scanf不安全的问题
猜你喜欢

51单片机+LCD12864液晶显示的俄罗斯方块游戏,Proteus仿真、AD原理图、代码、论文等

Uni app message push

金九银十,入职字节跳动那一天,我哭了(蘑菇街被裁,奋战7个月拿下offer)

顺序栈的基本操作

Qt界面优化:Qt去边框与窗体圆角化

Multisim Simulation Design of DC adjustable regulated power supply of LM317 (with simulation + paper + reference)

字节面试编程题:最小的K个数

进入新公司,运维工程师从下面这几项了解系统的部署

单片机的函数信号发生器,输出4种波形,频率可调,原理图,仿真和C程序

如何5分钟上手使用OCR
随机推荐
Usage of BC
直流可调稳压电源的Proteus仿真设计(附仿真+论文等资料)
51 Single Chip Microcomputer Design of traffic light system (with Proteus simulation, C program, schematic diagram, PCB, thesis and other complete data)
Redis cluster 原理
LLVM - 生成局部变量
DS1302的电子万年历_51单片机,年月日、星期、时分秒、农历和温度,带闹钟,全套资料
ssh限制登录的四种手段
JS progress bar, displaying the loading progress
Pass in external parameters to the main function in clion
Five ways of using synchronized to remove clouds and fog are introduced
TUN 设备原理
处理 mkdir:无法创建目录“aaa“:只读文件系统
js 抛物线运动方法封装
xx项目架构随记
async void 导致程序崩溃
gif转为静态图片处理
API gateway / API gateway (IV) - use of Kong - Integrated JWT and fuse plug-in
51单片机的花卉、农田自动浇水灌溉系统开发,Proteus仿真,原理图和C代码
Tongxin UOS php7 2.3 upgrade to php7.0 two point two four
TLS/SSL 协议详解 (28) TLS 1.0、TLS 1.1、TLS 1.2之间的区别