当前位置:首页 > 嵌入式 > 嵌入式软件
[导读]找出微处理器ADC电压的十六进制编码值

这种设计方案针对低档八管脚flash存储的8位微处理器,例如Freescale的MC68HC908QT4A,但是它也同样适用于任何一款拥有ADC模块的8位微处理器。在芯片内,ADC转换输入的模拟电压成数字信号格式。数字信号格式为8位的十六进制编码值,如$00。微处理器从ADC端口采集输入模拟信号范围从VSS对应的 $00到VDD对应的$FF。基于这些十六进制编码,在VSS和VDD之间的输入电压呈现出总共256个电平的线性变换。换句话说,输入电压越高,十六进制编码值就越大。

  最困难的地方在于写汇编代码实现算法的程序员必须知道不同输入模拟电平(例如1.6V)对应什么十六进制编码值。涉及到微处理器规格,甚至联系生产厂商也不能给出满意的答案。

  然而,本文提出解决这个问题的方案。假定微处理器工作电源电压为VDD,应用下面这个简单公式得到十六进制编码值:VIN/(VDD/255)=result value="hex" code(见编者按)。注意,在更高的十六进制编码转换精度之前,必须保证转换出的十六进制值能够覆盖整个模拟信号范围。下面的例子计算表明了使用已知电源电压5V的微处理器时,测量输入模拟信号电压为1.6V的十六进制编码值:1.6V/(5V/255)=81.6=82,或者$52。

  编者按:

  作者还提供了两个附件,一个查询表(PDF格式)和一个Excel格式的表格,读者可以对照这些附件与公式相互映证。最后,作者还在“反馈环”这篇文章为本篇文章提供了一些注释。

       英文原文:

  Find hex-code values for microcontroller’s ADC voltages

  Ease 8-bit microcontroller programming with a simple formula to calculate hex values of ADC output.

  Harry Gibbens Jr, Deafworks, Provo, UT; Edited by Charles H Small and Brad Thompson -- EDN, 4/12/2007

  This Design Idea is for low-end, eight-pin, flash-memory, 8-bit microcontrollers, such as the MC68HC908QT4A from Freescale, but it would apply to any 8-bit microcontrollers that use the ADC feature. In a nutshell, the ADC converts an input-analog-voltage level to a digital-signal format. The digital-signal format has an 8-bit hex-code value, such as $00. The microcontroller “sees” the input-analog-voltage level from its ADC ports ranging from $00 at VSS to $FF at VDD. Based on those hex-code values, there are a total of 256 ticks. The input voltages between VSS and VDD represent a straight-line linear conversion. In other words, the higher the input voltage, the higher the hex-code value.

  The difficulty is that a programmer who needs to write assembly code for a programming algorithm must know what the hex-code value is for a different input-analog-voltage level—1.6V, for example. Referring to the microcontroller’s specs and even contacting its manufacturers do not yield satisfactory answers.

  However, this Design Idea presents a solution to the problem. Given the microcontroller’s power operating-voltage source, VDD, use the following simple formula to obtain the hex-code value corresponding to an identified input-analog-voltage level: VIN/(VDD/255)=result value="hex" code (see Editor's note). Note that you must round off the result value to a whole number before converting to a hex-code value for better accuracy. The following sample calculation finds the hex-code value for a measured input-analog-voltage level of 1.6V when using a known microcontroller’s VDD of 5V:1.6V/(5V/255)=81.6=82, or $52

  Editor's Note:

  Correction and addition (4/27/2007): Due to an editing error, we originally printed the formula as "VIN×VIN/(VDD/255)." In addition, the author has provided two attachments, a lookup table (PDF) and an Excel spreadsheet that allows you to interact with the formula. Finally, the author has posted some comments in the "Feedback Loop" section for this article.

本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除。
换一批
延伸阅读

稳压二极管型号通常由字母和数字组成,其中字母代表制造厂家或特定系列,数字代表器件的特性参数。以下是一些常见的稳压二极管型号:

关键字: 稳压二极管 额定电流 电压

ADC(Analog to Digital Converter, 模数转换器), 用于实现模拟信号向数字信号的转换。A/D转换的作用是将时间连续、幅值也连续的模拟信号(电信号)转换为时间离散、幅值也离散的数字信号(二进制...

关键字: ADC 转换原理 模拟信号

逆变器作为光伏发电系统的核心设备,其作用是将光伏组件产生的可变直流电压转换为市电频率交流电,是光伏阵列系统中重要的系统平衡之一。

关键字: 逆变器 电压 电量

VGA接口主要用于将计算机的数字图像信号转换成模拟信号,从而可以在显示器上显示。这种接口通常包含15个针脚,分成3排,每排5个孔,可以传输红、绿、蓝三种基本颜色的信号以及水平和垂直同步信号。

关键字: vga接口 信号 电压

在日常生活和工业生产中,电压的稳定性对于各种电气设备的正常运行至关重要。然而,有时我们会遇到电压低的情况,这不仅会影响到设备的性能,还可能引发一系列问题。本文将对电压低的原因进行深入探究,并提出相应的应对措施。

关键字: 电压 电网

一直以来,ADC模数转换器都是大家的关注焦点之一。因此针对大家的兴趣点所在,小编将为大家带来模数转换器的相关介绍,详细内容请看下文。

关键字: ADC 模数转换器

双核心 Arm Cortex-A35、图形加速、高速连接能力,及内建硬件安全功能

关键字: 微处理器 电动车充电站 智能家居

开关电源的输入电压如果过低或过高,都有可能导致不起振的情况。当输入电压过低时,电源无法启动,因为电源无法获得足够的能量来开关。

关键字: 开关电源 电压 电源

2024年3月12日,中国 -- 服务多重电子应用领域、全球排名前列的半导体公司意法半导体(STMicroelectronics,简称ST;纽约证券交易所代码:STM)发布了新一代的STM32MP2系列工业级微处理器 (...

关键字: 微处理器 智能工厂 CPU

如果开关电源的输出电压低,可能是由于多种原因引起的故障。以下是一些可能的原因和对应的维修方法:

关键字: 开关电源 电压 励磁开关电源
关闭
关闭