You are on page 1of 55

DATA ACQUISITION AND LOGGING SYSTEM

1. INTRODUCTION
The processes to collect, analyze and store the data for later use is called logging. In this to record events during a test or measurement with the use of a system. The human brain and its memory, the natures creation, no doubt is the best data logging mechanism. Where there is the need to collect information faster than a human, data loggers can possibly collect the information and in cases where accuracy is essential. A data logger is a device that can be used to store and retrieve the data .Data logging also implies the control of how sensor collects and analyzes the data. It is commonly used in scientific experiments and in monitoring systems. The type of information recorded is determined by the user. Temperature is the ever-changing parameter because of exposition to huge array of stimuli from their environment. All of them infer temperature by sensing some change in a physical characteristic. So the measured temperature is different from the actual temperature of the system. In such a case the measured temperature will vary not only with the temperature of the system, but also with the heat transfer properties of the system. The objective of this work is to use data logging for temperature measurement. In order to meet the above requirements, a low cost, versatile, portable data logger is designed. A microcontroller based temperature data logger has been developed for measuring temperature at different input channels of ADC. The device is designed to receive data from temperature sensors and to store the results on external non-volatile electrically erasable programmable read only memory (EEPROM) for post process analysis. A pc also used for real time display of data acquired from various sensors.

1.1 Embedded systems:


An embedded system can be defined as a computing device that does a specific focused job. Appliances such as the air-conditioner, VCD player, DVD player, printer, fax machine, mobile phone etc. are examples of embedded systems. Each of these appliances will have a processor and special hardware to meet the specific requirement of the application along with the embedded software that is executed by the processor for meeting that specific requirement. The embedded software is also called firm ware. The desktop/laptop computer is a general purpose computer. You can use it for a
SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 1

DATA ACQUISITION AND LOGGING SYSTEM

variety of applications such as playing games, word processing, accounting, software development and so on. In contrast, the software in the embedded systems is always fixed listed below. Embedded systems do a very specific task; they cannot be programmed to do different things. Embedded systems have very limited resources, particularly the memory. Generally, they do not have secondary storage devices such as the CDROM or the floppy disk. Embedded systems have to work against some deadlines. A specific job has to be completed within a specific time. In some embedded systems, called real-time systems, the deadlines are stringent. Missing a deadline may cause a catastrophe-loss of life or damage to property. Embedded systems are constrained for power. As many embedded systems operate through a battery, the power consumption has to be very low. Some embedded systems have to operate in extreme environmental conditions such as very high temperatures and humidity. 1.1.1 Embedded System Architecture: Let us see the details of the various building blocks of the hardware of an embedded system. As shown in Fig 2.1 the building blocks are: Central Processing Unit (CPU) Memory (Read-only Memory and Random Access Memory) Input Devices Output devices Communication interfaces Application-specific circuitry

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 2

DATA ACQUISITION AND LOGGING SYSTEM

Fig 1.1.1 Block Diagram of Hardware of Embedded System

1.1.1.1 Central Processing Unit (CPU): The Central Processing Unit (processor, in short) can be any of the following: microcontroller, microprocessor or Digital Signal Processor (DSP). A micro-controller is a low-cost processor. Its main attraction is that on the chip itself, there will be many other components such as memory, serial communication interface, analog-to digital converter etc. So, for small applications, a micro-controller is the best choice as the number of external components required will be very less. On the other hand, microprocessors are more powerful, but you need to use many external components with them. D5P is used mainly for applications in which signal processing is involved such as audio and video processing. 1.1.1.2 Memory: The memory is categorized as Random Access 11emory (RAM) and Read Only Memory (ROM). The contents of the RAM will be erased if power is switched off to the chip, whereas ROM retains the contents even if the power is switched off. So, the firmware is stored in the ROM. When power is switched on, the processor reads the ROM; the program is program is executed. 1.1.1.3 Input Devices: Unlike the desktops, the input devices to an embedded system have very limited capability. There will be no keyboard or a mouse, and hence interacting with the
SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 3

DATA ACQUISITION AND LOGGING SYSTEM

embedded system is no easy task. Many embedded systems will have a small keypadyou press one key to give a specific command. A keypad may be used to input only the digits. Many embedded systems used in process control do not have any input device for user interaction; they take inputs from sensors or transducers produce electrical signals that are in turn fed to other systems. 1.1.1.4 Output devices: The output devices of the embedded systems also have very limited capability. Some embedded systems will have a few Light Emitting Diodes (LEDs) to indicate the health status of the system modules, or for visual indication of alarms. A small Liquid Crystal Display (LCD) may also be used to display some important parameters. 1.1.1.5 Communication interfaces: The embedded systems may need to, interact with other embedded systems at they may have to transmit data to a desktop. To facilitate this, the embedded systems are provided with one or a few communication interfaces such as RS232, RS422, RS485, Universal Serial Bus (USB), and IEEE 1394, Ethernet etc. 1.1.1.6 Application-specific circuitry: Sensors, transducers, special processing and control circuitry may be required fat an embedded system, depending on its application. This circuitry interacts with the processor to carry out the necessary work. The entire hardware has to be given power supply either through the 230 volts main supply or through a battery. The hardware has to design in such a way that the power consumption is minimized.

1.2 Literature Survey:


1. Implementation of microcontroller based system interface for a multi channel data acquisition system: The microcontroller 8051 is interfaced with external memory, key board and a graphical LCD module. The multi channel data acquisition system stores in external memory. With the help of micro controller data is fetched from external memory. The display through LCD will be provided depending on the request from keyboard at regular intervals.
SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 4

DATA ACQUISITION AND LOGGING SYSTEM

2. Microprocessor based data logging system: This data logging system can be used in the laboratories for monitoring and measurement the values of the slowly varying signals. This system is based upon microchips PIC16C73A microcontroller and stores over 4000 digital data values. Logs the data for a limited number of weeks with a power supply of 4AA alkaline batteries. 3. Data acquisition and logging system: Our data acquisition system (DAQ) should perform better than the existing ones in terms of lower cost, flexibility and accuracy. These are achieved by interfacing high performance microcontroller (AT89C51) with other architectural platforms. Using front end Analog to Digital converters and pc interfacing flexibility is highly improved it also monitors and controls the system parameters.

1.3 Advantages:
Allows us to view all the parameter readings simultaneously on the PC screen. Data logging can be carried out 24hours a day, 365 days of the year. Data logging is often more accurate because there is no like hood of human error.

1.4 Applications:
1. Useful in industries like: Textile mill. Pharmaceutical industry.

2. Weather station recording. 3. Research labs.

1.5 Organization of the project:


Chapter 2 deals with the Block Diagram description and individual block description of Data Acquisition systems. Chapter3 includes Hardware circuit and component description and working of DAQ. In chapter 4 we discussed about software tools like Kiel software and daq software. Finally in chapter 5 we discussed about result of the DAQ, Conclusion, future scope, appendix, terminology.
SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 5

DATA ACQUISITION AND LOGGING SYSTEM

2. BLOCK DIAGRAM
2.1 Block Diagram:

Fig.2.1 Block Diagram of Data acquisition and logging system

2.2 Description:
The above fig.3.1is the block diagram of data acquisition and logging system depicts the total blue print of the proposed project. The total essence and the functioning of the project is represented in a single block diagram. The block diagram mainly consists of 8 parts. They include Power supply LM35 Temperature sensor ADC0808 AT89C51 Microcontroller MAX 232 PC
Page 6

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

DATA ACQUISITION AND LOGGING SYSTEM

Relay Relay driver

2.3 Power Supply:


The input to the circuit is applied from the regulated power supply. The a.c. input i.e., 230V from the mains supply is step down by the transformer to 12V and is

fed to a rectifier. The output obtained from the rectifier is a pulsating d.c voltage. So in order to get a pure d.c voltage, the output voltage from the rectifier is fed to a filter to remove any a.c components present even after rectification. Now, this voltage is given to a voltage regulator to obtain a pure constant dc voltage.

2.4 LM35 temperature sensor:


The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage over linear temperature sensors calibrated in Kelvin, as the user is not required to subtract a large constant voltage from its output to obtain

convenient Centigrade scaling. The LM35 does not require any external calibration or trimming to provide typical accuracies of 14Cat room temperature and 34C over a full 55 to +150Ctemperature range. Low cost is assured by trimming and calibration at the wafer level.

2.5 Analog to digital converter:


Analog-to-digital converters are among the most widely used devices for data acquisition. Digital systems use binary values, but in the physical world everything is continuous i.e., analog values. Temperature, pressure (wind or liquid), humidity and velocity are the physical analog quantities. These physical quantities are to be converted into digital values for further processing. One such device to convert these physical quantities into electrical signals is sensor.

2.6 AT89C51 Microcontroller:


Microprocessors and microcontrollers are widely used in embedded systems products. Microcontroller is a programmable device. A microcontroller has a CPU in addition to a fixed amount of RAM, ROM, I/O ports and a timer embedded all on a
SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 7

DATA ACQUISITION AND LOGGING SYSTEM

single chip. The fixed amount of on-chip ROM, RAM and number of I/O ports in microcontrollers makes them ideal for many applications in which cost and space are critical. The CPU can work on only 8 bits of data at a time. Data larger than 8 bits has to be broken into 8-bit pieces to be processed by the CPU. 8051 is available in different memory types such as UV-EPROM, Flash and NV-RAM.

2.7 Max 232:


Max232 IC is a specialized circuit which makes standard voltages as required by RS232 standards. This IC provides best noise rejection and very reliable against discharges and short circuits. MAX232 IC chips are commonly referred to as line drivers. To ensure data transfer between PC and microcontroller, the baud rate and voltage levels of Microcontroller and PC should be the same.

2.8 Relay:
A relay is an electrically operated switch. Many relays use an electromagnet to operate a switching mechanism mechanically, but other operating principles are also used. Relays are used where it is necessary to control a circuit by a low-power signal (with complete electrical isolation between control and controlled circuits), or where several circuits must be controlled by one signal. The first relays were used in long distance telegraph circuits, repeating the signal coming in from one circuit and retransmitting it to another. Relays were used extensively in telephone exchanges and early computers to perform logical operations.

2.9 Relay driver:


The ULN2803 current driver is a high voltage, high current Darlington arrays each containing seven open collector Darlington pairs with common emitters. Each channel is rated at 500mA and can withstand peak currents of 600mA. Suppression diodes are included for inductive load driving and the inputs are pinned opposite the outputs to simplify board layout.

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 8

DATA ACQUISITION AND LOGGING SYSTEM

3. HARDWARE CIRCUIT AND COMPONENTS DESCRIPTION


3.1 Circuit Diagram:

Fig.3.1 Circuit Diagram of Data acquisition and logging system

3.2 Working of Project:


This is a temperature logging System .The idea of this project is to retrieve the real time data from the high temperature furnaces on computer. Four heat Sensors i.e., LM35 are used to sense the heat and an IC ADC0808 is used to convert the data into digital.LM35 digital sensor has got 3 pins i.e., VCC, GND and output pins when
SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 9

DATA ACQUISITION AND LOGGING SYSTEM

LM35 is heated the voltage at output pin increases, it is connected to the

analog to

digital convertor IC (ADC).Then the values of all the sensors are sent serially by MC through Max 32 IC to the Computer. Now MC processes this data and communicates with computer via RS232 communication and simultaneously switches ON & OFF the relays. One can set by interactive way some parameters like set point, low limit, and high limit on the computer screen. When temperature of some sensors increases beyond set point, the MC sends commands to relay driver IC ULN2803.The Max232 IC is used for RS232 communication and ULN2803 IC is used for relay control. The heaters (lamps in the test board) connected through relay contacts are (specific for that sensor) turned OFF (or ON in opposite case).When temperature goes above high limit or below low limit the alarm will be turned on. Software is used for keeping the real time records of heat sensors in computer. This software has a provision for eight sensors but only four have been used here.

3.3 Hardware Components:


Power Supply Temperature sensor ADC 0808 Microcontroller Max 232 Pc Relay Relay driver

3.3.1 Power Supply:


The input to the circuit is applied from the regulated power supply. The a.c. input i.e., 230V from the mains supply is step down by the transformer to 12V and is fed to a rectifier. The output obtained from the rectifier is a pulsating d.c voltage. So in order to get a pure d.c voltage, the output voltage from the rectifier is fed to a filter to
SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 10

DATA ACQUISITION AND LOGGING SYSTEM

remove any a.c components present even after rectification. Now, this voltage is given to a voltage regulator to obtain a pure constant dc voltage.

Fig.3.3.1 Block diagram of Power supply

3.3.1(a) Transformer: Usually, DC voltages are required to operate various electronic equipment and these voltages are 5V, 9V or 12V. But these voltages cannot be obtained directly. Thus the a.c input available at the mains supply i.e., 230V is to be brought down to the required voltage level. This is done by a transformer. Thus, a step down transformer is employed to decrease the voltage to a required level. 3.3.1(b) Rectifier: A Rectifier is an electrical device that converts alternating current (AC), which periodically reverses direction, to direct current (DC), current that flows in only one direction, a process known as rectification. Rectifiers have many uses including as components of power supplies and as detectors of radio signals. Rectifiers may be made of solid state diodes, vacuum tube diodes, mercury arc valves, and other components. A device which performs the opposite function (converting DC to AC) is known as an inverter. When only one diode is used to rectify AC (by blocking the negative or positive portion of the waveform), the difference between the term diode and the term rectifier is merely one of usage, i.e., the term rectifier describes a diode that is being used to convert AC to DC. Almost all rectifiers comprise a number of diodes in a specific

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 11

DATA ACQUISITION AND LOGGING SYSTEM

arrangement for more efficiently converting AC to DC than is possible with only one diode. 3.3.1(c) Filter: Capacitive filter is used in this project. It removes the ripples from the output of rectifier and smoothens the D.C. Output received from this filter is constant until the mains voltage and load is maintained constant. However, if either of the two is varied, D.C. voltage received at this point changes. Therefore a regulator is applied at the output stage. 3.3.1(d) Voltage regulator: As the name itself implies, it regulates the input applied to it. A voltage regulator is an electrical regulator designed to automatically maintain a constant voltage level. In this project, power supply of 5V and 12V are required. In order to obtain these voltage levels, 7805 and 7812 voltage regulators are to be used. The first number 78 represents positive supply and the numbers 05, 12 represent the required output voltage levels.

Fig.3.3.1 (d) Voltage Regulator

There are two types of regulator are they. 78xx: 78 indicate the positive series and xxindicates the voltage rating. Suppose 7805 produces the maximum 5V.05indicates the regulator output is 5V. Positive Voltage Series (78xx) and Negative Voltage Series (79xx)

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 12

DATA ACQUISITION AND LOGGING SYSTEM

79xx: 79 indicate the negative series and xxindicates the voltage rating. Suppose 7905 produces the maximum -5V.05indicates the regulator output is -5V. These regulators consists the three pins there are Pin1: It is used for input pin. Pin2: This is ground pin for regulator. Pin3: It is used for output pin. Through this pin we get the output. 3.3.2 Temperature Sensor: A sensor can be defined as a device which can convert one form of energy into electrical energy. Here we are using a sensor to sense the temperature around us. For this purpose we will be taking help of LM 35 which is a temperature sensor. 3.3.2(a) LM35: A sensor is a device that measures a physical quantity and converts it into a signal which can be read by an observer or by an instrument. For example, a mercuryin-glass thermometer converts the measured temperature into expansion and contraction of a liquid which can be read on a calibrated glass tube. A thermocouple converts temperature to an output voltage which can be read by a voltmeter. For accuracy, most sensors are calibrated against known standards.

Fig.3.3.2(a) Tempareture sensor

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 13

DATA ACQUISITION AND LOGGING SYSTEM

The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage over linear temperature sensors calibrated in Kelvin, as the user is not required to subtract a large constant voltage from its output to obtain

convenient Centigrade scaling. The LM35 does not require any external calibration or trimming to provide typical accuracies of 14Cat room temperature and 34C over a full 55 to +150Ctemperature range. Low cost is assured by trimming and calibration at the wafer level. The LM35s low output impedance, linear output, and precise inherent calibration make interfacing to readout or control circuitry especially easy. It can be used with single power supplies, or with plus and minus supplies. As it draws only 60A from its supply, it has very low self-heating, less than 0.1C in still air. The LM35 is rated to operate over a 55 to +150C temperature range, while the LM35C is rated for a 40 to +110C range (10with improved accuracy). The LM35 series is available packaged in hermetic TO-46 transistor packages, while theLM35C, LM35CA, and LM35D are also available in the plastic TO-92 transistor package. 3.3.2(b) Features: Calibrated directly in Celsius (Centigrade). Linear + 10.0 mV/C scale factor. 0.5C accuracy guarantee able (at +25C). Rated for full 55 to +150C range. Suitable for remote applications. Low cost due to wafer-level trimming. Operates from 4 to 30 volts. Less than 60 A current drain. Low self-heating, 0.08C in still air. Nonlinearity only 14C typical. Low impedance output, 0.1 W for 1 mA load.
Page 14

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

DATA ACQUISITION AND LOGGING SYSTEM

3.3.2(c) Typical Applications:

In this we directly connect the output of the sensor to the base of the transistor as of LM35 for every 1C rise of temperature the output will increase for 10mV. Now if the temperature reaches 70C the output voltage will be 0.7V which is enough for the transistor junction to be biased. Hence the transistor gets on and the output is sensed by the microcontroller. 3.3.3 Analog to digital converter: Analog-to-digital converters are among the most widely used devices for data acquisition. Digital systems use binary values, but in the physical world everything is continuous i.e., analog values. Temperature, pressure (wind or liquid), humidity and velocity are the physical analog quantities. These physical quantities are to be converted into digital values for further processing. One such device to convert these physical quantities into electrical signals is sensor. Sensors for temperature, pressure, humidity, light and many other natural quantities produce an output that is voltage or current. Thus, an analog-to-digital converter is needed to convert these electrical signals into digital values so that the microcontroller can read and process them. An ADC has an n-bit resolution where n can be 8,10,12,16 or even 24 bits. The higher resolution ADC provides a smaller step size, where step size is the smallest change that can be detected by an ADC. In addition to resolution, conversion time is another major factor in judging an ADC. Conversion time is defined as the time it takes the ADC to convert the analog input to a digital number .

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 15

DATA ACQUISITION AND LOGGING SYSTEM

Fig.3.3.3 (a) Pin diagram of ADC0808

I/O Pins Address line A, B, C The device contains 8-channels. A particular channel is selected by using the address decoder line. The table shown below the input states for address lines to select any channel.

Table 3.3.3 (b) Address lines to select any channel

Address Latch Enable ALE The address is latched on the Low High transition of ALE.

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 16

DATA ACQUISITION AND LOGGING SYSTEM

START The ADCs Successive Approximation Register (SAR) is reset on the positive edge i.e. Low- High of the Start Conversion pulse. Whereas the conversion is begun on the falling edge i.e. High Low of the pulse.

Output Enable Whenever data has to be read from the ADC, Output Enable pin has to be pulled high thus enabling the TRI-STATE outputs, allowing data to be read from the data pins D0-D7.

End of Conversion (EOC) This Pin becomes High when the conversion has ended, so the controller comes to know that the data can now be read from the data pins.

Clock External clock pulses are to be given to the ADC; this can be given either from LM 555 in A stable mode or the controller can also be used to give the pulses.

3.3.3(c) Algorithm: Start. Select the channel. A Low High transition on ALE to latch in the address. A Low High transition on Start to reset the ADCs SAR. A High Low transition on ALE. A High Low transition on start to start the conversion. Wait for End of cycle (EOC) pin to become high. Make Output Enable pin High. Take Data from the ADCs output Make Output Enable pin Low. Stop

The total numbers of lines required are: Data lines: 8


Page 17

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

DATA ACQUISITION AND LOGGING SYSTEM

ALE: 1 START: 1 EOC:1 Output Enable:1 i.e., total 12 lines. You can directly connect the OE pin to Vcc. Moreover instead of polling for EOC just put some delay so instead of 12 lines you will require 10 lines.You can also provide the clock through the controller thus eliminating the need of external circuit for clock.

Calculating Step Size: ADC 0808 is an 8 bit ADC i.e. it divides the voltage applied at Vref+ & Vref- into 28 i.e. 256 steps. Step Size = (Vref+ - Vref-)/256 Suppose Vref+ is connected to Vcc i.e. 5V & Vref- is connected to the Gnd then the step size will be Step size= (5 - 0)/256= 19.53 mv. Calculating Dout: The data we get at the D0 - D7 depends upon the step size & the Input voltage i.e. Vin. Dout = Vin /step Size. If you want to interface sensors like LM35 which has output 10mv/C then I would suggest that you set the Vref+ to 2.56v so that the step size will be Step size= (2.56 - 0)/256= 10 mv. So now whatever reading that you get from the ADC will be equal to the actual temperature. 3.3.3(d) Key specifications: Resolution 8 bits. Total Unadjusted Error 12 LSB and 1 LSB.
Page 18

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

DATA ACQUISITION AND LOGGING SYSTEM

Single Supply 5 VDC. Low Power 15 mW . Conversion Time 100 s .

3.3.3(e) ADC Interfacing with Micro controller : The ADC0808, ADC0809 data acquisition component is a monolithic CMOS device with an 8-bit analog-to-digital converter, 8-channel multiplexer and microprocessor compatible control logic. The circuit of A-to-D converter shown here is configured around ADC 0808, avoiding the use of a microprocessor. The ADC 0808 is an 8-bit A-to-D converter, having data lines D0-D7. It works on the principle of successive approximation. It has a total of eight analogue input channels, out of which any one can be selected using address lines A, B and C. Here, in this case, input channel IN0 is selected by grounding A, B and C address lines. Usually the control signals EOC (end of conversion), SC (start conversion), ALE (address latch enable) and OE (output enable) are interfaced by means of a microprocessor. Therefore the input control signals ALE and OE, being active-high, are tied to Vcc (+5 volts). The input control signal SC, being active-low, initiates start of conversion at falling edge of the pulse, whereas the output signal EOC becomes high after completion of digitization. This EOC output is coupled to SC input. As the conversion starts, EOC signal goes high. At next clock pulse EOC output again goes low, and hence SC is enabled to start the next conversion.

Fig3.3.3 (e) Interfacing with ADCO8O8 SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 19

DATA ACQUISITION AND LOGGING SYSTEM

3.3.4 AT8C51 Microcontroller: Microprocessors and microcontrollers are widely used in embedded systems products. Microcontroller is a programmable device. A microcontroller has a CPU in addition to a fixed amount of RAM, ROM, I/O ports and a timer embedded all on a single chip. The fixed amount of on-chip ROM, RAM and number of I/O ports in microcontrollers makes them ideal for many applications in which cost and space are critical. The Intel 8051 is Harvard architecture, single chip microcontroller (C) which was developed by Intel in 1980 for use in embedded systems. It was popular in the 1980s and early 1990s, but today it has largely been superseded by a vast range of enhanced devices with 8051-compatible processor cores that are manufactured by more than 20 independent manufacturers including Atmel, Infineon Technologies and Maxim Integrated Products.8051 is an 8-bit processor, meaning that the CPU can work on only 8 bits of data at a time.The microcontroller used in this project is AT89C51. Atmel Corporation introduced this 89C51 microcontroller. This microcontroller belongs to 8051 family. This microcontroller had 128 bytes of RAM, 4K bytes of on-chip ROM, two timers, one serial port and four ports (each 8-bits wide) all on a single chip. AT89C51 is Flash type 8051.The present project is implemented on Keil Uvision. In order to program the device, Proload tool has been used to burn the program onto the microcontroller. The features, pin description of the microcontroller and the software tools used are discussed in the following sections. 3.3.4(a) Description: The AT89C51 is a low-voltage, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash programmable memory. The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industry-standard MCS-51 instruction set. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer, which provides a highly flexible and cost-effective solution to many embedded control applications. In addition, the AT89C51 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and interrupt
SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 20

DATA ACQUISITION AND LOGGING SYSTEM

system to continue functioning. The power-down mode saves the RAM contents but freezes the oscillator disabling all other chip functions until the next hardware reset. 3.3.4(b) Features of AT89C51: 4K Bytes of Re-programmable Flash Memory. RAM is 128 bytes. 2.7V to 6V Operating Range. Fully Static Operation: 0 Hz to 24 MHz. Two-level Program Memory Lock. 128 x 8-bit Internal RAM. 32 Programmable I/O Lines. Two 16-bit Timer/Counters. Six Interrupt Sources Programmable Serial UART Channel. Low-power Idle and Power-down Modes.

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 21

DATA ACQUISITION AND LOGGING SYSTEM

Fig3.3.4(c) Block diagram

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 22

DATA ACQUISITION AND LOGGING SYSTEM

3.3.4(d) Pin Diagram:

Fig3.3.4 (d) Pin Diagram

Pin Description: VCC: Pin 40 provides supply voltage to the chip. The voltage source is +5V. GND: Pin 20 is the ground. XTAL1 and XTAL2: XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier that can be configured for use as an on-chip oscillator, as shown in Figure 11. Either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven, as
SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 23

DATA ACQUISITION AND LOGGING SYSTEM

shown in the below figure. There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed.

Fig3.3.4 (e) Oscillator Connections

C1,C2=30pF10Pf C1,C2= 40 pF 10 pF for Ceramic Resonators RESET:

for

Crystal

Pin9 is the reset pin. It is an input and is active high. Upon applying a high pulse to this pin, the microcontroller will reset and terminate all the activities. This is often referred to as a power-on reset. EA (External access): Pin 31 is EA. It is an active low signal. It is an input pin and must be connected to either Vcc or GND but it cannot be left unconnected. The 8051 family members all come with on-chip ROM to store programs. In such cases, the EA pin is connected to Vcc. If the code is stored on an external ROM, the EA pin must be connected to GND to indicate that the code is stored externally. PSEN (Program store enable): This is an output pin.

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 24

DATA ACQUISITION AND LOGGING SYSTEM

ALE (Address latch enable): This is an output pin and is active high. . PORTS 0, 1, 2 & 3: The four ports P0, P1, P2 and P3 each use 8 pins, making them 8-bit ports. All the ports upon RESET are configured as input, since P0-P3 have value FFH on them.

PORT 0(P0): Port 0 is also designated as AD0-AD7, allowing it to be used for both address and data. ALE indicates if P0 has address or data. When ALE=0, it provides data D0D7, but when ALE=1, it has address A0-A7. Therefore, ALE is used for demultiplexing address and data with the help of an internal lath. When there is no external memory connection, the pins of P0 must be connected to a 10K-ohm pull-up resistor. This is due to the fact that P0 is an open drain. With external pull-up resistors connected to P0, it can be used as a simple I/O, just like P1 and P2. But the ports P1, P2 and P3 do not need any pull-up resistors since they already have pull-up resistors internally. Upon reset, ports P1, P2 and P3 are configured as input ports. PORT 1 & PORT 2: With no external memory connection, both P1 and P2 are used as simple I/O. With external memory connections, port 2 must be used along with P0 to provide the 16-bit address for the external memory. Port 2 is designated as A8-A15 indicating its dual function. While P0 provides the lower 8 bits via A0-A7, it is the job of P2 to provide bits A8-A15 of the address. PORT 3: Port 3 occupies a total of 8 pins, pins 10 through 17. It can be used as input or output. P3 does not need any pull-up resistors, the same as port 1 and port 2. Port 3 has an additional function of providing some extremely important signals such as interrupts.

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 25

DATA ACQUISITION AND LOGGING SYSTEM

Table.3.3.4 (f) Port 3 Alternate Function

Addressing Modes: While operating, processor processes data according to the program instructions. Each instruction consists of two parts. One part describes what should be done and another part indicates what to use to do it. This later part can be data (binary number) or address where the data is stored. All 8051 microcontrollers use two ways of addressing depending on which part of memory should be accessed: Direct Addressing: On direct addressing, a value is obtained from a memory location while the address of that location is specified in instruction. Only after that, the instruction can process data. Obviously, a number being changed during operating a variable can reside at that specified address. For example: Since the address is only one byte in size ( the greatest number is 255), this is how only the first 255 locations in RAM can be accessed in this case the first half of the basic RAM is intended to be used freely, while another half is reserved for the SFRs. Indirect Addressing: On indirect addressing, a register which contains address of another register is specified in the instruction. A value used in operating process resides in that another register. For example: Only RAM locations available for use are accessed by indirect addressing (never in the SFRs). For all latest versions of the microcontrollers with additional memory block (those 128 locations in Data Memory), this is the only way of
SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 26

DATA ACQUISITION AND LOGGING SYSTEM

accessing them. Simply, when during operating, the instruction including @ sign is encountered and if the specified address is higher than 128 (7F hex.), the processor knows that indirect addressing is used and jumps over memory space reserved for the SFRs. Machine cycle for 8051: The CPU takes a certain number of clock cycles to execute an instruction. In the 8051 family, these clock cycles are referred to as machine cycles. The length of the machine cycle depends on the frequency of the crystal oscillator. The crystal oscillator, along with on-chip circuitry, provides the clock source for the 8051 CPU. The frequency can vary from 4 MHz to 30 MHz, depending upon the chip rating and manufacturer. But the exact frequency of 11.0592 MHz crystal oscillator is used to make the 8051 based system compatible with the serial port of the IBM PC. The assembly language program is written and this program has to be dumped into the microcontroller for the hardware kit to function according to the software. The program dumped in the microcontroller is stored in the Flash memory in the microcontroller. Before that, this Flash memory has to be programmed and is discussed in the next section. Programming the flash: The At89C51 is normally shipped with the on-chip Flash memory array in the erased state (that is, contents = FFH) and ready to be programmed. The programming interface accepts either a high-voltage (12-volt) or a low-voltage (VCC) program enable signal. The low-voltage programming mode provides a convenient way to program the At89C51 inside the users system, while the high-voltage programming mode is compatible with conventional third party Flash or EPROM programmers. The At89s52 is shipped with either the high-voltage or low-voltage programming mode enabled. The respective top-side marking and device signature codes are listed in the following table.

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 27

DATA ACQUISITION AND LOGGING SYSTEM

Table.3.3.4 (i) Top side marking & Device Signature codes

The At89c51 code memory array is programmed byte-byte in either programming mode. To program any nonblank byte in the on-chip Flash Memory, the entire memory must be erased using the Chip Erase Mode. Programming Algorithm: Before programming the At89C51, the address, data and control signals should be set up according to the Flash programming mode table. To program the At89C51, the following steps should be considered: Input the desired memory location on the address lines. Input the appropriate data byte on the data lines. Activate the correct combination of control signals. Raise EA/VPP to 12V for the high-voltage programming mode. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The byte-write cycle is self-timed and typically takes no more than 1.5 ms. Repeat steps 1 through 5, changing the address and data for the entire array or until the end of the object file is reached. Data Polling: The At89C51 features Data Polling to indicate the end of a write cycle. During a write cycle, an attempted read of the last byte written will result in the complement of the written datum on PO.7. Once the write cycle has been completed, true data are valid

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 28

DATA ACQUISITION AND LOGGING SYSTEM

on all outputs, and the next cycle may begin. Data Polling may begin any time after a write cycle has been initiated. Ready/Busy: The progress of byte programming can also be monitored by the RDY/BSY output signal. P3.4 is pulled low after ALE goes high during programming to indicate BUSY. P3.4 is pulled high again when programming is done to indicate READY. Chip Erase: The entire Flash array is erased electrically by using the proper combination of control signals and by holding ALE/PROG low for 10 ms. The code array is written with all 1s. The chip erase operation must be executed before the code memory can be re-programmed. Reading the Signature Bytes: The signature bytes are read by the same procedure as a normal verification of locations 030H, 031H, and 032H, except that P3.6 and P3.7 must be pulled to a logic low. The values returned are as follows. (030H) = 1EH indicates manufactured by Atmel (031H) = 51H indicates at89s52 (032H) = FFH indicates 12V programming (032H) = 05H indicates 5V programming Programming Interface: Every code byte in the Flash array can be written and the entire array can be erased by using the appropriate combination of control signals. The write operation cycle is self timed and once initiated, will automatically time itself to completion. All major programming vendors offer worldwide support for the Atmel microcontroller series.

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 29

DATA ACQUISITION AND LOGGING SYSTEM

Table.3.3.4 (J) Flash Programming Mode

3.3.5 Relays: A relay is an electrically controllable switch widely used in industrial controls, automobiles and appliances. The relay allows the isolation of two separate sections of a system with two different voltage sources i.e., a small amount of voltage/current on one side can handle a large amount of voltage/current on the other side but there is no chance that these two voltages mix up.

Fig.3.3.5 Circuit symbol of a relay

Perform logical operations. Operation: When a current flow through the coil, a magnetic field is created around the coil i.e., the coil is energized. This causes the armature to be attracted to the coil. The armatures contact acts like a switch and closes or opens the circuit. When the coil is not energized, a spring pulls the armature to its normal state of open or closed. There are all types of relays for all kinds of applications.

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 30

DATA ACQUISITION AND LOGGING SYSTEM

Fig3.3.5 (A) Relay Operation and use of protection diode

Transistors and ICs must be protected from the brief high voltage 'spike' produced when the relay coil is switched off. The above diagram shows how a signal diode (eg 1N4148) is connected across the relay coil to provide this protection. The diode is connected 'backwards' so that it will normally not conduct. Conduction occurs only when the relay coil is switched off, at this moment the current tries to flow continuously through the coil and it is safely diverted through the diode. Without the diode no current could flow and the coil would produce a damaging high voltage 'spike' in its attempt to keep the current flowing. In choosing a relay, the following characteristics need to be considered: 1.The contacts can be normally open (NO) or normally closed (NC). In the NC type, the contacts are closed when the coil is not energized. In the NO type, the contacts are closed when the coil is energized. 2.There can be one or more contacts. i.e., different types like SPST (single pole single throw), SPDT (single pole double throw) and DPDT (double pole double throw) relays. The voltage and current required to energize the coil. The voltage can vary from a few volts to 50 volts, while the current can be from a few milliamps to 20milliamps. 3. The relay has a minimum voltage, below which the coil will not be energized. This minimum voltage is called the pull-in voltage. 4.The minimum DC/AC voltage and current that can be handled by the contacts. This is in the range of a few volts to hundreds of volts, while the current can be from a few amps to 40A or more, depending on the relay.
SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 31

DATA ACQUISITION AND LOGGING SYSTEM

Vcc

AT89C51 P1.0

RELAY

GROUND

Fig.3.3.5 (b) Relay interfacing with microcontroller

3.3.6 Relay driver: The ULN2803 current driver is a high voltage, high current Darlington arrays each containing seven open collector Darlington pairs with common emitters. Each channel is rated at 500mA and can withstand peak currents of 600mA. Suppression diodes are included for inductive load driving and the inputs are pinned opposite the outputs to simplify board layout. These versatile devices are useful for driving a wide range of loads including solenoids, relays DC motors, LED displays filament lamps, thermal print heads and high power buffers. This chip is supplied in 16 pin plastic DIP packages with a copper lead frame to reduce thermal .

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 32

DATA ACQUISITION AND LOGGING SYSTEM

Fig.3.3.6 (a) Pin Connection

3.3.6(b) Transistor Driver Circuit: An SPDT relay consists of five pins, two for the magnetic coil, one as the common terminal and the last pins as normally connected pin and normally closed pin. When the current flows through this coil, the coil gets energized. Initially when the coil is not energized, there will be a connection between the common terminal and normally closed pin. But when the coil is energized, this connection breaks and a new connection between the common terminal and normally open pin will be established. Thus when there is an input from the microcontroller to the relay, the relay will be switched on. Thus when the relay is on, it can drive the loads connected between the common terminal and normally open pin. Therefore, the relay takes 5V from the microcontroller and drives the loads which consume high currents. Digital systems and microcontroller pins lack sufficient current to drive the microcontrollers pin can provide a maximum of 1-2milli amps current. For this reason, a driver such as a power transistor is placed in between the microcontroller and the relay.

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 33

DATA ACQUISITION AND LOGGING SYSTEM

AT89C51 P. 1.0

DRIVER RELAY CIRCUIT HEATER

Fig.3.3.6 (b) Relay driver interfacing with microcontroller

The operation of this circuit is as follows:

The input to the base of the transistor is applied from the microcontroller port pin P1.0. The transistor will be switched on when the base to emitter voltage is greater than 0.7V (cut-in voltage). Thus when the voltage applied to the pin P1.0 is high i.e., P1.0=1 (>0.7V), the transistor will be switched on and thus the relay will be ON and the load will be operated. When the voltage at the pin P1.0 is low i.e., P1.0=0 (<0.7V) the transistor will be in off state and the relay will be OFF. Thus the transistor acts like a current driver to operate the relay accordingly. 3.3.7 Switch Interfacing: CPU accesses the switches through ports. Therefore these switches are connected to a microcontroller. This switch is connected between the supply and ground terminals. A single microcontroller (consisting of a microprocessor, RAM and EEPROM and several ports all on a single chip) takes care of hardware and software interfacing of the switch. These switches are connected to an input port. When no switch is pressed, reading the input port will yield 1s since they are all connected to high (Vcc). But if any switch is pressed, one of the input port pins will have 0 since the switch pressed provides the path to ground. It is the function of the microcontroller to scan the switches
SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 34

DATA ACQUISITION AND LOGGING SYSTEM

continuously to detect and identify the switch pressed. The switches that we are using in our project are 4 leg micro switches of momentary type. Thus now the two conditions are to be remembered: 1. When the switch is open, the total supply i.e., Vcc appears at the port pin P2.0 P2.0 = 1 2. When the switch is closed i.e., when it is pressed, the total supply path is provided to ground. Thus the voltage value at the port pin P2.0 will be zero. P2.0 =0 By reading the pin status, the microcontroller identifies whether the switch is pressed or not. When the switch is pressed, the corresponding related to this switch press written in the program will be executed. Vcc

R
P2.0

Gnd
Fig.3.3.7 Switch interfacing

3.3.8 Serial Communication: The main requirements for serial communication are: 1. Microcontroller 2. PC 3. RS 232 cable 4. MAX 232 IC
SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 35

DATA ACQUISITION AND LOGGING SYSTEM

5. HyperTerminal When the pins P3.0 and P3.1 of microcontroller are set, UART which is inbuilt in the microcontroller will be enabled to start the serial communication. Timers: The 8051 has two timers: Timer 0 and Timer 1. They can be used either as timers to generate a time delay or as counters to count events happening outside the microcontroller.Both Timer 0 and Timer 1 are 16-bit wide. Since the 8051 has an 8-bit architecture, each 16-bit timer is accessed as two separate registers of low byte and high byte.Lower byte register of Timer 0 is TL0 and higher byte is TH0. Similarly lower byte register of Timer1 is TL1 and higher byte register is TH1. TMOD (timer mode) register: Both timers 0 and 1 use the same register TMOD to set the various operation modes.TMOD is an 8-bit register in which the lower 4 bits are set aside for Timer 0 and the upper 4 bits for Timer 1. In each case, the lower 2 bits are used to set the timer mode and the upper 2 bits to specify the operation. (LSB) (MSB)

GATE

C/T

M1

M0

GATE

C/T

M1

M0

TIMER 0

TIMER 1 TIMER 0

GATE

TIMER 1

Every timer has a means of starting and stopping. Some timers do this by software, some by hardware and some have both software and hardware controls. The timers in the 8051 have both. The start and stop of the timer are controlled by the way of software by the TR (timer start) bits TR0 and TR1. These instructions start and stop the timers as long as GATE=0 in the TMOD register. The hardware way of starting and

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 36

DATA ACQUISITION AND LOGGING SYSTEM

stopping the timer by an external source is achieved by making GATE=1 in the TMOD register. C/T Timer or counter selected. Cleared for timer operation and set for counter operation. M1 Mode bit 1 M0 Mode bit 0 M1 M0 0 0 Mode 0 Operating Mode 13-bit timer mode 8-bit timer/counter THx with TLx as 5-bit prescaler 0 1 1 16-bit timer mode 16-bit timer/counters THx and TLx are cascaded 1 0 2 8-bit auto reload timer/counter THx holds a value that is to be reloaded into TLx each time it overflows 1 1 3 Split timer mode

The mode used here to generate a time delay is MODE 2. This mode 2 is an 8-bit timer and therefore it allows only values of 00H to FFH to be loaded into the timers register TH. After TH is loaded with the 8 -bit value, the 8051 give a copy of it to TL. When the timer starts, it starts to count up by incrementing the TL registers. It counts up until it reaches its limit of FFH. When it rolls over from FFH to 00H, it sets high the TF (timer flag). If Timer 0 is used, TF0 goes high and if Timer 1 is used, TF1 goes high. When the TL registers rolls from FFH to 0 and TF is set to 1, TL is reloaded automatically with the original value kept by the TH register.
SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 37

DATA ACQUISITION AND LOGGING SYSTEM

3.3.8(a) Asynchronous and Synchronous Serial Communication: Computers transfer data in two ways: parallel and serial. In parallel data transfers, often 8 or more lines are used to transfer data to a device that is only a few feet away. Although a lot of data can be transferred in a short amount of time by using many wires in parallel, the distance cannot be great. To transfer to a device located many meters away, the serial method is best suitable. In serial communication, the data is sent one bit at a time. The 8051 has serial communication capability built into it, thereby making possible fast data transfer using only a few wires. The fact that serial communication uses a single data line instead of the 8-bit data line instead of the 8-bit data line of parallel communication not only makes it cheaper but also enables two computers located in two different cities to communicate over the telephone. Serial data communication uses two methods, asynchronous and synchronous. The synchronous method transfers a block of data at a time, while the asynchronous method transfers a single byte at a time. Synchronous communications allows faster data transfer rates than asynchronous methods, because additional bits to mark the beginning and end of each data byte are not required. The serial ports on IBM-style PCs are asynchronous devices and therefore only support asynchronous serial communications. Asynchronous means "no synchronization", and thus does not require sending and receiving idle characters. However, the beginning and end of each byte of data must be identified by start and stop bits. The start bit indicates when the data byte is about to begin and the stop bit signals when it ends. The requirement to send these additional two bits causes asynchronous communication to be slightly slower than synchronous however it has the advantage that the processor does not have to deal with the additional idle characters. There are special IC chips made by many manufacturers for serial data communications. These chips are commonly referred to as UART(universal asynchronous receiver-transmitter) and USART(universal synchronous-asynchronous receiver-transmitter). The 8051 has a built-in UART. In the asynchronous method, the data such as ASCII characters are packed between a start and a stop bit. The start bit is always one bit, but the stop bit can be one or two bits. The start bit is always a 0 (low) and stop bit (s) is 1 (high). This is called
SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 38

DATA ACQUISITION AND LOGGING SYSTEM

framing. The rate of data transfer in serial data communication is stated as bps (bits per second). Another widely used terminology for bps is baud rate. The data transfer rate of a given computer system depends on communication ports incorporated into that system. And in asynchronous serial data communication, this baud rate is generally limited to 100,000bps. The baud rate is fixed to 9600bps in order to interface with the microcontroller using a crystal of 11.0592 MHz. 3.3.8(b) RS 232 Cable: To allow compatibility among data communication equipment, an interfacing standard called RS232 is used. Since the standard was set long before the advent of the TTL logic family, its input and output voltage levels are not TTL compatible. For this reason, to connect any RS232 to a microcontroller system, voltage converters such as MAX232 are used to convert the TTL logic levels to the RS232 voltage levels and vice versa.

Fig.3.3.8 (b) Rs-232 cable

3.3.8(c) MAX 232: Max232 IC is a specialized circuit which makes standard voltages as required by RS232 standards. This IC provides best noise rejection and very reliable against discharges and short circuits. MAX232 IC chips are commonly referred to as line drivers. To ensure data transfer between PC and microcontroller, the baud rate and voltage levels of Microcontroller and PC should be the same. The voltage levels of microcontroller are logic1 and logic 0 i.e., logic 1 is +5V and logic 0 is 0V. But for PC, RS232 voltage levels are considered and they are: logic 1 is taken as -3V to -25V and
SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 39

DATA ACQUISITION AND LOGGING SYSTEM

logic 0 as +3V to +25V. So, in order to equal these voltage levels, MAX232 IC is used. Thus this IC converts RS232 voltage levels to microcontroller voltage levels and vice versa.

Fig.3.3.8(c) Max 232 pin diagram

SCON (serial control) register: The SCON register is an 8-bit register used to program the start bit, stop bit and data bits of data framing.

SM0

SM1

SM2

REN

RB8

TB8

TI

RI

SM0 SM1 SM2 REN TB8 RB8 TI

SCON.7 SCON.6 SCON.5 SCON.4 SCON.3 SCON.2 SCON.1

Serial port mode specifier Serial port mode specifier Used for multiprocessor communication Set/cleared by software to enable/disable reception not widely used not widely used Transmit interrupt flag. Set by hardware at the Beginning of the stop bit in mode 1. Must be

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 40

DATA ACQUISITION AND LOGGING SYSTEM

Cleared by software. RI SCON.0 Receive interrupt flag. Set by hardware at the Beginning of the stop bit in mode 1. Must be Cleared by software. SM0 0 0 1 1 SM1 0 1 0 1 Serial Mode 0 Serial Mode 1, 8-bit data, 1 stop bit, 1 start bit Serial Mode 2 Serial Mode 3

Of the four serial modes, only mode 1 is widely used. In the SCON register, when serial mode 1 is chosen, the data framing is 8 bits, 1 stop bit and 1 start bit, which makes it compatible with the COM port of IBM/ compatible PCs. And the most important is serial mode 1 allows the baud rate to be variable and is set by Timer 1 of the 8051. In serial mode 1, for each character a total of 10 bits are transferred, where the first bit is the start bit, followed by 8 bits of data and finally 1 stop bit. 3.3.8(e) About PC: In the PC based projects, the output will be seen in the hyper terminal window. In order to open the hyper terminal window first go to all programs. In this all programs we will have accessories in accessories go to communication in that u have hyper terminal software. Open that then you will be getting this type of window

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 41

DATA ACQUISITION AND LOGGING SYSTEM

As u can see there is a dialogue box in the above window, in which u can see there is name block in which we need to enter any name or at least an alphabet to move for the next window then press ok to see this window.

In the above window we can see the connection block. We will be having two options: COM1 TCP/1P Protocol

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 42

DATA ACQUISITION AND LOGGING SYSTEM

COM1- is used for communicating the PC to our microcontroller whereas TCP/IP Protocol- is used for communicating PC to PC So, when coming to our project as we need to connect the microcontroller to PC. We select COM1 after selecting COM1 press ok in order to move to wards further window.

As we can see above the COM1 properties in that we need to select the baud rate by default the baud rate is 2400bps we need to restore the defaults. The baud rate which we are using is 9600 bps.

Click on the restore defaults and press ok then you can see the other window below in which the cursor is blinking this means the hyper terminal window has been activated or ready to perform.

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 43

DATA ACQUISITION AND LOGGING SYSTEM

3.4. Additional components:


3.4.1 LED Indicator: The longer lead is the anode (+) and the shorter lead is the cathode (&minus). In the schematic symbol for an LED (bottom), the anode is on the left and the cathode is on the right. Light emitting diodes are elements for light signalization in electronics.

Fig.3.4.1 Led Indicator

They are manufactured in different shapes, colors and sizes. For their low price, low consumption and simple use, they have almost completely pushed aside other light sources- bulbs at first place. It is important to know that each diode will be immediately destroyed unless its current is limited. This means that a conductor must be connected in parallel to a diode. In order to correctly determine value of this conductor, it is necessary to know diodes voltage drop in forward direction, which depends on what material a diode is made of and what colors it is. Values typical for the most frequently used diodes are shown in table below: As seen, there are three main types of LEDs. Standard ones get full brightness at current of 20mA. Low Current diodes get full brightness at ten times lower current while Super Bright diodes produce more intensive light than Standard ones. Since the 8052 microcontrollers can provide only low input current and since their pins are configured as outputs when voltage level on them is equal to 0, direct confectioning to LEDs is carried out as it is shown on figure (Low current LED, cathode is connected to output pin). 3.4.2 Led Interfacing With The Microcontroller: LED stands for Light Emitting Diode. LEDs are the most widely used input/output devices of the 8051.Microcontroller port pins cannot drive these LEDs as these require high currents to switch on. Thus the positive terminal of LED is directly

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 44

DATA ACQUISITION AND LOGGING SYSTEM

connected to Vcc, power supply and the negative terminal is connected to port pin through a current limiting resistor. This current limiting resistor is connected to protect the port pins from sudden flow of high currents from the power supply. Thus in order to glow the LED, first there
should be a current flow through the LED. In order to have a current flow, a voltage difference should exist between the LED terminals. In this project, LEDS are used as the display units to indicate the level of the petrochemical liquid in the processor container which is to be purified, motor running indication and the relay on condition.

Vcc P1.0

Fig.3.4.2 LED Interfacing with the Micro controller

3.4.3 Resistor: Resistors "Resist" the flow of electrical current. The higher the value of resistance (measured in ohms) the lower the current will be. Resistance is the property of a component which restricts the flow of electric current. Energy is used up as the voltage across the component drives the current through it and this energy appears as heat in the component.

Fig3.4.3 circuit symbol 3.4.4 Capacitor: Capacitors store electric charge. They are used with resistors

in timing circuits because it takes time for a capacitor to fill with charge. They are used to smooth varying DC supplies by acting as a reservoir of charge. They are also used in
SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 45

DATA ACQUISITION AND LOGGING SYSTEM

filter circuits because capacitors easily pass AC (changing) signals but they block DC (constant) signals.

Fig3.4.4 Circuit symbol

Electrolytic capacitors are polarized and they must be connected the correct way round, at least one of their leads will be marked + or -. 3.4.5 Diodes: Diodes allow electricity to flow in only one direction. The arrow of the circuit symbol shows the direction in which the current can flow. Diodes are the electrical version of a valve and early diodes were actually called valves.

Fig.3.4.5 Circuit symbol

Diodes must be connected the correct way round, the diagram may be labeled a or + for anode and k or - for cathode (yes, it really is k, not c, for cathode!). The cathode is marked by a line painted on the body. Diodes are labeled with their code in small print; you may need a magnifying glass to read this on small signal diodes.

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 46

DATA ACQUISITION AND LOGGING SYSTEM

4. SOFTWARE TOOLS
4.1 Software required:
4.1.1 Keil Software: Keil compiler is software used where the machine language code is written and compiled. After compilation, the machine source code is converted into hex code which is to be dumped into the microcontroller for further processing. Keil compiler also supports C language code. 4.1.2 Proload: Proload is software which accepts only hex files. Once the machine code is converted into hex code, that hex code has to be dumped into the microcontroller and this is done by the Proload. Proload is a programmer which itself contains a microcontroller in it other than the one which is to be programmed. This microcontroller has a program in it written in such a way that it accepts the hex file from the keil compiler and dumps this hex file into the microcontroller which is to be programmed. As the proload programmer kit requires power supply to be operated, this power supply is given from the power supply circuit designed above. It should be noted that this programmer kit contains a power supply section in the board itself but in order to switch on that power supply, a source is required. Thus this is accomplished from the power supply board with an output of 12volts. 4.1.3 Keil Compiler: With the Keil tools, you can generate embedded applications for virtually every 8051 derivative. The supported microcontrollers are listed in the Vision Device Database. The Keil Software 8051 development tools are designed for the professional software developer, but any level of programmer can use them to get the most out of the 8051 microcontroller architecture.We are constantly adding new devices and simulation support for on-chip peripherals so be sure to check web-based Device Database if your plan to use a device that is currently not listed in your local Vision installation.
SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY Page 47

DATA ACQUISITION AND LOGGING SYSTEM

The Keil Software 8051 development tools listed below are programs you use to compile your C code, assemble your assembly source files, link and locate object modules and libraries, create HEX files, and debug your target program. Vision is an Integrated Development Environment that combines project management, source code editing, and program debugging in one single, powerful environment. The Cx51 ANSI Optimizing C Cross Compiler creates relocatable object modules from Test Programs with the Vision Debugger: This chapter describes the Debug Mode of Vision and shows you how to use the user interface to test a sample program. Also discussed are simulation mode and the different options available for program debugging.You can use Vision Debugger to test the applications you develop using the Cx51 Compiler and Ax51 Macro Assembler. The Vision Debugger offers two operating modes that are selected in the Options for Target Debug dialog. Use Simulator allows configuring the Vision Debugger as software-only product that simulates most features of the 8051 microcontroller without actually having target hardware. You can test and debug your embedded application before the hardware is ready. Vision simulates a wide variety of peripherals including the serial port, external I/O, and timers. The peripheral set is selected when you select a CPU from the device database for your target. Use Debugger Drivers that connect the Vision Debugger directly to emulators, Embedded ICE (On-chip Debug System) for example with the Keil ULINK USB-JTAG Adapter. 4.1.4 Application Program Execution: Vision lets execute your application program in several different ways: With the Debug Menu and Debug Commands.

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 48

DATA ACQUISITION AND LOGGING SYSTEM

With the Run till Cursor line command in the local context menu. The local context menu opens with a right mouse click on the code line in the Editor or Disassembly window.

In the Output Window Command page you can use the Go, Ostep, Pstep, and Tstep commands.

4.1.5 Simulation: The Vision3 Debugger incorporates a C script language you can use to create Signal Functions. Signal functions let you simulate analog and digital input to the microcontroller. Signal functions run in the background while Vision3 simulates your target program. The Vision3 simulator simulates the timing and logical behavior of serial communication protocols like UART, IC, SPI, and CAN. But Vision3 does not simulate the I/O port toggling of the physical communication pins on the I/O port. To provide fast simulation speed and optimum access to communication peripherals, the logic behavior of communication peripherals is reflected in virtual registers that are listed with the DIR VTREG command. This has the benefit that you can easily write debug functions that stimulate complex peripherals. Keil simulator contains several Signal function temples that you may use to simulate: Digital Input Push Button Interrupt Signal Impulse Patterns Analog Input Square Wave Signal saw tooth signal Sine Wave Noise Signal Signal Combination UART Communication CAN Communication
Page 49

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

DATA ACQUISITION AND LOGGING SYSTEM

IC Communication SPI Communication etc.

4.1.6 Using On-Chip Peripherals: There are a number of techniques you must know to create programs that utilize the various on-chip peripherals and features of the 8051 family. Many of these are described in this chapter. You may use the code examples provided here to quickly get started working with the 8051. There is no single standard set of on-chip peripherals for the 8051 family. Instead, 8051 chip vendors use a wide variety of on-chip peripherals to distinguish their parts from each other. The code examples in this chapter demonstrate how to use the peripherals of a particular chip or family. Be aware that there are more configuration options than are presented in this text. Startup Code Special Function Registers Register Banks Interrupt Service Routines Interrupt Enable Registers Parallel Port I/O Timers/Counters Serial Interface Watchdog Timer D/A Converter A/D Converter

Power Reduction Modes 4.1.7 Debugging: This chapter describes the Debug Mode of Vision3 and shows you how to use the user interface to test a sample program. Also discussed are simulation mode and the different options available for program debugging. You can use Vision3 Debugger to test the applications you develop. The Vision3 Debugger offers two operating modes that are selected in the Options for Target Debug dialog.

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 50

DATA ACQUISITION AND LOGGING SYSTEM

Use Simulator configures the Vision3 Debugger as software-only product that simulates most features of a microcontroller without actually having target hardware. You can test and debug your embedded application before the hardware is ready. Vision3 simulates a wide variety of peripherals including the serial port, external I/O, and timers. The peripheral set is selected when you select a CPU from the device database for your target. Use Advanced GDI drivers, like the ULINK Debugger to interface to your target hardware. For Vision3 various drivers are available that interface to: Monitor: that may be integrated with user hardware or is available on many evaluation boards. Emulator: which connects to the CPU pins of the target hardware. In-System Debugger: which is part of the user application program and provides basic test functions. The Status Bar shows the current active debugging tool. In simulation mode, timing statistic is provided.

4.2 DAQ Software:


DAQ System (software) is loaded on the computer which takes these values and displays them on its front panel, and also logs them in the database. One can set parameters like set point, low limit and high limit on the computer screen.

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 51

DATA ACQUISITION AND LOGGING SYSTEM

5. RESULTS
In this system, Temperature measurements from the four channels are taken. All the sensors are specified with accuracy. The accuracy indicates how closely the sensor can measure the actual or real world parameter value.

5.1 Output screen:

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 52

DATA ACQUISITION AND LOGGING SYSTEM

5.2 Conclusion and Future enhancement:


5.2.1 Conclusion: In this work, an attempt has been done to design a data logger, which is of less cost, portable, very low power consumption, self contained. It is an efficient data logger, which works in real time mode. The reduced number of channels also makes the system simple. The logger can use up to 8 channels of analog to digital converter in performing its task but that will result in increased number of channels. The programming and interfacing of microcontroller has been mastered during the implementation. This work includes the study of PC .Hence by this project we can control the temperature by means of PC using PCs hyper terminal window. 5.2.2 Future enhancement: This system can be connected to communication devices such as modems, cellular phones, or satellite terminal to enable the remote collection of recorded data or alarming of certain parameters. The new system will email information based upon a regular schedule of based upon alarms

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 53

DATA ACQUISITION AND LOGGING SYSTEM

6.REFERENCES
[1] ]Andrew J Thompson, John L Bahr and Neil R Thomson, Low power data logger, proceedings of conference department of physics, university of otago, Dunedin.

[2]

Peter Roberson, Using data loggers, science teachers workshop, 2004, north

Sydney.

[3] Muhammad Ali Mazidi and Janice Gillispe Mazidi, The 8051 microcontroller and embedded systems, Pearson education ltd., India, 2004.

[4] National Semiconductor Corporation, LM35 datasheet, precision centigrade temperature sensors, Atmel data book, November 2000 update.

[5] National Semiconductor Corporation, ADC0808/ADC 0809 data sheet, 8-bit Microprocessor compatible A/D converters with 8-channel multiplexer, national Semiconductor data book, October 2002 update . [6] H S kalsi, Electronic instrumentation, Tata McGraw-Hill Ltd., New Delhi, 1999.

[7] Atmel Corporation, AT89C51 data sheet, 8-bit microcontroller with 4k bytes flash, Atmel Data book, 2000 update.

[8]S. J. Perez, M. A. Calva, R. Castaneda, A microcontroller based data logging System.

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 54

DATA ACQUISITION AND LOGGING SYSTEM

SRINIVASA INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page 55

You might also like