亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? 溫度ltc1392 with pic16c84.txt

?? PIC單片機C源代碼集合
?? TXT
字號:

  Use of an LTC1392 10-bit Temperature, Vcc and Differential Voltage Monitor - Basic Stamp 2 and PIC16C84
歌林電子制作實驗室www.nbglin.com 
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_4<<1 ' 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_10<<1) | 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:\mplab\p16c84.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:\LCD\LCD_CTRL.ASM>
END

 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美系列在线观看| 日韩一区二区三区电影在线观看 | 日韩视频免费观看高清完整版 | 欧美bbbbb| 亚洲va天堂va国产va久| 一区二区在线免费观看| 国产精品久久久久久户外露出| 久久一留热品黄| 精品日韩一区二区三区| 精品国产一区二区三区忘忧草| 欧美丝袜丝交足nylons图片| 91久久一区二区| 在线观看国产精品网站| 欧美亚洲综合另类| 欧美在线观看你懂的| 色综合av在线| 91精品国产美女浴室洗澡无遮挡| 欧美一级片在线| 成人h动漫精品一区二区 | 日韩一级黄色大片| 国产精品久久毛片av大全日韩| 午夜视频一区二区三区| 国产91富婆露脸刺激对白| 欧美精品免费视频| 亚洲人精品一区| www.综合网.com| 国产日韩欧美制服另类| 蜜桃视频免费观看一区| 一本大道综合伊人精品热热| 91麻豆精品国产91久久久使用方法 | 亚洲黄一区二区三区| 日本aⅴ免费视频一区二区三区| 久久er99热精品一区二区| 99久久久国产精品| 欧美一区二区免费观在线| 久久精品一级爱片| 亚洲激情成人在线| 国产一区二区三区久久久| 欧美日韩综合色| 中日韩av电影| 毛片av一区二区| 91麻豆自制传媒国产之光| 欧美一区二区三区免费视频| 国产精品久久久久久久蜜臀| 毛片不卡一区二区| 欧美老年两性高潮| 亚洲日本一区二区| 国产自产视频一区二区三区| 7777精品久久久大香线蕉| 一区精品在线播放| 国产**成人网毛片九色| 日韩欧美国产不卡| 视频一区视频二区中文| 精品视频一区 二区 三区| 中文字幕不卡在线| 国产成+人+日韩+欧美+亚洲| 欧美精品一区二区三区蜜桃视频 | 不卡的av网站| 国产三级精品视频| 国产麻豆午夜三级精品| 日韩欧美美女一区二区三区| 日韩av中文在线观看| 91麻豆精品国产无毒不卡在线观看| 国产精品911| 欧美岛国在线观看| 精品无人码麻豆乱码1区2区| 精品国产91亚洲一区二区三区婷婷| 三级不卡在线观看| 日韩欧美123| 激情六月婷婷综合| 久久伊99综合婷婷久久伊| 成人免费黄色大片| 亚洲欧美区自拍先锋| 在线视频亚洲一区| 日韩1区2区3区| 国产网站一区二区| av在线这里只有精品| 一区二区国产盗摄色噜噜| 91精品国产综合久久久久| 国内久久精品视频| 亚洲免费成人av| 亚洲精品一区二区三区在线观看| 国产夫妻精品视频| 亚洲三级在线看| 日韩一级完整毛片| 成人午夜在线免费| 日本aⅴ亚洲精品中文乱码| 欧美激情一区二区三区全黄| 欧美在线影院一区二区| 国内精品伊人久久久久av影院 | 中文字幕亚洲精品在线观看 | 欧美tk丨vk视频| 色妹子一区二区| 国产高清不卡一区| 亚洲午夜在线观看视频在线| 久久久久久久网| 9191成人精品久久| 99re热这里只有精品免费视频 | 成人看片黄a免费看在线| 男人操女人的视频在线观看欧美| 一区二区三区中文在线| 国产精品天天摸av网| wwww国产精品欧美| 色婷婷综合久久久久中文 | 1区2区3区欧美| 久久久www成人免费毛片麻豆| 欧美xxxxxxxx| 欧美xxxxx裸体时装秀| 日韩一区和二区| 日韩视频免费观看高清完整版 | 激情深爱一区二区| 国产一区二区三区蝌蚪| 成人av在线网| 欧美少妇一区二区| 久久免费美女视频| 亚洲丝袜美腿综合| 午夜精品爽啪视频| 另类欧美日韩国产在线| 高清成人在线观看| 欧美性猛交一区二区三区精品| 3d动漫精品啪啪| 久久久精品黄色| 一区二区三区在线视频免费观看| 视频一区二区三区中文字幕| 亚洲美女在线国产| 亚洲午夜久久久久久久久久久 | 中文字幕在线不卡视频| 国产精品成人网| 亚洲伊人色欲综合网| 蜜臀久久久久久久| 成人av在线电影| 91久久人澡人人添人人爽欧美| 91黄色激情网站| 91精品国产综合久久精品图片| ww亚洲ww在线观看国产| 亚洲摸摸操操av| 久草中文综合在线| 在线视频一区二区免费| 欧美mv日韩mv国产| 亚洲精品日产精品乱码不卡| 日韩电影在线看| a4yy欧美一区二区三区| 欧美日韩国产天堂| 国产欧美日韩在线| 天堂在线亚洲视频| 波多野结衣在线aⅴ中文字幕不卡| 欧美日韩国产另类不卡| 中文字幕乱码久久午夜不卡| 日韩在线a电影| 91美女福利视频| 国产精品欧美一级免费| 麻豆高清免费国产一区| 欧洲亚洲国产日韩| 一区精品在线播放| 国产九色sp调教91| 日韩免费高清视频| 日本欧美一区二区| 欧美精品亚洲一区二区在线播放| 自拍偷自拍亚洲精品播放| 国产电影一区在线| 日韩欧美黄色影院| 人人狠狠综合久久亚洲| 88在线观看91蜜桃国自产| 亚洲激情综合网| 97久久久精品综合88久久| 国产女人aaa级久久久级| 国产传媒欧美日韩成人| 久久新电视剧免费观看| 国产自产视频一区二区三区| 精品国产99国产精品| 777欧美精品| 久久国产尿小便嘘嘘尿| 精品国产a毛片| 成人三级在线视频| 亚洲日本青草视频在线怡红院| 粉嫩aⅴ一区二区三区四区五区| 国产日韩在线不卡| 色噜噜夜夜夜综合网| 亚洲一区二区精品久久av| 欧美老肥妇做.爰bbww视频| 久久精品国产在热久久| 国产欧美久久久精品影院| 91无套直看片红桃| 青青草一区二区三区| 国产人伦精品一区二区| 91女厕偷拍女厕偷拍高清| 日韩va亚洲va欧美va久久| 久久人人97超碰com| 色综合久久久久久久久久久| 免费人成精品欧美精品| 亚洲欧洲日本在线| 日韩欧美另类在线| 97超碰欧美中文字幕| 免费在线观看日韩欧美| 国产精品久久网站| 欧美日韩电影在线| 成人永久看片免费视频天堂| 亚洲亚洲精品在线观看| 久久综合九色综合97婷婷女人 | 99久久伊人精品|