当前位置:网站首页>(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++;
}
边栏推荐
- Soft test software designer full truth simulation question (including answer analysis)
- Redis6.0 新功能
- Concatenate strings to get the result with the smallest dictionary order
- 中国氮化硅陶瓷基板行业研究与投资前景报告(2022版)
- P2592 [zjoi2008] birthday party (DP)
- 【Try to Hack】vulnhub DC4
- What is the effect of choosing game shield safely in the game industry?
- Alibaba cloud, Zhuoyi technology beach grabbing dialogue AI
- P2893 [usaco08feb] making the grade g (DP & priority queue)
- sql刷题1050. 合作过至少三次的演员和导演
猜你喜欢
Alibaba cloud, Zhuoyi technology beach grabbing dialogue AI
走进微信小程序
Template engine velocity Foundation
How to use etcd to realize distributed /etc directory
C語言輸入/輸出流和文件操作
SQL question brushing 627 Change gender
Yyds dry inventory MySQL RC transaction isolation level implementation
【PyG】文档总结以及项目经验(持续更新
GameFramework食用指南
Oom caused by improper use of multithreading
随机推荐
Gold, silver and four want to change jobs, so we should seize the time to make up
【C语言补充】判断明天是哪一天(明天的日期)
Research and investment strategy report of China's sodium sulfate industry (2022 Edition)
智能运维实战:银行业务流程及单笔交易追踪
Encryption and decryption of tinyurl in leetcode
In depth Research Report on China's disposable sanitary products production equipment industry (2022 Edition)
SystemVerilog-结构体(二)
中国生物降解塑料市场预测与投资战略报告(2022版)
Soft test network engineer full truth simulation question (including answer and analysis)
String的trim()和substring()详解
Babbitt | yuan universe daily must read: Naixue coin, Yuan universe paradise, virtual stock game Do you understand Naixue's tea's marketing campaign of "operation pull full"
China benzene hydrogenation Market Research and investment forecast report (2022 Edition)
Sword finger offer II 015 All modifiers in the string
(12) About time-consuming printing
Iommu/smmuv3 code analysis (10) page table operation
SQL question brushing 584 Looking for user references
P2592 [zjoi2008] birthday party (DP)
中国PBAT树脂市场预测及战略研究报告(2022版)
Computed property “xxx“ was assigned to but it has no setter.
多线程并发之CountDownLatch阻塞等待