DIY编程器网

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 402|回复: 0
打印 上一主题 下一主题

温度LTC1392 with PIC16C84单片机

[复制链接]
跳转到指定楼层
楼主
发表于 2012-1-27 18:22:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Introduction.
The Linear Technology LTC1392 is an inexpensive 10-bit A/D converter with the added capability of measuring the temperature of the IC and the value of the nominal +5 V supply. This makes it ideal in monitoring the health of the environment in any electronic equipment.
The low power dissipation also makes it an ideal IC for remote data logging using battery power. The quiescent current when idle is typically 0.2 uA. While performing a conversion the current drain rises to nominally 350 uA.
The device is available from DigiKey (LTC1392CN8-ND) for $7.50 in single unit quantities. A data sheet in .pdf format may be obtained from Linear Technologies.
In the following discussion, interfacing a Basic Stamp 2 with a single LTC1392 is illustrated. Interfacing the LTC1392 with a PIC is also discussed.
Sequence.
A measurement sequence is started by bringing /CS low which resets the device. Note that as it is the high to low transition, CS must first be at logic one. After bringing /CS low, a minimum delay of 80 usecs is required for a temperature measurement and 10 usecs for all other measurements.
Four configuration bits are then serially transmitted by the processor using the TX_DATA and CLK leads. In transmitting toward the device, the data is first set up on the on the TX_DATA lead and the CLK is then brought momentarily low. The actual capture of the data by the LTC1392 is on the rising edge of the clock.
Note that when the device is not selected (/CS high) and during the time this four bits is being sent by the processor, the devices D_out lead (RX_DATA) is in a high impedance mode.
Upon sending the four configuration bits, the 1392's D_out lead (RX_DATA) comes out of tri-state and the result is serially shifted toward the processor, beginning with a logic zero and then the most significant bit or a 10-bit result. Each data bit is transmitted by the LTC1392 on the falling edge of the clock.
Upon receipt of the 10 bits, the /CS is brought high, ending the measurement sequence.
Actually, I left a little out. The device may be configured such that after receipt of the 10 bit result in most significant bit format, continued clocking will cause the result to again be output in least significant bit format. I do not deal with this capability in this discussion. Actually, I am uncertain I grasp why anyone would want it.
The Command Bits.
After bringing /CS low, a four bit conguration word is sent to the device. Bit b_3, (the most significant bit) is always a logic one and is termed the "start" bit. Bits b_2 and b_1 determine the measurement mode as shown;
Mode b_2 b_1 Measurment
0 0 0 Temperature1 0 1 V_cc2 1 0 V_differential (1.0 V Full Scale)3 1 1 V_differential (0.5 V Full Scale)
Bit b_0 is used to specify whether the least significant bit first sequence is to follow the most significant bit first sequence and mentioned above. Let's just cut through the confusion and set it to a logic 1.
Thus, the configuration word is;
mode = 0x09 | (mode  D_IN (term 1); PORTB.1 (term 7) ---CLK------------> CLK (term 3); PORTB.0 (term 6) ---C_S------------> C_S (term 4);; copyright, Towanda Malone, Morgan State Univ, August 5, '97
LIST p=16c84#include __CONFIG 11h
CONSTANT RX_D = 3 ; bits defined on PortBCONSTANT TX_D = 2CONSTANT CLK = 1CONSTANT C_S = 0
CONSTANT DATA_BUFF = 18H
CONSTANT BASE_VAR = 0CH
MODE EQU BASE_VAR+0 ; mode = 0, 1, 2, or 3
TEMP EQU BASE_VAR+1 ; scratchpadNUM EQU BASE_VAR+2 ; index
DELAY_LOOP EQU BASE_VAR+3 ; timing
DAT_H EQU BASE_VAR+4 ; 10-bit quantity fetched from ltc1392DAT_L EQU BASE_VAR+5
ORG 000H
CLRF PORTBBSF STATUS, RP0BSF TRISB, RX_D ; inputBCF TRISB, TX_D ; TX_D, CLK and C_S are outputsBCF TRISB, CLKBCF TRISB, C_SBCF STATUS, RP0
MAIN:MOVLW DATA_BUFF ; pointer to beginning of data_buffMOVWF FSR
MOVLW .0MOVWF MODE
MAIN_1: CALL MAKE_MEAS ; make a measurment
MOVF DAT_H, W ; and save two bytes in data_buffMOVWF INDF
INCF FSR, FMOVF DAT_L, WMOVWF INDFINCF FSR, F
INCF MODE, F ; go through mode 0. 1, 2, 3MOVLW .4SUBWF MODE, WBTFSS STATUS, ZGOTO MAIN_1
CALL DISPLAY ; display content of data_buffMAIN_2:GOTO MAIN_2
MAKE_MEAS: ; performs a measurment in specified mode; result is returned in DAT_HI and DAT_LOCALL C_SEL_HICALL CLK_HICALL C_SEL_LO ; bring /CS lowCALL TX_DATA_4 ; send 4-bit commandCALL RX_DATA_10 ; fetch 10-bit resultCALL C_SEL_HIRETURN
DISPLAY: ; display content of data_buff on serial LCDCALL LCD_CLR
MOVLW DATA_BUFF ; initialize pointer to data_buffMOVWF FSR
MOVLW .4MOVWF NUM
DISPLAY_1:MOVF INDF, W ; fetch byte and display on serial LCDCALL LCD_VALINCF FSR, FMOVF INDF, WCALL LCD_VALINCF FSR, FMOVLW " " ; separate with a spaceCALL LCD_CHAR
DECFSZ NUM, FGOTO DISPLAY_1RETURN
TX_DATA_4: ; send 4-bit command to ltc1392BCF STATUS, CRLF MODE, W ; 09H | (mode END
                                
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏 分享分享 支持支持 反对反对
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|文字版|手机版|DIY编程器网 ( 桂ICP备14005565号-1 )

GMT+8, 2024-6-18 18:52 , 耗时 0.098691 秒, 18 个查询请求 , Gzip 开启.

各位嘉宾言论仅代表个人观点,非属DIY编程器网立场。

桂公网安备 45031202000115号

DIY编程器群(超员):41210778 DIY编程器

DIY编程器群1(满员):3044634 DIY编程器1

diy编程器群2:551025008 diy编程器群2

QQ:28000622;Email:libyoufer@sina.com

本站由桂林市临桂区技兴电子商务经营部独家赞助。旨在技术交流,请自觉遵守国家法律法规,一旦发现将做封号删号处理。

快速回复 返回顶部 返回列表