Sie sind auf Seite 1von 11

Robert Scott Fritzsche

68HC11 Temperature measure and Display


Introduction
This lab is to show how the A/D converter on the 68HC11 works and the
hardware required to do it. The objective and requirements of the lab were to write
code to use the A/D converter and know the hardware requirements to use the
temperature sensor.
We were to scale the Temperature sensor to read from 0 to 100 Celsius.
Included in this objective was the task of connecting the temperature sensor and
the LEDs to the HC11. Also included in this objective was the task of designing
software to do the following: initialize the A/D converter and serial subsystems;
control the measurement and storage of temperature in a RAM variable called
TEMP; and control the display of temperature on the LED outputs.
Procedures for testing and Design
Figure 1

Figure 1 shows the interaction between the 68HC11 and the LM3911 sensor.
Procedure was to test the LM6911 and record data off of the temperature reading of
an ice bath that is gradually heated.
Then on the input of the terminal tell the 68HC11 to read and display the temp and
the corresponding LED number for the given temp as well.

Robert Scott Fritzsche

Connecting the Temperature sensor to the 68HC11


The LM3911 is the sensor that was used in the lab. The
could not be directly connected to the 68HC11 because it
output a current and the 68HC11 A/D converter can only
be supplied with a Voltage source between 0-5V. To
solve this problem a new circuit was designed to convert
the current to voltage in the proper manor.

LM3911
would

To the right is the integrated op-amp that


allows for the LM3911 to supply a current and thus
supply a voltage to the 68HC11.

Testing procedure and results

Thermometer vs Water Bath vs 68HC11


90
80
70
60
50
40
30
20
10
0

10

Thermomitor

12

14

16

18

68HC11

Water Bath Reading

For the
Testing, we had a
bath of ice water inside for the water bath heater. To allow for consistent results we
also included a mercury thermometer. I took readings from the lowest point we

Robert Scott Fritzsche


could reach and read which was 2 degrees C and then took reading at 5 degree
intervals. At first there was a 7 degree difference between the 68HC11 and all the
other readings. To solve this we thought the problem might have been the
resistance not being exactly what was calculated. To fix this we added a 1K pot
resistor and tuned it till the results lined up. There are still some variations in the
results. But for the most part the readings were within a degree or so.

Conclusion
This report shows how the 68HC11 hardware and software combined with the
LM3911 can be used to make a viable temperature sensor. While all of the reading
were not exactly as read by either the thermometer or the water bath sensor, this
could be fine-tuned by either the resistors used or through code changes. The LED
lights connected to the Temperature readings was the easiest part of the coding.
This A/D conversion lab was completed properly and thoroughly introduced
me to the A/D converter.

Robert Scott Fritzsche

Appendix:
Figure 1 shows an accurate representation of the 68HC11 hardware. This picture
was taken from the internet and shows a slight problem. My code uses the PE1 port
and not the PE2 port on the 68HC11. The second problem is that the figure was
designed for 20-90 degrees F and not 0-100 degrees C.
Flow Chart

Robert Scott Fritzsche

ASM Code
*ENGR 4240 Introduction to Microcontrollers
*A/D Converter

*Static Variables

OUTRHLF
OUTA

EQU
EQU

$FFB5
$FFB8

OUTSTRG

EQU

$FFC7

OUTCRLF

EQU

$FFC4

OUTSTRGO

EQU

$FFCA

INCHAR

EQU

$FFCD

ADCTL

EQU

$1030

;Define the Subroutines

Robert Scott Fritzsche


PE1

EQU

$1032

*Dynamic Variables

d1

EQU

$DB01

d2

EQU

$DB02

d3

EQU

$DB03

d4

EQU

$DB04

d5

EQU

$DB05

PortB

EQU

org
DIGITAL

$1004

$8000
RMB

VOLTAGE

RMB

TEMP

RMB

;Reserve bytes

*Prompt user for keyboard press

ORG
Prompt

$9000

FCC
FCB

Celsius

"Press to display Temp"

$04

FCC
FCB

" Degrees Celsius"


$04

*Main loop

ORG
BACK

$A000

LDX

#Prompt

JSR

OUTSTRG

JSR

OUTCRLF

JSR

INCHAR

JSR

TEMPSUB

;Input
;Converts to decimal

Robert Scott Fritzsche


JSR

LEDSUB

JSR

BINBCD

JSR

Print

JMP

BACK

;Turn on LEDs
;Convert to decimal
;Prints temperature

*Temp SR

ORG

$B000

LDAA

#%00000001

STAA

ADCTL

LDAB

#16

TEMPSUB

Time

;Scan once, single channel, PE1

;wait loop (32 cycles)

DECB
BNE

Time

LDAA

PE1

STAA

DIGITAL

LDAB

#20

;Decrement B (two clock cycles)

MUL
STD

VOLTAGE

LDAA

DIGITAL

LDAB

#4

;voltage in millivolts

;step size

MUL
STD

TEMP

;Temp is in (degress C / 10)

RTS

*LED SR

ORG

$C000

LEDSUB
LDAA DIGITAL
stored in port B)

;Led 1 turns on from a range from values from 0-31 (all results

Robert Scott Fritzsche


LDAB

#31

STAB

$CF00

CMPA

$CF00

BHI

TWO

LDAA

#%00000001

STAA

PortB

JMP

DONE

TWO
LDAA

DIGITAL

LDAB

#63

STAB

$CF00

CMPA

$CF00

BHI

;Led 2 turns on from a range from values from 32-63

THREE

LDAA

#%00000011

STAA

PortB

JMP

DONE

THREE
LDAA

DIGITAL

LDAB

#91

STAB

$CF00

CMPA

$CF00

BHI

;Led 3 turns on from a range from values from 64-91

FOUR

LDAA

#%00000111

STAA

PortB

JMP

DONE

FOUR
LDAA

DIGITAL

;Led 4 turns on from a range from values from 92-127

Robert Scott Fritzsche


LDAB

#127

STAB

$CF00

CMPA

$CF00

BHI

FIVE

LDAA

#%00001111

STAA

PortB

JMP

FIVE

LDAA

#158

STAB

$CF00

CMPA

$CF00

;Led 5 turns on from a range from values from 128-158

SIX

LDAA

#%00011111

STAA

PortB

JMP

DONE

LDAA

DIGITAL

LDAB

#190

STAB

$CF00

CMPA

$CF00

BHI

;Led 6 turns on from a range from values from 159-190

SEVEN

LDAA

#%00111111

STAA

PortB

JMP

SEVEN

DIGITAL

LDAB

BHI

SIX

DONE

DONE

LDAA

DIGITAL

LDAB

#222

STAB

$CF00

CMPA

$CF00

;Led 7 turns on from a range from values from 191-222

Robert Scott Fritzsche


BHI

LDAA

#%01111111

STAA

PortB

JMP

EIGHT

EIGHT

DONE

LDAA
STAA

#%11111111 ;Led 8 turns on anything greater than 222

PortB

DONE
RTS

*Conversion SR

ORG

$D000

LDD

TEMP

LDX

#1000

BINBCD
;load digital value

IDIV
XGDX
STAB

d2

;stores the tens digit into db02

XGDX
LDX

#100

IDIV
XGDX
STAB

d3

;stores the ones digit into db03

XGDX
LDX

#10

IDIV
XGDX
STAB

d4

;stores the tenths digit into d04

Robert Scott Fritzsche

XGDX
STAB

d5

;stores the hundreths digit into db05

RTS

*Printing SR

ORG

$D800

LDAA

d2

PRINT

JSR

LDAA
JSR

LDAA
JSR

LDAA
JSR

LDAA

OUTRHLF

d3

;prints the hundreds digit

OUTRHLF

d4

;prints the tens digit

OUTRHLF

#$2E

;prints the decimal point with the OUTA subroutine

OUTA

d5

JSR

OUTRHLF

LDX

#Celsius

JSR

OUTSTRGO

JSR

OUTCRLF

RTS

;print the thousands digit

;prints the ones digit

;Degrees Celsius Value

Das könnte Ihnen auch gefallen