SENIOR PROJECT REPORT
uP CORRECTED TEMPERATURE DISPLAY

By Gary L. Camp
Submitted in partial fulfillment
of the requirements for the degree
of Bachelor of Science in Engineering
with major in
Electrical and Electronics Engineering
August 22, 1977

Report Grade A, Project Grade A
Approved (signed by advisor) 24 Aug 77

ABSTRACT

This project was intended to test the feasibility of correcting the nonlinear characteristics of a thermocouple and then taking this binary data and decoding it to display decimal centigrade.

The non-linearity of the Iron Constantan thermocouple can be removed by adding piecewise linear correction factors within the uP program, The display is Hexadecimal and is corrected to dis-play decimal by testing for greater than 9 and adding 6 if the test is positive. This displays 10 which is 16 (base 10) in hex. This is carried out repetitively over the entire range of 0 to 99.

The 1802 COSMAC uP was used because of low power, noise immunity and wide supply variation. The A/D is easy to use, reasonably priced and needs only a 741 to raise the voltage to a useful level.

From building, programming and testing this prototype, it has been determined that the uP can easily accomplish these goals. It is, in fact, somewhat of an overkill and would be impractical unless further use of the uP is required (which is intended).

TABLE OF CONTENTS

[page numbers shown]

ABSTRACT....ii
LIST OF FIGURES  ....v
1.0 OBJECTIVES  ....1
2.0 INITIAL CONSIDERATIONS
2.1 Discussion ....1
2.2 Block Diagram  ....2
3.0 uP CIRCUIT
3.1 Basic Circuit ....3
3.2 Control  ....3
3.3 Displays  ....5
4.0 A/D CONVERTER
4.1 Selection Considerations....5
4.2 Hardware Circuit ....5
5.0 SENSOR AND SIGNAL CONDITIONER
5.1 Thermocouple Considerations....7
5.2 Signal Conditioner Circuit....7
6.0 PROGRAMMING
6.1 Initialization  ....7
6.2 Input and Correction  ....10
6.3 Conversion and Output ....11
7.0 RESULTS AND FINDlNGS....12
8.0 COST SUMMARY....13
9.0 CONCLUSIONS  ....14
10.0 APPENDIX
10.1 Parts List ....15
10.2 Schematic....16
10.3 Program Listing....19
10.4 Thermocouple Graph ....21

LIST OF FIGURES

[page numbers shown]

1. Block Diagram....2
2. Basic uP System and Controls ....4
3. A/D  ....6
4. Thermocouples and Signal Conditioner....8
5. Flow Chart ....9
6. Cost Summary  ....13
7. Parts List ....15
8. Schematic ....16
9. Program Listing....19
10. Thermocouple Graph....21

1.0 OBJECTIVES

1.1 The intention here is to build a working breadboard to test the feasibility of using a uP to correct and control a temperature display. The temperature sensor is nonlinear (thermocouple) and will be corrected within the program. The output will be adjusted from binary to decimal display under program control, also. For an overview, a block diagram is provided, fig 1.

This will be the first iteration of a device intended for sale as a digital temperature readout for aircraft, Later models are to be simplified in hardware at the cost of more software, ROMs for RAMs, etc, but for this project only the basic idea is being evaluated.

2.0 INITIAL CONSIDERATIONS

[senior project]

2.1 To meet the stated objectives, the 1802 CMOS uP was selected for high noise immunity, wide power supply range, economy and availability. Furthermore, the 1802 has ease of programming, an onboard clock, and 16 registers eliminating the need for external RAMS in the final unit.

Thermocouples, though nonlinear, are used because their use is widespread in the aircraft industry. Thus, the digital display will be easy to hook up to, using existing sensors in most cases. For this project only, the reference for the thermocouple will be another thermocouple kept in ice water at equilibrium,

Also for this project only, switches, Hexadecimal display, and volatile RAMs are used to facilitate programming and modifications For a full schematic, see fig. (7) in the appendix.

3.0 uP CIRCUIT

[senior project]

3.1 The basic circuit for the 1802 uP was lifted right out of the manual, including the 1822 type CMOS RAMS, fig. (1). The data address and control lines from uP to RAMs, etc, are matched to appropriate pins, the R/W line being a selectable memory-protect (using s switch). CE2 is used as a standby memory protect along with a 3.5v self-charging battery supply, which is blocked by a diode from the rest of the circuit.

The data lines are routed out to an 8 bit bus to be used by other devices in the circuit.

A one MHz crystal was used for the clock frequency. All other unused inputs are tied high with a 47K resistor, except RAM CE 1, which is tied directly to ground fully selecting these RAMs (Since the 8 bit address lines fully cover the given 256 bytes).

3.2 The control elements were mostly gained from an article in Popular Electronics (Aug. 1976) on using the 1802 in a minimal system [called ELF].

Most switches are de-bounced by the use of SPDT switches and buffers, as shown in the schematic.

The switches are gated directly onto the data bus using the DMA facility and buffered by 4016 electronic switches controlled by some logic for timing, This provides a means to program, Step by step.

When CLEAR(not) on the processor is high, it is in Run mode. Reset occurs when WAiT(not) = 1 and CLEAR(not) = 0. When Wait(not) is low, it is in DMA mode (direct memory access). To affect the DMA load, DMA must go low, accomplished by flip flop IC12 and reset by the "DMA comeplete“ signal from SCI. All this is accomplished by the use of debounced switches for RUN, LOAD and RESET, as shown in the schematic, and allows simple Control over most functions

3.3 The displays are Hexadecimal LED with latches and decoders on board. This simplifies the output and loading of memory, but will be replaced later by 7 segment LEDs for cost savings at the expense of more programming to do the decoding.

Since the displays are TTL, buffers were needed to drive them. They are latched in by TPB, MREAD(not) and LOAD switch so that each number loaded is latched int. The LOAD input is wire or'ed with an output line, such that the display can be processor controlled also.

4.0 A/D CONVERTER

[senior project]

4.1 The 5357 A/D was chosen because it is inexpensive, available, and provides 8 bit data. 8 bits are convenient to work with and of sufficient accuracy to cover 100; or even 200, degrees of temperature range, It also has 3 state outputs for direct connection to the data bus.

4.2 The circuit is shown in fig. (3) including 4503 three state buffers on the data bus which were used only to check out the A/D control functions and are now not needed.

N0 gives the "start conversion" signal and N1 gives the enable signal after EF1 reads the "end of conversion" (E.O.C.) signal from the A/D. The Ns are outputs from the uP and the EFs are inputs. The A/D is so fast that it may not be necessary to wait for the E.O.C. signal as it will be finished before the first look, thus saving programming space. (br clear=all>

5.0 SENSOR AND SIGNAL CONDITIONER

[senior project]

5.1 The thermocouple used as the sensor is of a standard aircraft variety. It is also necessary to have a reference thermocouple, in this case to be dipped in ice water. It is the same bi-metal, iron constantan. Refer to appendix, fig. (9). The pots at Gain and Offset provide calibration adjustments. The Offset sets 0 volts when both thermocouples are immersed in ice water. The Gain sets the 3.92_volt output when the sensor is in boiling water and the reference is still in ice water. This will allow one degree of temperature rise to be one bit change in data input.

[senior project]

From Omega Engineering's "Temperature Measurement Handbook," the temperature/voltage relationship was plotted. Thus the correction factors necessary are calculated and programmed in.

5.2 The signal conditioner and thermocouples schematic is shown in fig. (A). Using a 741 with external offset and in an integrating configuration reduce the noise problems while still giving the greater than 1000 gain necessary. The pots, Gain and Offset, mentioned above are shown and the rest of the circuit is straight forward.

6.0 PROGRAMMING

[senior project]

6.1 Before the actual working program can begin, some house keeping must be done. Refer to Fig. (5), the flow chart, or fig. (8), the program listing. Working registers must be cleared or initialized to some value. For instance, there are 16 registers aivailable in the uP, called R(0) to R(F). R(0) will be the program counter automatically, unless changed later. Then R(3) can be the data temporary register but need not be cleared. R(2) can be set to the address just before the first correction factor, as it will always be incremented at least once. We can set R(1) = 0 for the Hex to decimal subroutine use, but since it is loaded for temperature storage, it is not necessary to clear it at all.

6.2 Again, the A/D must be signaled to start its conversion. A 61 (all instructions are in Hexadecimal) instruction will cause one of the outputs N0 to pulse high as it is connected to the Start conversion input of the A/D, as stated earlier. Putting the 61 at the beginning of the program allows enough time for the A/D to work so that no "end of conversion" test is needed. A 6A simultaneously pulses the N1 (to A/D enable) hi and loads the data into the designated memory location (and also the "D" register, to work with).

Next, a loop is set up, incrementing the address of the correction factor every time we add the length of the segment the correction factor covers (stopping at overflow). In this way, the address ia chosen in a very short loop. For example, if the number put in is 40(base 10) and the overall 256 levels are corrected every 32 bits (giving 8 correction factors), the program will add one to the address register (making it the first correction factor} then add 32 (20 hex) to the data number in D and check for overflow. It keeps this up in a loop until it does overflow. Thus it has now added 7 to the address and is at the 7th correction factor corresponding to numbers between 32 and 64. After that, it fetches the correction factor and adds it into the original number stored in memory.

6.3 Since the number from the A/D is the complement of the input data, it must now be complemented again before outputting.

An adjustment must also be made so the Hexadecimal displays only read 0 to 99. A check is made to see if the corrected data is greater than 245 (less than 10 in actuality because of the A/D complimenting). If it is, the corrected data wili bs complemented and gated out. If not less than 10 (greater than 245 compliment), adding 10 to the data and checking for overflow, each time adding 6 to a register {R(4)) will give the correct number of 6s to the data to display in decimal instead of Hex. For example, if the data is 10, add one 6 to a Hex display of 0A to get 10 in Hex. Lastly, return to start and reinitialize all registers.

7.0 RESULTS AND FINDINGS

The results of the project such as the accuracy and number of program steps were better than expected. The stated accuracy was 5% and the obtained accuracy is approximately 3% worst case‘ The program used only about 50 bytes.

The 1802 uP has a good selection of instructions but some of them are harder to get used to than others. Programming this uP is not easy until one has worked with it awhile, at least a period of adaptation is needed.

Too many supply levels (+5, -5, -12) caused some problems but these were corrected. Care must be taken using the Thermocouples and References also.

The greatest problems arose getting the uP to communicate with the A/D, The start conversion signal appeared too fast for the A/D and needed to be slowed down. The end of conversion signal was in turn too difficult for the uP to see in a looping search.

This was found to be a stimulating and useful project and a good preliminary introduction to the 1802. It also goes far in pointing the way to the final saleable temperature display mentioned earlier.

8.0 COST SUMMARY

1802 uP            $30
4050 RAMs          $15
Hex displays       Donated
A/D                $13
Other ICs          $ 6
Hardware           $ 3
Temperature sensor Donated
Misc.              $ 5
                --------
                   $73
ICs destroyed
        in test    $ 6
                -----
Project total      $79

9.0 CONCLUSIONS

In conclusion, it can be safely stated that the initial goals were met, the necessary knowledge was gained to go on to the next phase and in general the project is considered a success. The device was designed, constructed and tested, and presented as a working unit meeting stated objectives within the allowed time with a comfortable margin of safety overall.

10.1 PARTS LIST

C1 C4 C5 C10 .1 uf 1000v
G2 330 uf 16v
03 15pf 1ooov
C6, C7 250 uf 25v
C8, C9 50 uf 25v
D1 to D6 1N914
D8 RED LED
IC1 CDP1802 RCA uP
IC2, IC3 5040 CMOS RAMs
IC4, IC5 4050
IC6, IC7 HP 5082 ~ 7340 Hex display
IC8, IC9 4016
IC10 4023
IC11 4049
IC12 4013
IC13 MM5357 A/D
IC14, IC15 4503 3 state buffers
IC16 741 OP AMP
R1 to 7 47k
R8 10 MEG
R9 1k
R10 5k
R11, 12 100
R13 4.7k
R14 115k
R15, 16 10
R17 15k POT
R18 5k POT
R19,R20 500 POT
S0 to S11 SPDT
S12 NO NC push button

10.2 SCHEMATIC

[The full schematic was not available but the partial schematics shown are sufficient. - Herb]

10.3 PROGRAM LISTING

[Note: the original code was hand-assembled. This listing was from a cross-assembler, with labels and some minor corrections added to the code. The comments are almost all the same. - Herb

0000                 	ORG 0000H
                        
0000                 START:
0000   61            	OUT  1		;start A/D
0001   f8 24         	LDI  LOW DATA	;load D with 24
0003   a3            	PLO  3		;R3 data addr
0004   a2            	PLO  2		;R2 correction addr
0005   e3            	SEX  3		; X ->R3
0006   6a            	INP  2		;input A/D complimented data
0007                 LOOP:
0007   12            	INC  2		;incr R2, select corr factor
0008   fc 20         	ADI  20H	;add 20H 32D to D
000a   33 07         	BPZ  LOW LOOP	;goto 07 if no overflow
                        		;R2-> right corr factor
000c   42            	LDA  2		;M(R2)->D
000d   f4            	ADD		;M(R(X))+D -> D
                        		;add correction factor to data
000e   53            	STR  3		;D -> M(R3), save result
                        		;hex to decimal 0-99 for display
                        		; data is in c'ment form see text
000f   fc 0a         	ADI  0AH	;add 0AH (ten) to D
0011                 NEXT:
0011   33 1d         	BPZ  OFLO	;on overflow goto 1DH
0013   a1            	PLO  1		;D ->R1		
0014   f8 06         	LDI  06H	;06 -> D
0016   f5            	SD		;subtract M(R(X))-D -> D
0017   53            	STR  3		;D ->M(R3)
0018   81            	GLO  1		;R1 -> D		
0019   fc 0a         	ADI  0AH	;add 0AH to D
001b   30 11         	BR   NEXT	;goto 11H
001d                 OFLO:
001d   f0            	LDX		;load D from M(R(X))
001e   fb ff         	XRI  0FFH	;XOR D with FF to c'ment data
0020   53            	STR  3		;put data back in R3
0021   64            	OUT  4		;output to display
0022   30 00         	BR   START
0024                 DATA:
0024   00            	DB   00		;data storage
0025   00 01 00 00   	DB   00,01,00,00 ; correction factors
0029   ff fe fd fc   	DB   0FFH, 0FEH, 0FDH, 0FCH 
002d                 	END

10.4 Thermocouple Graph

[senior project]

For more information

Gary Camp has his own Web site at 4freeideas.weebly.com, and has a Web page about his NASA and APL spacecraft work.

At this linked Web page, Gary discusses with Herb Johnson, his work on this senior project and his NASA and JPL activites.


edited and published by Herb Johnson, New Jersey, USA
developed and written by Gary Camp
here's how to email and order @ me

Copyright © 2015 Herb Johnson