一、ADC,模拟数字转换器
1、定义
ADC(Analog to Digital Converter) :模数变换器;简称“模数转换器”,把模拟量转换为数字量的装置。
在计算机控制系统中,须经各种检测装置,以连续变化的电压或电流作为模拟量,随时提供被控制对象的有关参数(如速度、压力、温度等)而进行控制。计算机的输入必须是数字量,故需用模数转换器达到控制目的,过程有抽样、量化、编码(PCM编码,脉冲编码调制)。
其次简单介绍一下PCM编码:
(1)抽样:就是对模拟信号进行周期性扫描,把时间上连续的信号变成时间上离散的信号。该模拟信号经过抽样后述应当包含原信号中所有信息,也就是说能无失真的恢复原模拟信号。
(2)量化:就是把经过抽样得到的瞬时值将其幅度离散,即用一组规定的电平,把瞬时抽样值用最接近的电平值来表示,通常是用二进制表示。
(3)编码:就是用一组二进制码组来表示每一个有固定电平的量化值。然而,实际上量化是在编码过程中同时完成的,故编码过程也称为模/数变换,可记作A/D。
2、模拟信号
模拟信号是指用连续变化的物理量表示的信息,其信号的幅度,或频率,或相位随时间作连续变化,如目前广播的声音信号,或图像信号等。抓重点,连续的,如正弦波。
3、数字信号
数字信号指幅度的取值是离散的,幅值表示被限制在有限个数值之内。
二进制码就是一种数字信号。二进制码受噪声的影响小,易于有数字电路进行处理,所以得到了广泛的应用。抓重点,离散的,但在示波器中的方波一般指的是数字信号,把竖线去掉就是离散的了。
4、常用库函数
a.根据ADC_CommonInitTypeDef结构体,初始化ADC外设指定的参数(容易被忽略)
typedef struct
{
uint32_t ADC_Mode; /*!< Configures the ADC to operate in
independent or multi mode.
This parameter can be a value of @ref ADC_Common_mode */
uint32_t ADC_Prescaler; /*!< Select the frequency of the clock
to the ADC. The clock is common for all the ADCs.
This parameter can be a value of @ref ADC_Prescaler */
uint32_t ADC_DMAAccessMode; /*!< Configures the Direct memory access
mode for multi ADC mode.
This parameter can be a value of
@ref ADC_Direct_memory_access_mode_for_multi_mode */
uint32_t ADC_TwoSamplingDelay; /*!< Configures the Delay between 2 sampling phases.
This parameter can be a value of
@ref ADC_delay_between_2_sampling_phases */
}ADC_CommonInitTypeDef;
@param ADC_CommonInitStruct: pointer to an ADC_CommonInitTypeDef structure that contains the configuration information for All ADCs peripherals.
void ADC_CommonInit(ADC_CommonInitTypeDef* ADC_CommonInitStruct)
1
b.根据ADC_InitTypeDef结构体,初始化ADC外设指定的参数
typedef struct
{
uint32_t ADC_Resolution; /*!< Configures the ADC resolution dual mode.
This parameter can be a value of @ref ADC_resolution */
FunctionalState ADC_ScanConvMode; /*!< Specifies whether the conversion
is performed in Scan (multichannels)
or Single (one channel) mode.
This parameter can be set to ENABLE or DISABLE */
FunctionalState ADC_ContinuousConvMode; /*!< Specifies whether the conversion
is performed in Continuous or Single mode.
This parameter can be set to ENABLE or DISABLE. */
uint32_t ADC_ExternalTrigConvEdge; /*!< Select the external trigger edge and
enable the trigger of a regular group.
This parameter can be a value of
@ref ADC_external_trigger_edge_for_regular_channels_conversion */
uint32_t ADC_ExternalTrigConv; /*!< Select the external event used to trigger
the start of conversion of a regular group.
This parameter can be a value of
@ref ADC_extrenal_trigger_sources_for_regular_channels_conversion */
uint32_t ADC_DataAlign; /*!< Specifies whether the ADC data alignment
is left or right. This parameter can be
a value of @ref ADC_data_align */
uint8_t ADC_NbrOfConversion; /*!< Specifies the number of ADC conversions
that will be done using the sequencer for
regular channel group.
This parameter must range from 1 to 16. */
}ADC_InitTypeDef;
@brief Initializes the ADCx peripheral according to the specified parameters in the ADC_InitStruct.
@note This function is used to configure the global features of the ADC ( Resolution and Data Alignment), however, the rest of the configuration
parameters are specific to the regular channels group (scan mode activation, continuous mode activation, External trigger source and edge, number of conversion in the regular channels group sequencer).
@param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
@param ADC_InitStruct: pointer to an ADC_InitTypeDef structure that contains the configuration information for the specified ADC peripheral.
void ADC_Init(ADC_TypeDef* ADCx, ADC_InitTypeDef* ADC_InitStruct)
c.为选定的ADC常规通道进行配置
@brief Configures for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
@param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
@param ADC_Channel: the ADC channel to configure.
This parameter can be one of the following values:
@arg ADC_Channel_0~~~~~~arg ADC_Channel_18
@param Rank: The rank in the regular group sequencer.
This parameter must be between 1 to 16.
@param ADC_SampleTime: The sample time value to be set for the selected channel.
This parameter can be one of the following values:
@arg ADC_SampleTime_3Cycles: Sample time equal to 3 cycles
@arg ADC_SampleTime_15Cycles: Sample time equal to 15 cycles
@arg ADC_SampleTime_28Cycles: Sample time equal to 28 cycles
@arg ADC_SampleTime_56Cycles: Sample time equal to 56 cycles
@arg ADC_SampleTime_84Cycles: Sample time equal to 84 cycles
@arg ADC_SampleTime_112Cycles: Sample time equal to 112 cycles
上一篇:STM32模拟SPI通信
下一篇:STM32红外串口接收
推荐阅读


推荐帖子
- 顶标C80 88Z的芯片具体型号(已知是用作4分频)
- 如图,芯片顶标第一行:C80,第二行:88Z 已知在电路中是用作4分频的元件。 求具体型号,或者类似功能的芯片型号。 顶标C8088Z的芯片具体型号(已知是用作4分频)
-
huang0909
分立器件
- 分享一段十六进制转十进制的代码
- ACDBUF是一个int型十六进制数最大为0xfff。 a=ADCBUF&0XF00>>8; b=ADCBUF&0X0F0>>4; c=ADCBUF&0X00F; a=a&0x08*8+a&0x04*4+a&0x02*2+a&0x01;a=a*256; b=b&0x08*8+b&0x04*4+b&0x02*2+b&0x01;b=b*16; c=c&0x08*8+c&0x04*4+c&0x02*2+c&0x01; d=a+b+c;/
-
linjingui
嵌入式系统
- 使用毫微功耗运算放大器实现电流感应
- 设计者通过将一个非常小的“分流”电阻串联在负载上,在两者之间设置一个电流感应放大器或运算放大器,实现用于系统保护和监测的电流感应。虽然专用的电流感应放大器能够发挥十分出色的电流感应作用,但如果特别注重功耗的情况下,精密的毫微功耗运算放大器则是理想的选择。 有两个位置可以根据负载放置分流电阻:负载与电源之间,或者负载与接地之间。 在这两种情况下,为了利用已知阻值的电阻来感应电流,通过运算放大器来测量分流电阻两端的电压。运用欧姆定律(公式1),可以确定电流消耗
-
火辣西米秀
微控制器 MCU
- 关于AD10正反面布线的问题
- 本人在用AD10,今天布一个板子,两个焊点我想正反面都走线, 可是我正面布好线,再布反面的线,反面的线布好了,奇怪的是正面布好的线消失了,是不是软件哪里没有设置好,上个图!望大神指点!!! 关于AD10正反面布线的问题
-
zhangdaijinqf
PCB设计
- 是不是只有在模拟仿真时才能设端点调试啊?
- 我一直搞不懂MSP430FlashEmulationTool是怎么工作的,它在调试时每次都要把程序下装到目标芯片中运行,在标芯片中程序就自己独立运行了,那还怎么进行断点调试和控制?? 是不是开发MSP430的程序都只能进行软件模拟调试?模拟调试完成后,再下装到目标板中,如果是这样,那么所谓的仿真器充其量不过是个编程器而已。 开发大一点的系统将会是一场恶梦!!!!是不是只有在模拟仿真时才能设端点调试啊?
-
waytosun
微控制器 MCU
- 压电陶瓷片参数如何测试
- 压电陶瓷片参数如何测试 压电陶瓷片参数如何测试
-
QWE4562009
分立器件