12-Bit Thermometer Using an 8-

2011-12-28 15:08:18来源: 互联网

Figure 1. With an assembly-language routine and the free assembler, this circuit allows an 8-bit µC to implement a 12-bit digital thermometer. 

U1 is a low-cost, 8-bit flash µC with only 35 instructions. Unlike more expensive, multiply-friendly 16-bit µCs, this one has no multiply, divide, or even 16-bit math instructions. The result is a more challenging implementation of the thermometer! The µC (U1) receives a serial data word (Kcode) from the temperature sensor (U3). Using the following equations, it then converts Kcode to a binary representation of the temperature in degrees Celsius:

K = Kcode x 0.125, where K = temperature in degrees Kelvin.

°C = K - 273, where °C = degrees Celsius. 

Table 1 shows the data as it appears after each of five steps in the conversion process, using the decimal-equivalent number 2384 as an example for Kcode. The first step reads both halves of the Kcode value from U3 (high byte and low byte), and stores that data in separate 8-bit file registers. The second step aligns the Kcode data by rotating the bits in both 8-bit file registers two places to the right, checking the carry flag each time to properly shift the LSB of the high byte to the MSB of the low byte. The third step multiplies Kcode by 0.125. Multiplying by 0.125 is a bit complicated, but the equivalent operation of division by 8 is much easier. Because 8 is the third power of 2, division by 8 can be accomplished (with our limited instruction set) by three consecutive right shifts.

To convert to degrees Celsius, the fourth step subtracts 273 from the Kelvin temperature K. Eight-bit arithmetic, however, supports integers only to 255. Because 273 exceeds the 8-bit boundary, a code routine for 16-bit subtraction was used to produce a binary representation of the temperature in degrees Celsius.

To take full advantage of the BCD register map internal to U2, the last (fifth) step converts the binary representation of temperature in degrees Celsius to the BCD data format. A 16-bit routine for binary-to-BCD conversion allows temperature to be displayed using the LED display driver U2.

An assembly-language program for the µC is can be downloaded from the Maxim website.

Table 1. Five steps allow an 8-bit µC to support 12-bit temperature data and display it.
µC's 8-bit File Register #1 (high byte)
µC's 8-bit File Register #2 (low byte)
Step 1: The Kcode value is serially read out of U3. For example, Kcode = 2,384 decimal below.
X
X
MSB 
D12
D11
D10
D9
D8
D7
D6
D5
D4
D3
D2
LSB 
D1
0
0
X
X
1
0
0
1
0
1
0
1
0
0
0
0
0
0
Step 2: The Kcode is byte aligned. Kcode is still equal to 2,384 decimal below.
0
0
0
0
MSB 
D12
D11
D10
D9
D8
D7
D6
D5
D4
D3
D2
LSB 
D1
0
0
0
0
1
0
0
1
0
1
0
1
0
0
0
0
Step 3: Shifting the data right three places is equivalent to multiplying by 0.125 to obtain the Kelvin temperature. For example, K = 298 below.
0
0
0
0
MSB 
D12
D11
D10
D9
D8
D7
D6
D5
D4
D3
D2
LSB 
D1
0
0
0
0
0
0
0
1
0
0
1
0
1
0
1
0
Step 4: A 16-bit subtraction code routine must be used to subtract 273 from K, because 273 exceeds 8 bits. For example, °C = 25 below.
See code listing for the 16-bit subtraction code routine.
D8
D7
D6
D5
D4
D3
D2
LSB 
D1
0
0
0
1
1
0
0
1
Step 5: A 16-bit binary-to-BCD conversion routine must be used because that is the format used by the LED display driver. For example, 25C below. See code listing for the 16-bit binary to BCD conversion code routine.
LED 0
LED 1
LED 2
LED 3
CURRENTLY BLANK
D8
D4
D2
D1
D8
D4
D2
D1
Permanent "C" is displayed to represent " °C "
CAN BE NEGATIVE SIGN
0
0
1
0
0
1
编辑:神话 引用地址:http://www.eeworld.com.cn/mndz/2011/1228/article_13663.html
本网站转载的所有的文章、图片、音频视频文件等资料的版权归版权所有人所有,本站采用的非本站原创文章及图片等内容无法一一联系确认版权者。如果本网所选内容的文章作者及编辑认为其作品不宜公开自由传播,或不应无偿使用,请及时通过电子邮件或电话通知我们,以迅速采取适当措施,避免给双方造成不必要的经济损失。

上一篇:Crystal Considerations with Da
下一篇:Using the DS32kHz with Dallas

关注eeworld公众号 快捷获取更多信息
关注eeworld公众号
快捷获取更多信息
关注eeworld服务号 享受更多官方福利
关注eeworld服务号
享受更多官方福利

Warning: Invalid argument supplied for foreach() in /Data/webapps/cms/caches/caches_template/default/content/show.php on line 152
推荐阅读
全部

小广播

独家专题更多

东芝在线展会——芯科技智社会创未来
东芝在线展会——芯科技智社会创未来
2017东芝PCIM在线展会
2017东芝PCIM在线展会
TI车载信息娱乐系统的音视频解决方案
TI车载信息娱乐系统的音视频解决方案
汇总了TI汽车信息娱乐系统方案、优质音频解决方案、汽车娱乐系统和仪表盘参考设计相关的文档、视频等资源
电子工程世界版权所有 京ICP证060456号 京ICP备10001474号 电信业务审批[2006]字第258号函 京公海网安备110108001534 Copyright © 2005-2017 EEWORLD.com.cn, Inc. All rights reserved