基于单片机的波形发生器
2021-07-27张弛黄昊翀李子萱高华董爱国
张弛 黄昊翀 李子萱 高华 董爱国



摘 要:波形发生器是电子电路中常用的实验器材,目前市面上的波形发生器存在价格昂贵的问题,本文基于AT89C51单片机开发了一种低成本波形发生器,用简便的算法通过定时器实现了对波频率的控制。通过中断实现频率的任意调节,使用DAC0832集成芯片进行数模转换,最后可以实现三角波、正弦波、方波和锯齿波的发生。能手动切换波形,任意调节频率,幅度可连续调节,输出波形清晰稳定,波形延迟低,方法精简,成本低廉,具有很好的实际应用价值。
关键词:单片机 波形发生器 定时器 频率调制
中图分类号:TM935 文献标识码:A 文章编号:1674-098X(2021)02(a)-0043-06
Waveform Generator Based on MCU
ZHANG Chi HUANG Haochong LI Zixuan GAO Hua DONG Aiguo
(China University of Geosciences, Beijing, 100083 China)
Abstract: Waveform generator is an electronic circuit which is commonly used in the experimental equipment. The current waveform generator on the market is expensive. In this paper, a low-cost waveform generator is developed based on the AT89C51 MCU. A simple algorithm works with the timer to achieve control of the wave frequency. By interrupting frequency adjusted and the use of analog-to-digital conversion DAC0832 integrated chips can finally realize the triangle wave, sine wave, square wave, and sawtooth wave. It can manually switch waveforms at the same time, adjusted the frequency, amplitude of continuous adjustment, the output waveform is stable, clear waveform low latency. The method has good practical application value with compact and low cost.
Key Words: MCU; Waveform generator; Timer; Frequency modulation
波形發生器在电子电路、自动控制系统中许多实验中有着不可或缺的作用,可以为电子测量提供所需求的电信号,同时也普遍应用于电学类专业课教学、测控、通讯等领域[1]。采用专用硬件方法产生的信号虽然分辨率高, 稳定性好, 调整方便, 但价格昂贵[2]。本实验基于AT89C51单片机设计了一种简易波形发生器,结构精简,算法易懂,可满足一般的信号发生且能够调节所需频率。相比于高精度的波形发生器更易实现,能够满足普通实验的测量需要。可作为电子电路和电子设备的激励信号,提供电路所需的波形[3]。
1 设计原理
本实验中的低成本波形发生器主要由时钟模块、按键扫描模块、定时器模块、数模转换模块和显示模块组成。单片机的内部振荡电路产生时钟信号,按键扫描模块负责执行来自键盘的选择,让波形发生器完成使用者的命令。……
