|
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
|
|