Docsity

It is a Project report, Study Guides, Projects, Research of Microcontrollers

Partial preview of the text

Download It is a Project report and more Study Guides, Projects, Research Microcontrollers in PDF only on Docsity!

Microcontrollers

& Embedded Systems

(MTS -331)

DE-43 Mechatronics

Syndicate – C

Project Report

AT89C51 Based Carbon Monoxide Sensor and Alarm System

Names of Members:
1. NC Ahmed Saeed
Reg # 374405
2. NC Mohammad Bin Tila
Reg # 388525
Submitted to: Assistant Professor Anjum Malik

Table of Contents

Abstract

This is a report for the project of the course MTS-331 Microcontrollers and embedded systems. The goal of the project was to create a product that could solve a real-life problem or address a particular household or industrial need using an AT89C51 microcontroller. The chosen problem was that of carbon monoxide leaks in households and hence a senor and alarm system was created that could detect the presence of harmful levels of CO in the atmosphere and warn the occupants of the room with audio-visual signal. One of the considerations of the project was to keep it as low cost as possible to make it accessible to lower income households like those in Pakistan, as higher cost often prohibits access to such systems here. Both the software simulations and hardware were successfully prepared and tested in controlled environments.

Keywords: Microcontrollers, Carbon Monoxide, Sensors, detectors and alarms, inequality, low cost.

Sustainable Development Goals (SDGs)

SDG 3: Good Health and Well-being.

CO alarms protect people from the harmful effects of carbon monoxide poisoning, which can lead to health issues and even fatalities.

SDG 10: Reduced Inequalities.

Low-cost CO alarms will provide safety and security to low-income households, bringing them closer to higher income societies.

SDG 11: Sustainable Cities and Communities.

CO alarms enhance safety in urban areas, contributing to the development of resilient and sustainable cities.

SDG 13: Climate Action

CO alarms supports efforts to combat climate change and reduce greenhouse gas emissions, as elevated CO levels indicate inefficient combustion processes.

1. INTRODUCTION AND BACKGROUND

1.1 Microcontrollers for Everyday Problem Solving

In the rapidly advancing field of technology, microcontrollers have emerged as powerful tools for addressing and solving everyday problems. These compact, integrated circuits offer a versatile platform for the development of cost-effective solutions that cater to a wide range of applications. Their ability to process data and execute specific tasks makes them invaluable in the development of smart devices and sensors. This project explores the use of microcontrollers in the creation of a low-cost carbon monoxide alarm and sensor, aiming to make a significant contribution to the safety and well-being of lower-income households.

1.2 Carbon Monoxide: A Silent Threat

Carbon monoxide (CO) is a colorless, odorless gas produced by the incomplete combustion of fossil fuels. Carbon monoxide poisoning occurs when carbon monoxide builds up in the blood. When too much carbon monoxide is in the air, the body replaces the oxygen in the red blood cells with carbon monoxide. This can lead to serious tissue damage, or even death. Burning fuels, including gas, wood, propane, or charcoal, make carbon monoxide. Appliances and engines that aren't well vented can cause the gas to build up to dangerous levels. A tightly enclosed space makes the buildup worse. Other Common sources include gas appliances, wood-burning stoves, and motor vehicle exhaust. Despite its elusive nature, carbon monoxide poses a severe threat to human health. When inhaled, it competes with oxygen in the bloodstream, leading to hypoxia and potentially fatal consequences [1], [2]

1.3 Affordability Challenges in Lower-Income Households

Developed countries often enforce stringent building codes and safety regulations, elevating the awareness and adoption of carbon monoxide alarms as essential elements in home security. Conversely, in non-developed countries, including Pakistan, where access to advanced technology and safety measures may be limited, the prevalence of carbon monoxide alarms is unfortunately lower. Despite facing similar or even heightened risks due to the use of traditional cooking methods and inadequate ventilation systems, these regions frequently lack the resources to implement widespread safety measures. The economic constraints in non-developed countries exacerbate the challenge, making conventional carbon monoxide alarms unaffordable for many households, for example, the average price for a CO alarm in the U.K. was reported to be 90£ in 2023 [7], while no concrete figures exist for the prices in Pakistan, since most of these products are imported, they are known to command high prices in the market, starting from 4000-5000 PKR, often without installation charges. Consequently, there exists a stark contrast in the level of protection against carbon monoxide poisoning between developed and non-developed nations, underscoring the urgent need for cost-effective alternatives that can transcend economic disparities.

1.4 Project Rationale

This project addresses the critical intersection of microcontroller technology, public health, and economic accessibility. By developing a low-cost carbon monoxide alarm and sensor, the project aims to bridge the gap in safety measures, particularly for lower-income households. The prohibitive cost of conventional carbon monoxide alarms restricts their availability to lower-income households, leaving a vulnerable demographic without adequate protection. Indeed, in only the past few years, Pakistan has seen countless deaths due to CO poisoning, with the most common occurrences being due to gas stoves and heaters used for cooking and heating as well as generators used to combat the frequent power outages, especially in rural areas, where the knowledge about the dangers of these gases is not prevalent [8], [9]. The disparity in access to life-saving technology underscores the urgent need for a cost-effective alternative that ensures the safety of all individuals, regardless of their economic status.

The subsequent chapters will delve into the design, implementation, and testing phases, providing a comprehensive understanding of the methodology and outcomes.

2. SYSTEM DESIGN, SIMULATION AND FABRICATION

The software simulation & the hardware will be discussed in this section of the report.

Note that all 4 ports are being used with Port 0 having an additional resistor pack attached to it to pull up its pins.

● Port 0 is connected to the digital output of the Analog to digital converter, ADC0804. Who’s main task is to convert the incoming data from the MQ7 sensor (an analogue voltage) to a digital 8-bit value that can be utilized and displayed by the microcontroller. This is further explained in sections 2.1.2, 2.1.3 and 3.2. ● Port 1 is connected to the Seven Segment Display drivers, 74LS78, which are being used to display the PPM of CO on the SSDs. To display the data properly, the high and low bites are separately displayed, as the microcontroller gives a hexadecimal value which is then converted and displayed a decimal. ● Port 2 is connected directly to an LED bar graph which will light up successively as the concentration of CO increases in the air, acting as an alternative way of displaying this data for users who may have difficulty reading the SSD. This is basically using the same data that P0 is receiving. ● Port 3 is mostly left open in case additional systems are to be added to the alarm like louder audio signals, external interrupt conditions etc. However, Pin 3.7 is being used to toggle the buzzer in the circuit when the concentration of CO hits a lethal level in order to warn occupants to exit the room. This is especially important if the occupants are sleeping at the time of a leak. 2.1.2 The MQ-7 Air quality sensor The MQ-7 is a low-cost gas sensor designed to detect the presence of carbon monoxide (CO) in the air. It is commonly used in various applications, including air quality monitoring systems, gas leakage detectors, and environmental monitoring devices. Gas Detection: The primary function of the MQ-7 sensor is to detect the concentration of carbon monoxide (CO) gas in the surrounding environment. Sensitivity: The MQ-7 sensor is highly sensitive to carbon monoxide, having measurement increments of as low as 1PPM, making it suitable for applications where accurate and rapid detection of CO levels is crucial. However, in this case, the resolution is set to 4PPM. Operating Principle: The sensor operates on the principle of chemical reaction. When exposed to carbon monoxide, the resistance of the sensor changes, and this change is measured to determine the gas concentration.

Range: The MQ-7 sensor has a range of measurement from 20-2000PPM of CO, allowing it to detect low to moderate levels of carbon monoxide in the air. Here it is only being used in the 20-1000PPM range. Heating Element: The sensor contains a built-in heating element that ensures a stable and consistent operating temperature, contributing to the accuracy and reliability of the measurements. Analog Output: The MQ-7 sensor provides an analog voltage output that correlates with the concentration of carbon monoxide in the air. This analog signal can be interfaced with microcontrollers or other devices for further processing. Response Time: The response time of the MQ-7 sensor is relatively fast, enabling quick detection and response to changes in carbon monoxide levels.

Although the MQ-7 can give both analogue and digital outputs, for the sake of accuracy, the analog output is being used here along with an ADC. The analog output of the sensor is connected to the Vin+ pin of the ADC, further information about the sensor is available in the data sheet [11] and is discussed in section 3.2.

2.1.3 Analog to Digital Converter

An Analog-to-Digital Converter (ADC) is an electronic device that converts analog signals, typically in the form of voltage, into digital representations that can be processed and manipulated by digital systems. The ADC0804 is a specific type of ADC that has been widely used in various electronic applications.

On the left is the Vcc pin and the digital output pins that are connected to port 0 of the microcontroller. On the right, the Interrupt and WR pins are where the pulse is given from the 555 timer as the ADC needs a rising edge to give an output. Vin+ and Vin- are where the analog output is connected. CLK IN and CLK R are connected to the clock resistor of 10kΩ and grounded. The remaining pins, CS, RD, A GND (analog ground) and D GND (digital ground) mut also be grounded for use in this case. VREF/2 is not used in this case as we do not need to divide the reference voltage by 2 [12].

The rest of the components, i.e. the 555 timer, the buzzer, the SSDs, and their drivers as well as the RESPAKs and LEDs are basic electronic components whose working need not be explained here for understanding the circuit or the system, hence they are omitted.

2.2 Circuit Hardware:

The circuit hardware is divided into two parts, one being the main circuit which contains the sensors, audio alarm as well as a display for showing the concentration of CO in PPM. The second part of the circuit includes the microcontroller itself along with a set of LEDs that also display the concentration of CO using solid colors and levels. This is intended as an accessibility feature as the target market may contain individuals who cannot understand what the numbers on the primary display indicate. The first part of the circuit is currently constructed on a breadboard for testing howevr can be moved to a PCB like the micocontroller board for production models, both the circuits can also be constructed on a single board for ease of packaging, however for the purposes of testing and proof of concept, this layout will suffice. The projects Bill of materials is also attached as ANX – ‘A’.

3. SOFTWARE AND TESTING

The coding for the device was done in assembly language using ARMs Keil μVision software. The code will be attached as ANX – ‘B’.

The surface resistance of the sensor (Rs) is obtained through effected voltage signal output of the load resistance RL which series-wound. The relationship between them is described:

Rs\RL = (Vc-VRL) / VRL

Here it is important to note that the output values of the sensor are temperature and humidity dependent. Though the expected ambient temperatures in standard use cases are not expected to negatively affect the performance of this system, this temperature factor is important whenever the system is turned on as the sensor requires some time to heat up before it can give accurate readings of the CO concentrations, for this task, the MQ-7 comes with a built-in heating element. The sensitive sensing element of the sensor is made from SnO 2 and can last 5 years under normal usage conditions after which the entire sensor must be replaced, however, this is not a problem due to the low cost and modular nature of the sensor and the

circuit where it is installed, and a customer could very easily replace the sensor themselves if required [13].

Where,

Ro: sensor resistance at 100ppm CO in air at 33%RH and 20 degree Celsius.

Rs: sensor resistance at 100ppm CO at different temperatures and humidities.

Further information about the working principles of the MQ-7 is available in its detailed data sheet [13].

3.2.1 Conversion formula, library, and methodology Due to the prevalence of the MQ-7 sensor, the code required for the conversion of its Rs/Ro output to a PPM value was already available in online repositories. However, this was for the C++ or Python programming languages only, not for assembly, and hence required a different approach. From these libraries, the basic formula for the conversion factor of the sensor was found to be;

𝑎 × ( 𝑅 𝑅𝑠𝑜)

−0.

Where; ● a is the conversion constant for the sensor based on external factors. ● Rs/Ro are as explained before [14] While this equation is easily modeled in a language like C++ or python, it cannot be accomplished in assembly on AT89C51 using normal means. Methods like logarithms or reverse interpolation were considered and are technically possible but the complexity of the code required for them is extreme. In this situation, the simplest and fastest solution was deemed to be the creation of a data table in the microcontroller memory which would hold values of PPM corresponding to the Rs/Ro levels given by the sensor. This table is shown in figures 10 and 11.

3.3.1 Limitations ● Though the system achieves its intended goals, it is, at the end of the day, a low-cost sensor, and hence it cannot be expected to be highly precise nor sensitive. ● Due to the inability of the AT89C51 to model complex mathematical equations, the use of a data table is necessitated, which lowers the resolution and accuracy of the system. ● The heating element in the MQ-7, owing to its size, has a low output, which causes a considerable delay in the amount of time it takes for the sensor to output accurate values after start up. ● The range of the sensor is limited, indicating the necessity of multiple such devices being required around a house in order to have effective warning of leaks. 3.3.2 Solutions and further work ● Many of the limitations to the project can be solved by using higher quality and higher cost parts, however this is a tradeoff, as using cost prohibitive parts would defeat the purpose of a low-cost alarm system. ● Using a different, newer microcontroller like one of the ESP32 or AVR family can allow for more accurate results owing to their ability to solve more complicated mathematical problems. ● For further work, it would be ideal to combine the two separate hardware circuits into a single, preferably printed circuit board, including a housing for the electronics to create a more presentable and user-friendly form, however the modularity of the MQ7 sensor must be retained in order to allow replacements once the sensor array has expired. ● The Extra Capacitors, resistors and other basic elements can be reduced by design refinement.

Conclusions:

With a final product cost of an estimated 1500-2000PKR, which can be further brought down with design optimization as well larger scale production and procurement, the main goal of the project; to create a low-cost, dependable carbon monoxide detector and alarm, was

realized. Along the way, several lessons were learned about not only microcontrollers and their usage, but also about sensors, sensor and controller interface and integration. Overall, the project was successful in not only providing a viable solution to a known real-life problem using an AT89C51 microcontroller, but also in learning as a teaching aid in the subject of microcontrollers and embedded systems. The product stands as an example to bridge the gap between safety standards for household in higher and lower income countries, following the requirements set by the sustainable development goals 3, 10, 11 and 13.

References and Bibliography

[1] “Carbon Monoxide: What It Is, How It Works, and Risks.” Accessed: Dec. 12, 2023. [Online]. Available: https://www.verywellhealth.com/what-is-carbon-monoxide-

[2] “Carbon monoxide poisoning - Symptoms and causes - Mayo Clinic.” Accessed: Dec. 12,

  1. [Online]. Available: https://www.mayoclinic.org/diseases-conditions/carbon-monoxide/symptoms-causes/syc- 70642

[3] “Frequently Asked Questions | Carbon Monoxide Poisoning | CDC.” Accessed: Dec. 12,

  1. [Online]. Available: https://www.cdc.gov/co/faqs.htm

[4] T. A. Temrel, “Mortality rate associated with carbon monoxide poisoning in Turkey: A national database study,” J Pak Med Assoc , vol. 71, no. 1 B, pp. 262–266, Jan. 2021, doi: 10.47391/JPMA.637.

[5] N. R. C. (US) C. on A. E. G. Levels, “Carbon Monoxide Acute Exposure Guideline Levels,” 2010, Accessed: Dec. 12, 2023. [Online]. Available: https://www.ncbi.nlm.nih.gov/books/NBK220007/

[6] M. E. Hanley and P. H. Patel, “Carbon Monoxide Toxicity,” Med J , vol. 10, no. 10, pp. 1–16, Jan. 2023, Accessed: Dec. 12, 2023. [Online]. Available: https://www.ncbi.nlm.nih.gov/books/NBK430740/

[7] “What’s the Cost of Carbon Monoxide Alarm Installation in 2022? | Checkatrade.” Accessed: Dec. 12, 2023. [Online]. Available: https://www.checkatrade.com/blog/cost-guides/carbon-monoxide-alarm-installation-cost/