当前位置:网站首页>(十七)DAC转换实验
(十七)DAC转换实验
2022-07-01 16:51:00 【我爱笔记】
上一节我们写了关于ADC的相关内容,这一节我们就要写有关于DAC的相关内容,DAC即是将数字信号转换为模拟信号。它的功能与ADC相反,我们这节通过输出数字信号转换为模拟信号实现led灯先逐渐变亮再逐渐变暗来实现相应的功能。
关于DAC
我们知道了ADC其实有几个比较重要的特性,而DAC也有几个特别重要的特性。1也是分辨率,和ADC的特性完全相同。2是线性度,线性度的意思就是说实际转换特性曲线与理想直线特性之间的最大偏差。常用相对于满量程的百分数表示。3是绝对精度和相对精度,绝对精度是指在整个刻度范围内,任一输入数据对应的模拟量实际输出值与理论值之间的最大误差.相对精度与绝对精度是同一个含义,而绝对精度是由于DAC的增益误差(当输入代码为全1时、实际输出值与理想输出值之差)、零点误差(数码输入为全0时。DAC的输出值)、非线性误差和噪声引起的。4是建立时间,建立时间是指输入的数字量发生满刻度变化时,输出模拟信号达到满刻度值的1/2刻度值的时间,我们可以通过建立时间把DAC分类,有超高速,高速,中速,低速等。
关于DAC
在实际的研发过程中为了成本考虑,我们一般不会使用DAC,我们可以使用PWM来模拟DAC输出,那就需要先连接PWM的·相关内容。PWM中文意思是脉冲宽度调制,简称脉宽调制。我们可以直接看图应该就比较好理解了。

其实就是说我们可以通过调节脉冲的宽度来表示我们的电压的大小,这其实就是PWM的真实含义,而关于PWM的重要含义就是说我们这个方波占一个周期的大小,占空比越大,电压越大,我们就可以通过PWM来模拟模拟量。
关于硬件:

其中关于PWM电路的硬件电路,对于我们软件来说基本可以不用理解,我们只需要知道R21是作为我们的输入
关于软件:
我们使用PWM输出,完成让led灯先亮后灭再亮的过程。
#include "reg52.h"
int DIR;
int val = 0;
int count = 0;
int timer1 = 0;
sbit pwm = P2^1;
void t0_init(){
TMOD |= 0x01;
TL0 = 0xff;
TH0 = 0xff;
EA = 1;
ET0 = 1;
TR0 = 1;
}
void main(){
t0_init();
while(1){
if(count >= 100){
count = 0;
if(DIR == 1){
val++;
}
if(DIR == 0){
val--;
}
}
if(val >= 1000){
DIR = 0;
}
if(val <= 0){
DIR = 1;
}
if(timer1 >= 1000){
timer1 = 0;
}
if(timer1 < val){
pwm = 1;
}
else{
pwm = 0;
}
}
}
void t0_timer() interrupt 1{
TH0 = 0xff;
TL0 = 0xff;
timer1++;
count++;
}边栏推荐
- Activity的生命周期和启动模式详解
- 阿里云李飞飞:中国云数据库在很多主流技术创新上已经领先国外
- [Supplément linguistique c] déterminer quel jour est demain (date de demain)
- [live broadcast appointment] database obcp certification comprehensive upgrade open class
- 想做软件测试的女孩子看这里
- 【PyG】文档总结以及项目经验(持续更新
- 智能运维实战:银行业务流程及单笔交易追踪
- Report on Market Research and investment prospects of ammonium dihydrogen phosphate industry in China (2022 Edition)
- Sword finger offer II 015 All modifiers in the string
- PETRv2:一个多摄像头图像3D感知的统一框架
猜你喜欢
![Integer array merge [JS]](/img/0d/70535e0eb1c299bda25159b58c70d7.png)
Integer array merge [JS]

存在安全隐患 起亚召回部分K3新能源

整形数组合并【JS】
![[mathematical modeling] [matlab] implementation of two-dimensional rectangular packing code](/img/de/1f572c62a0d034da9a8acb5c2f9602.jpg)
[mathematical modeling] [matlab] implementation of two-dimensional rectangular packing code

ShenYu 网关开发:在本地启用运行

SystemVerilog-结构体(二)

官宣!香港科技大学(广州)获批!

如何使用 etcd 实现分布式 /etc 目录

Shenyu gateway development: enable and run locally

Machine learning 11 clustering, outlier discrimination
随机推荐
Please, stop painting star! This has nothing to do with patriotism!
[C language supplement] judge which day tomorrow is (tomorrow's date)
Official announcement! Hong Kong University of science and Technology (Guangzhou) approved!
Vulnhub range hacker_ Kid-v1.0.1
Sword finger offer II 015 All modifiers in the string
There is a new breakthrough in quantum field: the duration of quantum state can exceed 5 seconds
[C language foundation] 12 strings
在MeterSphere接口测试中如何使用JMeter函数和MockJS函数
换掉UUID,NanoID更快更安全!
Girls who want to do software testing look here
Redis6.0 新功能
SystemVerilog structure (II)
求求你们,别再刷 Star 了!这跟“爱国”没关系!
Shenyu gateway development: enable and run locally
美国国家安全局(NSA)“酸狐狸”漏洞攻击武器平台技术分析报告
Mysql database - Advanced SQL statement (2)
Redis distributed lock
Soft test network engineer full truth simulation question (including answer and analysis)
【PyG】文档总结以及项目经验(持续更新
China benzene hydrogenation Market Research and investment forecast report (2022 Edition)