当前位置:网站首页>(十七)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++;
}边栏推荐
- ACL 2022 | 分解的元学习小样本命名实体识别
- 中国氮化硅陶瓷基板行业研究与投资前景报告(2022版)
- redis -- 数据类型及操作
- 【splishsplash】关于如何在GUI和json上接收/显示用户参数、MVC模式和GenParam
- 免费抽奖 | 《阿巴豆》探索未来系列盲盒数字版权作品全网首发!
- Pytest learning notes (13) -allure of allure Description () and @allure title()
- Hi Fun Summer, play SQL planner with starrocks!
- Oom caused by improper use of multithreading
- The difference between the lazy mode of singleton mode and the evil mode
- Are you still using charged document management tools? I have a better choice! Completely free
猜你喜欢

走进微信小程序

SQL注入漏洞(Mysql与MSSQL特性)

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

Template Engine Velocity Foundation

PETRv2:一个多摄像头图像3D感知的统一框架

C语言输入/输出流和文件操作

Redis Distributed Lock

6月刊 | AntDB数据库参与编写《数据库发展研究报告》 亮相信创产业榜单

Transition technology from IPv4 to IPv6

Soft test network engineer full truth simulation question (including answer and analysis)
随机推荐
String类
【Kotlin】高阶函数介绍
Basic usage of Frida
LeetCode中等题之TinyURL 的加密与解密
Encryption and decryption of tinyurl in leetcode
GameFramework食用指南
6月刊 | AntDB数据库参与编写《数据库发展研究报告》 亮相信创产业榜单
拼接字符串,得到字典序最小的结果
ShenYu 网关开发:在本地启用运行
【Try to Hack】vulnhub DC4
P2592 [zjoi2008] birthday party (DP)
[kotlin] Introduction to higher-order functions
Integer array merge [JS]
SystemVerilog structure (II)
Internet News: "20220222" get together to get licenses; Many products of Jimi have been affirmed by consumers; Starbucks was fined for using expired ingredients in two stores
Soft test network engineer full truth simulation question (including answer and analysis)
[pyg] document summary and project experience (continuously updated
The amazing open source animation library is not only awesome, but also small
Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022
Research and investment strategy report of neutral protease industry in China (2022 Edition)