当前位置:网站首页>(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++;
}边栏推荐
- 智能运维实战:银行业务流程及单笔交易追踪
- 中国PBAT树脂市场预测及战略研究报告(2022版)
- Is the securities account given by the head teacher of goucai school safe? Can I open an account?
- Detailed explanation of activity life cycle and startup mode
- 越来越多地使用 SLO 来实现可观测性|DevOps
- (27) Open operation, close operation, morphological gradient, top hat, black hat
- 剑指 Offer II 105. 岛屿的最大面积
- Transition technology from IPv4 to IPv6
- Leetcode records - sort -215, 347, 451, 75
- [C language foundation] 12 strings
猜你喜欢

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

可迭代对象与迭代器、生成器的区别与联系

换掉UUID,NanoID更快更安全!

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

想做软件测试的女孩子看这里

GameFramework食用指南

Redis6.0 新功能

智能运维实战:银行业务流程及单笔交易追踪

(28) Shape matching based on contour features

Official announcement! Hong Kong University of science and Technology (Guangzhou) approved!
随机推荐
Integer array merge [JS]
FRP intranet penetration, reverse proxy
National Security Agency (NSA) "sour Fox" vulnerability attack weapon platform technical analysis report
China sorbitol Market Forecast and investment strategy report (2022 Edition)
How to use etcd to realize distributed /etc directory
libcurl下载文件的代码示例
mysql -- explain性能优化
Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022
麦趣尔:媒体报道所涉两批次产品已下架封存,受理消费者诉求
想做软件测试的女孩子看这里
Determine whether the linked list is a palindrome linked list
SQL question brushing 584 Looking for user references
SystemVerilog structure (II)
Research Report on China's enzyme Market Forecast and investment strategy (2022 Edition)
The amazing open source animation library is not only awesome, but also small
智能运维实战:银行业务流程及单笔交易追踪
中国冰淇淋市场深度评估及发展趋势预测报告(2022版)
【C语言补充】判断明天是哪一天(明天的日期)
Concatenate strings to get the result with the smallest dictionary order
Iommu/smmuv3 code analysis (10) page table operation