在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 溫度LTC1392 with PIC16C84單片機(jī)

            溫度LTC1392 with PIC16C84單片機(jī)

            作者: 時(shí)間:2011-03-08 來源:網(wǎng)絡(luò) 收藏

            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 Temperature
            1 0 1 V_cc
            2 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 1);

            where the mode is either 0, 1, 2 or 3 as noted in the above table.

            Conversions.

            Upon receiving the 10 bits of data, the temperature, V_cc or other voltage is calculated.

            Temperature.

            The range between -130 degrees C and 125.75 degrees C is broken into 1024 discrete bands. Thus,

            T_c = (125.75 - (-130)) * band / 1024 - 130.0

            or T_c = 256/1024 * band - 130
            = band / 4.0 - 130.0

            For the Stamp;

            T_100 = 100 * T_c = 25 * band - 13000

            V_cc.

            The range between 2.42 and three times 2.42 is broken into 1024 bands. Thus,

            V_cc = (3*2.42 - 2.42) * band / 1024 + 2.42
            = (2*2.42) * band / 1024 + 2.42
            = 4.84 * band / 1024 + 2.42

            For the Stamp;

            V_CC_100 = 100 * V_cc = (60 * band)/128+242

            Other.
            When measuring the differential voltage between +V_in and -V_in using the 1.0 full scale reference;

            V_diff = band / 1024 * 1.0

            For the Stamp;

            DIFF_VOL_100_1 = 100 * V_diff = (100 * band)/1024

            When using the 0.5 V full scale;

            V_diff = band / 1024 * 0.5

            For the Stamp;

            DIFF_VOL_100_2 = 100 * V_diff = (50 * band)/1024

            Basic Stamp 2 - Program LTC1392.BS2.

            In program LTC1392.BS2 a Basic Stamp 2 is used to fetch the values of temperature, V_cc and V_diff using both of the references. Note that it is assummed there is an applied voltage of less than 0.5 Volts between +V_in and -V_in.

            The four-measurement sequence is repeated ten times.


            ' LTC1392.BS2
            '
            ' Measures Temperature in degrees C, V_cc, V_diff (1.0 V Ref) and V_diff
            ' (0.5 V Ref). Ten such measurment sequences performed.
            '
            ' Basic Stamp 2 LTC1392
            '
            '
            ' PIN11 (term 15) ----RX_DATA --------- (term 2) D_out
            '
            ' PIN10 (term 14) ---- TX_DATA --------- (term 1) D_in
            ' PIN9 (term 13) ----- CLK ------------- (term 3) CLK
            ' PIN8 (term 12) ----- /CS ------------- (term 4) /CS
            '
            '
            ' ------- (term 6) +V_in
            ' ------- (term 7) -V_in
            '
            '
            ' +5 ---- (term 8) V_cc
            ' GRD --- (term 5) GRD
            '
            ' copyright, Towanda Malone, Morgan State University, May 22, '97
            '

            get_10 var word ' 10 bits fetched from LTC1392
            out_4 var byte ' 4 bits sent to 1392

            m var byte ' index used in main
            n var byte ' index used in subroutines
            mode var byte ' 0 - Temperature measurment
            ' 1 - V_CC meas
            ' 2 - V_diff (1.0 V Reference)
            ' 3 - V_diff (0.5 V Reference)

            T_100 var word ' 100 * T in degrees C
            VCC_100 var word ' 100 * V_CC (Volts)
            DIFF_VOL_100_1 var word ' 100 * V_diff (1.0 V Reference)
            DIFF_VOL_100_2 var word ' 100 * V_diff (0.5 V Reference)

            rx_data var in11
            tx_data con 10
            clk_pin con 9
            cs_pin con 8

            dirs = $07ff ' 8, 9, 10 Outputs, 11 Input

            main:
            for m = 1 to 10 ' make ten measurment sequences

            mode = $00 'temperature measurement in (degrees C).
            gosub make_meas
            T_100 = (25 * get_10)-13000
            debug "T_100 = "
            debug dec T_100, CR 'CR is carriage return.

            mode = $01 'VCC measurement.
            gosub make_meas
            VCC_100 = (60 * get_10)/128+242
            debug "VCC_100 = "
            debug dec VCC_100, CR

            mode = $02 'differential voltage measurement, 1V
            scale.
            gosub make_meas
            DIFF_VOL_100_1 = (100 * get_10)/1024
            debug "DIFF_VOL_100_1 = "
            debug dec DIFF_VOL_100_1, CR

            mode = $03 'differential voltage measurement,
            ' 0.5V scale.
            gosub make_meas
            DIFF_VOL_100_2 = (50 * get_10)/1024
            debug "DIFF_VOL_100_2 = "
            debug dec DIFF_VOL_100_2, CR

            debug CR
            pause 4000 ' pause between readings
            next
            stop

            make_meas:
            high clk_pin
            high cs_pin ' 1392 reset
            low cs_pin ' beginning of sequence
            gosub send_data_4 ' send 4 bit command
            gosub get_data_10 ' fetch 10 bit result
            high cs_pin ' disable 1392
            return


            send_data_4: ' send command nibble beginning with most sig bit
            out_4 = $09 | (mode 1) ' 1 M_1 M_0 1
            for n = 3 to 0
            if( (out_4 $08) = 0) then out_0 ' test bit 3
            high tx_data ' and output 1 or 0
            L2:
            gosub clock_pulse ' followed by negative clock
            out_4=out_41 ' align next bit in bit 3 pos
            next
            return

            out_0:
            low tx_data
            goto L2

            '''''''''''

            get_data_10: ' read ten bits on rx_data,
            ' beginning with most significant bit
            get_10 = 0
            gosub clock_pulse ' send one clock pulse
            for n = 0 to 9
            low clk_pin ' bring clock low
            get_10 = (get_101) | rx_data ' read bit
            high clk_pin ' clock back to high
            next
            return

            clock_pulse:
            low clk_pin
            high clk_pin
            return

             

            PIC16C84 - Program LTC1392.ASM.

            This program illustrates how to interface a PIC with an LTC1392.

            One measurement is made in each mode and the result is saved to a data buffer. Note that each measurement consists of 10-bits and thus, each measurement is saved in the data buffer as two bytes. The DAT_HI variable consists of the hgighest two bits and DAT_LO of the low eight bits.

            In the program, the raw measurement data is then displayed on a serial LCD. However, it is important to note that this data might be saved in a serial EEPROM for later retrieval and downloading to a PC.

            Unlike the program for the Basic Stamp, this program does not include any calculations on the raw data. Another discussion offers that in many instances, calculation is not necessary nor necessarily desireable. But, if it is thoughts are offered on how the calculations may be done with simple byte by byte multiplcation, two byte add and subtracts and BCD conversion routines. These are implemented in other discussions.

            One point of interest is the use of a two byte shift in the RX_DATA_10 routine which fetches the 10-bit result from the LTC1392.

            DAT_HI and DAT_LO are both initialized to zero and the following loop is executed ten times.

            BTFSS PORTB, RX_D
            BCF STATUS, C ; set CY to either a 0 or 1
            BTFSC PORTB, RX_D
            BSF STATUS, C
            RLF DAT_L, F ; do a two byte left shift
            RLF DAT_H, F

            Note that the carry bit is either set to a zero or one, depending on the state of the RX_D input bit. This is then left shifted into DAT_LO. Note that the most significant bit of DAT_LO is now in the carry bit. This is then left shifted into DAT_HI, such that it is now the least significant bit in DAT_HI.


            ; LTC1392.ASM
            ;
            ; 16C84 LTC1392
            ;
            ; PORTB.3 (term 9) --RX_D------------ D_OUT (term 2)
            ; PORTB.2 (term 8) ---TX_D-----------> 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 c:mplabp16c84.inc>
            __CONFIG 11h

            CONSTANT RX_D = 3 ; bits defined on PortB
            CONSTANT TX_D = 2
            CONSTANT CLK = 1
            CONSTANT 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 ; scratchpad
            NUM EQU BASE_VAR+2 ; index

            DELAY_LOOP EQU BASE_VAR+3 ; timing

            DAT_H EQU BASE_VAR+4 ; 10-bit quantity fetched from ltc1392
            DAT_L EQU BASE_VAR+5

            ORG 000H

            CLRF PORTB
            BSF STATUS, RP0
            BSF TRISB, RX_D ; input
            BCF TRISB, TX_D ; TX_D, CLK and C_S are outputs
            BCF TRISB, CLK
            BCF TRISB, C_S
            BCF STATUS, RP0

            MAIN:
            MOVLW DATA_BUFF ; pointer to beginning of data_buff
            MOVWF FSR

            MOVLW .0
            MOVWF MODE

            MAIN_1: CALL MAKE_MEAS ; make a measurment

            MOVF DAT_H, W ; and save two bytes in data_buff
            MOVWF INDF

            INCF FSR, F
            MOVF DAT_L, W
            MOVWF INDF
            INCF FSR, F

            INCF MODE, F ; go through mode 0. 1, 2, 3
            MOVLW .4
            SUBWF MODE, W
            BTFSS STATUS, Z
            GOTO MAIN_1

            CALL DISPLAY ; display content of data_buff
            MAIN_2:
            GOTO MAIN_2


            MAKE_MEAS: ; performs a measurment in specified mode
            ; result is returned in DAT_HI and DAT_LO
            CALL C_SEL_HI
            CALL CLK_HI
            CALL C_SEL_LO ; bring /CS low
            CALL TX_DATA_4 ; send 4-bit command
            CALL RX_DATA_10 ; fetch 10-bit result
            CALL C_SEL_HI
            RETURN

            DISPLAY: ; display content of data_buff on serial LCD
            CALL LCD_CLR

            MOVLW DATA_BUFF ; initialize pointer to data_buff
            MOVWF FSR

            MOVLW .4
            MOVWF NUM

            DISPLAY_1:
            MOVF INDF, W ; fetch byte and display on serial LCD
            CALL LCD_VAL
            INCF FSR, F
            MOVF INDF, W
            CALL LCD_VAL
            INCF FSR, F

            MOVLW " " ; separate with a space
            CALL LCD_CHAR

            DECFSZ NUM, F
            GOTO DISPLAY_1
            RETURN

            TX_DATA_4: ; send 4-bit command to ltc1392
            BCF STATUS, C
            RLF MODE, W ; 09H | (mode 1)
            IORLW 09H

            MOVWF TEMP ; save to scratch pad

            MOVLW .4 ; 4 bits
            MOVWF NUM

            TX_DATA_4_1:
            BTFSS TEMP, 3 ; most significant bit first
            BCF PORTB, TX_D ; set up TX_D
            BTFSC TEMP, 3
            BSF PORTB, TX_D

            CALL CLK_LO ; and then negative going clock pulse
            CALL CLK_HI

            RLF TEMP, F ; next bit to bit 3 position

            DECFSZ NUM, F
            GOTO TX_DATA_4_1
            RETURN

            RX_DATA_10: ; fetches 10 bit result from ltc1392
            CLRF DAT_H
            CLRF DAT_L

            CALL CLK_LO ; a dummy clock pulse
            CALL CLK_HI

            MOVLW .10 ; 10 bits
            MOVWF NUM
            RX_DATA_10_1:
            CALL CLK_LO ; bring clock low and read bit
            BTFSS PORTB, RX_D
            BCF STATUS, C ; set CY to either a 0 or 1
            BTFSC PORTB, RX_D
            BSF STATUS, C
            RLF DAT_L, F ; do a two byte left shift
            RLF DAT_H, F
            CALL CLK_HI

            DECFSZ NUM, F
            GOTO RX_DATA_10_1
            RETURN

            CLK_HI:
            BSF PORTB, CLK
            CALL DELAY_100USEC
            RETURN

            CLK_LO:
            BCF PORTB, CLK
            CALL DELAY_100USEC
            RETURN

            C_SEL_HI:
            BSF PORTB, C_S
            CALL DELAY_100USEC
            RETURN

            C_SEL_LO:
            BCF PORTB, C_S
            CALL DELAY_100USEC
            RETURN

            DELAY_100USEC:
            MOVLW .20
            MOVWF DELAY_LOOP ; 20 * 5 + 2 = 102 cycles
            DELAY_100USEC_1:
            NOP
            NOP
            DECFSZ DELAY_LOOP, F
            GOTO DELAY_100USEC_1

            RETURN

            #INCLUDE A:LCDLCD_CTRL.ASM>
            END



            評(píng)論


            相關(guān)推薦

            技術(shù)專區(qū)

            關(guān)閉