This report breaks down the preliminary design into two sections. In the first section, separate hardware and software designs are presented. The hardware designed for section one includes the temperature measurement circuit and the connection of LEDs to Port B. The software designed for section one initializes the A/D converter and serial subsystems, controls the measurement and storage of the temperature in a RAM variable called TEMP, and controls the display of temperature on the LED outputs.
In the second section of the report, the HC11 is connected to a remote PC terminal using an RS-232 connection. After adding the software required to initialize the serial subsystem, subroutines, which are added to the software program developed for the
report's first section, allow the HC11 to send a message to the PC if the
measured temperature falls below 20 degrees or above 90 degrees.
>
Description of Testing and Design
>
This section presents a description of the testing and design for this first preliminary design. This description is broken into sections: (1) connecting a temperature meausrement circuit to the HC11 microcontroller; and (2) adding a serial output to the HC11 microcontroller.
>
Connecting a Temperature Measurement Circuit to the HC11. Connecting a temperature measurement circuit to the HC11 microcontroller involved both hardware and software. Hardware was added to control the measurement and display of the temperature. This hardware includes a temperature measurement circuit and LEDs attached to Port B (the temperature measurement circuit is shown in Figure A-1 in Appendix A). The circuit was designed according to the specifications obtained from the Computer Engineering Laboratories website for ECPE 4535 [Lineberry, 1998]. Within the circuit is an LM3911 temperature controller integrated circuit (IC), the output of which is connected into a non-inverting opamp. The output of the opamp connects to the HC11 A/D input pin E2 through a 1000-ohm resistor. The circuitry is scaled so that 0 volts out means 0 degrees and 5 volts out means 110 degrees.
To each of the output pins of Port B, LEDs are connected using a 74HC244 buffer IC and 330-ohm current limiting resistors as shown in Appendix A. The LEDs are located in the breadboard area of the trainer kits.
To control this added hardware, the HC11 was programmed following the pseudo code, flow chart, and program listing given in Appendices B, C, and D, respectively. The program shown in Appendix D consists of three subroutines that are called from MAIN. The three subroutines are named STARTUP, GETTEMP, and SETDISP.
The STARTUP subroutine is used to enable the A/D converter subsystem, which
is connected to Port E. First the A/D is powered up by setting bit 7 of the OPTION register. After a 100 microsecond delay, the control word $22 is written to the ADCTL
register to start continuous, single-scan conversions on Port E pin E2.
The subroutine GETTEMP is used to input and scale the analog voltage from the temperature sensor circuit. The register ADR3 holds the result of the A/D conversions and is loaded into accumulator A and then multiplied by a scale factor contained in accumulator B by using the MUL instruction. The result contained in accumulator A is then right shifted once giving the temperature in degrees Fahrenheit, which is then stored in the RAM variable TEMP. The equation for finding TEMP is shown in (1).
The subroutine SETDISP controls the lighting of the LEDs connected to Port B based on the present value of TEMP. First, TEMP is loaded into accumulator A and compared with the value 20, the designated cut-off for low temperature. Accumulator B is cleared to zero and represents the initial count value for the number of LEDs to turn on. If the value in accumulator A is greater than or equal to 20, then the count in accumulator B is incremented and 10 is subtracted from accumulator A. The process then repeats as long as the value in accumulator A is greater than or equal to 20. This process is shown in flowchart form in Figure 2 and in Appendix C. After the number of LEDs to turn on have been determined as shown in Figure 2, the number of bits indicated by the count value in accumulator B are set high on Port B beginning with bit 0.
After modifying the STARTUP subroutine, the OUTSCI subroutine was added to write data bytes from the HC11 to the remote PC terminal. The data byte to be sent is contained in accumulator A. The subroutine checks that the TDRE bit is set in the SCSR register, and if it is, the data byte in accumulator A is written to the SCDR register. If the TDRE bit is not set, the program continually reads the SCSR register until bit TDRE is set before writing accumulator A to the SCDR register.
The subroutine MESSOUT utilizes the OUTSCI subroutine to write character strings to the remote PC terminal. Before calling MESSOUT, the X index register is set to point to the beginning of the character string to be sent. The MESSOUT subroutine then sends out the string by calling OUTSCI for each character until the NULL character is reached, which marks the end of a string.
Lastly, the subroutine TEMPCHK was added to the existing software program to check the temperature range. The subroutine TEMPCHK calls MESSOUT to print the message "Temperature is very low.\n" if TEMP is less than 20 degrees Fahrenheit. If TEMP is greater that 90 degrees Fahrenheit, TEMPCHK calls MESSOUT to print the message "Temperature is very high.\n" A flag variable called FLG ensures that the messages are not repeatedly sent for each entry into the very hot or very cold temperature regions. FLG is set to zero if TEMP is between 20 and 90 degrees and to one otherwise.
.
.
.
.
.
.
***************
Subroutine Listings
***************
***************
Interrupt Service Routines
***************