29
Water Consumption Monitoring System EC-316 Microprocessor Lab Project Netaji Subhas Institute of Technology Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water flow rates at regular intervals and computes the amount of water used in 16 minutes. This data will be represented through bar graph on a 16x2 LCD screen. Every 16 minutes the bar graph is refreshed and the data recorded over the previous 16 minutes will be pushed out of the screen and replaced by the latest data.

Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

Water Consumption Monitoring System

EC-316 Microprocessor Lab Project

Netaji Subhas Institute of Technology

Asmita Goyanka (41/EC/13)

Saurabh Miglani (158/EC/13)

The water consumption monitoring system samples the water flow rates at regular intervals and computes the amount of water used in 16 minutes. This data will be represented through bar graph on a 16x2 LCD screen. Every 16 minutes the bar graph is refreshed and the data recorded over the previous 16 minutes will be pushed out of the screen and replaced by the latest data.

Page 2: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

TABLE OF CONTENTS

1. Acknowledgements 2. Justification 3. Introduction 4. Project desription 5. Schematic FIle 6. Board file 7. Bill of Materils 8. Hardware Photographs 9. Flowcharts 10. Code 11. Testing 12. Conclusion 13. Bibliography

Page 3: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

Acknowledgements

We would sincerely like to thank Prof. Dhananjay V. Gadre for providing us with this learning opportunity as a part of EC-316 and for his valuable guidance, support and motivation during the entire project. We would also like to thank our peers who helped us in the process.

Page 4: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

Justification

With the environment in great peril, things as simple as leaky taps are a threat to mother earth. It is estimated that if a tap leaks at even the miniscule rate of 1 drop per minute, it can waste about 10 liters a day. We felt that a device that can detect this wastage and notify humans about this leakage and the amount of wastage caused will be a step forward in the direction of greater environmental awareness.

When we decided to do this project, we were apprehensive about its execution, but Prof. D.V. Gadre guided us in the right direction and encouraged us to work on this project.

Page 5: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

Introduction

Water is a precious resource. Millions of people do not have access to clean drinking water, and as many as 4000 children die from water contaminated illnesses every day. Yet, we continue to be wasteful with our resources. The overarching goal of this project is to motivate more sustainable water use behavior and raise awareness about global water issues.

The relevance of a water consumption monitoring system has been discussed, and such a system must consist of a flow meter, an LCD to display water amount consumed and of course, an 8085 microprocessor that computes the water consumed and interfaces the LCD.

The user simply has to let the water flow, and wait. After taking multiple samples, the water consumed every second will be displayed as a bar graph on the LCD screen.

Page 6: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

Project Description

In our project, we have interfaced an Intel 8085 with ICs 8254 and 8255 to further interface the water flow sensor and the LCD screen using these ICs. We’ll discuss the operation of each component one by one.

The water flow sensor is a device that consists of a turbine, a hall effect meter and a pathway for the water to flow. It can be fixed at the end of tap and as the water flows, the turbines rotates. Depending on the amount of water flowing the speed of rotation of the turbine changes. In the YFS201 “Hall Effect Water Flow Sensor”used, there is an integrated magnetic Hall-Effect sensor that outputs an electrical pulse with every revolution. By counting the pulses from the output of the sensor, we can easily calculate the water flow rate (in litre/hour – L/hr) using the formula F=7Q.

Water Flow Sensor

The IC chip 8254 helps in counting the number of these pulses. 8254 contains 3 16-bit down counters and each of them consists of three pins: gate, clock and output. To count the number of pulses, we connected the gate of the counter 0 to a 1 Hz square wave that we generated using counters 1 and 2. Thus, the counter 0 is counts for half a second, and then remains off for the next half second. In the second half, we read the value of the count using read back command. The 1Hz square wave is

Page 7: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

generated by initialising counters 1 and 2 in mode 3, with counts 50000 and 40 in both respectively. The output of the counter 1 drives counter 2. The output of counter 2 goes to the gate of counter 0, and to RST 7.5 of the 8085. While we planned to use the interrupt, we were unable to precisely incorporate in our project and therefore decided to disable it for the final code.

The second piece of the project consists of the 8255 and LCD interfacing. The LCD was connected to the port B of the 8255, with its control pins to independent pins of Port C. Interfacing it was simply a matter of programming it right.

Page 8: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water
Page 9: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water
Page 10: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

Bill of Materials

1. Intel 8085 Microprocessor 2. An 8254 3. Latches - 74HCT573N 4. Decoder - 74138N 5. 32K EEPROM 6. 32K RAM 7. EEPROM Programmer 8. SMD Micro USB Port 9. 8255 10. Red LEDs 11. LCD Screen (16X2) 12. Push buttons

Page 11: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

Hardware Photos

Page 12: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

Flowcharts

YES To A

NO

START

Initialise LCD and 8255

Define CGROM

Initialise 8254

Initialise registers

Call DELAY for 450ms

Latch Counter0 of 8254 and read its t

Call DELAY for 500ms

Adjust the read count

DCR B

B=0

Page 13: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

Put sample in

Compare to

Call P1

Compare to

Call P2

Compare to

Call P3

Compare to Call P4

Compare to

Call P5

Compare to

Call P6

Compare to

Call P7

SMALLER

SMALL

SMALLER

SMALLER

SMALLER

SMALLER

SMALLER

ELSE

ELSE

ELSE

ELSE

ELSE

ELSE

A

Page 14: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

Call P8

ELSE

Page 15: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water
Page 16: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

CODE

.ORG 0000H LXI SP,0FFFFH ;STACK POINTER INITIALISATION MVI A, 10010000B ;Port A as Input, B as Output in Mode 0 OUT 043H LXI H,8001H MVI A,0AH MOV M,A INX H MVI A,54H MOV M,A INX H MVI A,68H MOV M,A INX H MVI A,72H MOV M,A INX H MVI A,A1H MOV M,A INX H MVI A,11H MOV M,A MVI A,0AH MOV M,A INX H MVI A,54H MOV M,A INX H MVI A,68H MOV M,A INX H MVI A,72H MOV M,A INX H MVI A,A1H MOV M,A INX H MVI A,11H MOV M,A MVI A,0AH MOV M,A INX H MVI A,54H

Page 17: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

MOV M,A INX H MVI A,68H MOV M,A INX H MVI A,72H MOV M,A INX H MVI A,A1H MOV M,A INX H MVI A,11H MOV M,A INX H MVI A,23H MOV M,A INX H MVI A,C2H MOV M,A INX H MVI A,5DH MOV M,A INX H MVI A,E7H MOV M,A INX H MVI A,1FH MOV M,A INX H MVI A,9AH MOV M,A INX H MVI A,84H MOV M,A INX H MVI A,A8H MOV M,A INX H MVI A,C9H MOV M,A INIT: MVI A, 00110000B MOV B, A CALL OUTPUT CALL CMDOUT

Page 18: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

CALL CMDOUT MVI A, 00111000B ;8 BIT, 2 LINES, 5X7 DISP CALL CMDOUT MVI A, 00001000B ;DISPLAY OFF CALL CMDOUT MVI A, 00000001B ;CLEAR DISPLAY CALL CMDOUT MVI A, 00000110B ;ENTRY MODE SET, SHIFT AND INCREMENT CURSOR CALL CMDOUT MVI A, 00001100B ;DISPLAY ON CURSOR, BLINKING OFF CALL CMDOUT DISP1: MVI A,40H; CGRAM 1st location set CALL CMDOUT MVI A, 00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,1FH; FIRST BAR CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH; SECOND BAR CALL DTAOUT

Page 19: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH; THIRD BAR CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH; FOURTH BAR CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH

Page 20: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

CALL DTAOUT MVI A,1FH;FIFTH BAR CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH; SIXTH BAR CALL DTAOUT MVI A,00H CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH; SEVENTH BAR CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT

Page 21: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

MVI A,1FH CALL DTAOUT MVI A,1FH CALL DTAOUT MVI A,1FH; EIGTH BAR MVI A,C0H CALL CMDOUT MVI E,00H LXI H,8000H AGAIN: CALL DELAY60 INX H MOV A,M CALC:CPI 07H JC P1 CPI 24H JC P2 CPI 41H JC P3 CPI 5EH JC P4 CPI 7BH JC P5 CPI 9AH JC P6 CPI B5H JC P7 JMP P8 CMDOUT: MOV B, A CALL CHK OUTPUT: MVI A, 004H ;reset RS OUT 043H MVI A, 002H ;reset RW (enable W) OUT 043H MVI A, 00000001B ;set EN OUT 043H MOV A, B OUT 042H MVI A, 00000000B ;reset EN OUT 043H RET DTAOUT: MOV B, A CALL CHK MVI A, 005H ;set RS OUT 043H

Page 22: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

MVI A, 002H ;reset RW (enable W) OUT 043H MVI A, 00000001B ;set EN OUT 043H MOV A, B OUT 042H MVI A, 00000000B ;reset EN OUT 043H RET CHK: MVI A, 10010010B ;set Port B as input OUT 043H MVI A, 004H ;reset RS OUT 043H MVI A, 003H ;set RW OUT 043H READ: MVI A, 00000001B ;set EN OUT 043H IN 042H RLC MVI A, 00000000B ;reset EN OUT 043H JC READ MVI A, 10000000B ;set Port B back as output OUT 043H RET DELAY60:PUSH D PUSH B MVI D,2CH DELAY: DCR D JNZ DELAY1 POP B POP D RET DELAY1: LXI B,22CCH DELAY2: DCX B MOV A,C ORA B JNZ DELAY2 JMP DELAY P1: INR E MOV A,E CPI 11H CNC SHIFT MVI A,00H

Page 23: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

CALL DTAOUT JMP AGAIN P2: INR E MOV A,E CPI 11H CNC SHIFT MVI A,01H CALL DTAOUT JMP AGAIN P3: INR E MOV A,E CPI 11H CNC SHIFT MVI A,02H CALL DTAOUT JMP AGAIN P4: INR E MOV A,E CPI 11H CNC SHIFT MVI A,03H CALL DTAOUT JMP AGAIN P5: INR E MOV A,E CPI 11H CNC SHIFT MVI A,04H CALL DTAOUT JMP AGAIN P6: INR E MOV A,E CPI 11H CNC SHIFT MVI A,05H CALL DTAOUT JMP AGAIN P7: INR E MOV A,E CPI 11H CNC SHIFT MVI A,06H CALL DTAOUT JMP AGAIN P8: INR E

Page 24: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

MOV A,E CPI 11H CNC SHIFT MVI A,07H CALL DTAOUT JMP AGAIN SHIFT: MVI A,C0H SIM MVI A,18H CALL CMDOUT RET OVER: HLT

Page 25: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

Testing STAGE I: Testing the LCD

We tested the working of the LCD by writing a code to print the character ‘L’ on the LCD. This was done using a simple test code and after a lot of trial and error, the code finally worked.

STAGE II: Testing the output of the counters 1 and 2.

The code we used for this was a simple code that initialized the counters in mode 3 with an initial count of 50,000 in counter 1 and 40 in counter 2. The output of the counter 1 drives the counter 2. The output

of the counter 2 was a perfect 1Hz square wave.

40 Hz wave at the output of counter 1

1 Hz wave at the output of counter 2

STAGE III: Taking a sample from 8085 counter 0.

We programmed the 8085 to take 1 sample from the 8254 counter 0, initialised port B of our 8255 and output the value of the frequency obtained from the sample to the port B.

The output was measured using an MSO and was as required.

Page 26: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

Value of sample at the MSO

STAGE IV: Testing the code of the bargraph

The code to print a bar graph on the LCD was burned on the ROM and tested. The result was the desired output.

STAGE V: Taking a sample and displaying it to the LCD

In this stage, we integrated the codes from stages 3 and 4 and tested it. The output was the bar of size corresponding to the sample taken. (The value of the sample was predetermined by the input wave and stage 3 testing)

STAGE VI: Taking multiple samples and displaying them to the LCD

This stage proved to be a troublesome one. To input a new sample and then print it, we needed to apply delays between each cycle of sampling and printing. However this proved to be greatly problematic because with each successive cycle, the amount of total delay incremented and this caused the code to run incorrectly.

We fixed this problem by first taking multiple samples, and then outputing all of their corresponding bar graphs simultaneously.

Page 27: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

Proposed Gantt Chart

Actual Gantt Chart

Page 28: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

Conclusion

EC-316 was a great learning experience. It was an excellent opportunity to put our theoretical knowledge to practical use. Designing, coding and presenting this project was an enriching experience. It didn’t just help us develop a deep understanding of the Intel 8085 microprocessor and introduce us to various aspects of PCB design, development, programming and testing, but also gave us a sense of intrinsic understanding of embedded systems. Debugging our project from both a hardware and a software perspective made all the theoretical ideas we’ve studied a real thing. Trying to adhere to our proposed Gantt chart and trying to meet our goals together was a challenge in itself but it taught us teamwork, time management, and perseverance. In all, this project gave us a sense of real world engineering.

Page 29: Water Consumption Monitoring System - 8085 Projects · 2016-12-01 · Asmita Goyanka (41/EC/13) Saurabh Miglani (158/EC/13) The water consumption monitoring system samples the water

Bibliography

TEXTBOOKS Microprocessor Architecture, Programming, and Applications with the 8085 Author: Ramesh Gaonkar Publisher: Penram International Publishing (India) Pvt. Ltd Edition: 5th edition WEBLINKS 1. http://www.circuitstoday.com/lab-manuals/microprocessor-lab 2. http://www.alldatasheet.com/datasheet-pdf/pdf/92530/INTEL/8085AH.html 3. http://www.ti.com/lit/ds/symlink/sn74ls138.pdf 4. www.nxp.com/documents/data_sheet/74HC_HCT573.pdf