微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 温度LTC1392 with PIC16C84单片机

温度LTC1392 with PIC16C84单片机

时间:03-08 来源:互联网 点击:

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.

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top