P. 1
3927892 Design of a Data Logger

3927892 Design of a Data Logger

|Views: 14|Likes:
Published by fabi235

More info:

Published by: fabi235 on Jan 21, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

07/18/2014

pdf

text

original

Sections

  • 1 Introduction
  • 1.1 Overview
  • 1.2 Physical Implementation
  • 1.3 Proposed Operation
  • 2 Implementation
  • 2.1 Measurement Module
  • 2.1.1 Measurement Unit
  • 2.1.1.1 Temperature and Humidity Measurement
  • 2.1.1.2 Time Stamping
  • 2.1.1.3 Control
  • 2.1.2 Memory Unit
  • 2.1.2.1 Sampling Rate
  • 2.1.2.2 Data Storage
  • 2.1.2.3 Measurement Data
  • 2.1.2.4 Time Stamped Data
  • 2.1.2.5 Physical Implementation
  • 2.1.2.6 Power Consumption
  • 2.1.2.7 Writing to EEPROM
  • 2.1.2.8 Development and Testing of EEPROM Software
  • 2.1.3 System Operation
  • 2.1.3.1 Tasks Required
  • • Sampling and Storage of Base Time Stamp
  • 2.1.3.2 Sampling and Storage of Base Time Stamp
  • 2.1.4 Complete Circuit Diagram
  • 2.1.5 Construction of Measurement Module
  • 2.2 PC Interface Module
  • 2.2.1 Hardware Requirements
  • 2.2.2 The Download Procedure
  • • Communication Protocol
  • 2.2.2.1 Communication Protocol
  • 2.2.2.2 USART Communication
  • 2.2.2.3 EEPROM read process
  • 2.2.2.4 Actual download procedure
  • 2.2.2.5 The Visual Basic Graphical User Interface
  • 2.2.2.6 Data manipulation using PC software
  • 3 Housing
  • 3.1 The Measurement Unit
  • 3.2 The Memory Unit
  • 3.3 The PC Interface Unit
  • 4 Module Tests
  • 5 Analysis of Design
  • 5.1 The Measurement Module
  • 5.2 The PC Interface Module
  • 5.3 Housing
  • 6 Costing
  • 7 Conclusion
  • References
  • Contacts
  • Appendix A
  • Average Sensor Supply Current Calculation
  • Power Calculation for EEPROM
  • Power Comparison between Microcontroller Based RTC and Dedicated RTC
  • Power Calculation for Microcontroller

COURSE: REPORT ON: REPORT BY

:

Electronic Design 3 Design of a Data Logger (Phase 3 Report) Group 6 (Corresponding Author: Muhammad Simjee - simjeem@gmail.com) Irisa Govender Mark Joseph Nicol Naidoo Seeralin Nayager 203502431 203504473 203503153 203505544

Muhammad Simjee 203503366 Shivan Singh 202511992

Abstract
This report covers the theoretical design and implementation of a Data Logging device. The report aims to highlight the design stages undertaken from initial conception through to the testing of the end product constructed. The design was initiated in order to aid conservationists in researching the living conditions of bats. Thus the procedure which was adopted to create a cost effective and user-friendly device can be clearly seen, in the report, as the system is developed. The data logger created stores hourly samples of temperature and humidity data for a period of 6 months. In order to allow the system to operate off batteries low power consumption was an important criterion in the design process. The device allows the user to download the stored data to a PC via the USB port. PC software has also been created that will enable the user to view the data in a suitable format. Due to the environment in which the device will have to operate a robust housing was created. The system created was also tested and the results of these tests have also been included in the report as well as a detail analysis of the design which highlights areas of improvement.

ii

Contents
Abstract ................................................................................................................................................... ii Contents.................................................................................................................................................. iii List of Abbreviations............................................................................................................................... v 1 Introduction ..................................................................................................................................... 1 1.1 1.2 1.3 2 Overview................................................................................................................................ 2 Physical Implementation........................................................................................................ 4 Proposed Operation................................................................................................................ 5

Implementation................................................................................................................................ 5 2.1 2.1.1 Measurement Module ............................................................................................................ 5 Measurement Unit ............................................................................................................. 5 Temperature and Humidity Measurement ................................................................ 5 Time Stamping.......................................................................................................... 9 Control .................................................................................................................... 15

2.1.1.1 2.1.1.2 2.1.1.3 2.1.2

Memory Unit ................................................................................................................... 15 Sampling Rate......................................................................................................... 16 Data Storage............................................................................................................ 16 Measurement Data .................................................................................................. 16 Time Stamped Data................................................................................................. 17 Physical Implementation......................................................................................... 17 Power Consumption................................................................................................ 18 Writing to EEPROM............................................................................................... 18 Development and Testing of EEPROM Software .................................................. 20

2.1.2.1 2.1.2.2 2.1.2.3 2.1.2.4 2.1.2.5 2.1.2.6 2.1.2.7 2.1.2.8 2.1.3

System Operation ............................................................................................................ 22 Tasks Required ....................................................................................................... 22 Sampling and Storage of Base Time Stamp............................................................ 22

2.1.3.1 2.1.3.2 2.1.4 2.1.5 iii

Complete Circuit Diagram............................................................................................... 26 Construction of Measurement Module ............................................................................ 28

.4 2.............................2........................................................................................................................................................................2 2.............................................. 46 5................................... 35 The Visual Basic Graphical User Interface........................................................................................................................2 5..........2........ 43 The PC Interface Unit ............................................................................................................................. 45 Analysis of Design .......................2.......................................................................................................................................... 29 The Download Procedure ..................................................................................................................................................................... 53 Appendix A ................................................3 The Measurement Unit ............................. 39 Data manipulation using PC software.......................................................................................................2.......2................................................. 55 Power Comparison between Microcontroller Based RTC and Dedicated RTC............................2.........2 3....6 3 Housing ..............................................................................................................................................1 2................3 The Measurement Module ................................................2 PC Interface Module .....................................................2.........2...............2 2.................................................................. 49 References .......... 46 6 7 Costing ............................................................................................................... 32 EEPROM read process .................................................... 33 Actual download procedure ................................ 31 USART Communication...............2..................... 30 Communication Protocol .................................2...........................................2........1 2.................................................................................................2.......................................... 43 3.......................... 57 iv ......................................................................... 46 The PC Interface Module........... 50 Contacts............................ 54 Average Sensor Supply Current Calculation....................................................... 48 Conclusion............................................................................5 2................................................................. 40 2................... 54 Power Calculation for EEPROM .........................2.................................................................................. 44 4 5 Module Tests ...........................................................................................................................................................2..........................................2..1 5............................. 55 Power Calculation for Microcontroller ........... 29 Hardware Requirements ................................................. 43 The Memory Unit .........1 3.. 46 Housing........................3 2.....................................................................................................................................

List of Abbreviations ISR LED RTC PC MSB RH RTD SCK CRC EEPROM FAT MMC SD GUI USART BCD Interrupt Service Routine Light Emitting Diode Real time clock Personal computer Most Significant bit Relative Humidity Resistive Temperature Devices Synchronous Clock Cyclic Redundancy Check Electrically Erasable Programmable Read Only Memory File allocation Table Multimedia Cards Secure Digital Graphical User Interface Universal Synchronous Asynchronous Receiver Transmitter Binary Coded Decimal v .

Facilities in order to process this data on the PC will also have to be made available. A direct result of this is that the device had to be designed for low power consumption. the animals are displaced and as such there are a growing number of animals making their way onto the endangered species list. these devices are not always user friendly nor are they compact. In order for a prospective user to access the data on the device a simple and user-friendly method of transferring the data to a PC would be required. Besides the exorbitant costs of the average data loggers currently available. research into the optimum living conditions of bats must be investigated if sanctuaries and homes for these creatures are to be constructed. As humans encroach on the habitats of animals. Due to the sites of implementation of the devices it was realized that these units would have to be completely battery operated. it was concluded that the most sought after data. A myriad of conservation groups exists with a goal of being able to save these amazing creatures. pertaining to the dwellings of bats. Table 1: Overall System Tasks and Constraints 1 . It was thus the objective of this design to create a data logging device that was inexpensive. Most conservation groups are non-profit organizations and field researchers often run into the problem of insufficient funds for technology capable of capturing and storing data. in order to successfully achieve this goal. easy to use and convenient to transport to the site of implementation. Furthermore. Many different species of bats are also becoming part of this harmful trend. However. is temperature and relative humidity. The table below provides a summary of the tasks and constraints which the project is subject to. After consultation with various individuals that play an integral role in research and conservation of bats. Thus the group set out to design an autonomous product capable of measuring and storing these parameters for a period of 6 months. the device would have to be in a robust housing which provides water resistance and a measure of shock absorption.1 Introduction The conservation of wildlife is becoming a major concern of modern society. In order for the data to be to functional to researchers it was required that the temperature be accurate to 2°C and the humidity to 4 % whilst the respective ranges of operation are 0°C-50°C and 0%-100%.

1 For reasons of simplicity the functional unit performing the task of measurement and data storage will be known as the measurement module 2 For reasons of simplicity the functional unit performing the tasks of data download and data processing will be known as the PC Interface module 2 . namely the measurement and storage of data (Memory Module)1 and the other being the downloading of data to the PC and the processing of data (PC Interface Module)2. Evaluation of the tasks revealed that two major tasks were required.1. These tasks are made visible on the following block diagram. Figure 1: Overall System Block Diagram Of the constraints displayed the most difficult to achieve is the 6 months of operation on standard batteries. In order to achieve this goal all major design decisions were taken in order to minimize power consumption.1 Overview Using the tasks illustrated in Table 1 a system block diagram was created.

However. physically separating the functions provides advantages that are undoubtedly superior.Figure 2: Block Diagram of System Modules The implementation of these two functions could be achieved in a single physical device. since both functions can be done independently. These benefits are now discussed with reference to the following diagrams. Table 2: Tasks and Constraints of the Measurement Module Table 3: Tasks and Constraints of the PC Interface 3 . Such an implementation would be cost effective as manufacturing. housing and materials costs would be reduced.

2 Physical Implementation Evaluation of Figure 3 highlights that the memory device is used by both modules. Memory Unit and PC interface Unit. The PC Interface Unit connected to the Memory Unit in conjunction with a PC forms the PC Interface Module. To create the required system three separate units were designed and constructed. The Measurement Unit in conjunction with Memory Unit forms the Measurement Module. The units and their associated modules are illustrated in the following diagram. That is that the main constraint of the system. power consumption. will only influence the design of the Measurement Module. There are further benefits in terms of product usability that will be illustrated. 1. namely: Measurement Unit.The separation of the functions into different units highlights a major factor. Limiting the constrained region of the project would allow for greater design freedom and increased functionality in the PC Interface Module. Figure 3: Block Diagram of System Modules Including Memory and PC Interface Unit 4 . In order to increase the functionality of the system the memory device was designed as an independent unit which could be transferred between modules when required.

unlike the SHT which has a response time of between 5s and 30s.05˚C-1. especially at high humidity levels. The SHT71 is a capacitive sensor with accuracy between 2% and 3.1˚C-1˚C respectively. typically providing 3% to 5% accuracy. The best accuracy available on the market comes with the calibrated sensor probes and this is approximately 1. these devices are extremely expensive and used rather as a reference for the calibration of high precision sensor components.1. The most accurate humidity measurement instruments available are chilled mirror hygrometers.1 Measurement Module The Measurement Module consists of the Measurement Unit and the Memory Unit. The versatility of the system when separated into units cannot be emphasised enough. Further.4˚C at 25˚C. During this period the unit is required to obtain time stamped temperature and humidity data. The device will obtain measurements for 6 months after which the client will return to the device and remove the Memory Unit. The measurement data will then be downloaded to the PC where it will be processed. Unfortunately. offering 0. This module is placed in the field and will operate for a period of 6 months. has a significant effect on relative humidity. By creating separate units a potential customer has greater flexibility when purchasing and using the product.0. These sensors are also more suited for use in non-condensing environments.5%. however for this application such high accuracy is not imperative. with RH being dependent on temperature. The Measurement Unit as well as the Memory Unit will be placed in an area where temperature and humidity data are required. For example a 1˚C change at 50˚C and a RH of 80˚C results in a 4% change in humidity.5˚C and 0. The Memory Unit will then be docked with the PC interface unit which is connected to a PC. However. Thermistors are not perfect neither do they perform very well in environments with significant moisture. Resistive sensors do not offer the same accuracy for RH measurements. The Sensirion SHT71 offers the closeness of sensors that is required as both are present on the same chip.1. these sensors require frequent recalibration. This change is due to a directly proportional relationship between saturation vapour pressure and RH.5% RH. For example a consumer wishing to purchase multiple systems will only be required to purchase a single PC Interface Unit.3 Proposed Operation The understanding of the systems operation is best explained by use of an example of how a potential customer would use the device. If temperature increases or decreases then the saturation vapour pressure has a corresponding change. 2. This may not be as accurate as the sensor probe but it does not require frequent recalibration and for this particular application such high levels of accuracy are unnecessary. The temperature sensor on the SHT is also capacitive and provides an accuracy of +/. Negative Temperature Coefficient (NTC) thermistors and platinum Resistive Temperature Devices (RTD’s) are capable of a higher accuracy. consequently there is a change in RH. This also minimizes the component count and hence reduces hardware complexity. The SHT71 was found to be the best suited for 5 . Hence any slight change in temperature.1.1.1 Temperature and Humidity Measurement Temperature and Relative Humidity (RH) are very closely related. if long term measurements were required a user could simply refresh the Measurement Unit after 6 months have elapsed. The major limiting factor in the design of the measurement unit is power consumption. 2 Implementation 2. Platinum RTD’s shortfall is in that it has a very slow response time 1s-50s. They are also prone to self-heating and are therefore not being suitable for this design. 2. It would thus be an advantage to have both the temperature and RH sensors in as close proximity as possible to obtain an accurate relationship between the two environmental conditions by avoiding the temperature gradient that would exist between two separate sensors.1 Measurement Unit The Measurement Unit is tasked with gathering time stamped temperature and humidity data.

1. The timing diagram in Figure 5 is a graphical representation of this sequence. 2. This is integral to the overall objective of reducing power requirements to meet the 6 month lifespan of the device. The flow chart alongside illustrates the general order of events to be followed to request the sensor to take measurements and read the information placed on the Data Line by the sensor. A transmission start sequence is generated by pulling the Data Line low during a positive clock pulse and then releasing the line on the following clock pulse.04 temperature resolution and a 0.1. The sensor requires no other peripheral hardware except for a source.application in this design. 20% to 80% RH.1. decoupling and connection to the microcontroller.1. The sensor and the microcontroller interact using 2 wire communication.1 The Sensor Configuration It was decided that the sensor would be setup to output temperature data in a 12 bit format and RH in an 8 bit format.1 Overview As previously stated the sensor uses a two wire method of communication. This allows for a simple two wire method of communicating with the device. These accuracies are independent of resolution as they are merely characteristics of the sensor itself that cannot be altered.1.1. In order to interact with the sensor a specific sequence of events must be followed. 2. Temperature accuracy of the sensor varies with an increase or decrease from 25˚C. This provides the microcontroller with a 0. The pin on the micro-controller that is used as the data line must be stable.1. 2. The only shortfall of the device is its cost and is by far the most expensive component employed. Figure 4: Communication Sequence 6 .1.2.2. hence only two pins on the microcontroller are required.2 Communicating with the Sensor 2.2 The Transmission Start Sequence At the start of a transmission session with the sensor the microcontroller has to initiate a specific series of high and low signals on the Data Line.5 RH resolution. The SHT71 has very low power consumption. One of the pins will be used to create a synchronous clocking signal whilst the other will be used for bidirectional data transfer between the two devices. corresponding to the synchronous clock.1. hence the line must be pulled up in order to prevent signal contention.1. The protocol used for sensor communication is discussed in detail in the sections to follow. reaching levels of up +/.1.1. Another major advantage of this sensor over the others is that it provides a digital output.25˚C at 50˚C whilst RH is stable at an accuracy of +/-3% over a wider range of values. approximately 30µW.1. Since the analogue to digital conversion takes place within the chip it reduces the risk of the data being distorted by noise.

sensor transmission is stopped by omitting the final acknowledge signal. Since the RH measurement. After each byte is received the microcontroller must send an acknowledge signal. Once this is achieved the lower byte of data is then transmitted to the microcontroller and communication with the sensor is ended. Figure 6: Timing Diagrams for the Temperature Command 2. which for this sensor.Figure 5: Timing Diagram for a Transmission Start Sequence 2. 7 . There is a limited set of commands available for communicating with the sensor.2. The sensor will acknowledge the reception of the command by pulling the Data Line low on the falling edge of the 8th synchronous clock (SCK) and releasing the line on the falling edge 9th SCK. On the 5th SCK the sensor starts transmitting the measurement data. Attached to the upper byte are three address bits. It should be noted that all data is sent and received MSB first. The following timing diagram demonstrates the command signal transmission as well as the transmit start sequence.1. as these are the only address bits that are currently supported.4 Measurement Process Once the microcontroller issues the command for the sensor to measure RH it then has to wait whilst the sample is taken and the SCK must be stopped. Only then can the microcontroller start the SCK once again. The timing diagram below displays the sequence of flow of data. When the sensor has finished taking the reading it pulls the data line low. when the two bytes of data are downloaded from the sensor both are used as the sensor is configured to send temperature data as a 12 bit value.1.2.1. Temperature sampling can then be requested by first sending the transmission start sequence and then the command. is 8 bits then the sensor will transmit one byte of zero’s and one byte for the actual data. with the current sensor configuration. Once this first byte is received by the microcontroller an acknowledge signal is sent to the sensor. However. has to be set to ‘000’. The upper nibble of the upper byte is set to zero whilst the lower nibble contains the MSB’s of the temperature data.3 Transmitting a Command Following the transmission start sequence a command can be sent to the sensor.1.1.1. Naturally only the lower byte is stored and once this last byte is read in.

This subprogram also made use of two other routines that were employed specifically for reading in 8 bits of data from the Data line and placing 8 bits on the line. Successful completion of this task would be denoted by an acknowledge signal from the sensor. A routine was created which sent the command to the sensor to measure the temperature or humidity.1.1. The first task that required accomplishment was to send a transmission start and then attempt to send a command to the sensor.Figure 7: Timing Diagram for Data Received 2. This allowed for the sensor code to be easily integrated into the overall system code. Fortunately. The first command issued was to write to the status register and once the acknowledge signal was returned to the microcontroller. depending on what was requested. These tests were crude and not calibrated but were done with the intention of checking that if the ambient humidity or temperature was increased or decreased then the 8 .1.4 Testing the Sensor After the correct functioning of the code was tested. This was a crucial first step in the communication process as it would affirm the understanding of the sensor protocol and mean effective interaction with the sensor could be achieved. It was found that in working with the sensor and testing the code a delay should be included between measurements to prevent the sensor from heating up and producing inaccurate results. This makes the communication process more complex as receive and transmit procedures together with acknowledge detection and transmission and clock signals have to manually coded. this task was successfully completed without complications and progress with the sensor followed quickly. the ability of the sensor to take measurements had to be qualitatively investigated.3 Implementation of Sensor Communication The sensor has a specific protocol that has to be adhered to. the value needed to configure the sensor was written and again the sensor returned an acknowledge signal. The method of using functions and calling these subprograms was implemented for all the operations of reading and writing to the sensor.1. Both these programs were individually tested by using them in writing to and reading from the status register.1. The entire measurement routine was tested by placing the returned measured values on a port and displaying this on LEDs. This allowed any errors in programming or incorrect sequence of events to be quickly identified and rectified. After this reset was carried out the status register was reinitialized before measurements were taken. in order to be able to interact with it. This process of writing to the status register was then converted to a callable routine. 2.1. It was thus decided that the communication sequence would be broken down into smaller sections that could be tested individually for correct execution rather than endeavouring to write code for the entire communication process and attempting to test the whole code. When this problem occurred during the testing process a full connection reset was performed on the sensor that reset all registers as well as the serial interface.

with the microcontroller and sensor in power-down modes until an alarm occurs. The RTC is required to transmit the time from its internal registers to memory. The humidity change was effected by exhaling on the sensor when a measurement was being taken.2 Time Stamping In order to satisfy the task of time stamping sampled data. in order to time stamp the data.1. a Low Power RTC is required. multiple power supply connections and trickle charging. Two of the three configurations allow for the connection of a backup battery in addition to the main power supply of the system.1.3 . In a battery operated system.1. the DS1305’s internal algorithms controls timekeeping and alarm activation. The temperature reading change was evoked by placing the sensor close to a transformer that had become significantly hot during the process of its operation and subsequently increased the temperature of the surrounding air. with different functions. 2. Three separate power supply configurations are available. Communication with the microcontroller takes place through three-wire interface or Serial Peripheral Interface.1. like a data logger. 2. Both these tests proved to be successful. the consumer is not required to enter time or date settings at any point in the product life.sensor would reflect an increase or decrease. a device which can keep time is required.2.2.1. The selection of real time clock is important as the different features available allow for different implementations of the data logging system. depending on the capabilities of the microcontroller. Such a device is a real time clock (RTC).1. 2.1. As such. Once the time has been written to the real time clock. Programmable alarms allow the RTC to send a signal to a device like a microcontroller on certain time match conditions. 2. This feature allows for the design of a system where the real time clock controls the timing of data requests and data acquisition through interrupts generated when the alarm is activated. It is known that exhaled air has high moisture content thus the humidity reading. via the microcontroller. taken when the sensor is exposed to exhaled air. calibrated tests were carried out on the functioning of the measurement module in its entirety and these tests will be discussed in Module Tests (Section 4) . The alarm function is attractive as it allows for the option of making the data logger interrupt driven.1 .1. proving that the sensor was operational. Many real time clocks only keep time and upload this time to the system. Other real time clocks have features like programmable alarms. The selection of a real time clock is important as the different features available allow for different implementations of the data logging system. The group has decided on the Maxim DS1305 RTC. which is discussed in the next section.2 .2. The DS1305 Real Time Clock The DS1305 offers low power consumption and two programmable alarms. Therefore.1. should be elevated when compared to humidity of the room. the third method uses only a single battery to power up the real time clock. This single battery method is the most power efficient method available on the DS1305. More precise. Using the dedicated battery to power up the DS1305 makes it possible to program the time into the real time clock once during the data logger manufacturing process only. Other Methods of Implementing a Real Time Clock Another method of implementing a real time clock is through the use of the microcontroller’s internal 9 . A real time clock can be programmed with the actual time during the product manufacture process and then keep time for a substantial period. Real Time Clock Features There are a wide range of real time clocks available. the RTC is required to support communications with a microcontroller.

4 Power Comparison between Methods3 In order to compare the microcontroller based real time clock and a dedicated real time clock.5 Hardware The real time clock requires a continuous power supply in order to keep time. and with the maximum prescaler value of 1024. As the DS1305 requires a minimum of 2V to operate. It is apparent that in terms of power the dedicated real time clock is a superior method.4µA for the dedicated real time clock and 2mA for the microcontroller based method.777 − 15) ÷ (0.3µA . This maximum count makes it possible to generate a timer interrupt every 15 seconds. 2. the currents drawn by each method are compared.256 × 10 −3 sec = 16.0 volts. To count to 15 seconds. At this voltage.1. Many microcontrollers have a 16 bit timer that can be used to implement the microcontroller based real time clock. The results yield a current consumption of 92.777 sec .2.1. Once an initial time stamp from an external real time clock comes in. The CR2016 is rated at 90mAh at 2. the microcontroller takes control of time-keeping.256 × 10 −3 sec Using the 16 bit timer implies that a maximum count of 216 × 0. Using the microcontroller at a clock frequency of 4 MHz. 2. Ignoring the non-linear voltage-capacity behaviour of the battery.timer. The current drawn for the real time clock is approximately 20 times less than that for the microcontroller based method. the expected service life of the battery can be calculated by: 3 Current consumption based on the ATmega16L 10 . the period between timer overflows is:  4 Mhz  period =    1024  −1 = 0. the value that needs to be loaded into the timer’s register is: (16.2.1.256 × 10 −3 ) = 4369 Using another register as a counter allows for the control of the data logging period. The selected battery for the real time clock is the CR2016. This requirement would increase the power consumption of the device if it was connected to the system’s main power supply. The real time clock. is therefore connected to a dedicated battery. The most important factor in the choice between the different methods is the power consumed by each. and any components necessary for its operation. The power calculations for the two methods are included in Appendix A. the real time clock draws I average = 0. Power estimates have been performed for the different method and a comparison based on the estimates yields the dedicated real time clock as a more power efficient option. the Vcc2 pin is connected to a single 3V lithium coin battery.1.

Communication between the DS1305 and the ATmega16L is done via the Serial Peripheral Interface. I average t service = 90mAh = 300 × 10 3 hrs 0. however. The clock pulse is generated on the “SCK” pin of the ATmega16L. For simplicity. it is capped at a shelf life of the CR2016 which is 20 years. 11 . Integrating the real time clock. 40 39 38 37 36 35 34 33 32 GND 31 30 29 28 27 26 25 24 23 22 21 1 2 3 4 5 6 SS MOSI Vcc1 16 1 2 3 Crystal Vcc2 Vbat 7 MISO SCK 8 9 10 11 12 13 14 15 16 17 18 19 20 INT0 ATmega16L 15 VccIF 14 SDO 13 SDI 12 SCLK CE SERMODE 4 RTC 5 6 7 8 GND INTO 3V battery 11 10 9 Figure 8: Schematic diagram of the real time clock. The “MOSI” and “MISO” pins of the microcontroller are used to clock out or clock in data respectively.2.3µA The above figure translates into 34 years. The microcontroller is the master device.1. however. was accomplished by first implementing the SPI protocol between two microcontrollers which is illustrated in the following flow diagram.1. and as such. 2. Figure 8 below represents the hardware configuration of the DS1305 real time clock.t service = Capacity . . however. controls the timing of the communication.6 . The master uses the slave select (“SS”) pin to enable or disable data transfer between itself and the RTC. coupled with climatic changes which were ignored in the calculations implies that the battery will not last for the calculated service life. Data Transfer between the Real Time Clock and the Microcontroller The real time clock is programmed once during the manufacture of the data logger but is accessed at subsequent intervals whenever the data time stamp is acquired. the non-linear behaviour of the battery. only the connections between the microcontroller and the RTC are shown.

Clear SPI interrupt flag by reading SPSR and SPDR. MOSI. The SPI protocol involves the process where one device must be configured as the master and the other device being the slave. It was effectively noted that “main_data” in the data register (SPDR) of the slave device is ‘shifted’ to the master device only when the master transmits an arbitrary byte of data (“arb_data”).Master Initialistaion Slave Initialistaion SS. this concept is described in Figure 10. 12 . Set bit SPE of SPCR register. SPDR = arb_data No Wait for SPI interrupt flag Yes Ouput main_data to LED’s End process Figure 9: SPI test procedure between two microcontrollers. Figure 10: Data transfer between the master and slave. SPDR = main_data No Wait for SPI interrupt flag Yes No Wait for SPI interrupt flag Yes End process Clear SPI interrupt flag by reading SPSR and SPDR. SCK => i/p pins MOSI => o/p pin Set bits SPE and MSTR of SPCR register. The slave clocks out the data byte to its master when the master transmits the next byte of data. SCK => o/p pins MISO => i/p pin SS. The idea of data transmission between a master and its slave can be thought of as using a single 16-bit shift register. The test was conducted by the team to investigate the success in the transmission and reception of a byte of data (“main_data” in the above diagram). MOSI. Clear SPI interrupt flag by reading SPSR and SPDR.

1. day. For timekeeping purposes. Each time data byte (seconds. hence the time and date settings are not required to be entered by the user on initial start-up or any subsequent startups. MOSI. minutes. hours. RTC_Initialisation Transmit_data SS.7 Programming the Real-Time Clock Programming of the real time clock is performed as part of the manufacturing process.2. the time is written to the appropriate registers in order to initialise the DS1305. In terms of the SPI protocol. In the programming process. hours.1. the microcontroller is configured as the master whilst the DS1305 real time clock is considered as the slave device. the seconds. The initialisation process of the real time clock is shown in Figure 10. day. SPDR = data Enable SPI on RTC No Wait for SPI interrupt flag Yes Call Transmit_data Return Call Transmit_data Disable SPI on RTC All time info sent? No Yes End process Figure 11: RTC initialisation process. minutes. month and year byte) transmitted is preceded by its corresponding RTC register address byte and this explains the reason for the procedure “Transmit_data” being called twice. SCK => o/p pins MISO => i/p pin Clear SPI interrupt flag by reading SPSR and SPDR. 13 . Timekeeping is done in the real time clock’s internal registers and the current time is stored and read in binary coded decimal (BCD) format. The RTC byte write process is illustrated by the timing diagram in Figure 11 where ‘A’ represents the address byte and ‘D’ the data byte. month and year registers are written to.2. The initialisation process includes writing to the RTC control register to enable the alarm function and start the clock by enabling the oscillator. Set bits SPE and MSTR of SPCR register.

2. The setting of the ‘Alarm Interrupt Enable’ bit in the RTC’s control register and the ‘Time of Day Alarm Mask’ bits generates an active low alarm signal at time periods determined by the mask bits. this procedure is done so as to disable the current alarm interrupt and permits the execution of the next interrupt.1. the ‘low’ I NT 0 signal is converted to a ‘high’ signal by writing to the RTC’s alarm register. During each interrupt routine. For instance.8 Real-Time Clock Alarm function and Read procedure The alarm feature of the DS1305 was used to effectively ‘wake up’ the microcontroller in an hourly event and subsequently retrieve the measurement samples from the sensor. whereas the final product involves an hourly alarm interrupt.1. Figure 13: Real Time Clock Read Procedure. The active low alarm signal requires an external pull-up resistor which is provided by the internal pullup from the port pin on the microcontroller.2. in the data logging demonstrating process it would be efficient to generate an alarm interrupt every minute. The real time clock read procedure (shown in Figure 13 below) takes place whenever the current time stamp is requested by the microcontroller.Figure 12: Timing Diagram for SPI single Byte Write. 14 .

The timing diagram for the SPI single byte read process is illustrated in Figure 14 below. 2.3. 2.1. however. the decision to implement the ATmega16L was based on Atmel’s release of their Pico Power Range. The software issues relating to the microcontroller are discussed in section 2.1. The MSP430 series manufactured by Mixed Signals Controllers is a superior microcontroller in terms of power consumptions with its active current requirement being a quarter of the ATmega16L.3 Control 2. not the group’s first choice. In order to reduce the time taken for the micro-controller to transition from power down mode to active mode a ceramic resonator was employed as an external clock source.2.1.3.1.1. followed by transmitting an arbitrary byte. The implementation of the ATmega165p would significantly reduce power consumption. However. The tasks and constraints of the Memory Unit are illustrated in Table 4. however procurement of the device has been difficult since it was launched in early March 2006.3.5. The circuit diagram illustrating the microcontroller’s implementation is depicted in the complete circuit diagram Figure 23.1. The ATmega16L produced by the Atmel Corporation was chosen for implementation primarily due to its availability. 15 . 2. The device known as the ATmega165p offers active and standby current which are far superior to both ATmega16L and the MSP430 as well as offering greater functionality in terms of program memory and I/O ports. Thus by using the ATmega16L the group would be able to upgrade to the ATmega165p with relative ease since both products are from the same family of Atmel’s 8 – bit RISC microcontrollers. This is a low power device whilst having all the required I/O functionality required to handle communication between the other IC’s in the system as well as satisfying program memory requirements. Further the microcontroller will be operated at a frequency of 1 MHz in order to reduce power consumption.Note that the “Transmit_data” procedure is invoked twice as the microcontroller reads the time-stamp data from the real time clock by first transmitting the addresses of the corresponding time-field registers.1 Product Selection A microcontroller carries out all its tasks concerned with the system control.2 Implementation Issues The hardware setup of the microcontroller was based on the manufacturer’s recommendation documented in Atmel application note “AVR042: AVR Hardware Design Considerations”.1. The ATmega16L was. Figure 14: Timing Diagram for SPI Single Byte Read.1.2 Memory Unit The Memory Unit is an integral part of the measurement module as it provides storage capability.

2 Data Storage Data storage refers to the process in which data is stored in order to provide 6 months of time stamped measurements. requiring more than 12 bits of space and thus defeating the point of reduction. (The compression method investigated by the group was a method where data was only stored if its value varied by certain figure from the previous data). The decision on the device’s sampling rate was taken in conjunction with the researchers who would use such a product. Similarly to the temperature data this is reduced to 6 bits which results in resolution of 2% and a worst case error of 4%.e. as the sampling rate is an important criterion during research. which is within specifications. These calculations are illustrated in the power budget section 2. There are two types of data used in the system.1. Thus during every hourly cycle 12 bits of data would be saved. 2. Over a period of 6 months (183 days) with an hourly sampling rate. which is larger than the specified range of this device.1.4˚C at 25.3 Measurement Data The temperature and humidity sensor Sensirion SHT 71 provides temperature data in a 12 bit format. Thus to obtain the actual temperature it is required that the output of the sensor be divided by 25.4. Selection of an optimum data storage process would not only reduce power consumption but would also minimise the total memory required to store 6 months of time stamped data. However. temperature and humidity data.Table 4: Tasks and Constraints Affecting Memory Module 2. it was found that an hourly sampling rate would provide the optimum balance. This is possible because the raw data output of the sensor is already scaled up by 25. Memory is an expensive commodity and its efficient usage will minimize the system costs.1. this caters for a range of -40°C to 124°C. This results in a resolution of 1.28°C and a worst case accuracy of 1. The aim of the group was to select a sampling rate which achieved a balance between power consumption and data integrity.4˚C. 6588 bytes of memory would be required.2.2. Using an iterative process based on individual power consumptions. However. The humidity data is received by the microcontroller in an 8 bit format.1. Since the efficient use of memory space is integral to the design of the device it was decided that this 12 bit format will be reduced.1 Sampling Rate The sampling rate refers to period between each pair of temperature and humidity measurements. Instead a shift operation will be implemented that will involve a shift left of 5 bits resulting in a final data length of 6 bits.1.2. division in the microcontroller requires a large amount of processor power which is not very efficient as well as the fact that division will result in floating point numbers. In order to guarantee 6 months of operation the group would have to 16 . as bit 11 is ignored since the temperature of the unit measures a maximum of 50°C. Use of compression methods often result in a memory requirement which varies depending on the researched environment. Although this requirement is high and compression methods exist to reduce this number the group chose not to do so.1. The reasons for this decision are as follows: the sampling rate is low by design decision and further degradation of this may reduce the integrity of the data. 2. time stamp data and measurement data i.

implement a worst case approximation of the memory requirement. This would nullify the effect of the reduction process. Further, a variable memory system would not allow for the simplistic method of time stamping addressed in the following section. 2.1.2.4 Time Stamped Data The accurate time stamping of data is essential for data integrity. However, the real time clock, DS1305, supplies up to 7 bytes of data per time stamp. Use of these 7 bytes, hourly, would result in excessive memory usage and a memory efficient process was required. Initially the group proposed the use of a base time stamp which could be offset depending on the number of a specific sample. The alarm function provided by the RTC would be used to ensure that samples are taken hourly, thus the number of any specific sample could be used as an offset from the base time in order to provide an accurate time stamp. However, it was decided that the use of this method posed substantial risk to the integrity of the data. If the microcontroller were to not respond to the alarm of the RTC an hourly sampled would be missed and the entire data set would be offset. The group thus modified the process, by obtaining the hour data from the RTC every eight hours hence allowing regular time stamp synchronisation and eliminating the risk of losing six months of data. Thus if the microcontroller were to skip an hourly sample the worst case offset would be eight hours. The operation of assigning data sets individual time stamps is carried out during the processing of the data in a PC and is thus discussed in detail in the appropriate section. Thus the memory requirement for time stamp data over a six month period is 550 bytes. Combining this requirement with the Data storage requirement of 6588 bytes yields a total memory requirement of 7138 bytes. 2.1.2.5 Physical Implementation

2.1.2.5.1 Memory Options The options for data storage included the use of a Multimedia Card (MMC), a Secure Digital Card (SD) or Electrically Erasable Programmable Read Only Memory (EEPROM). MMC and SD cards presented an attractive option to store data, as cards are easily removable and replaceable when the end-user requires the data. The cards also remove the user from dealing with the internal hardware of a more complex memory system. The issues surrounding the implementation of a MMC or SD card included the high current consumption (approximately 150mA) of the device and the requirement of File Allocation Table (FAT) 16 formatting. To implement FAT 16 formatting a microcontroller with large program memory, and thus large power consumption, would have been required. EEPROM offered lower power consumption than the MMC/SD card alternative. Parallel communication EEPROM has shorter read and write times than serial EEPROM. Serial EEPROM, however, required fewer pins on a microcontroller, which allowed for the use of a smaller microcontroller with lower power consumption. The group chose the Atmel AT24C64A as the EEPROM device for implementation based on its low power consumption and capacity. The physical implementation of the EEPROM is designed to emulate the operation of MMC/SD cards. 2.1.2.5.2 Hardware The group achieved the emulation of the MMC functionality by attaching male headers to a printed circuit board and female headers to the appropriate part of the PC Interface and Measurement Modules. 17

Figure 15: MMC Emulation Using EEPROM

The AT24C64A is a Two Wire Interface (TWI) device communicates via this protocol with a master device, such as a microcontroller. The master device is responsible for the control of the communication timing and the flow of data. In order to interface the EEPROM to the microcontroller, a pull-up resistor is required on each of the Two-Wire lines. Figure 16 shows the physical interface between the EEPROM and the microcontroller. For simplicity, connections to other devices such as the main power supply and other components are not shown. The connections shown in red indicate the use of the microcontroller’s pull-up resistor. The EEPROM requires a minimum of 1.8V for proper operation and any voltage below 1.8V results in the EEPROM entering write protect mode.

Figure 16: The Physical Interface between the Microcontroller and EEPROM

2.1.2.6 Power Consumption The average current consumed by the EEPROM from the main power supply is 2.83µA. Appendix A shows the detailed power calculation for the EEPROM. Of all devices connected to the main power supply, the EEPROM is the second lowest consumer of power. 2.1.2.7 Writing to EEPROM Writing to EEPROM involved the use of TWI, with the EEPROM setup as a slave device and the microcontroller setup as the master. 18

The Write Protect (WP) pin on the EEPROM was grounded to enable writes to the EEPROM. To write a data set to EEPROM, the master had to send at least four bytes following a start condition– one byte for the slave address and the write command, one byte each for the upper and lower data addresses, and then the data byte. After each byte was sent, the EEPROM would respond with an acknowledge bit. The acknowledgement occurred in the ninth clock cycle and allowed for testing during the software development process, as well as error handling in the final program. Writing to EEPROM involved the development of a procedure, EWrite, which incorporated two subprocedures and a function. An array passes the data to be stored to EEPROM to the EWrite procedure. Figure 17 illustrates TWI_Initialisation, the sub-procedure to initialise the TWI communication between the microcontroller and the EEPROM. TWI_Initialisation sets up the speed of the TWI clock, as well as the microcontroller’s master address. Once the start condition is sent, the TWI is initialised and is ready to transfer data.

Start

Setup Bit Rate Register

Setup Master Address

Send Start Condition

End

Figure 17: Flow Diagram of TWI_Initialisation

Figure 18 illustrates the function, TWI_Stat, used to monitor the status of transmission. The subprocedure waits until the TWINT flag in the control register is set, indicating the end of a nine-bit transmission. The value stored in the Two Wire Status Register (TWSR) indicates whether a transmission has been successful. After each call of the TWI_Stat function, the TWI_Stat passes the TWSR value back to EWrite for comparison. If the comparison indicates that the transmission has been unsuccessful, the that particular data transmission is repeated.

19

1. When an error occurred. but with the EEPROM on a breadboard and the microcontroller on an STK500 programming board. The following section describes the development and testing of the software to write to EEPROM. from the main program. EWrite comprises a number of loops where TWI_Stat is called. the EEPROM was connected in a similar manner to that described in Figure 16. 2. These loops allowed for testing of the software during the development phase.8 Development and Testing of EEPROM Software For the development process. The diagram beside is the flow diagram illustrating the operation of the EWrite procedure. the microcontroller performs a comparison between the value in the TWSR and the transmission code.2. The EWrite code was then re-examined and edited to output the value of TWSR in order to Low Byte of Data Address sent? 4 NO YES Send Data Call TWI_Stat Acknowledge Received 5 NO YES YES More Data to Send 20 NO Send Stop Condition END . It was therefore possible to test the operation of the code by lighting up the Light Emitting Diodes (LEDs) on the STK500 board when the value in TWSR did not match the expected value. The sequence of LEDs light up was chosen to represent the value of the loop position (indicated beside the decision boxes in the diagram beside). Once EWrite is called. the start condition is sent through the Two Wire Interface.TWI_Stat Start Read in TWI Control Register Start Clear lower 7 bits of TWCR Call TWI_Initialisation Call TWI_Stat TWINT flag set? YES 1 NO Start Condition sent? YES Send Slave Address and Write Command Call TWI_Stat NO Read in TWI Status Register Mask Lower 3 Bits of TWSR Pass masked version of TWSR back to EWrite Start Slave Address sent? YES Send Higher Byte of Data Address Call TWI_Stat 2 NO Figure 18: Flow Diagram of TWI_Stat High Byte of Data Address sent? 3 NO YES Send Lower Byte of Data Address Call TWI_Stat TWI_Initialisation and TWI_Stat make up the bulk of the procedure EWrite. as well as the data to be written. which is utilised to write to EEPROM. After each call of TWI_Stat. EWrite obtains the addresses to write to. The EEPROM’s slave address is loaded and sent. the number of the last correctly executed loop was determined from the LEDs on the STK board.

21 . The reception of the NACK bit occurred because of the incorrect sequence of events being followed.8. 2.determine the cause of the error. two hourly samples of temperature and humidity which have been modified to use 3 bytes of memory space.2.1 Memory Mapping In order to efficiently use the available memory. To correct the error. Errors encountered included the receipt of a “not acknowledged” (NACK) bit or the occurrence of an undefined TWI operation. The measurement data comprises of 4 bytes.1. it was decided that the measurement data would be manipulated before storage. The 6 bits of data in the 4th register will then be split between groups of two bits. as well as aid in the writing process. Figure 19: Figure Illustrating the Data Manipulation Procedure The memory map is used to illustrate the addressing structure of the memory. the function TWI_Stat was created using the correct sequence of events. The process is most simply described by the following diagram. The process has been done in a manner which will allow for the data to be recombined when the downloading process were to take place. After every pair of hourly samples there will exist four 8 bit registers containing six bits of data each. Each group of 2 bits will then be added to the other 3 registers in a specific order.

3.3 System Operation The overall flow of the system is designed to efficiently use the individual components in order to achieve the desired system operation. date and hour data from the RTC. .1.3. 2. Download Time Stamp – the process where the RTC transmits the requested data to the microcontroller.1 Tasks Required The tasks involved in the system are as follows: • • • • • • Sampling and Storage of Base Time Stamp Sampling and Storage of Synchronization Time Stamp Sampling Temperature and Humidity Manipulation of Temperature and Humidity Data Storing of Temperature and Humidity Data Sample Counter 2. The task can be further broken into three functions: • • • 22 Request Time Stamp – the process in which the microcontroller requests year. Store Time Stamp – the process of writing the downloaded data to EEPROM.0x00 -------n------Hour ------------------Date ------------------Month ------------------Year Measured Data Measured Data Measured Data Measured Data Hour 0x0F 0x10 n7 → n8 (Temperature and Humidity Data) 0x12 0x13 0x14 Time Stamp Synchronisation 0x01 0x02 Time Stamp Data (4 Bytes) 0x06 0x07 0x09 0x0A 0x0C 0x0D Number of Samples Taken (2 bytes) n1 → n2 (Temperature and Humidity Data) n3 → n4 (Temperature and Humidity Data) n5 → n6 (Temperature and Humidity Data) Measured Data Reserved 0x1BE0 0x1BE2 n4391 → n4392 (Temperature and Humidity Data) 0x2000 Figure 20: Memory Map of the AT24C64A Serial EEPROM 2. This is achieved by combining the functions discussed in the previous section.2 Sampling and Storage of Base Time Stamp This task is only carried out each time the device takes its first sample.1.1. month.

Details of these functions including the associated error handling provided by the sensor have been discussed in the relevant section. Store Synchronization – the process of writing the downloaded synchronization data to EEPROM. 2. The function is used to convert 4 bytes of measurement data into 3 bytes before storage to EEPROM takes place. • Request Humidity .3. Since three bytes are being stored the counter will increment by 3 every time the function is called.1.1.2. these being that only hour data is requested from the RTC and the request download and storage of this data to EEPROM takes place every 8 hours.the process where the temperature and humidity sensor transmits the requested humidity data to the microcontroller.1. This function will be called immediately after the Manipulation of Temperature and Humidity Data function and will thus run every 2 hours. • Download Humidity .1 Sampling and Storage of Synchronization Time Stamp The process of obtaining the synchronization time stamp is similar to the previous process except for two differences.process by which the microcontroller requests humidity data from the temperature and humidity sensor. 2. in this mode the external interrupts are enabled allowing the microcontroller to enter active mode on command.3. However. this function will only be called every 2 hours.2.5 Microcontroller Operation The microcontroller will be used to control the use of the functions described in the previous section. Download Synchronization – the process where the RTC transmits the requested data to the microcontroller.2. Thus the microcontroller will operate in 3 modes: • • • In 23 Initialisation Active Mode Power Down Mode order to use the microcontroller in a power down mode an entirely interrupt driven system is .2 Sampling Temperature and Humidity In order to achieve the sampling rate this task must be carried out hourly. • 2.process by which the microcontroller requests temperature data from the temperature and humidity sensor.1.1. • Download Temperature .4 Storing of Manipulated Temperature and Humidity Data The task of storing the manipulated temperature data is done by a single function.2. A counter will be used in this function in order to point to the required address in EEPROM. Since 4 bytes of relevant data will be available after 2 hourly samples.2.3 Manipulation of Temperature and Humidity Data This task is accomplished by a single function previously discussed in the section on memory. The functions used in order to carry out these tasks are: Request Temperature . The power down mode is a low power mode where all unused modules of the microcontroller are shut down thereby saving power. The following functions were used: • • • Request Synchronization – the process in which the microcontroller requests hour data from the RTC.2.the process where the temperature and humidity sensor transmits the requested temperature data to the microcontroller. 2. Since the system will only sample data hourly the microcontroller can remain in a power down mode for the majority of the system operation.3.3.3.

In this routine all the required tasks are performed. Once this is achieved a counter is incremented which indicates that the tasks of sampling temperature and humidity data have been completed. This counter is then checked to determine if its value is equal to 43933. The flow diagram below illustrates the 3 modes of operation. If no previous samples have been taken the system will then carry out the tasks required to obtain the initial base time stamp. which by design decision has been selected with an alarm function. This is done in order to prevent the overwriting of stored data in EEPROM as the power supply is designed to operate for periods in excess of 6 months. On completion of this process the device enters power down mode. The reason for this procedure is to allow for the base time stamp to be taken on the first sample only. The interrupt source will be provided by the RTC. The Interrupt Routine (ISR) is discussed with reference to Figure 22. Thus if the sample counter is exactly divisible by two the process of manipulating and storage of the temperature and humidity data will commence. then 6 months of samples has been completed and the system is disabled. If so. On completion of this task the sample counter is tested for divisibility by 8. The manipulation and storage of data only takes place after two samples have been taken. Functions for the requesting and download of temperature and humidity are then called. The device will enter active mode hourly and execute the interrupt routine. 24 . otherwise normal operations commence. It involves the setting of all ports and the required interrupts as well as setting all counters to the desired initial condition.required. Once all processes are completed the system will also return to power down mode. in order to ensure the desired system requirements. Start Initialization Power Down Mode If Interrupt Occurs Active Mode (Interrupt Service Routine) Figure 21: Flow Chart Illustrating States of the Microcontroller The initialization process will be carried out each time the system is powered up. This test allows for the process of time stamp synchronization to take place every 8 hours. Upon entering the ISR the number of samples obtained is first checked to determine if any previous samples have been taken. The RTC can be set to provide this interrupt signal hourly thus allowing the microcontroller to carry out the tasks required to achieve an hourly sampling rate.

Figure 22: Hourly Interrupt Routine 25 .

4 2.1. 26 .4 Complete Circuit Diagram Using the requirements of the individual components the complete circuit diagram of the measurement module was created. VCC DATA GND 4 1 SCK SHT71 3 2 VDD 40 39 38 37 36 35 34 33 32 GND 31 30 29 28 27 26 PC3 25 PC2 24 SDA 23 SCL 22 21 1 2 3 4 SS 5 MOSI 6 7 MISO 8 SCK 9 RESET VCC 10 11 GND 12 XTAL2 13 XTAL1 14 15 16 17 18 19 20 INT0 Vcc1 16 15 VccIF 14 SDO 13 SDI 12 SCLK CE SERMODE 1 2 3 4 Vcc2 Vbat RTC 5 6 7 8 Crystal ATmega16L 11 10 9 INTO 3V battery GND Vcc WP SCL SDA 8 7 1 A0 A1 A2 GND 2 AT24C64A 6 5 3 4 Figure 23: Complete Circuit Diagram of Measurement Module 4 The notation N_Sample refers to an internal counter which tracks the total number of samples which have been taken.

1×10 −6 .1.392 ×10 3 ) = 808.015 ×10 −6 + 2. Lifespan (hours) = rating I TOTAL = 27 5500 ×10 −3 184. the cumulative average supply currents from all the devices within the Measurement Unit was included in the calculation.26 ×10 −6 = 184. Rechargeable cells also have a lower shelf life than alkaline cells and they lose up to 4% of their charge per day.hrs Based on the above calculation it was decided that Energizer AA batteries would be used for the Measurement Unit.hrs.1.59mA. to meet the 6 month lifespan requirement of the Measurement Unit. In addition to this rechargeable cells. initially. Using the configuration of cells shown in Figure 24 it can be seen that the effective rating of this battery will be doubled to 5500mA.2. The individual average supply current requirements for the sensor. Figure 24: Battery Configuration to be used Using this result the lifespan of the battery is calculated below. Rechargeable cells were not implemented as simplicity.1 Power Budget It was decided that in order to supply the Measurement Unit with power ordinary alkaline cells would be used. I TOTAL = I AVG _ SHT + I AVG _ EEP + I AVG _ MICRO = 1.10 × 10 −6 A Number of hours the battery must source current for = 183days × 24hrs = 4.392 × 10 3 hrs Hence the rating of the battery should be = I TOTAL × hrs = (184. microcontroller as well as the RTC may be found in Appendix A. was of paramount importance. In order to calculate the size of the battery needed. EEPROM. cost far more than ordinary alkaline cells.4. These cells are relatively inexpensive.83 ×10 −6 + 180.hrs.10 ×10 −6 )(4. convenient in size and readily available. These batteries are rated at 2750mA. with regards to use and maintenance of the product. The RTC average supply current was omitted from this calculation as it does not use the main power supply but rather its own battery source.

35 years. 2. in theoretical calculation factors such as impulse currents could not be taken into account as such data is not provided by manufacturers.5 Construction of Measurement Module On completion of testing and verification of the individual components. The required EEPROM data was downloaded to a PC for validation. Phase 4 involved the programming of the microcontroller routines for manipulation of the data as well as the setting of the requirement counters in order to allow for the required functions to be called in their specific sequence. The lifespan of the battery is significantly reduced when temperatures exceed its operating range and is completely destroyed at temperatures in excess of 60°C and below 0°C. a routine which could read from EEPROM and transmit data to the PC was created. The first phase involved the use of the RTC to generate an interrupt and within this interrupt time stamp data was requested and downloaded. Thus temperature limitations of the battery limit the overall performance of the system thereby limiting the overall operating range o f the data logging system. The testing of the final product is discussed in the testing and results section 4. For testing purposes the RTC was programmed to generate an interrupt every minute as this allowed for a more practical testing process. In phase 2 the temperature and humidity sensor was connected and the functions for the request and download of the data were included in the interrupt routine generated by the RTC.88 ×10 3 hrs This is equivalent to the battery being able to last for approximately 3. This process was broken down into phases where devices were connected one-by-one to the microcontroller and all connections were done on bread board with the microcontroller on a STK 500 development board. which once successful marked the end of the prototyping phase for the Measurement Module. Further. The reason that such a large margin is included is to attempt to guarantee the user an operation window of 6 months.1. However. the process of integration commenced. The theoretical calculations are only valid for temperatures in the range of 0°C to 55°C. A simple serial port routine was written to allow the data to be viewed on a PC. it must be noted that all batteries have temperature limitations. In order to test for the successful storage of data.= 29. Again the downloaded data was transmitted to a PC where it was validated by comparison to an independent sensor. It was discovered that this problem was caused by a faulty bread board track which prevented the write protect pin of the EEPROM from being correctly set. This phase of testing did pose significant problems as the group was unable to write data to the EEPROM. which is well in excess of the required lifespan of 6 months. This allowed for PCB’s to be designed manufactured and produced. 28 . Phase 3 involved the connection of the EEPROM and the storage of data to the device within the interrupt routine generated by the RTC.

One of the options was to implement a microcontroller (for the PC interface module) which has an embedded USB interface. • Windows CE.NET 4. 29 . 2. The Memory Unit is connected using the standard two-wire interface as discussed in section 2. creates a virtual communications port which allows the PC to interface with a microcontroller as if it were using a standard serial port. development of such software would be time consuming and problematic. in the design. handles all protocol requirements in order to interface to a USB port. including drivers. The group decided to instead use a UART to USB interface device. the connection between the PC Interface Unit and the PC required careful consideration. The PC Interface Unit provides a bridge between the Memory Unit and a PC. Further.1.7. 2000. 98SE. to implement a simple and efficient method in which the data would download from the memory module to the PC at the request of the user. This product. Since the PC serves as a medium between the client and the product.the serial port is being phased out and most laptops no longer provide this port. Figure 25 illustrates the hardware configuration of the PC Interface Unit and Memory Unit. for a relatively low price.2 PC Interface Module The PC interface module consists of units which allow the client to conveniently retrieve the data samples stored in memory. This communication interface benefits the user as it results in the compatible PC interface device being a “plug and play” device. Drivers for the following operating systems will be provided. The group selected the FT232RL USB-UART IC.2. Client preferences and product reliability are considered indispensable to the design team. the PC interface device) is “automatically” recognized and configured by the PC. ME. However. The chip. Another advantage of implementing the USB interface is the fact that the PC Interface Unit would not have to contain its own power supply.2. The only period at which the device would be in use is when data is being downloaded. XP. The most cost effective solution is to use a standard 8-bit microcontroller which will be programmed to handle all protocol requirements. Whilst the serial port does provide the benefits of cost efficiency as well as a simplistic implementation. namely the serial port and the Universal Serial Bus (USB) port. therefore the form of data communication between the PC and the PC interface unit had to be thoroughly reviewed. hence the design team considered each possible avenue. the group would be required to create its own PC drivers. as it requires minimal programming and provides a complete solution. this implies that the module can be powered off the PC via the USB port. in conjunction with its associated drivers.1 Hardware Requirements It is essential. There are various ways in which USB communication can be implemented.4 and greater The device has been designed in order to allow simple integration with any microcontroller that has a UART function. manufactured by Future Technologies. thus making the system compatible with virtually any computer with a USB port: • Windows 98.2 & 5. • Windows Vista / Longhorn* • Windows XP 64-bit.2. it has a major disadvantage . However. The USB interface was chosen due to the ease with which the USB peripheral device (in this case. Server 2003. OS-X • Linux 2. This however results in a costly design solution.0 • MAC OS 8 / 9.* • Windows XP Embedded. it is imperative that a suitable Graphical User Interface be developed to ensure a user friendly environment. Two such options were considered.

VCC 47nH 4.2. The MCU. 2.7uF 100nF 40 39 38 37 36 35 34 33 AREF GND AVCC 1 2 3 4 5 6 7 8 9 RESET VCC TXD VCCIO RXD GND 32 31 30 29 28 27 26 ATmega16L 10 11 12 13 14 15 16 17 18 19 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 FT232RL 28 27 26 25 24 23 22 21 20 19 18 17 16 15 TEST AGND CBUSO GND VCC RESET GND 3V3OUT USBDM USBDP 4k7 RXD TXD PC3 PC2 SDA SCL 25 24 23 22 21 100nF Vcc 8 7 1 A0 FERRITE BEAD A1 WP 2 SCL AT24C64A 6 5 3 4 A2 SDA GND TO USB PORT 100nF 10nF 4. thus creating a user friendly 30 . FT232RL and AT24C64A (EEPROM) are each powered off the PC via the USB port.7uF Figure 25: Hardware configuration of the PC interface unit and Memory Unit The ATmega16L microcontroller was chosen on the basis of its low cost and familiarity (as it is also implemented in the measurement module).2 The Download Procedure The download procedure is the process from which the client initiates the download event (through the PC GUI) to the point at which all the data stored in EEPROM is saved in a particular format on a PC. It requires minimal user interaction through the Visual Basic GUI.

The procedure consists of the following modules which are discussed in greater detail: • • • • • Communication Protocol The Visual Basic Graphical User Interface USART communication Actual download procedure Data manipulation 2.environment. However. as this method provides only limited capabilities alternatives were found. Further.2.2. containing eight hours of temperature and humidity data as well as the synchronization time stamp as illustrated below. The modified protocol has been designed to handle two data types: • Initialization Data – six bytes of data containing the total number of samples taken as well as the base time stamp data. the original protocol lacked handshaking mechanisms which were also redefined. The group initially proposed the use of parity checking as means of error handling. In order to increase efficiency the protocol was designed to handle blocks of data instead of single bytes. n Number of Samples n hours date Base Time Stamp month year Figure 26: Initialization Data Block Measurement Data – 12 bytes of data.1 Communication Protocol The communication protocol implemented by the design team is substantially different to that of the original design. • Figure 27: Measurement Data Block 31 . The diagram below illustrates the initialization data block.

The process of serial communication involves the initialization of parameters such as type of transmission.1.2. Initialization Data Block (6 Bytes) Measurement Data Block (13 bytes) Checksum Checksum Figure 28: Data Blocks with Checksum 2.2. The error check is accomplished by adding a check sum byte to each block of data.1 Error Handling One of the major tasks of the protocol is to provide error checking of the transmitted data.2. The baud rate indicates the number of bits that would be transferred in one second. 2. stop and parity bits). the eight bits followed by a stop bit. This is accomplished with the use of an acknowledge byte. The data consists of one start bit. The TXD and RXD pins on Port D are used for the transmission and reception of data respectively.e. baud rate and number of bits transmitted (including the start. Asynchronous transmission was chosen over synchronous transmission as a separate clock signal and data line is not required. The PC is therefore configured through Visual Basic with the same baud rate. The check sum value is computed by adding the numerical value of each byte in the data block and storing only the lower 8 bits of the accumulated value.2. The stop bit indicates that the information has been transmitted. The start bit indicates that the next eight bits contain information.1. The check sum is then appended to the data blocks before transmission as illustrated below.2 Handshaking Handshaking is employed in order to ensure that the receiver and transmitter are synchronised. The receiver transmits the acknowledge byte in order to indicate to the transmitter that a block of data has been received correctly i.2. 32 . A baud rate of 19200bps was chosen. the checksum value computed by the receiver equals the checksum value received.2.2 USART Communication The ATmega16L USART feature allows data to be transmitted in both directions (commonly known as half duplex operation). It is vital that the PC and the microcontroller baud rates be equal for proper data transmission.2.

To read from EEPROM.2. A check is then done to ensure that no other data is stored in the buffer or is being transmitted.7. 33 .7. however.1. The ERead process calls both the sub-procedure TWI_Initialisation and the function TWI_Stat used in the EWrite procedure.2.2. the PC would send a signal to the microcontroller which activates the “receive” interrupt routine.Figure 29: A Basic Serial Communication Sequence The above flow chart shows the initialization of the USART (baud rate. Figure 30 shows the process followed for the mock write. initializing serial communication. For the read process. which was discussed in section 2.1. 2.3 EEPROM read process Reading from EEPROM involved a similar process to that of writing to EEPROM. When the download procedure begins. the master is required to initiate a “mock write” to the EEPROM in order to read from a specific address. asynchronous operation and frame structure). When the buffer is empty. the procedure ERead is required to pass the data from the EEPROM to the microcontroller. TWI_Initialisation and TWI_Stat were discussed in section 2.2. the data is transferred from a register to the transmit buffer which is then transmitted to the PC.

The sequences of events to be followed include resending the device address and then reading the data from the EEPROM. provided the microcontroller responds an acknowledge (ACK) bit in the ninth clock cycle. The microcontroller sends the ACK for every data byte to be read beside the final byte. the master can then read the data from the EEPROM. Multiple bytes can be read from EEPROM. Figure 31 shows the flow diagram for the ERead process.Figure 30: Flow Diagram Illustrating a Mock Write After the master sends the repeated start condition. 34 .

1. with known data written to certain addresses in EEPROM.1 Development and Testing of Software The development and testing of the ERead procedure followed a similar method to that of the EWrite procedure mentioned in section 2. they were incorporated into the programs for their respective modules. Once the ERead procedure operated without errors.2. without any errors.Start Resend Device Address Call TWI_Stat Address Sent? YES Wait NO TWINT Flag Set? YES Read in Data Send Acknowledgement Bit NO Pass Data to Main YES More Data to Read? NO No Acknowledgement Send Stop Condition End Figure 31: The ERead Procedure 2. Once both procedures were fully operational.2.8 . the EWrite and Eread procedures were executed sequentially.2.4 Actual download procedure The sequence of events involved in the download procedure is as follows: 35 . The data was then read from the EEPROM.2.2. and compared with the known data. 2.3. displayed on the LEDs of the STK500.

This interrupt prompts the microcontroller to resend the previous block of data. This counter is incremented by six after initialization data is read and by 13 each time measurement data is read from EEPROM. This process is highlighted in the following flow chart. the PC would not send an acknowledge signal and the entire block would have to be retransmitted by the microcontroller. 36 . If the timer runs for a period in excess of 50ms an interrupt would occur. The process of waiting for the acknowledge signal is accomplished using a timer-driven interrupt. The above diagram illustrates an ideal transmission sequence in which all checksum values were verified correct. In the event that a corrupted data block was detected by the PC. On completion of transmission the timer is started and the system waits for the acknowledge signal.Microcontroller PC User invokes start condition by clicking “Download” start Microcontroller waits for start condition Initialization Block(+ Checksum) Transmitted Data Microcontroller waits for Acknowledge ACK Checksum is verified and Acknowledge Transmitted Measaurement Block(+ Checksum) Transmitted Data ACK Checksum is verified and Acknowledge Transmitted Microcontroller waits for Acknowledge Measaurement Block(+ Checksum) Transmitted Data Checksum is verified and Acknowledge Transmitted Figure 32: The data download procedure. The microcontroller tasks required to achieve the following events are as follows: • Download required Block of Data from EEPROM • Compute Checksum for associated block • Transmit block of data with checksum • Wait for acknowledge The downloading of the correct data from EEPROM was done by implementing a counter which points to the required address in EEPROM where data would be downloaded from.

The diagram below indicates the entire microcontroller operation in the PC Interface Module.Figure 33: Process describing block data transfer. Wait for Start No Start Condition Recieved Yes Read address 0x00 – 0x05 of EEPROM (Initialization Data) Compute Checksum Transmit Function n=6 Read address n – (n + 8) of EEPROM (Measurement Data) Compute Checksum Transmit Function n=n+8 Figure 34: Microcontroller operation in the PC Interface Module The PC works in conjunction with the microcontroller to download data via the developed communication protocol. The user initializes the download procedure by clicking on the “Download” 37 .

the microcontroller transmits the data packet with a corresponding checksum value appended to it. The checksum value is then recalculated on the PC side and compared to the checksum value that was received with the packet. then an acknowledge signal is transmitted to the microcontroller to inform it that the data received is valid. A start condition is then transmitted to the microcontroller. This will cause the microcontroller’s timer to “time-out” and the microcontroller will have to re-transmit the packet. If these values are equal. if the checksum values differ. However. Click Download “Start” condition sent to microcontroller Data packet received by PC with Checksum PC processes Data PC Recalculates Checksum PC_Checksum = Received_Checksum? False Discard packet True Transmit ACK to Microcontroller Wait Figure 35: Download process between PC and microcontroller. then the PC will discard that data packet and an acknowledge signal will not be transmitted.button on the GUI. 38 . In turn.

The user is prompted to enter in a file name to which the data will be uploaded to. By saving the data in this format.2. Figure 37: Graphical User Interface 39 . The application may be accessed by simply double clicking on the execution (exe) file. It was also imperative that the interface be created in a manner that provides a user friendly application.5 The Visual Basic Graphical User Interface The main objective of the computer-based user interface is to allow the client to easily retrieve and analyze the downloaded data.2. the user is allowed to further process and view the data using any program or tool that the client is more acquainted with. A help file developed for this software will be provided as an online guide to the user for downloading and viewing the data. This interface allows the user to download and save data to a specified directory with any desired file name (valid in Windows). Figure 36: User Interface Start-up Screen The actual GUI then pops up onto the screen.2. Immediately. a splash screen is displayed to the user while the form loads in the background. a Visual Basic application was created. The user may also select the path and directory of this file. To this end.txt). The file is saved as an ordinary text file (.

by simply adding both of these decimal values. All of these attributes build towards the application being as user-friendly as possible.Upon clicking the “Download” button.6 Data manipulation using PC software Since the data packets received are raw. The time stamp data (bytes 3 to 6) need to be converted from their BCD values to decimal values. the download process (discussed in Section 2. The function also ensures that the binary value returned is an 8-bit value. If at any stage the user requires assistance with respect to the application or to the project as a whole. This 8-bit value is then separated into a lower and upper nibble. This is done by referencing the user-defined function “DecimalToBinary”. Then. user manuals as well as the three reports written by the group are provided. The 4-bit upper nibble is then sent to another user-defined function (“BinaryToDecimal”) to convert it into decimal. The first packet that is received contains six bytes. and the remaining four bytes are 8-bit BCD values which contain the initial time stamp (as illustrated in Figure 39). a certain amount of data processing was required on the PC side through the VB application.2.2. Figure 38: Figure Illustrating Access to the User Manual 2. the result yields the decimal equivalent of the original 40 .2. a message is displayed informing the user that the download is complete. Figure 39: Format of initial data packet. This process is illustrated in Figure 40 The actual BCD value that is read is converted to its binary equivalent. The lower nibble is also converted to its decimal equivalent. These are accessed by clicking on the “Help” drop-down menu.4) commences. This value is then multiplied by 10. The first two bytes hold the number of samples taken.2. When this procedure is finished.

These values were stored over an 8 hour period. The 12 bytes within the received packet can be viewed as four 3-byte values. 8-bit Data 6-bit Data b7 b6 b5 b4 b3 b2 b1 b0 b7 b6 b5 b4 b3 b2 b1 b0 Temperature 1 b7 b6 b5 b4 b3 b2 b1 b0 b7 b6 b5 b4 b3 b2 b1 b0 b7 b6 b5 b4 b3 b2 b1 b0 Temperature 2 b7 b6 b5 b4 b3 b2 b1 b0 b7 b6 b5 b4 b3 b2 b1 b0 Humidity 1 LSB MSB b7 b6 b5 b4 b3 b2 b1 b0 Humidity 2 LSB MSB Figure 41: Data manipulation of measurement samples. All that then remains to do is to store these values in an array so that the corresponding temperature and humidity values are next to each other. not available immediately and require processing before they can be stored as physical temperature and humidity values. The first 12 bytes hold the encoded temperature and humidity values. however. Each 3 byte value holds four data samples – two temperature readings and two humidity readings. This process then continues for the remaining bytes in the packet. These values are.BCD value. These values must then be multiplied by a scaling factor to convert them to a physical temperature or humidity value. The 13th byte contains an “hour value”. As illustrated in Figure 41 above. The data packets that follow contain 13 bytes. The data contained in the first packet acquires a time stamp based on the initial time stamp – this is achieved by simply incrementing the initial hour value and 41 . Read BCD Value Convert to 8-bit Binary b8 b7 b6 b5 b4 b3 b2 b1 Separate Upper and Lower nibbles b8 b7 b6 b5 b4 b3 b2 b1 Convert to Decimal And Multiply by 10 Convert to Decimal Add Upper & Lower Values Figure 40: Process of converting BCD to binary. the two Most Significant Bits are extracted from each of the 3 bytes – effectively resulting in four 6-bit values.

So. the subsequent data samples all receive a time stamp based on the previous packet’s “hour value”. the hour value is now forced to the value contained in the 13th byte.adjusting the other time stamp parameters if necessary. The process is illustrated in Figure 42. After assigning the correct time value to the data samples in the packet. Figure 42: Synchronisation of Time Stamp 42 .

It was thus imperative that the housing be designed in such a way that the internal circuitry is protected against all possible climatic conditions. To this end the external lid is fastened with stainless steel retaining bolts and nickel plated brass inserts are used for securing the lid and device plate. Figure 43: Measurement Unit Housing 3. the group intended on implementing the SH1. The unit has also been designed with a female header in order to allow easy docking with the Memory Unit. it is not imperative that this unit be water resistant or very robust as it is contained within the Measurement Unit. However. due to the environments in which the devices will be placed. The casing. It was thus decided to make this unit as light and compact as possible. In order to maintain water resistivity whilst not inhibiting the sensors ability to take measurements. Humidity levels as well as small bodies of water are all conditions that the housing must protect the circuitry against. a filter cap. had to be breached to create a hole for the sensor to be exposed in order to measure air temperature and humidity. The first issue that was addressed. This minimalistic 43 . however. which is innately a hydrophobic substance.1 The Measurement Unit The environment that this unit will be exposed to varies from the ceilings of houses to the inside of caves.3 Housing 3.2 The Memory Unit Even though the Memory Unit would be in the same environment as the Measurement Unit. In order to achieve water resistivity the housing is constructed out of fibreglass with o-ring seals. The housing must also be rugged enough to withstand accidental falls. The Memory Unit is composed of the EEPROM mounted on a PCB with a set of male connectors. It was then decided that a seal around the sensor would be created using silicon. was moisture. procurement of the filter cap was very difficult and attempts at obtaining the cap were unsuccessful. The walls of the housing are also thickened for extra strength and sturdiness.

A sufficiently small enough casing for the PCB could not be found hence it was decided to omit housing. On this surface the date and time of activation of that particular unit would have been written. This was to be done in order to ensure that in the event of time stamp data corruption the writing surface could be used as a last resort to salvage the 6 months of data. Figure 45: PC Interface Unit 44 . Initially it was decided that an erasable writing surface will be adhered to the Memory Unit. This unit was thus made of ordinary hardened plastic with a female header attached to the lid of the module. Figure 44: Memory Unit 3. for docking with the Memory Module.3 The PC Interface Unit The PC Interface Unit does not require any special housing due to the fact that it would not be used in the field. and a USB cable. The housing is designed to be aesthetically appealing as this unit will be used in a visible location near a PC.approach was adopted to essentially imitate the SD card appearance and ease of use. this surface is no longer needed as time stamp data is now taken every 8 hours thus the loss of 6 months of data is no longer a concern. However.

The readings taken using the Measurement Module were then compared to those taken using a hygrometer. This deviation from the accuracy achieved at 25˚C can be attributed to the inaccuracy of the sensor at these temperatures. not exceeding those specified by the range of operation of the system. The changes in air temperature were induced using a standard oil heater. the hygrometer used was not very accurate . Unfortunately. and readings were taken. and an air-conditioned environment. As it is well known steam increases the moisture content of the surrounding air thus creating conditions of increased humidity.6˚C and 22. Conditions of low humidity were induced by using a heater to dry the air.4 Module Tests The Measurement Module was subjected to different temperatures. Graph 1: Temperature Measurements 50 45 40 35 30 25 20 15 10 5 0 1 2 3 4 5 6 7 Sample Number Temperature (degrees C) System Output Thermometer As can be seen the system output closely tracks the thermometer readings taken.6˚C.6˚C at thermometer measurements of 40. These readings were then compared to a calibrated digital thermometer’s readings taken at the same time. Humidity was first tested by placing the measurement module in close proximity to boiling water. The largest error between the two measurements was found to be 1. for reduced temperatures. The results of these tests are shown in Graph 1 below. to increase temperature. 45 .thus the readings taken by the hygrometer were used merely as a rough estimate of the humidity to give the group an idea of region in which the measurement unit’s readings should be.

Due to a design decision of minimum memory capacity. Cyclic Redundancy Checking error checking methods provide better data protection by applying a more complex algorithm to the data to obtain the final checking value. These predefined combinations would correspond to a different period of operation for the device. Another problem that arose with the use of VCP was that the assigned communication port varied from PC to PC. There are two methods in which this problem could be solved. Naturally. This would create a self-sufficient initialization procedure which is highly desirable. however. Another solution to this problem is to merely increase the size of the memory. Once a duplicate block of data is identified it can then be discarded. However. this was not implemented as it would defeat one of the groups overall objectives . it retransmits the data packet to the PC. due the environmental conditions that the device would possibly have to withstand. Another area of concern is related to the accuracy of the stored data. However. which is not a viable option in this case.1 The Measurement Module A problematic area of the design related to the theoretical calculations of the lifespan of the battery. The only way in which the theoretical calculations could be verified is to perform long term tests. since these bytes should not be identical for two blocks of data. whilst providing data protection. 5. would be to create an auto-detect sequence that would be capable of updating the port number in the software without requiring input from the user. The optimal solution though would have been to create an installation wizard that would eliminate any driver installation uncertainties. A better solution. This results in the PC having two identical sets of data. The first method would be to compare synchronization bytes.2 The PC Interface Module The PC Interface Module has two main areas that could be improved upon. given more time. Currently.cost reduction. this was due to the lack of information from the supplier. This problem was addressed by having the user manually enter the communication port being used upon request by the software. 5. This process is quite complex for individuals with minimal computer experience thus the group has created a detailed user manual in an attempt to alleviate any problems. if the microcontroller does not receive an acknowledge signal and its internal timer expires. is not the best error checking method. However. the housing for this unit was designed to be water resistant and 46 . The primary focus for the housing was the Measurement Module. An apparent problem with regard to the protocol is that there is no procedure to handle the case of a lost acknowledge signal. namely: protocol and error handling. which would allow for the accuracy and sampling rate to be selected from certain predefined combinations. the best solution to this problem would be to implement an Automatic Repeat Request (ARQ) protocol which would ensure that a reliable data link is created. if the end user requires a higher level of accuracy the group proposed that user settings be included. The use of Checksum as a method of error checking.5 Analysis of Design Testing has shown that the data logger works according to the required specification. an amount of accuracy in the measurement data had to be relinquished in order to meet the memory constraint.3 Housing The last area where improvements could be made is the housing of the modules. The PC Interface Module also requires the user to install a Virtual Communications Port (VCP) driver onto their PC. there are still areas of concern that the group would have liked to have improved upon. 5. For example temperature effects and impulse currents were not included in calculations. Even though it was calculated that the system would last for more than 6 months there were numerous factors affecting the lifespan of the battery that could not be taken into consideration. However. In an attempt to counter the uncertainty related to these calculations the group has added extra cells to increase the effective rating of the battery and thus guarantee the user with a period of 6 months of operation.

procurement of the cap was not possible hence this had to be omitted and instead a water resistant seal was created around the sensor using silicon. The Memory Module was designed to emulate the likeness of the SD or MMC card. 47 . designed to protect the sensor. allowing only the male header pins to protrude from the casing. is to include some manner of indicating to the user that the device has been successfully activated. Two other problems relating to the housing are that it lacks sufficient shock resistance and there is no mounting point. This would have to be a low power method such as flashing an LED for a short period. The problem is that the device is subject to damage. these tasks could not be carried out. Unfortunately. The only problem was that the housing had to be modified to create an aperture large enough to allow the sensor to the exposed to the environment. A further improvement that is imperative be made.robust. The group planned to make use of a filter cap. and create a seal around the filter cap. during a downloading process. and the data could be corrupted if the pins of the EEPROM were to be shorted. if dropped in water. it would result in unpredictable behaviour of the EEPROM upon start up. however. Both these problems are not particularly difficult to solve. In addition to this a method of indicating a safe turn off period for the device should be included as if by chance the device had to be switched off. midway through a write sequence. The groups’ solution to this problem is a housing small enough to hold the EEPROM and PCB. Due to time constraints.

6 Costing Description Sensor Real time clock Microcontroller EEPROM Manufacturer Unit Price(R) Sensirion Maxim Atmel Atmel Enlec Energizer Panasonic FTDI Murata 210 20 40 10 90 5 5 13 4 45 8 Total (R) 210.00 80.00 12.00 20.00 Quantity Component 1 1 2 1 3 1 4 1 3 1 1 SHT71 DS1305 ATtiny2313 AT24C64A Fibre box glass Housing Connector Batteries Battery Serial ports USB UART IC Ceramic Resonator USB connector AA batteries Lithium Battery DB9 port FT232RL CSB384J TOTAL R 518.00 5.00 20.00 13.00 48 .00 45.00 10.00 90.00 8.

It was decided that rather than taking only an initial base time stamp and incrementing this based on the number of a sample. Further the group has evaluated the potential flaws in the design and given the time for further development the group is confident that a market ready product can be achieved. Added technical support is provided by way of user manuals and help files. The design was achieved using a modular design approach which optimized the efficiency of the system. 49 . However. increased its versatility as well significantly aided in troubleshooting during the prototyping stage. the hygrometer used. methods of further simplifying this process do exist but due to a lack of sufficient time these methods could not be implemented. were also achieved and validated by comparing the measured temperature results to a calibrated digital thermometer. The group also tested the ability of the system to measure humidity. The hygrometer readings were thus used as a rough estimate of humidity and it was ensured that the system readings were approximately the same. The desired accuracy. The design was achieved with a degree of user friendliness and provides hassle free operation. Thus a versatile cost effective and off course user friendly system with a high level of robustness has been achieved. a time stamp would be taken every 8 hours. The cost of the design is R518 in total. The main expense in the design is the sensor that was implemented. for temperature measurements. However. placing the group R18 over budget. which was a threat that the initial method posed. constructed and tested. The main change in operation of the Measurement Unit was with regard to the Time Stamping Method employed. as an independent means of comparing system readings. However. was unfortunately not very accurate. The PCI module which is responsible for the downloading and processing of stored data was successfully designed. This objective was successfully achieved within the low power consumption condition. it was decided that this expenditure was worth the cost to ensure low power consumption and dependability in the environments that the device would be exposed to.7 Conclusion The fundamental objective of the design was to create a system that could take temperature and humidity measurements for a period of 6 months and store all this data till such time that it is needed. This change was effected in order to eliminate the risk of losing 6 months worth of data. The product has been designed with the potential user always in mind.

com/.“AVR035: Efficient C Coding for AVR”.com/ .“Interfacing I2C Serial Real-Time Clocks to a Microcontroller”.atmel. accessed on 1 March 2006 [5].“Lithium Coin Battery cr2016”.com/.com/. www. www.avrhelp. Atmel Corporation. accessed 11 March 2006 [7]. www.com/AN3300.atmel. Atmel Corporation.com/Using_the_SPI_protocol. Sensirion.References [1].“Avr151: Setup and use of the SPI” .“ATtiny2313 datasheet “. Atmel Corporation.nanotron.energizer.sensirion. Energizer. www.sensirion.com/ .com /. Energizer. Nanotron Technologies. www.com/.accessed 11 March 2006 [11].“SHT 1x / SHT7x Humidity and temperature Sensor”.com/. accessed on 11 March 2006 [10]. accessed on 25 February 2006 [9].com / accessed on 25 February 2006 [6].html.“Lithium Battery Considerations” www.accessed on 23 February 2006 [2]. accessed 11 March 2006 50 .maxim-ic.“Wiring Configurations of the Serial Peripheral Interface”. accessed on 5 March 2006 [4].“AVR310: Using the USI module as a I2C master “www. www.atmel. Maxim . www.energizer. accessed on 11 March 2006 [8]. accessed on 1 March 2006 [3].alldatasheet. “Using the SPI protocol”. www.mcselec.Sensirion-“Relative_Humidity_Basics” www. Atmel Corporation.

com/ .maxim-ic.com/ .maxim-ic.repairfaq. www. accessed 25 February 2006 [18]. “Temperature sensors”.necelam. Maxim.com/. Intersil Corporation “Real Time Clock X12xx Features & Application”. apc. American Power Conversion Corporation “Real world battery life predictions”. accessed 25 February 2006 Chip” [20].com .com/AN3300. www. NEC“Power Consumption Optimization in NEC Electronics Microcontrollers”.“ENERGIZER NO. Energizer.sensirion.accessed 23 February 2006 [16].accessed on 23 February 2006 [23].com/ .“Non linearity Compensation” www.com/ . Maxium.ysitetemperature. Parallax“Using the DS1302 Trickle Charge Timekeeping www.accessed on 25 March 2006 [22]. Sensirion.“Lithium coin-cell batteries: predicting an application lifetime”. www. accessed on 23 February 2006 51 . accessed 25 February 2006 [19].“CRC_Calculation” www.intersil.org .energizer. www.www. accessed 14 March 2006 [15]. Sensirion. accessed 25 February 2006 [21]. “A pointless guide to CRC error detection algorithm”.sensirion. www. accessed 11 March 2006 [14].com/dl/docs/prod/appkit/ds1302Rtc .maxim-ic.com/.parallax. Maxim.“Serial Alarm Real-Time Clock”.[12]. accessed 21 March 2006 [17].“Application Note 701 Using the DS32kHz with Dallas RTCs” www. www.com. www.com/. accessed 12 March 2006 [13]. L91”.

“AVR402:Hardware design considerations” . Thermocouple or Thermister” www. Atmel Corporation.com . http://www. Future Technology Devices “FT232R USB UART I.com/.“Interfacing AT24CXX Serial EEPROMs with AT89CX051 Microcontrollers”.“AN232B-05 Configuring FT232R.C”. www.dataloggerstore.ftdichip.com/.accessed 16 March 2006 [30]. “Choosing an RTD. Future Technology Devices .atmel.ftdichip. http://www.accessed 16 March 2006 [29]. “Advantages and Disadvantages”.com .accessed 16 March 2006 52 .ysitetemperature. accessed on 11 March 2006 [27]. accessed on 28 March 2006 [28].com .[24].FT2232C and FT232BM Baud Rates” . www.atmel.ftdichip.com . http://www. Atmel Corporation.com . www. accessed on 24 February 2006 [25]. Future Technology Devices – “AN232R-02 FTDIChip-ID™ for the FT232R and FT245R”. accessed on 24 February 2006 [26].

za Mike Devlin The Endangered Wildlife Trust mdevlin512@aol.za Nigel Fernsby Guateng and Northern Regions Bat Interest Group fernsby@netactive.durban.org.com Peter Taylor Durban Bat Interest Group petert@crsu.co.za Eleanor Richardson Bat Researcher ejrichardson@worldonline.co. Claire Peterson Manager: Bat Conservation Group ewt@ewt.za 53 .gov.Contacts Much of the design decisions in the project have been made in consultation with researchers who would possibly use such a device. Their contact details have been listed below.

hrs 54 . I AVG _ SHT = I SHT + I S (3600 − 1) = 55.Appendix A Average Sensor Supply Current Calculation Current required during measuring (IM): 550µA Current required during sleep (IS): 1µA Time taken to measure temperature: 55ms Time taken to measure humidity: Total active time: 66ms 11ms Let us assume that at worst case the active cycle (tA) is 100ms.9 × 10 −6 + (1 × 10 −6 )(3599 ) = 3.9 × 10 −6 A. The active cycle is included in the calculation above and current drawn for one second will be included in the calculation below to cater for the active cycle .s Average Current drawn over an hour: The current drawn is averaged over an hour as this is the length of the sampling period employed. Current for 1s of operation (active cycle): If the sensor is active for 100ms then it will be in sleep mode for tS=900ms I SHT = I M t A + I S t S = (550 × 10 −6 )(100 × 10 −3 ) + (1 × 10 −6 )(900 × 10 −3 ) = 55 × 10 ( −6 ) + (900 × 10 −9 ) = 55.65 × 10 −3 A.

Figure 46: The Current Characteristics of the AT24C64A The AT24C64A has the following electrical characteristics at Vcc = 5V : Iwrite 3mA Iidle 2µA twrite 1 sec tidle 3599 sec ttotal 3600 sec The electrical characteristics above yield an average current of 2.83µA . The write operation draws three times as much current as a read operation. 55 . Power Comparison between Microcontroller Based RTC and Dedicated RTC Figure 38 below shows how the current drawn by the microcontroller varies.Convert to Amperes I AVG _ SHT = I AVG 3600 = 1. all communications with the EEPROM is assumed to be a write operation.015 × 10 −6 A Power Calculation for EEPROM The average current may be calculated by I avg = (I idle × t idle ) + (I active × t active ) t total . To achieve a worst case power scenario for the EEPROM.

The DS105 communicates with the microcontroller during its active cycle. The 50k resistor sources 92µA from the main 4.3µA. The RTC uses the microcontroller’s internal pull-up during its idle time. 56 . This means that the electrical characteristics of the microcontroller changes to: Iidle 92µA Iactive 0.35mA tidle 3599 seconds tactive 1 second ttotal 3600 seconds The microcontroller therefore draws 92. the microcontroller draws a current from the main supply. Figure 39: Current Characteristics of the DS1305 The electrical characteristics of the DS1305 at Vcc = 2V are: Iidle 0.4mA Iactive 0.3µA tidle 3599 seconds tactive 1 second ttotal 3600 seconds The above values yield an average current of 0.5V power supply.1µA.999975 s tactive 25 µs ttotal 15 s These values yield an average current of 2mA.Figure 38: Current Characteristic of ATmega16L The average current may be calculated by I avg = (I idle × t idle ) + (I active × t active ) t total The microcontroller’s electrical characteristics at Vcc = 2V are: Iidle 2mA Iactive 5mA tidle 14. During this period.

which is lower than the current drawn by a microcontroller based method. Figure 47: Current Characteristic of ATMega16L The microcontroller’s electrical characteristics at Vcc = 3V are summarized in the table below: Ipowerdown 180µA Iactive 1. is 0.This implies that the total current drawn by the DS1305 method. Power Calculation for Microcontroller Assume that the active cycle of the microcontroller takes 1s hence for the rest of the sample period.25µA. The average current may be calculated by I avg = (I powerdown × t powerdown ) + (I active × t active ) t total These values yield an average current of 180. Figure below shows how the current drawn by the microcontroller varies during sampling periods. 3599s.4 µA . The active current for the microcontroller is given as 1.3µA + 92. the microcontroller will be in a power down mode.1mA whilst the current drawn in power down mode was found to be 216.26µA.1µA = 92.1mA Tpowerdown 3599 s tactive 1s ttotal 3600 s . due to internal pull ups being utilised. 57 .

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->