Stand-Alone Datalogger with a Graphical User Interface Final Year Electronic & Computer Engineering Project Report Paul Boyle Supervisor: Pat Byrne April 2002 Electronic & Computer Engineering Acknowledgements Acknowledgements This project was made possible by the efforts and talents of many people. I want to express my appreciation to my project supervisor Pat Byrne for her support and advise through the course of this project. At this point, the end of my time in the NUI Department of Electronic Engineering, I want to express my gratitude to all members of the Department who have helped me in any way during the past two years. Also, many thanks to Aodh, Martin and Myles in helping me with the design and construction of the prototype Logger board. I also wish to thank the many contributions to this project. Without their input, this project would be next to impossible. Lastly, but most importantly, I thank my parents and family. Whatever I have achieved, or may achieve in the future, is a result of their support and effort. I hope that some day I can begin to repay them. Many thanks to all Paul Boyle Stand-Alone Datalogger with GUI 2 Electronic & Computer Engineering Abstract Abstract This report describes a final year Electronic & Computer Engineering project entitled “Stand-Alone DataLogger with Graphical User Interface”. This project involves designing and constructing a Stand-Alone Datalogger that can be used to monitor temperature inside a drinks vending machine and, which the user interacts with the DataLogger in the initializing and data-downloading modes through a Graphical User Interface (GUI). This project is both hardware and software based with the software being developed in Java and the hardware being based around the 8051 Microcontroller chip developed by Analog Devices. This report will describe the passage from design feasibility to final operation of the Stand-Alone Datalogger. The project was completed by Paul Boyle under the supervision of Pat Byrne. This report was submitted to the Department of Electronic Engineering, National University of Ireland Galway, in April 2002. Stand-Alone Datalogger with GUI 3 Electronic & Computer Engineering Contents CONTENTS 1. AIMS & OBJECTIVES................................................................................................7 2. INTRODUCTION..........................................................................................................8 3. BACKGROUND............................................................................................................9 3.1. ADUC812 OVERVIEW................................................................................................9 3.1.1. ADuC812 Features..............................................................................................9 3.2. WHAT IS I2C?............................................................................................................10 3.2.1. Principles of the I2C Bus....................................................................................10 3.2.2. How the I2C Bus Operates.................................................................................12 3.3. SERIAL PORT OVERVIEW..........................................................................................12 3.4. JAVA OVERVIEW.......................................................................................................13 3.4.1. Java Features.....................................................................................................14 3.4.2. Java Pros...........................................................................................................15 3.4.3. Java Cons...........................................................................................................15 4. CIRCUIT DESCRIPTION.........................................................................................16 4.1. CENTRAL CONTROL UNIT.........................................................................................17 4.2. ANALOGUE-TO-DIGITAL CONVERTER UNIT..............................................................20 4.3. MEMORY UNIT.........................................................................................................22 4.4. REAL TIME CLOCK UNIT..........................................................................................24 4.5. RS232/TTL TRANSLATOR UNIT...............................................................................25 5. ADUC812 SOFTWARE DEVELOPMENT..............................................................26 5.1. INTRODUCTION.........................................................................................................26 5.2. DESCRIPTION OF MAIN CODE...................................................................................26 5.3. LCD OPERATION......................................................................................................29 5.3.1. Program Variables.............................................................................................29 5.3.2. Description of Code...........................................................................................30 5.4. TEMPERATURE OPERATION......................................................................................34 5.4.1. Description of Code...........................................................................................34 5.5. ADUC812 I2C OPERATION.......................................................................................37 5.5.1. Program Variables.............................................................................................37 5.5.2. Description of Code...........................................................................................38 Stand-Alone Datalogger with GUI 4 Electronic & Computer Engineering Contents 5.6. SCAN INTERVAL LOOP OPERATION...........................................................................42 5.6.1. Program Variables.............................................................................................42 5.6.2. Description of Code...........................................................................................42 5.7. REAL TIME CLOCK OPERATION................................................................................44 5.7.1. Program Variables.............................................................................................44 5.7.2. Description of Code...........................................................................................45 6. JAVA SOFTWARE DEVELOPMENT.....................................................................48 6.1. INTRODUCTION.........................................................................................................48 6.1.1. What is a Design Pattern?.................................................................................48 6.2. LOGGERUI APPLICATION..........................................................................................49 6.2.1. Specifications.....................................................................................................49 6.2.2. Dataflow Diagrams............................................................................................50 6.2.3. Class Diagrams..................................................................................................52 6.2.4. LoggerUIs Superclasses.....................................................................................53 6.2.5. LoggerUIs Framework Details..........................................................................54 6.3. DESIGN BY CONTRACT..............................................................................................57 6.3.1. LoggerUncheckedException..............................................................................58 6.4. ACTIONSITE..............................................................................................................60 6.4.1. LoggerMenu.......................................................................................................60 6.5. LOGGER CHECK........................................................................................................62 6.6. LOGGER SETUP.........................................................................................................63 6.7. SERIAL PORT INTRODUCTION....................................................................................64 6.7.1. javax.comm extension package..........................................................................64 6.7.2. InitialisePort......................................................................................................66 6.8. GRAPH INTRODUCTION.............................................................................................68 6.8.1. LoggerLineGraphUI..........................................................................................68 6.8.1.1. The Overriden reshape method...................................................................69 6.8.1.2. The Overriden paint method.......................................................................70 6.8.1.3. Adding and Removing items to be Graphed...............................................70 6.8.2. GraphItem Class................................................................................................71 6.8.2.1. Plotting the GraphItems..............................................................................71 Stand-Alone Datalogger with GUI 5 Electronic & Computer Engineering Contents 7. PROBLEMS ENCOUNTERED.................................................................................74 7.1. ADUC812 PROBLEMS ENCOUNTERED......................................................................74 7.2. JAVA PROBLEMS ENCOUNTERED..............................................................................75 8. CONCLUSION............................................................................................................78 APPENDIX A : ADUC812 REGISTER SETTINGS...................................................80 A.1. ADUC812 TMOD, TCON & SCON REGISTER SETTINGS......................................82 A.2. I2C IMPLEMENTATION ON THE ADUC812................................................................85 APPENDIX B : ADUC812 CODE..................................................................................88 APPENDIX C : JAVA HELP.......................................................................................101 C.1. HELPMAP.JHM FILE...............................................................................................101 C.2. LOGGERUIINDEX.XML FILE...................................................................................102 C.3. LOGGERUITOC.XML FILE.......................................................................................103 C.4. HELPSET.HS FILE...................................................................................................104 BIBLIOGRAPHY..........................................................................................................105 Stand-Alone Datalogger with GUI 6 Electronic & Computer Engineering Aims & Objectives 1. Aims & Objectives AIMS 1. To produce a Stand-Alone Datalogger which will interface with the PC though the serial port of the host computer. 2. To design the circuitry for the Stand-Alone Datalogger which will incorporate the Analog Devices ADuC812 microcontroller. 3. To design and write the software to implement the microcontroller operations. 4. To design and write the host computer software to allow the user to interface with the Datalogger during its three modes of operation. OBJECTIVES 1. To make a single sided circuit board to the minimum of size. 2. To ensure that the circuit board will utilise the appropriate supply lines for the ICs and other discrete devices on the board. 3. To design the software to operate the microcontroller and allow it to communicate with other devices on the circuit board and with the host computer. 4. To design the necessary programs to allow the host computer communication with the Datalogger using the serial port, to be designed for and written in Java and to provide a Graphical User Interface for the end user. 5. To present a report which should contain the passage from design feasibility to final operation Stand-Alone Datalogger with GUI 7 Electronic & Computer Engineering Introduction 2. Introduction In environmental monitoring applications, parameters such as temperature, humidity, water levels or pollution need to be monitored continuously over long periods. A conventional personal computer based data acquisition system can be used but such a system involves a computer and a Datalogger, making it expensive. Secondly, the physical size is large. Thirdly, power assumption will be high, and this implies that a powerful battery pack is required in the application where there is no mains supply. A Stand-Alone Datalogger is a useful device for such an application. Firstly, it is dedicated. Its only task is to acquire data and save the data into its memory. It can be connected to a computer at any time to allow its collected data to be transferred and analysed. The Datalogger that has been designed will have one input. The input will be an analogue input that will measure temperature. The Datalogger will be used to monitor the conditions within a drinks vending machine. The temperature sensor will monitor the temperature within the vending machine to make sure the drinks are kept to the required temperature and any changes with the temperature will be recorded i.e. time, day, month, year, and the temperature. At the end of each day the Datalogger may be removed, (if required) from the vending machine and connected to the host computer, and all the data is off-loaded onto the host computer. This allows the logged data to be analyzed and permanently stored. The connection between the host computer and the Datalogger is though serial port. This is used because it is the common connection between peripherals and is more than sufficient for the system needs i.e. don’t require high-speed data transfer between host computer and the Datalogger. When all the data has been off-loaded onto the host computer the user will again initialize the Datalogger through the Graphically User Interface (GUI). This GUI will be constructed from the Java language, and will be the users only way to interact with the Datalogger. Such a Datalogger will be made small in size and with ultra-low power consumption. Such a Datalogger’s small size allows it to be placed in almost any location. It can collect data continuously over a period of time without having its battery changed. The Datalogger will be based around Analog Devices 8051 microcontroller (ADuC812). This has a built-in temperature sensor and an Analogue-to-Digital Converter (ADC) with a conversion accuracy of 12-bits as well as memory, although using external memory will extend this. The ADuC812 does not contain a Real Time Clock (RTC) therefore a dedicated RTC is used. The Datalogger will have a Liquid Crystal Display (LCD), which displays to the user the current temperature read, what percentage of memory is remaining and also informs the user what mode the Datalogger is in. When driven by a lithium 9V PP3 sized battery it could capture data for a month or so unattended. Stand-Alone Datalogger with GUI 8 Electronic & Computer Engineering Background 3. Background 3.1 ADuC812 Overview Analog Devices ADuC812 is a fully integrated 12-bit data acquisition system incorporating a high performance self- calibrating multichannel Analogue-to- Digital Converter (ADC), two 12-bit Digital-to-Analogue Converters (DAC) and programmable 8-bit (8051-compatible) MCU on a single chip. The programmable 8051-compatible core is supported by 8K bytes Flash/EE program memory, 640 bytes Flash/EE data memory and 256 bytes data SRAM on-chip. Additional MCU support functions include watchdog timer, power supply monitor and ADC DMA function. 32 programmable I/O lines, I2C-compatible, SPI and standard UART serial port I/O are provided for multiprocessor interfaces and I/O expansion. Normal, idle and power-down operating modes for both the MCU core and analogue converters allow for flexible power management schemes suited to low power applications. 3.1.1 ADuC812 Features Analogue I/O features: • Eight channel, high accuracy 12-bit ADC • On-chip, 40 ppm/oC voltage reference ADC-to-RAM capture • Two 12-bit voltage output DACs • On-chip temperature sensor function • High speed 200 kSPS • DMA controller for high speed Memory features: • 8K bytes on-chip flash/EE program memory • 640 bytes on-chip flash/EE data memory • On-chip charge pump (No Ext. V requirements) pp • 256 bytes on-chip data RAM • 16M bytes external data address space • 64K bytes external program address space 8051-Compatible core: • 12 MHz nominal operation (16MHz max) • Three 16-bit timer/counters • 32 programmable I/O lines • High current drive capability—Port 3 • Nine interrupt sources, two priority levels Stand-Alone Datalogger with GUI 9 Electronic & Computer Engineering Background Power features: • Specified for 3V and 5V operation • Normal, idle and power-down modes On-chip peripherals: • UART serial I/O • 2-wire (I2C compatible) an SPI serial I/O • Watchdog timer • Power supply monitor 3.2 What is I2C bus? Devised by Phillips, I2C stands for inter-IC-communication. It is a data bus that allows integrated circuits or modules to communicate with each other. The bus allows data and instruction to be exchange between devices via only two wires. This greatly simplifies the design of a complex electronic circuits. There is a family of I2C compatible devices available for various applications. They include I/O expansion, analogue-to-digital and digital-to-analogue conversion, time keeping, memory and frequency synthesis, etc. 3.2.1 Principle of the I2C bus The I2C bus consists of two lines: a bi-directional data line called SDA and a clock line called SCL. Both are pulled up to the positive power supply via resistors. An I2C bus system is shown in Fig. 3-1 Fig. 3-1. An I2C bus consists of only two dta lines: serial, SCL and serial data, SDA. I2Ccompatible devices connect to the bus using these tow wires, making hardware design simpler. A device generating a message is a ‘transmitter’ while a device receiving a message is the ‘receiver’. The device controlling the bus operation is the ‘master’ and devices controlled by the master are ‘slaves’. The following communication protocol is defined: (cid:190) A data transfer may be initiated only when the bus is not busy (cid:190) During the data transfer, the data line must remain stable whenever the clock line is high. Stand-Alone Datalogger with GUI 10
Description: