امروز برابر است با :6 دی 1403

DigiThermo 0-100 °C

DigiThermo 0-100 °C

Wichit Sirichote, kswichit@kmitl.ac.th 

Build your own a laboratory instrument for measuring time and temperature. The DigiThermo demonstrates the use of ‘C’ language, a dual-slope converter, LCD interfacing, and digital filtering as well.

شكل : اينجا را كليك نماييد

Introduction

The DigiThermo is a device designed for measuring time and temperature used in chemistry laboratory. The circuit of Digithermo employs a 89C4051, 20-pin CMOS Microcontroller with built-in 4kB code memory. Temperature was measured by LM35D, National Semiconductor Temperature sensor producing 10mV/°C. The CA3162, 3-digit DVM converts dc output provided by LM35D and sends BCD output to port1 (P1.0-P1.3). The program resided in code memory of 89C4051 was written in ‘C’ language, thermo.c. The program read BCD output from the A/D converter, performs digital filtering,10-point moving average, and sends the output reading to a 16×1 line LCD display. A 10ms cputick was used as a timebase producing 1 s for time counting. The LCD displays time in 1 s and temperature in 0.1°C resolutions.

Circuit Description

Figure 1 depicts circuit diagram of the DigiThermo. The MCU is ATMEL 89C4051 CMOS Microcontroller having 4kB code memory, 128 bytes On-chip RAM and 8-bit Port1 and Port3. The A/D chip is HARRIS CA3162, 3-digit DVM. The A/D converter employs dual-slope integrator providing 10Hz sampling rate. Digital output sent to MCU is multiplex four bit BCD started from MSD, LSD and NSD respectively. The MSD signal was tied to P3.7 indicating first digit ready to be read. Integrating capacitor is a 330nF Polyester type. The 10k POT connected to pin13 is a gain adjustment and 50k POT to pin 8 and 9 is for zero adjustment. The input of the converter is true differential pin 11 for HI and pin 10 LO signal. Temperature was measured by a precision solid-state sensor from National Semiconductor, LM35D. The output signal is 10mV/°C. Since the A/D converter is capable of providing 0-1000mV reading with 1mV resolution, thus the converter can resolve 0.1°C (not absolute accuracy). A 100k and 0.02uF forms a first order low-pass filter used to be front-end hardware filtering. The 16×1 line LCD is connected in 4-bit interfacing to P1.4-P1.7 with control signal RS and E to P3.4 and P3.5 respectively. The +5V power supply uses a 78L05 TO92 case with external +9V adapter.

Figure 2: Circuit Diagram of the DigiThermo

 

شكل: اينجا را كليك نماييد

Software

The program thermo.c that control the Digithermo was written in ‘C’ language and was compiled by Micro-C Compiler from Dunfiled Development Systems. The memory model is TINY that use minimal hardware, i.e., single chip mode. The hex file of thermo.c suitable for downloading by Easy-Downloader V1.1 is thermo.hex. Variables and stack use the area of 128-byte on-chip RAM. Figure 2 depicts pseudo code of the control

program.

 

initialize timer0 

init variable 

init LCD module 

put title message to LCD buffer 

do forever 

{ do the following tasks every 100 ms; 

time(); /* update time base */ 

putxin(); /* put converted digital data to 10-word FIFO buffer */ 

puttemp(); /* put temperature reading to LCD */ 

puttime(); /* put second counter to LCD */ 

}

Figure 2: Pseudo code of program thermo.c

Main program separates tasks into four tasks, i.e., time( ), putxin( ), puttemp( ), and puttime( ). These tasks were executed every 100ms. Time( ) set FLAG1 bit0, bit1 and bit2 when time has elapsed 100ms, 1st 10 count, and 1s respectively. Putxin( ) shifts a converted digital word to LSW of 10-word registers performing 10-point data moving. Puttemp( ) computes average value of 10-sample and put to LCD buffer. Similarly puttime( ) writes variable count to LCD buffer. The device driver routines are readadc( ), read BCD from CA3162, LCDINI( ), initialize LCD, LCDWI( ), write LCD instruction, LCDWD( ), write ASCII code to LCD buffer, pulseE( ) generates Enable pulse, and delay(n), delay n milliseconds. As seen in the listing of thermo.c program, some function has embedded assembly code because of time critical requirements. Variable ACC and temp are used to pass value to and from ‘C’ program. Please study in details writing style and variables usage.

Zero and Gain of A/D Adjustment

Before inserting LM35D, A/D needs a bit adjustment by adjusting ZERO which done by short pin HI and LO to GND. Then adjust 50k POT at pin 8 and 9 until temperature reading is 0. Put the reference voltage source 500mV to input of the A/D, adjust 10k POT until display shows 50.0.

Calibrating Temperature Reading

Although the LM35D is calibrated to Celsius, gain of the CA3162 may influence directly to accuracy of the reading. It is good idea to make calibration with standard thermometer. Theoretically, the standard thermometer to be used as a reference should provide more precision at least one order. Suppose we want to calibrate our Digithermo with the designed precision of 0.1 °C, the standard reference should have precision at least 0.01 °C. Not easy to find the reference right? Assume you may get one but having only 0.1 °C resolution for our calibration. First you need to have a temperature reservoir to put the reference thermometer and LM35D probe together. Ensure both are at the same temperature. Let the desired temperature range to be calibrated is 0-20.0 °C. Start records both readings from 0 to 20.0 by slowly warming the reservoir. An exemplary (not real measurement) of such recording data would be as shown in Table1.

TABLE 1 Recording of Temperature read by DigiThermo and Reference Thermometer

 

Sample

DigiThermo

Reading(‘C)

Reference

Reading(‘C)

1

0.0

0.1

2

1.0

0.9

3

2.0

2.1

4

3.0

3.2

5

4.1

3.9

6

5.2

5.0

7

6.0

5.9

8

6.9

7.1

9

8.0

8.3

10

9.3

9.1

11

10.2

10.5

12

11.0

11.2

13

12.1

12.6

14

13.3

13.0

15

14.6

14.2

16

15.5

15.1

17

16.8

16.3

18

17.1

17.3

19

18.0

18.4

20

19.1

19.5

To find the correlation between our instrument and the reference may easily done by using linear regression function in Excel spreadsheet. Plot the reading of the Digithermo in X-axis and reference in Y-axis. Plot trend line using linear least square, we get the correlation equation as Y = 1.0053X – 0.0115. With this equation, reading from Digithermo is then easily be adjusted to the value read as read by reference thermometer. However the 1st version of DigiThermo does not provide such equation in the source program. Student should try insert the equation with some adaptation, since Micro-C math provides only integer mathematics.

 دريافت اين مقاله بصورتPDF

http://www.4shared.com/file/1180491/d77f8ff4/termo_digital.html

bselectron.mihanblog.com

اشتراک گذاری