当前位置:网站首页>(十七)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++;
}边栏推荐
- In aks, use secret in CSI driver mount key vault
- redis -- 数据类型及操作
- 巴比特 | 元宇宙每日必读:奈雪币、元宇宙乐园、虚拟股票游戏...奈雪的茶这波“操作拉满”的营销活动你看懂了吗?...
- 阿里云、追一科技抢滩对话式AI
- Official announcement! Hong Kong University of science and Technology (Guangzhou) approved!
- sql刷题586. 订单最多的客户
- [C language supplement] judge which day tomorrow is (tomorrow's date)
- What are the differences between PHP and DW
- China BMS battery management system Market Research Report (2022 Edition)
- Is the securities account given by the head teacher of goucai school safe? Can I open an account?
猜你喜欢

【Try to Hack】vulnhub DC4

sql刷题627. 变更性别

【flask入门系列】Cookie与Session

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

为什么你要考虑使用Prisma

【PyG】文档总结以及项目经验(持续更新

Pytest learning notes (13) -allure of allure Description () and @allure title()

String类

SQL question brushing 1050 Actors and directors who have worked together at least three times

Jojogan practice
随机推荐
软件工程导论——第六章——详细设计
How to use etcd to realize distributed /etc directory
【C语言基础】12 字符串
String类
[C language foundation] 12 strings
ACL 2022 | 分解的元学习小样本命名实体识别
Yyds dry inventory MySQL RC transaction isolation level implementation
智能运维实战:银行业务流程及单笔交易追踪
阿里云、追一科技抢滩对话式AI
In aks, use secret in CSI driver mount key vault
There is a new breakthrough in quantum field: the duration of quantum state can exceed 5 seconds
Detailed explanation of activity life cycle and startup mode
Activity的生命周期和启动模式详解
Shenyu gateway development: enable and run locally
Mysql database - Advanced SQL statement (2)
Redis distributed lock
Is the securities account given by the head teacher of goucai school safe? Can I open an account?
Redis Distributed Lock
【splishsplash】关于如何在GUI和json上接收/显示用户参数、MVC模式和GenParam
Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022