当前位置:网站首页>51 single chip microcomputer - ADC explanation (a/d conversion, d/a conversion)
51 single chip microcomputer - ADC explanation (a/d conversion, d/a conversion)
2022-07-02 05:55:00 【I don't know who】
51 MCU must learn series
51 Single chip learning —— Interrupt the system
51 Single chip learning —— Memory details ( Program memory 、 Intraslice RAM、 expand RAM、EEPROM)
51 Single chip learning —— Timer / Counter
51 Single chip microcomputer ——A/D transformation
to update ing
51 The single chip computer of ——A/D transformation
Preface
A/D The conversion module is a high-function module of MCU , Used for digital conversion of analog signals , This article takes STC8H8K64U For example, SCM ( Principle and others 51 There is no difference between single-chip computers ), The single chip microcomputer A/D The module is 16 passageway 12 position . This article mainly excerpts STC Ding Xiangrong 《 Single chip microcomputer principle and Interface Technology 》.
A/D Structure of conversion module
STC8H This single chip computer A/D The input channel of the conversion module has 16 individual ( More channels , At the same time, the more analog quantity can be received ), Respectively ADC0——ADC15, among ADC15 Used to test internal 1.19V Reference voltage , Working hours , Each input channel works in the high resistance state .
About digits :12 Bits are used for precision , The more digits , The higher the accuracy , With 5v Voltage as an example , When one , It can only be divided into two ,2.5v Above is 1,2.5v The following is a 0, When two , Can be divided into 4 Share , That is to say 1.25v,2.5v,3.75v,5v Demarcation , Improved accuracy , And so on .
The single chip microcomputer A/D The conversion module consists of Multiple selector switch 、 The comparator 、 Compare registers one by one 、12 Bit digital to analog converter (D/A Conversion module )、A/D Conversion result register 、A/D Conversion module control register and A/D Conversion module configuration register constitute .
A/D Classification of conversion modules
According to the principle of transformation : Successive approximation type 、 Double integral type 、 parallel / Serial comparison type 、 Voltage frequency conversion type, etc
Classification by conversion speed : Superhigh speed <=1ns、 High speed <=20us、 Medium speed <=1ms、 low speed <=1s.
Classification by converted digits :8、12、14、16.
At present, there are mainly Successive comparison converter ( Most commonly used ) and Double integral converter , So next, we will mainly talk about the successive comparison converter .
Successive comparison converter
The successive comparison type analog-to-digital converter is based on the logic of successive comparison , From the top (MSB) Start , The voltage of each input is simulated and internal D/A The converter outputs are compared , After many comparisons , Make the converted digital quantity approach the corresponding value of the input analog quantity , until A/D End of conversion .
The following figure is the schematic diagram of the successive comparison converter
A/D Reference voltage source of conversion module
The A/D The power supply of the conversion module is the same as that of the MCU , but A/D The module has an independent reference voltage source input .
When the measurement accuracy is not high , You can directly use the working voltage of the MCU , Use accurate reference voltage for high accuracy .
A/D Control of conversion module
A/D The conversion module mainly consists of ADC_CONTR、ADCCFG、ADC_RES、ADC_RESL and A/D Conversion module timing control register ADCTIM And control A/D Control and management of the interrupt related control registers of the conversion .
Because there are too many register flag bits , Here, only the more important individual registers are listed .
/**************** measurement AD value *************************/
uint Get_ADC12bitResult(uchar channel) //channel = 0~15
{
ADC_RES = 0; // Clear the conversion result register 0
ADC_RESL = 0;
ADC_CONTR = (ADC_CONTR & 0xe0) | 0x40 | channel; // start-up ADC
_nop_(); _nop_(); _nop_(); _nop_();// You need to wait for the circuit to stabilize at the beginning for the first time
while((ADC_CONTR & 0x20) == 0) ; // wait for ADC complete
ADC_CONTR &= ~0x20; // eliminate ADC End mark
return (((uint)ADC_RES << 8) | ADC_RESL );
}
The registers that appear in this code are ADC_CONTR,ADC_RES,ADC_RESL.
among ADC_RES and ADC_RESL Together as a storage result register ,RES It's high 8 position ,RESL It's low 8 position .
ADC_CONTER Everyone is shown in the figure below :
B7 yes A/D Power control bit of the module ,1 open ,0 close .
B6 yes A/D Switch start control bit ,1 Start the conversion , Automatically clear after conversion 0, by 0 It has no effect on ( When A/D After the conversion module starts , Even if you write 0 Can't stop )
B5 Is the completion flag bit , After conversion 1, Manual cleaning is required 0.
The main : start-up A/D Make sure that A/D The conversion module is powered on ,A/D Close after conversion A/D Converting module power can reduce energy consumption . Appropriate time delay is required when opening for the first time , Wait for the internal circuit to stabilize before starting A/D transformation .
A/D Conversion module conversion result selection
A/D After the conversion of the conversion module , The results are saved to ADC_RES and ADC_RESL in ( the reason being that 12 position , A register 8 position , So you need to put together two registers to store the result ), But there are two storage formats , from ADCFG Medium RESFMT control .
RESFMT=0 when , The result is left aligned , The empty space on the right is automatically 0.
RESFMT=1 when , Align results right , The left space is automatically 0.
边栏推荐
- [leetcode] day92 container with the most water
- Pytorch Chinese document
- Zzuli:1061 sequential output of digits
- 运动健身的一些心得经验
- 1036 Boys vs Girls
- Cube magique infini "simple"
- [Chongqing Guangdong education] selected reading reference materials of British and American literature of Nanyang Normal University
- Gcnet: non - local Networks meet Squeeze excitation Networks and Beyond
- Zzuli:1067 faulty odometer
- Reading notes of cgnf: conditional graph neural fields
猜你喜欢
深度学习分类网络 -- AlexNet
3D printer G code command: complete list and tutorial
vite如何兼容低版本浏览器
Lantern Festival gift - plant vs zombie game (realized by Matlab)
《CGNF: CONDITIONAL GRAPH NEURAL FIELDS》阅读笔记
5g market trend in 2020
文件包含漏洞(二)
keepalived安装使用与快速入门
VSCode paste image插件保存图片路径设置
Huawei Hongmeng OS, is it OK?
随机推荐
VSCode paste image插件保存图片路径设置
Stick to the big screen UI, finereport development diary
1036 Boys vs Girls
OLED12864 液晶屏
memcached安装
servlet的web.xml配置详解(3.0)
深度学习分类网络 -- AlexNet
Common protocols and download paths of NR
Typora installation (no need to enter serial number)
Happy Lantern Festival | Qiming cloud invites you to guess lantern riddles
Redis key value database [seckill]
页面打印插件print.js
keepalived安装使用与快速入门
php获取cpu使用率、硬盘使用、内存使用
495.提莫攻击
js判断移动端还是pc端
使用sha256文件验证下载的文件
“简单”的无限魔方
Matplotlib double Y axis + adjust legend position
PHP obtains some values in the string according to the specified characters, and reorganizes the remaining strings into a new array