Documente Academic
Documente Profesional
Documente Cultură
com
DATA LOGGER
ABSTRACT
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
ABSTRACT
As in the process control system it is very often required to record the various process parameters like temperature, pressure, flow, voltage, current, strain etc..And this parameter values will be used for maintaining the process control system automatically. Sensing and recording of physical parameters plays an important role in many industries. In the past analog devices were used for measurement of such parameters. A simple technique combining analog and digital circuit theory together with programming techniques has been used in this paper to design a temperature and pressure sensing system. The sensors analog signal is applied to a micro-controller based data logger for storage purposes. The main objective of our project is to log and store the data and by using this data we can analyze the performance of the system s. Generally in any process industries along with the supervision of the parameters, analyzing the system performance is also an important task .So, in order to analyze the performance we need to acquire the data regarding that particular device. For this purpose we use data loggers. In this project the physical quantities that we are measuring are temperature, pressure and liquid level. All the three parameters are sensed by using particular sensors, temperature is measured by using temperature transducer, pressure by using multi turn pot and liquid level is sensed by using limit switch.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
The outputs of these sensors are given to microcontroller which is used for automation, Real time clock to find out date and time of occurrence of the incident, a permanent memory (EEPROM) for keeping the detail coming from the RTC. A key board and display unit is used for the user interface. The data logged is displayed on LCD. Here we are using micro switches as key board in order to set the time, temperature, pressure. And when the operator wants these details can be accessed using a key board and it will be displayed in the LCD display.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
LIST OF CONTENTS
CHAPTER CHAPTER 1 1.0 1.1 1.2 1.3 CHAPTER 2 2.0 2.1 2.2 CHAPTER 3 3.0 3.1 TITLE INTRODUCTION WHAT IS DATA LOGGER DIFFERENT TYPES OF DATA LOGGERS NETWORKING AIM OF THE PROJECT WORKING PRINCIPLE BLOCK DIAGRAM OF DATA LOGGER FUNCTIONAL DIAGRAM CIRCUIT DESCRIPTION DESIGN PROCEDURE POWER SUPPLY PIC 16F877 MICROCONTROLLER 3.1.1 INTRODUCTION TO MICROPROCESSORS 3.1.2 INTRODUCTION TO MICROCONTROLLERS 3.1.3 PIC 16F877 MICROCONTROLLER I2C PROTOCOL REAL TIME CLOCK EEPROM TEMPERATURE SENSOR MULTI TURN POT LIMIT SWITCH LCD MICRO SWITCHES RESULTS OF THE PROJECT ADVANTAGES AND APPLICATIONS ADVANTAGES OF USING A DATA LOGGER FOR COLLECTING DATA DATA LOGGING VERSUS DATA ACQUISITION APPLICATIONS CONCLUSION AND FUTURE DIRECTIONS APPENDIX BIBLIOGRAPHY PAGE NO 10 11 11 12 12 13 14 15 16 17 18 21 21 21 22 31 40 48 56 67 69 70 75 76 82 83 83 85 86 88 107
3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 CHAPTER 4 CHAPTER 5 5.0 5.1 5.2 CHAPTER 6
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
CHAPTER 1 INTRODUCTION
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
This includes many data acquisition devices such as plug-in boards or serial communication systems which use a computer as a real time data recording system. However, most instrument manufacturers consider a data logger a stand alone device that can read various types of electrical signals and store the data in internal memory for later download to a computer. Data loggers vary between general purpose types for a range of measurement applications to very specific devices for measuring in one environment only. It is common for general purpose types to be programmable however many remains as static machines with only a limited number of changeable parameters. Electronic data loggers have replaced chart records in many applications.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
1.2
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
DISPLAY
RTC
EMBEDDED CONTROLER
EPROM
POWER SUPPLY
Fig 1:
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
Fig 2:
FUNCTIONAL DIAGRAM
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
3.0
POWER SUPPLY
RECTIFIER:
The rectifier circuit is used to convert the AC voltage into its corresponding DC voltage. There are half wave and full wave rectifiers available for this specific function. The most important simple device used in rectifier circuit is the diode the simple function of the diode is to conduct when forward biased and not to conduct in reverse bias. The efficient circuit used is the full wave bridge rectifier circuit. The output voltage of the rectifier is in ripple form. The ripples from the obtained DC voltages are removed by using the filter circuit.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
INPUT FILTER:
Capacitors are used as filters. The ripples from the DC voltage are removed and pure DC voltage is obtained. The primary action performed by capacitor is charging and discharging; it charges in positive half cycle of the AC voltage and discharges during the negative half cycle. So it allows only the AC voltage and does not allow DC voltage. This filter is fixed before the regulator thus the output is free from ripples.
REGULATOR UNIT:
Regulator regulates the output voltage to be always constant. The output voltage is maintained constant irrespective of the fluctuations in the input AC voltage. When the internal resistance of the power supply is greater than 30ohms the output gets fluctuated. Thus this can be successfully reduced here. The regulators are mainly classified for low voltage and for high voltage. Positive regulator regulates the positive voltage. Negative regulator regulates the negative voltage.
Fig: VOLTAGE REGULATOR The series 78XX regulators provide fixed regulated voltages from +5V to +24V. Figure shows how one such IC, a 7805, is connected to provide voltage regulation with output from this unit of +5V DC. An unregulated input voltage Vi is filtered by capacitor Ci and connected to the ICs IN terminal. The ICs OUT terminal provides a regulated +5V, which is filtered by capacitor Co (mostly for any high frequency noise). The third terminal of IC is connected to ground (GND). While the input voltage may vary over some permissible voltage range and the output load may vary over some acceptable range, the output voltage
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
remains constant within specified voltage variation limits. These limitations are spelled out in the manufacturers specification sheets. A table of positive voltage regulated ICs is provided in the following table:
IC PART 7805
OUTPUT VOLTAGE(V)
MINIMUM Vi(V)
OUTPUT FILTER:
The filter circuit is often fixed after the regulator circuit. Capacitor is most often used as filter. The principle of the capacitor is to charge and discharge. It charges during the positive half cycle of the AC voltage and discharges during the negative half cycle. So it allows only the AC voltage and does not allow the DC voltage. This filter is fixed after the regulator circuit to filter any of the possibly found ripples in the output received finally. The output at this stage is 5V and is given to the micro controller PIC16F877.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
PERIPHERAL FEATURES:
Timer0: 8-bit timer/counter with 8-bit prescaler Timer1: 16-bit timer/counter with prescaler, can be incremented during SLEEP via external Crystal/clock Timer2: 8-bit timer/counter with 8-bit period register, prescaler and post scaler Two Capture, Compare, PWM modules Capture is 16-bit, max. resolution is 12.5 ns Compare is 16-bit, max. resolution is 200 ns PWM max. resolution is 10-bit
10-bit multi-channel Analog-to-Digital converter Synchronous Serial Port (SSP) with SPI(Master mode) and I2C(Master/Slave) Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with 9bit address detection Parallel Slave Port (PSP) 8-bits wide, with external RD, WR and CS controls (40/44pin only) Brown-out detection circuitry for Brown-out Reset (BOR)
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
TTL/ST(2) Interrupt-On-Change pin or incircuit debugger pin. Serial programming clock. TTL/ST(2) Interrupt-On-Change pin or incircuit debugger pin. Serial programming data. PORTC is a bi-directional I/O port.
RC0/T1OSO/T1CKI 15 RC1/T1OSI/CCP2 16
I/O I/O
ST RC0 can also be the Timer1 OSC output or a Timer1 CLK input. ST RCI can also be the Timer1 OSC input or capture2 input/ compare2 output/ PWM2 output..
RC2/CCP1 RC3/SCK/SCL
17 18
I/O I/O
ST RC2 can also be capture1 input/ compare2 output/ PWM1 output.. ST RC3 can also be the synchronous serial clock input/ output for both SPI and I2C modes.
23 24 25
ST ST ST RC4 can also be the SPI data in (SPI mode) or data I/O (I2C mode). RC5 can also be the SPI Data Out RC6 can also be the USSART asynchronous transmit or synchronous clock. RC6 can also be the USSART asynchronous receive or synchronous data.
RC7/RX/DT
26
I/O
ST
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
PIN NAME
DIP PIN #
I/O/P TYP E
BUFFER TYPE
DESCRIPTION PORTD is a bi-directional I/O port or parallel slave port when interfacing to a microprocessor bus.
19 20 21 22 27 28 29 30
ST/TTL(3) ST/TTL(3) ST/TTL(3) ST/TTL(3) ST/TTL(3) ST/TTL(3) ST/TTL(3) ST/TTL(3) PORTE is a bi-directional I/O port.
RE0/RD/AN5
ST/TTL(3) RE0 can also be read control for the parallel slave port or analog input 5. ST/TTL(3) RE1 can also be write control for the parallel slave port or analog input 6. ST/TTL(3) RE2 can also be select control for the parallel slave port or analog input 7. Ground reference for logic and I/O pins. Positive supply for logic and I/O pins
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
MEMORY ORGANIZATION:
There are three memory blocks in each of the PIC16F87X MCUs. The Program Memory and Data Memory have separate buses so that concurrent access can occur.
FIGURE:
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
Each bank extends up to 7Fh (128 bytes). The lower locations of each bank are reserved for the Special Function Registers. Above the Special Function Registers are General Purpose Registers, implemented as static RAM. All implemented banks contain Special Function Registers. Some frequently used Special Function Registers from one bank may be mirrored in another bank for code reduction and quicker access.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
OPERATION:
First, the MCU will issue a START condition. This acts as an 'Attention' signal to all of the connected devices. All ICs on the bus will listen to the bus for incoming data. Then the MCU sends the ADDRESS of the device it wants to access, along with an indication whether the access is a Read or Write operation (Write in our example). Having received the address, all IC's will compare it with their own address. If it doesn't match, they simply wait until the bus is released by the stop condition (see below). If the address matches, however, the chip will produce a response called the ACKNOWLEDGEMENT signal. Once the MCU receives the acknowledge, it can start transmitting or receiving DATA. In our case, the MCU will transmit data. When all is done, the MCU will issue the STOP condition. This is a signal that the bus has been released and that the connected ICs may expect another transmission to start any moment. We have had several states on the bus in our example: START, ADDRSS, ACKNOWLEDGEMENT, DATA and STOP. These are all unique conditions on the bus. Before we take a closer look at these bus conditions we need to understand a bit about the physical structure and hardware of the bus.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
(note that external pull-up resistors are necessary for this which is easily forgotten). To put a signal on the bus, the chip drives its output transistor, thus pulling the bus to a LOW level. The "pull-up resistor" in the devices as seen in the figure is actually a small current source or even non-existent.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
STOP: The Bus Master first releases the SCL and then the SDA line.
A single message can contain multiple Start conditions. The use of this socalled "repeated start" is common in I2C.
A Stop condition always denotes the END of a transmission. Even if it is issued in the middle of a transaction or in the middle of a byte. It is "good behavior" for a chip that, in this case, it disregards the information sent and resumes the "listening state", waiting for a new start condition.
As the I2C bus gained popularity, it was soon discovered that the number of available addresses was too small. Therefore, one of the reserved addresses has been
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
allocated to a new task to switch to 10-bit addressing mode. If a standard slave (not able to resolve extended addressing) receives this address, it won't do anything (since it's not its address). If there are slaves on the bus that can operate in the extended 10-bit addressing mode, they will ALL respond to the ACK cycle issued by the master. The second byte that gets transmitted by the master will then be taken in and evaluated against their address.
All the master has to do is generate a rising edge on the SCL line (2), read the level on SDA (3) and generate a falling edge on the SCL line (4). The slave will not change the data during the time that SCL is high. (Otherwise a Start or Stop condition might inadvertently be generated.) During (1) and (5), the slave may change the state of the SDA line. In total, this sequence has to be performed 8 times to complete the data byte. Bytes are always transmitted MSB first
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
The meaning of all bytes being read depends on the slave. There is no such thing as a "universal status register". You need to consult the data sheet of the slave being addressed to know the meaning of each bit in any byte transmitted.
This means that as soon as the master pulls SCL low to complete the transmission of the bit (1), SDA will be pulled low by the slave (2). The master now issues a clock pulse on the SCL line (3). The slave will release the SDA line upon completion of this clock pulse (4).
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
The bus is now available again for the master to continue sending data or to generate a stop condition. In case of data being written to a slave, this cycle must be completed before a stop condition can be generated. The slave will be blocking the bus (SDA kept low by slave) until the master has generated a clock pulse on the SCL line.
After transmission of the last bit to the master (1) the slave will release the SDA line. The SDA line should then go high (2). The Master will now pull the SDA line low (3) . Next, the master will put a clock pulse on the SCL line (4). After completion of this clock pulse, the master will again release the SDA line (5).The slave will now regain control of the SDA line (6). If the master wants to stop receiving data from the slave, it must be able to send a stop condition.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
Since the slave regains control of the SDA line after the ACK cycle issued by the master, this could lead to problems. Let's assume the next bit ready to be sent to the master is a 0. The SDA line would be pulled low by the slave immediately after the master takes the SCL line low. The master now attempts to generate a Stop condition on the bus. It releases the SCL line first and then tries to release the SDA line - which is held low by the slave. Conclusion: No Stop condition has been generated on the bus. This condition is called a NACK: Not acknowledge.
This is not exactly a condition. It is merely a state in the data flow between master and slave. If, after transmission of the 8th bit from the master to the slave the slave does not pull the SDA line low, then this is considered a No ACK condition. This means that either:
The slave is not there (in case of an address) The slave missed a pulse and got out of sync with the SCL line of the master. The bus is "stuck". One of the lines could be held low permanently.
In any case the master should abort by attempting to send a stop condition on the bus.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
APPLICATIONS
IC is appropriate for peripherals where simplicity and low manufacturing cost are more important than speed. Common applications of the IC bus are: Reading configuration data from SPD EEPROMs on SDRAM, DDR SDRAM, DDR2 SDRAM memory sticks (DIMM) and other stacked PC boards Supporting systems management for PCI cards, through a SMBus 2.0 connection. Accessing NVRAM chips that keep user settings. Accessing low speed DACs. Accessing low speed ADCs. Changing contrast, hue, and color balance settings in monitors (Display Data Channel). Changing sound volume in intelligent speakers. Controlling OLED/LCD displays, like in a cell phone. Reading hardware monitors and diagnostic sensors, like a CPU thermostat and fan speed. Reading real time clocks. Turning on and turning off the power supply of system components.
A particular strength of IC is that a microcontroller can control a network of device chips with just two general-purpose I/O pins and software. Peripherals can also be added to or removed from the IC bus while the system is running, which makes it ideal for applications that require hot swapping of components.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
FEATURES:
Real-time clock (RTC) counts seconds, minutes, hours, date of the month, month, and day of the week, and year with leap-year compensation valid up to 2100 56-byte, battery-backed, nonvolatile (NV) RAM for data storage Two-wire serial interface Programmable square wave output signal Automatic power-fail detect and switch circuitry Consumes less than 500nA in battery backup mode with oscillator running Optional industrial temperature range: -40C to +85C Available in 8-pin DIP or SOIC Underwriters Laboratory (UL) recognized
PIN DESCRIPTION
VCC - Primary Power Supply X1, X2 - 32.768 kHz Crystal Connection VBAT - +3V Battery Input GND - Ground SDA - Serial Data
PIN ASSIGNMENT
DS1307 8-Pin DIP (300mil) SCL - Serial Clock SQW/OUT - Square Wave/Output Driver
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
DESCRIPTION:
The DS1307 Serial Real-Time Clock is a low power; full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially via a 2-wire, bi-directional bus. The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with AM/PM indicator. The DS1307 has a built-in power sense circuit that detects power failures and automatically switches to the battery supply.
OPERATION:
The DS1307
implementing a START condition and providing a device identification code followed by a register address. Subsequent registers can be accessed sequentially until a STOP condition is executed. When VCC falls below 1.25 x VBAT the device terminates an access in progress and resets the device address counter. Inputs to the device will not be recognized at this time to prevent erroneous data from being written to the device from an out of tolerance system. When VCC falls below VBAT the device switches into a low-current battery backup mode. Upon power-up, the device switches from battery to VCC when VCC is greater than VBAT + 0.2V and recognizes inputs when VCC is greater than 1.25 x VBAT. The block diagram in Figure 1 shows the main elements of the serial RTC.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
SIGNAL DESCRIPTIONS:
VCC, GND DC power is provided to the device on these pins. VCC is the +5V
input. When 5V is applied within normal limits, the device is fully accessible and data can be written and read. When a 3V battery is connected to the device and V CC is below 1.25 x VBAT, reads and writes are inhibited. However, the timekeeping function continues unaffected by the lower input voltage. As VCC falls below VBAT the RAM and timekeeper are switched over to the external power supply (nominal 3.0V DC) at VBAT.
VBAT Battery input for any standard 3V lithium cell or other energy source.
Battery voltage must be held between 2.0V and 3.5V for proper operation. The nominal write protect trip point voltage at which access to the RTC and user RAM is denied is set by the internal circuitry as 1.25 x VBAT nominal. A lithium battery with 48mAhr or greater will back up the DS1307 for more than 10 years in the absence of power at 25C. UL recognized to ensure against reverse charging current when used in conjunction with a lithium battery.
SCL (Serial Clock Input) SCL is used to synchronize data movement on the serial
interface.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
SDA (Serial Data Input/Output) SDA is the input/output pin for the 2-wire serial
interface. The SDA pin is open drain, which requires an external pull up resistor.
SQW/OUT (Square Wave/Output Driver) When enabled, the SQWE bit set to 1, the
SQW/OUT pin outputs one of four square wave frequencies (1Hz, 4kHz, 8kHz, 32kHz). The SQW/OUT pin is open drain and requires an external pull-up resistor. SQW/OUT will operate with either Vcc or Vbat applied.
X1, X2 Connections for a standard 32.768 kHz quartz crystal. The internal oscillator
circuitry is designed for operation with a crystal having a specified load capacitance (CL) of 12.5pF. DS1307 can also be driven by an external 32.768 kHz oscillator. In this configuration, the X1 pin is connected to the external oscillator signal and the X2 pin is floated.
CLOCK ACCURACY:
The accuracy of the clock is dependent upon the accuracy of the crystal and the accuracy of the match between the capacitive load of the oscillator circuit and the capacitive load for which the crystal was trimmed. Additional error will be added by crystal frequency drift caused by temperature shifts. External circuit noise coupled into the oscillator circuit may result in the clock running fast.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
CONTROL REGISTER:
The DS1307 control register is used to control the operation of the SQW/OUT pin.
OUT (Output control): This bit controls the output level of the SQW/OUT pin when the square wave output is disabled. If SQWE = 0, the logic level on the SQW/OUT pin is 1 if OUT = 1 and is 0 if OUT = 0. SQWE (Square Wave Enable): This bit, when set to logic 1, will enable the oscillator output. The frequency of the square wave output depends upon the value of the RS0 and RS1 bits. With the square wave output set to 1Hz, the clock registers update on the falling edge of the square wave. RS (Rate Select): These bits control the frequency of the square wave output when the square wave output has been enabled. Table 1 lists the square wave frequencies that can be selected with the RS bits.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
access, and generates the START and STOP conditions. The DS1307 operates as a slave on the 2-wire bus.
DC ELECTRICAL CHARACTERISTICS:
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
3.4 EEPROM
ELECTRICALLY ERASABLE PROGRAMMABLE READ ONLY MEMORY
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
EEPROM_24LC64 PINDIAGRAM:
FEATURES:
Single supply with operation down to 2.5 V
Low power CMOS technology - 1 mA active current typical - 1 A standby current (max.) (I-temp) Organized as 8 blocks of 8K bit (64K bit) 2-wire serial interface bus, I2C compatible Cascadable for up to eight devices Schmitt Trigger inputs for noise suppression Output slope control to eliminate ground bounce 100 kHz (24AA64) and 400 kHz (24LC64) Compatibility Self-timed write cycle (including auto-erase) Page-write buffer for up to 32 bytes 2 ms typical write cycle time for page-write Hardware write protect for entire memory Can be operated as a serial ROM Factory programming (QTP) available ESD protection > 4,000V 1,000,000 erase/write cycles Data retention > 200 years 8-lead PDIP, SOIC, TSSOP, and MSOP package Available temperature ranges: Industrial (I): - 40oC to +85 oC
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
PIN DESCRIPTIONS:
A0, A1, A2 Chip Address Inputs: The A0, A1, A2 inputs are used by the 24XX64 for multiple device operation. The levels on these inputs are compared with the corresponding bits in the slave address. The chip is selected if the compare is true. Up to eight devices may be connected to the same bus by using different chip select bit combinations. These inputs must be connected to either VCC or VSS.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
BLOCK DIAGRAM:
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
DESCRIPTION:
The Microchip Technology Inc. 24AA64/24LC64 is a 64 K bit Electrically Erasable PROM. The device is organized as eight blocks of 1K x 8-bit memory with a 2-wire serial interface. Low voltage design permits operation down to 1.8V with standby and active currents of only 1 uA and 1 mA respectively. It has been developed for advanced, low power applications. Such as personal communications or data acquisition. The 24XX64 also has a page-write capability for up to 32 bytes of data. Functional address lines allow up to eight devices on the same bus, for up to 512 K bits address space. The 24XX64 is available in the standard 8-pin PDIP, surface mount SOIC, TSSOP and MSOP packages.
FUNCTIONAL DESCRIPTION:
The 24XX64 supports a bi-directional 2-wire bus and data transmission protocol. A device that sends data onto the bus is defined as transmitter, and a device receiving data as receiver. The bus has to be controlled by a master device which generates the serial clock (SCL), controls the bus access and generates the START and STOP conditions, while the 24XX64 works as slave. Both master and slave can operate as transmitter or receiver, but the master device determines which mode is activated.
BUS CHARACTERISTICS:
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
The following bus protocol has been defined: Data transfer may be initiated only when the bus is not busy. During data transfer, the data line must remain stable whenever the clock line is IGH. Changes in the data line while the clock line is HIGH will be interpreted as a START Or STOP condition. Accordingly, the following bus conditions have been defined.
DEVICE ADDRESSING:
A control byte is the first byte received following the START condition from the master device (Figure 3-2).The control byte consists of a four bit control code; for the 24XX64 this is set as 1010 binary for read and writes operations. The next three bits of the control byte are the chip select bits (A2, A1, and A0). The chip select bits allow the use of up to eight 24XX64 devices on the same bus and are used to select which device is accessed. The chip select bits in the control byte must correspond to the logic levels on the corresponding A2, A1, and A0 pins for the device to respond. These bits are in effect the three Most Significant bits of the word address.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
The last bit of the control byte defines the operation to be performed. When set to a one a read operation is selected, and when set to a zero a write operation is selected. The next two bytes received define the address of the first data byte (Figure 3-3). Because only A12...A0 are used, the upper three address bits are dont care bits. The upper address bits are transferred first, followed by the less significant bits. Following the START condition, the 24XX64 monitors the SDA bus checking the device type identifier being transmitted. Upon receiving a 1010 code and appropriate device select bits, the slave device outputs an Acknowledge signal on the SDA line. Depending on the state of the R/W bit, the 24XX64 will select a read or write operation.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
DC CHARACTERISTICS:
WRITE OPERATIONS:
2 types: 1) Byte write. 2) Page write.
READ OPERATIONS:
There are three basic types of read operations: 1) Current Address Read 2) Random Read 3) Sequential Read
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
AC Characteristics:
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
TYPES OF TRANSDUCERS:
ELECTROMAGNETIC: Antenna - converts electromagnetic waves into electric current and vice versa. Cathode ray tube (CRT) - converts electrical signals into visual form Fluorescent lamp, light bulb - converts electrical power into visible light Magnetic cartridge - converts motion into electrical form Photodetector or Photoresistor (LDR) - converts changes in light levels into resistance changes ELECTROCHEMICAL: PH probes Electro-galvanic fuel cell
ELECTROMECHANICAL: Electro active polymers Galvanometer MEMS Rotary motor, linear motor Vibration powered generator Potentiometer when used for measuring position Load cell converts force to mV/V electrical signal using strain gauge
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
ELECTROACOUSTIC: Geophone - convert a ground movement (displacement) into voltage Gramophone pick-up Hydrophone - converts changes in water pressure into an electrical form Loudspeaker, earphone - converts changes in electrical signals into acoustic form Microphone - converts changes in air pressure into an electrical signal Piezoelectric crystal - converts pressure changes into electrical form Tactile transducer
ELECTROSTATIC: Electrometer
THERMOELECTRIC: RTD Resistance Temperature Detector Thermocouple Peltier cooler Thermistor (includes PTC resistor and NTC resistor)
RADIO ACOUSTIC: Receiver (radio) Eiger-Mller tube used for measuring radioactivity.
WHY DS1621??
DS1621 is a Digital Thermometer and Thermostat which measures temperature with out any external components from -55C to +125C in 0.5C
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
increments and Converts it to digital word in less than 1 second. Temperature is read as a 9-bit value (2-byte transfer). It also provides a wide power supply range of 2.7V to 5.5V.It is available in 8-pin DIP or SO package (150mil and 208mil) with a price of 200-300. DS1621 well supports I2c communication protocol. Because of all the available features and considering its low cost we can say it best suits the application of DATA LOGGER.
PIN ASSIGNMENT
PIN DESCRIPTION
SDA - 2-Wire Serial Data Input/Output SCL - 2-Wire Serial Clock GND Ground TOUT - Thermostat Output Signal Voltage A0 - Chip Address Input A1 - Chip Address Input A2 - Chip Address Input V DD - Power Supply
DESCRIPTION:
The DS1621 Digital Thermometer and Thermostat provides 9-bit temperature readings, which indicate the temperature of the device. The thermal alarm output, TOUT, is active when the temperature of the device exceeds a user-defined temperature TH. The output remains active until the temperature drops below user defined temperature TL, allowing for any hysteresis necessary. User-defined temperature settings are stored in nonvolatile memory so parts may be programmed prior to insertion in a system. Temperature settings and temperature readings are all communicated to/from the DS1621 over a simple 2-wire serial interface.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
OPERATION:
MEASURING TEMPERATURE:A block diagram of the DS1621 is shown in Figure 1.The DS1621 measures temperature using a band gap-based temperature sensor. A delta-sigma analog-to digital converter (ADC) converts the measured temperature to a digital value that is calibrated in C; for F applications, a lookup table or conversion routine must be used. The temperature reading is provided in a 9-bit, twos complement reading by issuing the READ TEMPERATURE command. The data is transmitted through the 2wire serial interface, MSB first. The DS1621 can measure temperature over the range of -55_C to +125_C in 0.5_C increments.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
Table 2. TEMPERATURE/DATA RELATIONSHIPS Since data is transmitted over the 2-wire bus MSB first, temperature data may be written to/read from the DS1621 as either a single byte (with temperature resolution of 1_C) or as two bytes. The second byte would contain the value of the least significant (0.5_C) bit of the temperature reading as shown in Table 1.Note that the remaining 7 bits of this byte are set to all "0"s
Temperature is represented in the DS1621 in terms of a _C LSB, yielding the following 9-bit format:
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
Where DONE = Conversion done bit. 1 = Conversion complete, 0 = Conversion in progress. THF = Temperature High Flag. This bit will be set to 1 when the temperature is greater than or equal to the value of TH. It will remain 1 until reset by writing 0 into this location or removing power from the device. This feature provides a method of determining if the DS1621 has ever been subjected to temperatures above TH while power has been applied. TLF = Temperature Low Flag. This bit will be set to 1 when the temperature is less than or equal to the value of TL. It will remain 1 until reset by writing 0 into this location or removing power from the device. This feature provides a method of determining if the DS1621 has ever been subjected to temperatures below TL while power has been applied. NVB = Nonvolatile Memory Busy flag. 1 = Write to an E 2 memory cell in progress, 0 =nonvolatile memory is not busy. A copy to E 2 may take up to 10 ms. POL = Output Polarity Bit. 1 = active high, 0 = active low. This bit is nonvolatile. 1SHOT = One Shot Mode. If 1SHOT is 1, the DS1621 will perform one temperature conversion upon receipt of the Start Convert T protocol. If 1SHOT is 0, the DS1621 will continuously perform temperature conversions. This bit is nonvolatile. X = Reserved.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
A device that acknowledges must pull down the SDA line during the acknowledge clock pulse in such a way that the SDA line is stable LOW during the HIGH period of the acknowledge related clock pulse. Of course, setup and hold times must be taken into account. A master must signal an end of data to the slave by not generating an acknowledge bit on the last byte that has been clocked out of the slave. In this case, the slave must leave the data line HIGH to enable the master to generate the STOP condition.
Figure 4 details how data transfer is accomplished on the 2-wire bus. Depending upon the state of the R/W bit, two types of data transfer are possible: 1. Data transfer from a master transmitter to a slave receiver. The first byte transmitted by the master is the slave address. Next follows a number of data bytes. The slave returns an acknowledge bit after each received byte. 2. Data transfer from a slave transmitter to a master receiver. The master transmits the first byte, the slave address. The slave then returns an acknowledge bit. Next follows a number of data bytes transmitted by the slave to the master. The master returns an acknowledge bit after all received bytes other than the last byte. At the end of the last received byte, a not acknowledge is returned. The master device generates all of the serial clock pulses and the START and STOP conditions. A transfer is ended with a STOP condition or with a repeated START condition. Since a repeated START condition is also the beginning of the next serial transfer, the bus will not be released
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
COMMAND SET
Data and control information is read from and written to the DS1621 in the format shown in Figure 5. To write to the DS1621, the master will issue the slave address of the DS1621 and the R/W bit will be set to 0. After receiving an acknowledge, the bus master provides a command protocol. After receiving this protocol, the DS1621 will issue an acknowledge and then the master may send data to the DS1621. If the DS1621 is to be read, the master must send the command protocol as before and then issue a repeated START condition and the control byte again, this time with the R/W bit set to 1 to allow reading of the data from the DS1621. The command set for the DS1621 as shown in Table 3 is as follows:
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
TIMING DIAGRAM:
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
POTENTIOMETER TYPES:
Material Carbon Manufacturing Method Common uses Deposited as a carbon insulating Cermet (usually Power (Typ) Most common material, especially for 0.1 to
composition ink on an cheap to average quality pots. Has a 0.5W a reasonable life, and noise level is phenolic resin) body quite acceptable in most cases. Ceramic/metal composite, High quality trimpots and some 0.25 to using a metallic resistance conventional panel mount types. Low 2W element on a ceramic noise and high stability. Relatively (or substrate limited life more) Conductive Special impregnated 0.25 to High quality pots, both rotary and Plastic plastic material with well 0.5W linear (slide). Excellent life, low controlled resistance noise and very good mechanical feel characteristics Wire wound Insulating former, with High power and almost indefinite 5 to resistance adhesive movement wire to wound life. Resistance is "granular", with 50W prevent completely smooth transition from more) one resistance winding to the next. Low noise, usually a rough mechanical feel. around it, and bound with discrete small steps rather than a (or
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
MULTI TURN POT is a potentiometer of 47K which varies from 0 to 47K.For each turn the resistance will be changed by 10 . It consists of three pins. PIN 1 is connected to +5V (Vcc). PIN 2 is connected to AN0 of Microcontroller. PIN 3 is connected to Ground (GND) The analog voltage is given to the AN0 pin of the microcontroller which indicates the changes in the pressure.
DESCRIPTION:
Multi turn pot is a manually adjustable, variable, electrical resistor. It has a resistance element that is attached to the circuit by three contacts, or terminals. The ends of the resistance element are attached to two input voltage conductors of the circuit, and the third contact, attached to the output of the circuit, is usually a movable terminal that slides across the resistance element, effectively dividing it into two resistors. Since the position of the movable terminal determines what percentage of the input voltage will actually be applied to the circuit, the potentiometer can be used to vary the magnitude of the voltage; for this reason it is sometimes called a voltage divider. Typical uses of potentiometers are in radio volume controls and television brightness controls.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
CONNECTIVITY:
This limit switch is connected to PIN-D2 of the microcontroller. This limit switch consists of three pins of first two are normally open (NO) and next two are normallyclosed(NC).
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
3.8 LCD
LIQUID CRYSTAL DISPLAY
INTRODUCTION:
A liquid crystal display (LCD) is a thin, flat display device made up of any number of color or monochrome pixels arrayed in front of a light source or reflector. It is often utilized in battery -powered electronic devices because it uses very small amounts of electric power.
OVERVIEW:
Each pixel of an LCD typically consists of a layer of molecules aligned between two transparent electrodes, and two polarizing filters, the axes of transmission of which are (in most of the cases) perpendicular to each other. With no liquid crystal between the polarizing filters, light passing through the first filter would be blocked by the second (crossed) polarizer. The surfaces of the electrodes that are in contact with the liquid crystal material are treated so as to align the liquid crystal molecules in a particular direction. This treatment typically consists of a thin polymer layer that is unidirectionally rubbed using, for example, a cloth. The direction of the liquid crystal alignment is then defined by the direction of rubbing. Electrodes are made of a transparent conductor called "ITO" or Indium Tin Oxide. Before applying an electric field, the orientation of the liquid crystal molecules is determined by the alignment at the surfaces. In a twisted nematic device (still the most common liquid crystal device), the surface alignment directions at the two electrodes are perpendicular to each other, and so the molecules arrange themselves in a helical structure, or twist. Because the liquid crystal material is birefringent , light passing through one polarizing filter is rotated by the liquid crystal helix as it passes through the liquid crystal layer, allowing it to pass through the second polarized filter.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
Half of the incident light is absorbed by the first polarizing filter, but otherwise the entire assembly is transparent. When a voltage is applied across the electrode s, a torque acts to align the liquid crystal molecules parallel to the electric field, distorting the helical structure (this is resisted by elastic forces since the molecules are constrained at the surfaces). This reduces the rotation of the polarization of the incident light, and the device appears gray. If the applied voltage is large enough, the liquid crystal molecules in the center of the layer are almost completely untwisted and the polarization of the incident light is not rotated as it passes through the liquid crystal layer. This light will then be mainly polarized perpendicular to the second filter, and thus be blocked and the pixel will appear black. By controlling the voltage applied across the liquid crystal layer in each pixel, light can be allowed to pass through in varying amounts thus constituting different levels of gray.
LCD USED:
In this project we are making use of 20 character X 40 line LCD module with LED backlight DMC20481
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
BLOCK DIAGRAM:
FEATURES:
Interface with 8-bit or 4-bit MPU is available. 192 kinds of alphabets, numerals, symbols and special characters can be displayed by built-in character generator (ROM). Other preferred characters can be displayed by character generator (RAM). Various functions of instruction are available by programming: Clear display Shift display cursor at home shift cursor on/off cursor blink character
Compact and light weight design which can be easily assembled in devices. Single power supply +5V drive (except for extended temp. type) Low power consumption.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
PIN ASSIGNMENT:
Pin No. Symbol 1 2 3 4 5 6 7 8 9 10 11 12 13 Vss Vcc VEE RS R/W E DB0 DB1 DB2 DB3 DB4 DB5 DB6
Level H/L H/L H,H-L H/L H/L H/L H/L H/L H/L H/L
Function 0V(GND) Power Supply +5V For LCD Drive Register Select Signal Register H : Data Input Select L : Instruction Input H : Data Read (Module-MPU) L : Data Write (Module-MPU) Enable Signal (No Pull-Up Resistor)
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
TIMING CHART:
Item
Unit
Enable Cycle Time 1000 Enable Pulse Width, High 450 Level Enable Rise and Decay Time Address Setup Time, RS, R/W- 140 E Data Delay Time Data Setup Time 195 Data Hold Time(Write 10 Operation) Data Hold Time(Read 20 Operation) Address Hold Time 10
ns ns ns ns ns ns ns ns ns
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
DATA LOGGER
INTRODUCTION:
A micro switch is a generic term used to refer to an electric switch that is able to be actuated by very little physical force. They are very common due to their low cost and extreme durability, typically greater than 1 million cycles and up to 10 million cycles for heavy duty models. . This durability is a natural consequence of the design. Internally a stiff metal strip must be bent to activate the switch. This produces a very distinctive clicking sound and a very crisp feel. When pressure is removed the metal strip springs back to its original state.
APPLICATIONS:
Common applications of micro switches include computer mouse buttons and arcade game's joysticks and buttons. Micro switches are commonly used in tamper switches on gate valves on fire sprinkler systems and other water pipe systems, where it is necessary to know if a valve has been opened or shut. They have also been used as anti-handling devices in booby trapped improvised explosive devices manufactured by paramilitary groups e.g. the Provisional IRA during the Troubles.
CONNECTIVITY:
In our project we are using 4 micro switches each for a specific purpose as a keypad. These switches are connected to the PORTD of microcontroller. The function of these switches is Switch 1 - Up key for Incrementing purpose- which is connected to pin D4 of microcontroller. Switch 2 - Down key for Decrementing purpose and to retrieve exceeded parameter data This is connected to pin D5 of microcontroller. Switch 3 Set key for setting date and time which is connected to pin D6 of microcontroller. Switch 4 Settp key for setting temperature and pressure which is connected to pin D7 of
Microcontroller
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
RESULTS OF PROJECT
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
1.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
WHEN WE SWITCH ON THE POWER SUPPLY IT WILL DISPLAY THE SET TEMPERATURE AND PRESSURE
2.
SWITCH 1 UPKEY
SWITCH 2 DOWNKEY
SWITCH 3 SETKEY
SWITCH 4 SETTPKEY
3.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
WHEN WE PRESS SWITCH 3 IT WILL ASK TO SET THE DATE AND TIME i.e.; TO
ENTER MONTH, DATE, YEAR, HOUR, MINUTES, SECONDS AND AFTER COMPLETING IT WILL DISPLAY TIME SET OVER.
4.
WE CAN SET TEMPERATURE AND PRESSURE AS OUR INTEREST JUST BY PRESSING SWITCH 4.BY PRESSING SWITCH 4 IT WILL ASK TO SET TEMPERATURE FIRST AND THEN TO SET PRESSURE. TEMPERATURE AND PRESSURE ARE SET WITH THE HELP OF UP KEY (FOR INCREMENTING) OR DOWN KEY (FOR DECREMENTING)
5.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
WHEN THERE IS NO REQUIRED LIQUID LEVEL IN THE TANK THE LIMIT SWITCH THAT WE ARE USING FOR LEVEL SENSING GETS CLOSED AND IT WILL BE DISPLAYED AS LEVEL LOW UNTIL IT GETS OPENED THE SYSTEM REMAINS IN A STILL STATE.
6.
WHEN THE SENSED TEMPERATURE, PRESSURE EXCEEDS THEIR SET VALUES IT CAN GIVE ALARAM AND IT CAN ALSO DISPLAYS THAT HOW MANY TIMES TEMPERATURE AND PRESSURE EXCEEDED
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
7.
CHAPTER 5 ADVANTAGES
& APPLICATIONS
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
comparison, a data logger accepts an input which is fed into an analog-to-digital converter prior to analysis and storage. This method has advantages in accuracy and resolution, while only a recorder can provide a truly continuous trend recording.
Given the extended recording times of data loggers, they typically feature a time-and datestamping mechanism to ensure that each recorded data value is associated with a date and time of acquisition. As such, data loggers typically employ built-in real-time clocks whose published drift can be an important consideration when choosing between data loggers.
Data logger range from simple single-channel input to complex multi-channel instruments. Typically, the simpler the device the less programming flexibility. Some more sophisticated instruments allow for cross-channel computations and alarms based on predetermined conditions. The newest of data loggers can serve web pages, allowing numerous people to monitor a system remotely.
The unattended and remote nature of many data logger applications implies the need in some applications to operate from a DC power source, such as battery. Solar power may be used to supplement these power sources. These constraints have generally led the data logger industry to ensure that the devices they market are extremely power efficient relative to computers. In many cases they are required to operate in harsh environmental conditions where computers will not function reliably.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
This unattended nature also dictates that the data loggers must be extremely reliable. Since they may operate for long periods nonstop with little or no human supervision, and may be installed in harsh or remote locations, it is imperative that so long as they have power, they will not fail to log data for any reason. Manufacturers go to great length to ensure that the devices can be depended on in these applications. As such data loggers are almost completely immune to the problems that might affect a general-purpose computer in the same application, such as program crashes and the instability of some operating systems.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
5.2
Unattended weather station recording (such as wind speed / direction, temperature, relative humidity, solar radiation) Unattended hydrographic recording (such as water level, water depth, water flow, water PH, water conductivity). Unattended soil moisture level recording. Unattended gas pressure recording. Road traffic counting. Measure temperatures (humidity etc) of perishables during shipments. Process monitoring for maintenance and troubleshooting applications Wild life research. Measure vibration handling (drop height) environment of distribution packaging. Tank level monitoring. Deformation monitoring of any object with geodetic or geotechnical sensors controlled by an automatic deformation monitoring system. Environmental monitoring. Vehicle testing Monitoring of relay status in railway signaling. For science education enabling measurement, scientific investigation and an appreciation of change. Record trend data at regular intervals in veterinary vital signs monitoring
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
CONCLUSION:
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
Data logger is not limited for any particular application, it can be used any where in a process industries with little modifications in software coding according to the requirements. This concept not only ensures that our work will be usable in the future but also provides the flexibility to adapt and extend, as needs change. Basically, Data logger is a stand alone device but we can even connect it to a PC by using RS232.We can also use Agilent VEE Pro software which is a graphical programming environment optimized for use with electronic instruments for providing the lab view of the parameters measured using Data Loggers
FUTURE DIRECTIONS:
Data Loggers are changing more rapidly now than ever before. The original model of a stand alone data logger is changing to one of a device that collects data but also has access to wireless communications for alarming of events, automatic reporting of data and remote control. Data Loggers are beginning to serve web pages for current readings e-mail their alarms and FTP their daily results into databases or direct to the users.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
APPENDIX
APPENDIX- A
SOURCE CODE:
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
/*
data.c
*/
#include<16f877a.h> #use delay (clock=4000000) #fuses xt,nowdt,nolvp,protect #use i2c(master, sda=PIN_C1,scl=PIN_C0) #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7) #include <lcdd.c> #define settpkey PIN_d7 #define setkey PIN_d6 #define downkey PIN_d5 #define upkey PIN_d4 #define buzer PIN_d3 #define limit PIN_d2 int sec,min,hour,day,date,month,year,k,mo; int temp,temp1; int temph,templ,press,pressset,tempset,countt=0,countp=0,memadrt=0,memadrp=130; int date1,month1,hour1,min1,temph1,b; long int a,q; #include <temparature.c> #include <rtclock.c> #include <timeset.c> #include <pressure.c> #include <setting.c> #include <memwrite.c> #include <memread.c> void main() { lcd_init(); time_read(); if ((min==0Xff)&(hour==0Xff)) rtc_init(); temp_init(); tempset = read_EEPROM (0x00); pressset= read_EEPROM (0x01); lcd_putC(" \f DATA LOGGER "); lcd_gotoxy(1,2); printf(lcd_putc,"TEMP. SET :%u dc",tempset ); lcd_gotoxy(1,3); printf(lcd_putc,"PRESS.SET :%ukg/sq.cm",pressset ); delay_ms(5000); q=3; while(1)
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
{ LEVEL:if(!input(limit)) { lcd_putC(" \f DATA LOGGER "); lcd_putC(" \n LEVEL LOW "); delay_ms(1000); GOTO LEVEL; } q--; if(q>2)goto skip; if((temph>=tempset)||(press>=pressset))mem1(); skip: if(q<2)q=3; { delay_us(500); if(!input(settpkey))ati(); if(!input(setkey)) { month=monthset(month); date=dateset(date); hour=hourset(hour); min=minuteset(min); lcd_putC(" \f TIME SET OVER "); rtc_set(); delay_ms(500); time_read(); delay_ms(300); } time_read(); temp_read(); pressure(); if (templ==0x80)templ=5; else templ=0; printf(lcd_putc," \f%02x/%02x/2008",date,month ); printf(lcd_putc," %02x:%02x:%02x",hour,min,sec); lcd_gotoxy(1,2); printf(lcd_putc,"TEMPERATURE: %02d.%d dc",temph,templ);
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
lcd_gotoxy(1,3); printf(lcd_putc,"PRESSURE: %02ukg/sq.cm",press); printf("\f"); printf("TEMP: %02d.%d,",temph,templ); printf(" PRESSURE: %02ukg/sq.cm",press); delay_ms(1000); if(!input(downkey))mem2();
} } }
/* temperature .c */
temp_init() { i2c_start(); i2c_write(0x90);// device address i2c_write(0xac);// control register i2c_write(00);// write mode i2c_stop(); delay_ms(10); i2c_start(); i2c_write(0x90);// device address i2c_write(0xee);// control register i2c_stop(); } temp_read() { i2c_start(); i2c_write(0x90); i2c_write(0xaa); i2c_start(); i2c_write(0x91); temph=i2c_read(); templ=i2c_read(0); i2c_stop(); }
/*
rtclock.c */
void rtc_init()
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
{ //printf("\n i2c initilization"); i2c_start(); i2c_write(0xd0); i2c_write(0x00); i2c_write(00);//seconds i2c_write(00);//minutes i2c_write(0x12);//hours i2c_write(01);//day i2c_write(01);//date i2c_write(01);//month i2c_write(0x08);//year i2c_write(0x10); i2c_stop(); } void rtc_set() { //printf("\n RTC SETTING "); i2c_start(); i2c_write(0xd0); i2c_write(0x00); i2c_write(00);//seconds i2c_write(min);//minutes i2c_write(hour);//hours i2c_write(day);//day i2c_write(date);//date i2c_write(month);//month i2c_write(0x08);//year); i2c_write(0x10); i2c_stop(); } time_read() { i2c_start(); i2c_write(0xd0); i2c_write(0x00); i2c_start(); i2c_write(0xd1); sec=i2c_read(); min=i2c_read(); hour=i2c_read(); day=i2c_read(); date=i2c_read(); month=i2c_read(); year=i2c_read(0); i2c_stop(); }
/*
timeset.c */
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
int dec_bcd(int a) { temp=abs(a/10); temp1=a%10; a=(temp*16)+temp1; return(a); } int bcd_dec(int a) { temp=abs(a/16); temp1=a%16; a=(temp*10)+temp1; return(a); } monthset(int m) { //int mo; lcd_putc("\f ENTER MONTH"); mo=bcd_dec(m); printf(lcd_putc,"\n month %02d",mo); k=0; code0: delay_ms(500); K++; if (K>=60) goto modem; if(!input(upkey)) { mo++; if (mo>=0X0d) mo=1; printf(lcd_putc,"\f month %02d",mo); } if(!input(downkey)) { mo--; if(mo<=1) mo=1; printf(lcd_putc,"\f month %02d",mo); } if(input(setkey)) goto code0; modem: mo=dec_bcd(mo); return(mo); } //*********************************************************** dateset(int n)
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
{ int da; lcd_putc("\f ENTER DATE"); da=bcd_dec(n); printf(lcd_putc,"\fDATE %02d",da); k=0; code2: delay_ms(500); K++; if(K>60) goto moded; if(!input(upkey)) { da++; if((mo==2)&&(da>0X1d)) da=0X1d; if((mo==4)||(mo==6)||(mo==9)||(mo==0X0B)&&(da>0X1E)) da=0X1E; if((mo==1)||(mo==3)||(mo==5)||(mo==7)||(mo==8)||(mo==0X0a)|| (mo==0X0c)&&(da>0x1f)) da=0X1f; printf(lcd_putc,"\fDATE %d",da); } if(!input(downkey)) { da--; if(da<1) da=1; printf(lcd_putc,"\fDATE %02d",da); } if(input(setkey)) goto code2; moded: da=dec_bcd(da); return(da); } //******************************************************************** ***** hourset(int o) { int ho; lcd_putc("\fENTER HOUR"); ho=bcd_dec(o); printf(lcd_putc,"\fhour %02d",ho); k=0; code21: delay_ms(500);
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
K++; if(k>=60) goto modeh; if(!input(upkey)) { ho++; if(ho>=24) ho=0; printf(lcd_putc,"\fhour %02d",ho); } if (!input(downkey)) { ho--; if (ho<0) ho=23; if(ho>=24) ho=0; printf(lcd_putc,"\fhour %02d",ho); } if (input(setkey)) goto code21 ; modeh: ho=dec_bcd(ho); return(ho); } //************************************************ minuteset(int p) { int mi; lcd_putc("\fENTER MINUTE"); mi=bcd_dec(p); printf(lcd_putc,"\f minutes %02d",mi); k=0; code3: delay_ms(500); K++; if (K>=60) goto modem; if(!input(upkey)) { mi++; if (mi>=60) mi=00; printf(lcd_putc,"\f minutes %02d",mi); } if(!input(downkey)) { mi--; if(mi<=1)
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
mi=0; if(mi>=60) mi=0; printf(lcd_putc,"\f minutes %02d",mi); } if(input(setkey)) goto code3; modem: mi=dec_bcd(mi); return(mi); } //***********************************************************
/* pressure.c */
pressure() { setup_adc_ports( ALL_ANALOG ); setup_adc(ADC_CLOCK_INTERNAL ); set_adc_channel( 0 ); press = read_adc(); press=press/2.55; setup_adc( ADC_OFF ); }
/*
ati() {
setting.c
*/
lcd_putC(" \fSET TEMPARATURE "); delay_ms(1000); while(input(settpkey)) { if(!input(upkey)) { tempset++; if(tempset>=100)tempset=100; lcd_gotoxy(1,2); printf(lcd_putc,"TEMP SET: %u dc",tempset); delay_ms(1000); write_eeprom(0x00,tempset);
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
/*
mem1() { if(temph>=tempset) {
memwrite.c */
countt++; if(countt>=121) { countt=0; memadrt=0; } output_low(buzer); delay_ms(1000); output_high(buzer); delay_ms(1000); i2c_start(); i2c_write(0xa0); // Device address i2c_write(0x00); // Data to device i2c_write(memadrt); i2c_write(temph); i2c_write(month); i2c_write(date); i2c_write(hour); i2c_write(min); i2c_stop(); delay_ms(100); memadrt=memadrt+5; } if(press>=pressset) { countp++; if(countp>=251) { countp=0; memadrp=0; } output_low(buzer); delay_ms(1000);
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
output_high(buzer); delay_ms(1000); output_high(buzer); // printf(lcd_putc," \f%02x/%02x/2008",date,month ); // lcd_gotoxy(11,2); // printf(lcd_putc," %02x:%02x:%02x",hour,min,sec); // lcd_gotoxy(1,3); // printf(lcd_putc,"pressure-%02ukg/sq.cm",press); // delay_ms(7000); i2c_start(); i2c_write(0xa0); // Device address i2c_write(0x00); // Data to device i2c_write(memadrp); i2c_write(press); i2c_write(month); i2c_write(date); i2c_write(hour); i2c_write(min); i2c_stop(); delay_ms(100); memadrp=memadrp+5; } }
/*
mem2() {
memread.c */
int c,d,rmonth,rdate,rmin,rhour,counttm,countpm; c=memadrt-5; d=memadrp-5; printf(lcd_putc,"\fTEMP.EXCEEDED "); printf(lcd_putc,"\n%u TIMES",countt); delay_ms(3000); for(b=1;b<=countt;b++) { i2c_start(); i2c_write(0xa0); // Device address i2c_write(0x00); // Data to device i2c_write(c); i2c_start(); i2c_write(0xa1); // to change data direction temph=i2c_read(); // Now read from slave rmonth=i2c_read(); rdate=i2c_read();
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
rhour=i2c_read(); rmin=i2c_read(0); i2c_stop(); delay_ms(100); printf(lcd_putc,"\fTEMP.DATA %u",b); delay_ms(2000); lcd_gotoxy(1,2); printf(lcd_putc," \f%02x/%02x/2008",rdate,rmonth ); lcd_gotoxy(1,2); printf(lcd_putc," %02x:%02x:%02x",rhour,rmin,sec); lcd_gotoxy(1,4); printf(lcd_putc,"TEMP : %02d.%d dc",temph,templ); delay_ms(5000); c=c-5; } printf(lcd_putc,"\fPRESS. EXCEEDED"); printf(lcd_putc,"\n%u TIMES",countP); delay_ms(3000); for(b=1;b<=countp;b++) { i2c_start(); i2c_write(0xa0); // Device address i2c_write(0x00); // Data to device i2c_write(d); i2c_start(); i2c_write(0xa1); // to change data direction press=i2c_read(); // Now read from slave rmonth=i2c_read(); rdate=i2c_read(); rhour=i2c_read(); rmin=i2c_read(0); i2c_stop(); delay_ms(100); printf(lcd_putc,"\fPRESS.DATA %u",b); delay_ms(2000); printf(lcd_putc," \f%02x/%02x/2008",rdate,rmonth ); lcd_gotoxy(1,2); printf(lcd_putc," %02x:%02x:%02x",rhour,rmin,sec); lcd_gotoxy(1,4); printf(lcd_putc,"PRE:%02ukg/sq.cm",press); delay_ms(5000); d=d-5; }
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
/*
lcdd.c
*/
//////////////////////////////////////////////////////////////////////////// //// LCD420.C //// //// Driver for common 4x20 LCD modules //// //// //// //// lcd_init() Must be called before any other function. //// //// //// //// lcd_putc(c) Will display c on the next position of the LCD. //// //// The following have special meaning: //// //// \f Clear display //// //// \n Go to start of second line //// //// \b Move back one position //// //// //// //// lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1) //// //// //// //// lcd_getc(x,y) Returns character at position x,y on LCD //// //// //// //////////////////////////////////////////////////////////////////////////// //// (C) Copyright 1996,1997 Custom Computer Services //// //// This source code may only be used by licensed users of the CCS C //// //// compiler. This source code may only be distributed to other //// //// licensed users of the CCS C compiler. No other use, reproduction //// //// or distribution is permitted without written permission. //// //// Derivative programs created using this software in object code //// //// form are not restricted in any way. //// //////////////////////////////////////////////////////////////////////////// // As defined in the following structure the pin connection is as follows: // B0 enable // B1 rs // B2 rw // B4 D4 // B5 D5 // B6 D6 // B7 D7 // // LCD pins D0-D3 are not used and PIC B3 is not used. struct lcd_pin_map { // This structure is overlayed BOOLEAN enable; // on to an I/O port to gain BOOLEAN rs; // access to the LCD pins. BOOLEAN rw; // The bits are allocated from BOOLEAN unused; // low order up. ENABLE will int data : 4; // be pin B0. } lcd; #byte lcd = 6 // This puts the entire structure
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
BYTE const LCD_INIT_STRING [4] = {0x20 | (lcd_type << 2), 0xc, 1, 6}; // these bytes need to be sent to the LCD // to start it up. // The following are used for setting // the I/O port direction register. struct lcd_pin_map const LCD_WRITE = {0,0,0,0,0}; // For write mode all pins are out struct lcd_pin_map const LCD_READ = {0,0,0,0,15}; // For read mode data pins are in BYTE lcdline; BYTE lcd_read_byte() { BYTE low,high; set_tris_b(LCD_READ); lcd.rw = 1; delay_cycles(1); lcd.enable = 1; delay_cycles(1); high = lcd.data; lcd.enable = 0; delay_cycles(1); lcd.enable = 1; delay_us(1); low = lcd.data; lcd.enable = 0; set_tris_b(LCD_WRITE); return( (high<<4) | low); } void lcd_send_nibble( BYTE n ) { lcd.data = n; delay_cycles(1); lcd.enable = 1; delay_us(2); lcd.enable = 0; }
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
void lcd_send_byte( BYTE address, BYTE n ) { lcd.rs = 0; while ( bit_test(lcd_read_byte(),7) ) ; lcd.rs = address; delay_cycles(1); lcd.rw = 0; delay_cycles(1); lcd.enable = 0; lcd_send_nibble(n >> 4); lcd_send_nibble(n & 0xf); } void lcd_init() { BYTE i; set_tris_b(LCD_WRITE); lcd.rs = 0; lcd.rw = 0; lcd.enable = 0; delay_ms(15); for(i=1;i<=3;++i) { lcd_send_nibble(3); delay_ms(5); } lcd_send_nibble(2); for(i=0;i<=3;++i) lcd_send_byte(0, LCD_INIT_STRING[i]); } void lcd_gotoxy( BYTE x, BYTE y) { BYTE address; switch(y) { case 1 : address=0x80;break; case 2 : address=0xc0;break; case 3 : address=0x94;break; case 4 : address=0xd4;break; } address+=x-1; lcd_send_byte(0,address); } void lcd_putc( char c) { switch (c) { case '\f' : lcd_send_byte(0,1); lcdline=1; delay_ms(2);
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
break; case '\n' : lcd_gotoxy(1,++lcdline); break; case '\b' : lcd_send_byte(0,0x10); break; default : lcd_send_byte(1,c); break; } } char lcd_getc( BYTE x, BYTE y) { char value; lcd_gotoxy(x,y); lcd.rs=1; value = lcd_read_byte(); lcd.rs=0; return(value); }
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
APPENDIX_B
DEVICE DIFFERENCES
CONVERSION CONSIDERATIONS
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
APPENDIX-C
NOTE 1:
Legend: I = input O = output I/O = input/output P = power = Not used TTL = TTL input ST = Schmitt Trigger input
NOTE 2:
1. ICCS specified with VCC = 5.0V and SDA, SCL = 5.0V. 2. VCC = 0V, VBAT = 3V. 3. After this period, the first clock pulse is generated. 4. A device must internally provide a hold time of at least 300ns for the SDA signal (referred to the VIHMIN of the SCL signal) in order to bridge the undefined region of the falling edge of SCL. 5. The maximum tHD: DAT has only to be met if the device does not stretch the LOW period (tLOW) of the SCL signal. 6. CB Total capacitance of one bus line in pF. 7. ICCA SCL clocking at max frequency = 100 kHz. 8. VPF measured at VBAT = 3.0V.
NOTE 3:
1. All voltages are referenced to ground. 2. I/O pins of fast mode devices must not obstruct the SDA and SCL lines if VDD is switched off. 3. ICC specified with TOUT pin open. 4. ICC specified with VCC at 5.0V and SDA, SCL = 5.0V, 0C to 70C. 5. After this period, the first clock pulse is generated. 6. A device must internally provide a hold time of at least 300ns for the SDA signal (referred to the VIH MIN of the SCL signal) in order to bridge the undefined region of the falling edge of SCL. 7. The maximum tHD: DAT has only to be met if the device does not stretch the LOW period (tLOW) of the SCL signal. 8. CB total capacitance of one bus line in pF.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
BIBLIOGRAPHY
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
BIBLIOGRAPHY
BOOKS REFERRED:
1) Adler, R. B., A. C. Smith, and R. L. Longani: Introduction to Semiconductor Physics, vol. 1, p. 78, Semiconductor Electronics Education Comitee, John Wiley & Sons, Inc., New York ,1964. 2) Schade, O. H.: Analysis of Rectifier Operation, proc. IRE, vol.31, pp. 341361, July, 1943. 3) Stout, M. B.: Analysis of Rectifier Circuits, Elec. Eng., vol. 54, September, 1935. 4) Jacob Millman Christos C. Halkias.: Electronic Devices And Circuits, Tata McGraw-Hill Publishing Company Ltd. Sep, 2003. 5) Fair, Z. E.: Piezoelectric Crystals in Oscillator Circuits, Bell System Tech. J., vol.24, April, 1945. 6) Hakim, S. s.:Open and Closed Loop Response of Feedback Amplifiers, Electron. Eng., October, 1962 7) Bode, H. W.: Negative Feedback in Current Amplifier Design, D. Van Nostrand Company, Inc., Princeton, N.J., 1945. 8) Sawhney, A.K.: Electrical and Electronic Measurements and Instruments, Dhanpat Rai & Co. 2003. 9) Yang, E.S: Fundamentals of Semiconductor Devices, chap. 1 McGraw Hill Book Company, New York, 1978. 10) Shive, J.N.: Semiconductor Devices, chaps 8&9, D.Van Nostrand Inc. Princeton, N.J., 1959. 11) Millman, J.: Microelectronics: Digital and Analog Circuits and Systems, McGraw Hill Book Company, New York, 1979. 12) Roger L Stevens : Serial Communications, Dontrics, 1997 13) Robert Terusalim: Programming in Luo 2-nd edition, D. Van Nostrand Company, Inc., Princeton, N.J., 1987.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
14) Jan Axelson: Parallel Port Complete, McGraw Hill Book Company, New York, 1989. 15) Peter H.Anderson, PIC C Routines copyright, Baltimore, MD, Nov,99 16) Bahadur, B.: Liquid Crystals- Applications and Uses, Litton Systems Canada, 1992. 17) Myke Predko: Programming and Customizing PIC Microcontrollers, Amazon, 1998. 18) Myke Predko: Handbook of Microcontrollers, Amazon, 1887.
Journals Referred
1) Innovation: Magazine of Research & Technology,2000 2) International Journal of Reliability, Quality and Safety Engineering(IJRQSE) Editor-in-chief Hoang Pham Dept. of Industrial Eng 3) Journal of Electronics Manufacturing (JEM) Editor-in-Chief Paul P. Conway Wolfson School of Mechanical & Manufacturing Engineering 4) Foundations and Trends in Electronic Design Automation (FTEDA) Editor in-chief Sharad Malik, Dept.of Electrical Eng., Princeton University. 5) Printed Circuit Design Online (Magazine). 6) Design Magazine. 7) Journal of Instrumentation (JNIST). 8) Microcontroller solutions.
www.final-yearproject.com | www.finalyearthesis.com
DATA LOGGER
Websites:
1) http://www.microchip.com/ 2) http://www.optrex.com/ 3) http://www.howstuffworks.com/ 4) http://www.maxim-ic.com/ 5) http://www-us2.semiconductors.philips.com/acrobat/various/ 6) http://www.esacademy.com/faq/i2c/index.htm 7) http://www.embedded.com/story/OEG20020528S0057 8) http://www.amplicon.com/ 9) http://www.grainger.com/ 10) http://www.sound.westhost.htm 11) http://www.wikipedia.org/wiki/level-sensor 12) http://www.smcelectronics.com/ 13) http://www.honeywell.com/ 14) http://www.logicteach.com/applications.htm 15) http://www.google.com/ 16) Electronic Devices And Circuits 17) http://www.bg800.com 18) http://www.omega.com
DATA SHEETS:
1) Dallas semiconductor datasheets. 2) Optrex LCD data sheet 3) I2C_BUS_SPECIFICATION_1995.pdf