当前位置:网站首页>(17) DAC conversion experiment
(17) DAC conversion experiment
2022-07-01 17:10:00 【I love notes】
In the last section, we wrote about ADC Related content of , In this section, we will write about DAC Related content of ,DAC That is to convert digital signals into analog signals . Its function and ADC contrary , In this section, we convert the output digital signal into analog signal led The light turns on gradually and then turns dark to realize the corresponding function .
About DAC
We know ADC In fact, there are several important features , and DAC There are also several particularly important features .1 Also resolution , and ADC They have exactly the same characteristics .2 Is linearity , Linearity means the maximum deviation between the actual conversion characteristic curve and the ideal straight line characteristic . It is usually expressed as a percentage of full scale .3 It is absolute precision and relative precision , Absolute accuracy refers to the whole scale range , The maximum error between the actual output value of analog quantity corresponding to any input data and the theoretical value . Relative precision and absolute precision have the same meaning , The absolute accuracy is due to DAC Gain error ( When the input code is all 1 when 、 The difference between the actual output value and the ideal output value )、 Zero error ( Digital input is all 0 when .DAC Output value )、 Caused by nonlinear error and noise .4 Is the establishment time , Setup time refers to the time when the input digital quantity changes to full scale , When the output analog signal reaches the full scale value 1/2 Time of scale value , We can set up time to DAC classification , Super high speed , High speed , Medium speed , Low speed, etc .
About DAC
In the actual research and development process, for the sake of cost , We don't usually use DAC, We can use PWM To simulate the DAC Output , Then you need to connect PWM Of · Related content .PWM Chinese means pulse width modulation , Short for pulse width modulation . We can look at the picture directly, which should be easier to understand .

In fact, we can adjust the pulse width to indicate the size of our voltage , This is actually PWM True meaning , And about the PWM The important meaning of the square wave is that our square wave occupies a period , The larger the duty cycle , The higher the voltage , We can go through PWM To simulate analog quantity .
About hardware :

It's about PWM Hardware circuit of the circuit , For our software, there is basically no need to understand , We just need to know R21 As our input
About software :
We use PWM Output , Finish let led The process of light first on, then off and then on .
#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++;
}边栏推荐
- 美国国家安全局(NSA)“酸狐狸”漏洞攻击武器平台技术分析报告
- China nylon 11 industry research and future forecast report (2022 Edition)
- Hi Fun Summer, play SQL planner with starrocks!
- 【C补充】【字符串】按日期排序显示一个月的日程
- DNS
- 中国茂金属聚乙烯(mPE)行业研究报告(2022版)
- 中国一次性卫生用品生产设备行业深度调研报告(2022版)
- 开发那些事儿:EasyCVR集群设备管理页面功能展示优化
- Gold, silver and four want to change jobs, so we should seize the time to make up
- In aks, use secret in CSI driver mount key vault
猜你喜欢
随机推荐
Sword finger offer 20 String representing numeric value
美国国家安全局(NSA)“酸狐狸”漏洞攻击武器平台技术分析报告
Vulnhub range hacker_ Kid-v1.0.1
Redis 分布式鎖
Soft test software designer full truth simulation question (including answer analysis)
China benzene hydrogenation Market Research and investment forecast report (2022 Edition)
String的trim()和substring()详解
[C language supplement] judge which day tomorrow is (tomorrow's date)
多线程使用不当导致的 OOM
ShenYu 网关开发:在本地启用运行
走进微信小程序
How wild are hackers' ways of making money? CTF reverse entry Guide
【splishsplash】关于如何在GUI和json上接收/显示用户参数、MVC模式和GenParam
Is the securities account given by the head teacher of goucai school safe? Can I open an account?
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
libcurl下载文件的代码示例
整形数组合并【JS】
Hi Fun Summer, play SQL planner with starrocks!
DNS
剑指 Offer 20. 表示数值的字符串








