当前位置:网站首页>(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++;
}边栏推荐
- Object. fromEntries()
- pyqt5中,在控件上画柱状图
- (1) CNN network structure
- [C language foundation] 12 strings
- 多线程使用不当导致的 OOM
- 中国生物降解塑料市场预测与投资战略报告(2022版)
- Encryption and decryption of tinyurl in leetcode
- vulnhub靶场-hacksudo - Thor
- Introduction to software engineering - Chapter 6 - detailed design
- 【splishsplash】关于如何在GUI和json上接收/显示用户参数、MVC模式和GenParam
猜你喜欢

Transition technology from IPv4 to IPv6

SQL question brushing 627 Change gender

Alibaba cloud, Zhuoyi technology beach grabbing dialogue AI

Detailed explanation of activity life cycle and startup mode

LeetCode中等题之TinyURL 的加密与解密

(十七)DAC转换实验

Iommu/smmuv3 code analysis (10) page table operation

Detailed explanation of string's trim() and substring()

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

在MeterSphere接口测试中如何使用JMeter函数和MockJS函数
随机推荐
In depth Research Report on China's disposable sanitary products production equipment industry (2022 Edition)
Transition technology from IPv4 to IPv6
Judge whether a binary tree is a balanced binary tree
Judge whether the binary tree is a binary search tree
Report on Market Research and investment prospects of ammonium dihydrogen phosphate industry in China (2022 Edition)
Research and investment strategy report of neutral protease industry in China (2022 Edition)
China benzene hydrogenation Market Research and investment forecast report (2022 Edition)
AI高考志愿填报:大厂神仙打架,考生付费围观
[C language foundation] 12 strings
剑指 Offer 20. 表示数值的字符串
Today, at 14:00, 15 ICLR speakers from Hong Kong University, Beihang, Yale, Tsinghua University, Canada, etc. continue!
Vulnhub range hacker_ Kid-v1.0.1
Object. fromEntries()
可迭代对象与迭代器、生成器的区别与联系
中国PBAT树脂市场预测及战略研究报告(2022版)
Jojogan practice
PETRv2:一个多摄像头图像3D感知的统一框架
如何写出好代码 — 防御式编程指南
多线程使用不当导致的 OOM
SystemVerilog-结构体(二)