You are on page 1of 40

BACHELOR OF SCIENCE IN ELECTRICAL AND

ELECTRONIC ENGINEERING

SMART UTILITY LOAD MANAGEMENT AND FAULT


DETECTION

Submitted By
Md Ruhul Quader 008-34-32
Khaled Ashraf Nayan 008-34-57

Supervisor
Fahmida Sharmin Jui
Assistant Professor
Department of Electrical & Electronic Engineering
Southern University Bangladesh

Submitted To:
DEPARTMENT OF
ELECTRICAL & ELECTRONIC ENGINEERING
SOUTHERN UNIVERSITY BANGLADESH
Spring-2023
SMART UTILITY LOAD MANAGEMENT AND FAULT
DETECTION

Submitted by
Md Ruhul Quader 008-34-32
Khaled Ashraf Nayan 008-34-57

Supervisor:

Fahmida Sharmin Jui


Assistant Professor
Department of Electrical & Electronic Engineering
Southern University Bangladesh

This project report is submitted to the Department of Electrical & Electronic Engineering, Southern University
Bangladesh, in partial fulfillment of the requirement for the degree of Bachelor of Science in Electrical and
Electronic Engineering.

DEPARTMENT OF
ELECTRICAL & ELECTRONIC ENGINEERING
SOUTHERN UNIVERSITY BANGLADESH
Spring-2023

ii
SMART UTILITY LOAD MANAGEMENT AND FAULT
DETECTION

Submitted by
Md Ruhul Quader 008-34-32
Khaled Ashraf Nayan 008-34-57

This Project is submitted to the Department of Electrical & Electronic Engineering, Southern University
Bangladesh in partial fulfillment of the requirement for the degree of Bachelor of Science in Electrical and
Electronic Engineering.

Approved By

______________________

Fahmida Sharmin Jui Supervisor


Assistant Professor
Department of Electrical & Electronic Engineering
Southern University Bangladesh

__________________
Professor Mohammad Abdul Alim External
Professor
University of Chattogram

iii
ACKNOWLEDGEMENT

We are thankful to almighty, for giving His blessings and mercy to work hard for completing this
project. We would like to express our sense of gratitude and indebtedness to our respected project
supervisor Fahmida Sharmin Jui, Professor, Department of Electronics and Communication
Engineering for her valuable guidance, generous advice, endless encouragement and unfilled
enthusiasm given throughout the research and preparation of the entire project. We are thankful to our
honorable head of the department Dr. Hadaate Ullah and all teachers of the department of Department
of Electrical & Electronic Engineering, Southern University Bangladesh for their cordial help and
support. We are also indebted to all those who made constructive criticism, as well as those who shared
their thoughts and we are also heartily thankful to our classmates and senior brothers for their helpful
suggestions throughout the project. We like to convey our deepest gratitude to our parents for their
unconditional love and indulgence at the moment of triumph turmoil

iv
Table Of Contents
ACKNOWLEDGEMENT.................................................................................................................. iv
Table Of Contents.............................................................................................................................v
ABSTRACT.....................................................................................................................................vii
CHAPTER 01.........................................................................................................................................1
INTRODUCTION & OBJECTIVES...................................................................................................1
1.1 Introduction...........................................................................................................................1
1.2 Motivation............................................................................................................................. 1
1.3 Project Objectives................................................................................................................ 2
CHAPTER 02.........................................................................................................................................3
LITERATURE REVIEW.................................................................................................................... 3
2.1 Historical Background.......................................................................................................... 3
2.2 Recent Plans........................................................................................................................ 5
2.3 Related Research History.................................................................................................... 6
2.4 Load Adjustment/Load Balancing........................................................................................ 8
2.5 Peak Curtailment/leveling and Time of Use Pricing............................................................. 9
CHAPTER 03.......................................................................................................................................10
EXPERIMENTAL SETUP...............................................................................................................10
3.1 Block Diagram.................................................................................................................... 10
3.2 Working Procedure of Block Diagram................................................................................ 10
3.3 System Flow Chart............................................................................................................. 11
3.4 Circuit Diagram...................................................................................................................12
3.5 Circuit Description.............................................................................................................. 12
3.6 Arduino Nano..................................................................................................................... 13
3.7 Current Sensor................................................................................................................... 13
3.8 Wi-Fi Module (ESP8266)....................................................................................................13
3.9 Liquid-Crystal Display.........................................................................................................14
3.10 Relay Switch Circuit......................................................................................................... 14
3.10.1 NPN Relay Switch Circuit........................................................................................15
CHAPTER 04.......................................................................................................................................17
RESULT ANALYSIS....................................................................................................................... 17
4.1 Result................................................................................................................................. 17
4.2 Controlling & Monitoring Section IoT Result with Hardware.............................................. 18
4.3 Discussion.......................................................................................................................... 19
4.4 Application..........................................................................................................................19
4.5 Advantages........................................................................................................................ 20
4.6 Cost Analysis......................................................................................................................20
CONCLUSION............................................................................................................................... 21
FUTURE WORK............................................................................................................................ 22
REFERENCE................................................................................................................................. 23
APPENDIX..................................................................................................................................... 25

v
LIST OF FIGURES
Figure No Figure Name Page Number

3.1 Block Diagram 15

3.2 System Flow Chart 17

3.3 Circuit Diagram 18

3.4 Arduino Nano 19

3.5 Current Sensor 24

3.6 Wi-Fi module 25

3.7 LCD Display 27

3.8 NPN relay switching circuit 28

4.1 Electrical Load Monitoring at LCD 31

4.2 Transmission Line Fault Monitoring 32

4.3 Transmission Main Line Fault Monitoring 32

4.4 Transmission Main Line Fault Monitoring

4.5 Electrical Load Controlling by server

4.6 Total System

v
LIST OF TABLES
Table No Table Name Page Number

6.1 Load Calculation 15

6.2 Priority Based Load Management 17

6.3 Fault Analysis

6.3 Cost Analysis 18

vi
ABSTRACT
Load management we can handle the output loads and save the energy. Load management, also known
as demand side management, is the process of balancing the supply of electricity on the network with
the electrical load by adjusting or controlling the load rather than the power station output. This can be
achieved but direct intervention of the utility in real time, by the use of sensitive relay triggering the
circuit breakers, by time clock or by using special tariffs to influence consumer behavior. Load
management allows utilities to reduce demand of electricity during peak usage times, which can, in
turn reduce costs by eliminating the need for peaking power plants. This paper also proposes a
low-cost small hydropower plant that can benefit communities in rural areas which are endowed with
small hydropower resources. Consumer wants to reduce the electricity bills so we use this type of
power generation.

vii
CHAPTER 01
INTRODUCTION & OBJECTIVES
1.1 Introduction
The project is an automatic load operation system that controls load operation, multiple numbers of
times according to programmed instruction. The project eliminates the manual ON/OFF switching of
load. This project is required for load shedding time management which is used when the electricity
demand exceeds the supply and there comes a need for manually switching ON/OFF the electrical
devices in time. Hence this system eliminates the manual operation by automatically switching the
load ON/OFF. A matrix keypad is interfaced with the microcontroller from where the specified time is
input to the microcontroller. When this input time equals the real time, based on the commands the
microcontroller initiates that particular relay to switch ON/OFF the load. The time is displayed on a
LCD display. [1]
Load shedding is the thing that electric utilities do when there is a huge demand interest for power that
surpasses the supply. In this way in a distribution framework, it should decisively control the for the
particular timeframe. Programmable load shedding time administration framework is a dependable
circuit that assumes control over the manual undertaking of switch ON/OFF the electrical gadgets
concerning time. While the set time equivalents to the constant, at that point microcontroller, offers the
charge to the comparing transfer to turn ON the heap and afterward another order to turn OFF
according to the program. Numerous ON/OFF time passage is the greatest favorable position with this
project. A grid keypad helps to enter the time. A LCD show is interfaced to the microcontroller to
show time.

1.2 Motivation
Bangladesh has energy crisis but load shedding has a huge potential on the contrary. Our system may be
a possible solution for meeting the increasing demand of electricity. Asit can automatically detect,
calculate and distribute electricity as per load requirements & reduces the system loss at the same time.
➢ Power Saving Using Time Operated Electrical Appliance Controlling System is a reliable circuit
that takes over the manual task of switch on/off the electrical devices with respect to time.
➢ When this time equals to the programmed ‘ON’ time, then the corresponding Relay for the device is
switched ON and then OFF as per the ‘OFF’ time that finally switches the load ON or OFF.
➢ Multiple ON/OFF times entry is the biggest advantage with this project. ➢ Matrix keypad helps
entering the time while relays used with relay drivers for the loads. ➢ The complete circuit has its
on-board power supply.

1
1.3 Project Objectives
➢ To control load in distribution line by using this system.
➢ To develop a fully automated IoT based smart load management. Also monitor and controlled for
remote area only by the authorized personal at a very low cost.
➢ To address the zone fault detection through our purpose system.

2
CHAPTER 02
LITERATURE REVIEW

2.1 Historical Background


Electricity was introduced to the country on 7 December 1901 under British rule. Electricity is the
major source of power for most of the country's economic activities. Bangladesh's total installed
electricity generation capacity (including captive power) is 25,700 MW.

Automatic Load Shedding:


This is a result of concurrent failures of major element(s) in the national grid (e.g. co-incidental
generator or key transmission line failures), resulting in protection schemes initiating the automatic
isolation of additional parts of the national grid, to protect the entire grid from cascading to a total
blackout. Automatic load shedding always occurs on the transmission system level, with the result
being large amounts of electricity and large blocks of customers taken off supply in a very short time.
Typical load reduction amounts can be in the order of 1000MW – 2000MW, affecting hundreds of
thousands of customers. [2]
Renewable Energy:
To date, total installed capacity of renewable power in Bangladesh stands at around 631
MW comprising less than 3% share of total electricity generation, which falls far short of its target of
2000 MW.Sep 21, 2020

3
Generation report of BPDP
Chattagram Zone

Installed Derated Actual Peak Actual Peak


SL No. Name of Power Station
Capacity Capacity Day Evening

Karnaphuli Hydro PP
1 Unit-1,2,3,4,5 230.00 230.00 46.00 46.00

2 Chattogram Tpp:Unit-1 210.00 180.00 0.00 0.00

3 Chattogram Tpp:Unit-2 210.00 180.00 0.00 0.00

4 Kaptai 7 MW Solar PP 7.00 7.00 4.00 0.00

5 Raozan 25 MW PP 25.00 25.00 8.00 17.00

Teknaf 20 MW PP
6 Solartech 20.00 20.00 19.00 0.00

Patenga 50 MW
7 PP(Baraka) 50.00 50.00 6.00 6.00

Sikalbaha 105 MW PP(


8 Baraka Sik) 105.00 105.00 33.00 17.00

b) Shikalbaha Peaking
9 (GT) 150.00 150.00 0.00 0.00

Shikalbaha 225 MW
10 CCPP 225.00 225.00 204.00 204.00

Anwara 300 MW PP
11 (United) 300.00 300.00 85.00 100.00

Juldah 100 MW PP
12 Unit-3(Acorn) 100.00 100.00 25.00 25.00

Dohazari Kalaish 100


13 MW PP 102.00 102.00 51.00 68.00

Hathazari 100 MW
14 Peaking pp 98.00 98.00 24.00 25.00

Barabkunda 22 MW PP
15 (Regent) 22.00 22.00 18.00 18.00

Malancha, Ctg.EPZ
16 (United) 0.00 0.00 0.00 17.00

4
Installed Derated Actual Peak Actual Peak
SL No. Name of Power Station
Capacity Capacity Day Evening

Chittagong 108 MW PP
17 ECPV 108.00 108.00 0.00 0.00

Sikalbaha 54 MW
Power Plant (Jodiac
18 Power) 54.00 54.00 17.00 0.00

19 Karnaphuli Power Ltd. 110.00 110.00 33.00 17.00

20 Juldah Unit-2 (Acorn) 100.00 100.00 25.00 25.00

Juldah 100 MW Unit-1


21 (Acorn) 100.00 100.00 25.00 25.00

Chattogram 116MW PP
22 (Anlima Energy Ltd.) 116.00 116.00 0.00 17.00

23 Mirsharai 150MW 163.00 163.00 35.00 145.00

Chattogram 2*612MW
Coal Based PP (SS
24 Power Unit-1) 1224.00 1224.00 300.00 410.00

Matarbari 2*600MW
25 (CPGCL) 0.00 0.00 568.00 589.00

26 Coxs |Bazar wind pp 0.00 0.00 0.00 1.00

Total 3829 3769 1526

Total electricity generation of Bangladesh


The utility electricity sector in Bangladesh has one national grid with an installed capacity of 25,700 MW as of
June 2022. Bangladesh's energy sector is not up to the mark. However, per capita energy consumption in
Bangladesh is considered higher than the production.

2.2 Recent Plans

The Ministry of Power and Energy has been mobilizing Tk 40,000 crore ($5.88 billion) to generate
5,000 MW of electricity to reduce load shedding to a tolerable level within the next four and half years
during the term of the present government. Under the plan, the Power Development Board (PDB) had
produced 500 MW gas-fired electricity between July and December, 2009 to overcome load shedding

5
within December. The PDB had hired furnace-oil based 1,000MW of electricity from the private sector
from January to June 2010. In 2011, the government would install
furnace-oil based 800 MW capacity of power plant. The PDB officials would seek suitable places to
establish the plant, a senior official of the PDB said. Besides, the government would also hire another
diesel or furnace oil based power plant having capacity of 700 MW in 2012 to keep load shedding to a
mild level, the official said. However, the government also contemplates to establish four coal
fired based power plants with capacity of producing 500 MW of electricity each with public and
private partnership (PPP) in Rajshahi and Chittagong region. The government has initially tried to
create a fund of Tk 6,000 crore to implement the plan, sources said. The power division has tried to
utilize the government's budgetary allocation of Tk. 2000 crore for PPP in this regard, sources added.
"If we can create the fund of Tk. 6,000 crore, it would be possible also to mobilize Tk 40,000 crore
under PPP to produce 5,000 MW of electricity within four and half years," PDB chairman ASM
Alamgir Kabir told the New Nation on June 29, 2010. During the meeting, Prime Minister Sheikh
Hasina permitted the power division to implement the PDB plan to reduce load shedding up to a
tolerable level. [5]

Nuclear Power Plant

Bangladesh plans to set up the 1,000 MW power plant at Rooppur, 200 km (125 miles) northwest of
the capital Dhaka, by 2011.

2.3 Related Research History


Bartica et al (1998) described client–server architecture for remote monitoring of instrumentation over
the Internet network. The proposed solution allows multi-user, multi-instrument sessions by means of a
queuing and instrument locking capability. A queue mechanism has been added to the remote
environment along with the possibility for each client to query the actual server load. The
communication between server and clients can be obtained either at instrument level or by means of
encoded requests in order to reduce the network-imposed overhead. Tso et al (2000) presented a study
that indicates that while a number of frameworks related to global systems have been described in
contemporary publications, the detailed structure and formulation of the central monitoring mechanism
of such a partnership system has not received as much attention as it deserves. The proposed
framework of a service network is characterized by its coordinating as well as monitoring capabilities.
The main feature of the presented system is its rule-based reasoning capability to convert a job request
from clients into basic tasks which are to be carried out by a group of virtual agents equipped with
various defined capabilities. Tso et al also presented a prototype program that has been developed
and13 tested in an emulated factory environment, thereby validating the application of agent-based
systems in enterprise networks. Tommila et al (2001) discussed new ways of implementing existing
6
functions and defined that new functionality, e.g. management of hierarchical structures and exception
handling should be included in the basic control platform and engineering tools. The current ‘flat’
collection of application modules like loops and sequences had to be organized in a more hierarchical
fashion based on process structure. Each process system is seen as an intelligent resource capable of
performing different processing tasks. The interaction mechanisms between different automation
activities are defined on the basis of object-oriented analysis and design and emerging international
standards. A standardized distribution middleware takes care of the needs specific to the control
domain. Above that, a higher level working environment for the other system components of the
control platform is needed. The client-server architecture devoted to the management of measurement
instruments over the Internet has been described by Piagetian et al (2003). The proposed architecture
exploits the flexibility, portability and network-oriented features of the Java language, thus avoiding the
use of proprietary, license-bound software tools. The central feature of the proposed distributed
measurement system is its easy extensibility. This attribute results from the high level of abstraction of
client-server applications. In order to verify the correct operation of the system, a specific application
has been developed to run a remote calibration procedure. Kazantzakis et al (2003) developed a
Supervisory Control Data Acquisition (SCADA) based remote monitoring system for renewable
energy systems. It is based on client / server architecture and it does not require a physical connection,
e.g. through network, serial communication port or14 standard interface such as the IEEE-488 of the
monitored system with data collection server. [6]
A smart IoT based system for monitoring and controlling the substation equipment electrical load.
Remote monitoring and controlling of the substation equipment is an important issue for the power/energy
management department which is normally done manually, or using an expensive PLC and SCADA system.
With the emergence of the internet and computational era, a smart monitoring and reliable controlling system
over the entire substation equipment is highly desirable that can be achieved by introducing the Internet of
Things (IoT) technology. IoT is the network of physical devices embedded with electronics, software, sensors,
actuators and network connectivity which have the ability to identify, collect and exchange the data. Each thing
is uniquely identifiable through its embedded computing system and able to interoperate within the existing
internet infrastructure. This paper proposed an IoT based network strategy for monitoring and controlling the
substation equipment so that managing time and resources can take place as efficiently as possible. The IoT
based system allows objects to be sensed or controlled remotely across existing network infrastructure, creating
opportunities for more direct integration of the physical world into computer-based systems and resulting in
improved efficiency, accuracy and economic benefit with the added merits of minimum human intervention.
Moreover, a prototype system has been implemented and tested for measuring the effectiveness of the proposed
model. [7]
Sub-stations are an important part of the power system and a typical sub-station consists of different types of
equipment such as transformers, circuit breakers (CB), relays, lightning arresters (LA), current transformers
(CT), potential transformers (PT), isolators, capacitors, and so on. In other words, sub-station is the assembly of
apparatus used to change some characteristic (e.g. voltage AC to DC, voltage level, frequency, power factor,

7
etc.) of electric supply. Usually, the sub-stations are monitored and controlled manually, or by using expensive
PLCs and SCADA system which required more manpower and involved a higher maintenance cost. Under the
conventional protection of substation especially in differential protection, the relay often requires pilot wires to
operate itself which involves a greater capital cost in addition with a sudden interruption of relay operation. To
mitigate the mentioned disadvantages, IoT based substation monitoring and controlling offers a promising
solution with a fully automated system ensuring a greater level of reliability, and thereby increasing the system
performance with the efficient use of the equipment.
“Internet of Things” in short form IoT is created from the word “Internet” and “Things” where “Things” refers
to any internet connected device. The Internet of Things (IoT) is a system of interrelated computing devices,
mechanical and digital machines, objects, animals or people that are provided with a unique identifier and the
ability to transfer data over a network without requiring human-to-human or human-to-computer interaction. In
recent years, the IoT is augmented with sensors and actuators, the technology becoming an instance of the more
general class of cyber-physical-systems, which also encompasses technologies such as smart grids, virtual power
plants, smart homes, intelligent transportation, and smart cities. Because of low-cost, networkable
micro-controller modules, the Internet of Things is considered as the key technology to establish a smart
substation. However, IoT itself has still not reached maturity and many IoT communication protocols such as
CoAP MQTT, XMPP have been proposed as IoT standards. These protocols vary in characteristics with
different strengths and limitations. Finally, due to the technological revolution all over the world, smart
technologies are replacing the old ones. In the power sector, IoT technology is becoming more attractive
nowadays. It is expected that within 2020, around 20–50 billion things would be connected to the internet
throughout the world. [8]
The main aim of this work is to develop a fully automated IoT based substation by which associated equipment
can be protected, monitored and controlled from any place in the world only by the authorized personnel at a
very low cost. Reliability and reduction of manpower using IoT technology are also the prime concerns while
developing smart substation framework.
The rest of the paper is organized as follows. A thorough review of related studies is discussed in Section 2.
Section 3 illustrates the system model highlighting the major parts of the system. Section 4 represents the
experimental setup along with the practical circuit diagram. Section 5 includes the results and discussion.
Finally, Section 6 concludes this paper.

2.4 Load Adjustment/Load Balancing


The total load connected to the power grid can vary significantly over time. Although the total load is
the sum of many individual choices of the clients, the overall load is not necessarily stable or slow
varying. For example, if a popular television program starts, millions of televisions will start to draw
current instantly. Traditionally, to respond to a rapid increase in power consumption, faster than the
start-up time of a large generator, some spare generators are put on a dissipative standby mode. A
sub-station may warn all individual television sets, or another larger customer, to reduce the load
temporarily[19] (to allow time to start up a larger generator) or continuously (in the case of limited
resources). Using mathematical prediction algorithms it is possible to predict how many standby
8
generators need to be used, to reach a certain failure rate. In the traditional grid, the failure rate can
only be reduced at the cost of more standby generators. In a substation, the load reduction by even a
small portion of the clients may eliminate the problem.
While traditionally load balancing strategies have been designed to change consumers' consumption
patterns to make demand more uniform, developments in energy storage and individual renewable
energy generation have provided opportunities to devise balanced power grids without affecting
consumers' behavior. Typically, storing energy during off-peak times eases high demand supply during
peak hours. Dynamic game-theoretic frameworks have proved particularly efficient at storage
scheduling by optimizing energy cost using their Nash equilibrium. [9]

2.5 Peak Curtailment/leveling and Time of Use Pricing


To reduce demand during the high-cost peak usage periods, communications and metering
technologies inform smart devices in the home and business when energy demand is high and track
how much electricity is used and when it is used. It also gives utility companies the ability to reduce
consumption by communicating to devices directly in order to prevent system overloads. Examples
would be a utility reducing the usage of a group of electric vehicles charging stations or shifting
temperature set points of air conditioners in a city. To motivate them to cut back use and perform what
is called peak curtailment or peak leveling, prices of electricity are increased during high demand
periods, and decreased during low demand periods. It is thought that consumers and businesses will
tend to consume less during high demand periods if it is possible for consumers and consumer devices
to be aware of the high price premium for using electricity at peak periods. This could mean making
trade-offs such as cycling on/off air conditioners or running dishwashers at 9 pm instead of 5 pm.
When businesses and consumers see a direct economic benefit of using energy at off-peak times, the
theory is that they will include energy cost of operation into their consumer device and building
construction decisions and hence become more energy efficient. See Time of day metering and demand
response. [10]

9
CHAPTER 03
EXPERIMENTAL SETUP
3.1 Block Diagram

3.2 Working Procedure of Block Diagram


A switched-mode power supply (SMPS) is an electronic circuit that converts power using switching
devices that are turned on and off at high frequencies, and storage components such as inductors or
capacitors to supply power when the switching device is in its non-conduction state. Switching power
supplies have high efficiency and are widely used in a variety of electronic equipment, including
computers and other sensitive equipment requiring stable and efficient power supply. A switched
10
mode power supply is also known as a switch-mode power supply or switching-mode power supply.
The Main heart of this project is the Arduino nano unit which takes the input signal from Gas sensor &
current sensor, pushes the switch as input and processes the whole unit according to configuration. All
routers have a web page that you can connect for configuring the Wi-Fi security. And turn on WEP (Wired
Equivalent Privacy) and enter a password. The radio signals are transmitted from antennas and routers that
signals are picked up by Wi-Fi receivers, such as computers and cell phones that are ready with Wi-Fi cards.
Whenever the computer receives the signals within the range of 100-150 feet for the router it connects the
device immediately.
The range of the Wi-Fi depends upon the environment, indoor or outdoor ranges. The Wi-Fi cards will read the
signals and create an internet connection between user and network.

3.3 System Flow Chart


The overall working of the system can be explained with the help of a flowchart. The sensors record
the data continuously and send signals to the Arduino Nano. The Arduino Nano processes all the
received data and responds based on the values of the sensor outputs. Whenever the sensor output is
TRUE and activates the electric load. Arduino Nano switches on the web server to upload and
download for data monitoring. All data showed the server and controlled the electrical load by IoT for
automatically switching in any place.

Flow Chart

11
3.4 Circuit Diagram

Fig 3.3: Circuit Diagram’


3.5 Circuit Description
In this system circuit diagram is shown. All the connections of the modules that have been used in this
system with the Arduino board are shown clearly in this diagram. All the VCC and GND connection of
Current Sensor, Transistor relay switching circuit, Wifi module, Key pad, microcontroller Ic and LCD
has been connected with the GND and VCC Connection of the Arduino. The arduino-nano is started
and simultaneously the Wi-Fi module is powered and connection is established between the Wi-Fi
module and the access point through which it can upload and access the sensor value over the internet.
12
The controls taken through the user are sent by arduino nano and uploaded over the cloud server, then
from the cloud server the controller retrieves the data through Wi-Fi module and performs the required
action, depending on the control signal provided by the user.
3.6 Arduino Nano
Arduino is an open-source hardware and software company, project and user community that designs
and manufactures single-board microcontrollers and microcontroller kits for building digital devices.
Its products are licensed under the GNU Lesser General Public License (LGPL) or the GNU General
Public License (GPL), permitting the manufacture of Arduino boards and software distribution by
anyone. Arduino boards are available commercially in preassembled form or as do-it-yourself (DIY)
kits. Input Voltage.

Fig 3.4: Arduino Nano


3.7 Current Sensor
A current sensor is a device that detects electric current in a wire and generates a signal proportional to
that current. The generated signal could be analog voltage or current or even a digital output. The
generated signal can be then used to display the measured current in an ammeter, or can be stored for
further analysis in a data acquisition system.

Fig 3.5: Current Sensor

3.8 Wi-Fi Module (ESP8266)


ESP8266 offers a complete and self-contained Wi-Fi networking solution, allowing it to either host the
application or to offload all Wi-Fi networking functions from another application processor. When
ESP8266 hosts the application, and when it is the only application processor in the device, it is able to
boot up directly from an external flash. It has an integrated cache to improve the performance of the
13
system in such applications, and to minimize the memory requirements.

Fig 3.6: Wi-Fi Module (ESP8266)


3.9 Liquid-Crystal Display
A liquid-crystal display (LCD) is a flat-panel display or other electronically modulated optical device
that uses the light-modulating properties of liquid crystals combined with polarizers. Liquid crystals do
not emit light directly, instead using a backlight or reflector to produce images in color or
monochrome.[1] LCDs are available to display arbitrary images (as in a general-purpose computer
display) or fixed images with low information content, which can be displayed or hidden, such as
preset words, digits, and seven-segment displays, as in a digital clock. They use the same basic
technology, except that arbitrary images are made from a matrix of small pixels, while other displays
have larger elements. LCDs can either be normally on (positive) or off (negative), depending on the
polarizer arrangement.

Fig 3.7: LCD Display

3.10 Relay Switch Circuit


Relays are electromechanical devices that use an electromagnet to operate a pair of movable contacts
from an open position to a closed position. The advantage of relays is that it takes a relatively small
amount of power to operate the relay coil, but the relay itself can be used to control motors, heaters,
lamps or AC circuits which themselves can draw a lot more electrical power. The electro-mechanical
relay is an output device (actuator) which comes in a whole host of shapes, sizes and designs, and has
many uses and applications in electronic circuits. But while electrical relays can be used to allow low
power electronic or computer type circuits to switch relatively high currents or voltages both “ON” or
14
“OFF”, some form of relay switch circuit is required to control it.
3.10.1 NPN Relay Switch Circuit
A typical relay switch circuit has the coil driven by a NPN transistor switch, TR1 as shown depending
on the input voltage level. When the Base voltage of the transistor is zero (or negative), the transistor is
cut-off and acts as an open switch. In this condition no Collector current flows and the relay coil is
de-energized because being current devices, if no current flows into the Base, then no current will flow
through the relay coil.
If a large enough positive current is now driven into the Base to saturate the NPN transistor, the current
flowing from Base to Emitter (B to E) controls the larger relay coil current flowing through the
transistor from the Collector to Emitter. For most bipolar switching transistors, the amount of relay coil
current flowing into the Collector would be somewhere between 50 to 800 times that of the required
Base current to drive the transistor into saturation. The current gain, or beta value ( β ) of the general
purpose BC109 shown is typically about 290 at 2mA (Datasheet).

Fig 3.8: NPN Switching Circuit

Transmission Fault Detection

Line to line Fault


Line to Line Fault. An unbalanced line-to-line fault in an electrical system refers to a type of
short-circuit that occurs between two phases of a three-phase system, resulting in an imbalance in the
current flowing through the system

Line open fault

An open-circuit fault occurs if a circuit is interrupted by a failure of a current-carrying wire (phase or


neutral) or a blown fuse or circuit breaker. In three-phase systems, a fault may involve one or more
phases and ground, or may occur only between phases.

No voltage fault

0V is a point in the circuit that you assign as your zero volt potential and it is usually referred to as
15
“common ground”. 0 ground is a 0V point literally connected to an external grounding facility.
Low Voltage Fault

One common cause of low voltage system faults is faulty or damaged wiring. Inspect the wiring and
connections in the affected area or device for any signs of wear and tear. Look for loose connections,
exposed wires, or damaged insulation

Transformar Banking System

Banked transformers are tied together through secondary mains and are supplied by the same primary
feeder. Banked transformers help to reduce lamp flicker, decrease the capacity required, produce better
average voltage along the secondary lines, and have greater flexibility for load growth.

16
CHAPTER 04
RESULT ANALYSIS
4.1 Result
Table 6.1: Load calculation
SL No Load 01 Load 02 Load 03 Load 04 Voltage Watt Current

01 Off On On Off 220v Ac 120W 1.2 mA

02 Off On Off On 220v Ac 120W 1.2 mA

03 On Off On On 220v Ac 180W 1.6 mA

04 On Off Off Off 220v Ac 60W 0.70mA

05 On On On On 220v Ac 240W 2.1 mA

Table 6.2: Priority Based Load Management


SL No Load in Watt Shut Down Consumer Load

01 120 Watt Zone 01 1, 6 Turn On

02 160 Watt Zone 02 1, 6, 2 Turn On

03 240 Watt Zone 03 1, 6, 2, 4 Turn On

04 300 Watt Zone 04 1, 6, 2, 4, 5 Turn On

Table 6.3: Fault Analysis


SL No Types of Faults Reason

01 Line Open Fault When Load Open

02 Line to Line Fault When Transmission line Short

03 No Voltage Fault When Load Supply Voltage Zero

04 Low Voltage Fault When Load Supply Voltage less then 11V DC

17
4.2 Controlling & Monitoring Section IoT Result with Hardware

Fig 4.1: Electrical Load Monitoring at LCD.

Fig 4.2: Transmission Line Fault Monitoring16

Fig 4.5: Electrical Load Controlling by server .

18
Fig 4.6: Total System

4.3 Discussion
Our Proposed system is a smart utility Load Management System is a system that helps to manage the
load of electricity in a smart way. It is designed to gain advanced control and minimize cost by
reducing downtime, reducing energy costs, supporting capacity planning, improving efficiency, and
providing a view into the system as a whole. Load management is the process of balancing the supply
of electricity on the network with the electrical load by adjusting or controlling the load rather than the
power station output. We focus on the priority based load management line in a different zone and
consumer section which is shown in the above table 6.2 and 6.3. There are many methods of load
management which can be followed by an industry or a utility, such as load shedding and restoring,
load shifting, installing energy-efficient processes and equipment, energy storage devices, co
generation, non-conventional sources of energy, and reactive power control. We also develop renewable
energy like hydro power generation.

4.4 Application

▪ Demand Response and Consumer Energy Efficiency


▪ Wide‐ rear situational awareness
▪ Electric Transportation
▪ Network Communications
▪ Load Shedding time management system.
▪ Industrial Applications.

19
▪ Domestic Applications.
▪ Mobile tower Applications
4.5 Advantages
▪ Improving power reliability and quality
▪ Better controlling and monitoring using sensor networks and communications. ▪ Better and faster
balancing of supply and demand
▪ Reduced operations and management cost.
▪ Enhancing the capacity and efficiency of the electric load control.

4.6 Cost Analysis


Table 6.4: System Cost Analysis
Table Table 6.4: System Cost Table 6.4: System Table 6.4: System Table 6.4:
6.4: Analysis Cost Analysis Cost Analysis System Cost
System Analysis
Cost
Analysi
s

01 Arduino Nano 02 600 1200/-

02 Current Transformer 03 160 480/-

03 Transformer (Step Down) 04 210 840/-

04 Relay Switching Circuit 10 40 400/-

05 AC Light Holder with Light 11 50 550/-

06 Vero Board 02 40 80/-

07 SMPS 01 250 250/-

08 On-Off Switch 03 15 45/-

09 DC Motor 01 150 150/-

10 PVC Board 01 250 250/-

11 Others -- 1000 1255/-

Total = 5500/-

20
CONCLUSION
The suggested framework will be a demo rendition that gives expense effectiveness, taking less time,
and technically the easiest way for differentiating objects. This framework utilizes Arduino Nano
which makes this model simple to utilize. Therefore, it is very important to have proper and checked
sensors. Further, making desirable changes can be used in small-scale and large-scale industries as
well. A prototype of programmable load time management for the utility department using IoT is
developed that is competent to recognize various kinds of load shedding in the work station or
industries such as production factory, food packaging factory etc. for emergencies. To confirm that the
system works according to the requirements specified time management, it was broadly tested. To
increase more human interference this system is enhanced by the webserver for monitoring the
electrical load present condition. It has been underlined that this hardware solution can perfectly
address the current challenges in these fields such as high control performance, reliability, and
efficiency. Programmable parameters allow complete control over the whole system.

21
FUTURE WORK

• Interfacing the system with PLC control.


• Interfacing the system with the faster internet for controlling and monitoring from any location.
• Storage the data at server
• Controlling hazard situations by using different sensors like temperature sensor, gas sensor, humidity
sensor etc.

22
REFERENCE
[1] .K.Mehta and Rohit Mehta, “ principles of power system”, 4th ed, . hand publication, 2008.
[2] Ashfaq Husain, “Electrical power system”, 5th ed, B publishers and distributors vt. Ltd., 2007.
[3] M. .O liveira and . . Barioni, “Technical loss calculation by distribution system segment with
corrections from measurements'', roc.20th international conference and Exhibition on Electricity
Distribution, Prague, Czech Republic, June 2009, pp. 1–4.
[4] unil . Rao, “ switchgear protection and power systems”, 9th ed, Khanna publishers, 2012. [5] .
.Wadhwa, “Electrical power systems”, 4th ed, New Age International Publishers, 2005. [6] C. J.
Bandim, E. R. Alves ., A. V. Pinto, F. C. Souza, M. R. B. Loureiro, C. A. Magalhaes
and F. Galvez- urand, “Identification of Energy Theft band Tampered Meters sing a central Observer
Meter: Mathematical approach”, Transmission and distribution conference and exposition, 2003 IEEE
PES, vol. 1, pp. 163-168,2003.
[7] “RW -434N datasheet”, Wenshing electronics co., td., Taipei, Taiwan. [8] J.J. Ford, H. Bevrani, G.
edwich, " adaptive load shedding and regional protection,” International Journal of Electrical power
Energy systems”, volume 31, ages 611-618. Issue 10, November-December 2009
[9] F. apitanescu, B. Otomega, H. efebvre, . ermanson, T. an utsem, “ decentralized tap changer
blocking and load shedding against voltage instability: Prospective tests on the RTE system,Electrical
power and Energy systems”, ol 31, Issue 9, 2009, pp 570–576.
[10] R. M. Maliszewski, R. . unlop, and G. . Wilson, “Frequency Actuated load shedding and
restoration Part I— philosophy”, IEEETransactions on power apparatus and systems, vol. 90, no. 4,
1971, pp.1452–1459.
[11] A. Saffarian, M. Sanaye-pasand, H. sadi,” performance Investigation of New combinational load
shedding schemes”, Joint International conference on power system Technology and IEEE Power
IndiaConference, 2008. pp 1 – 8.
[12] A. A. Abou, A. Zein El- in, . R. pea, .R., “Optimal load shedding n power systems”, Eleventh
International Middle East Power SystemsConference, Volume 2, 2006, pp. 568 – 575.

[13] Tah Eric Wesoff mid (2 April 2013). "Aquion Energy's Disruptive Battery Tech Picks Up $35M in
VC". greentechmedia.com. Archived from the original on 6 August 2013.

22
[14] Zachary Shahan (9 May 2015). "Tesla Powerwall & Powerpacks Per-kWh Lifetime Prices vs
Aquion Energy, Eos Energy, & Imergy". CleanTechnica. Retrieved 19 March 2018.

[15] David L. Chandler, MIT News Office (19 November 2009). "Liquid battery big enough for the
23
electric grid?". MIT News. Archived from the original on 13 February 2010.

[16]" Appalachian Power Dedicates Mega Battery; New Technology Provides Extra Power,
Reliability" (Press release). Appalachian Power. 20 July 2006. Archived from the original on 22
October 2006.

[17] Eric Wesoff (24 May 2012). "Sadoway's MIT Liquid Metal Battery Startup Adds $15M and
Khosla Ventures as Investor". greentechmedia.com. Archived from the original on 25 September 2012.

[18] "Renewable. Rechargeable. Remarkable.", Feature Article, September 2005 Archived 15 January
2009 at the Wayback Machine

[19] "Grid-Scale storage with vanadium redox flow batteries". REDT Energy Storage. Archived from
the original on 15 May 2014.

[20] "Wind farm with battery storage in Ireland". Leonardo Energy. Archived from the original on 2
November 2007.

[21] Parker, Robin; Clapper, Jr, William L. "HYDROGEN-BASED UTILITY ENERGY STORAGE
SYSTEM" (PDF). Archived (PDF) from the original on 26 January 2017. Retrieved 2 February 2017.

[22] Gyuk I, Kulkarni P, Sayer JH, et al. (2005). "The United States of storage". IEEE Power and
Energy Magazine. 3 (2): 31–9. doi:10.1109/MPAE.2005.1405868.

24
APPENDIX

#include <LiquidCrystalSerial.h>
#include <SoftwareSerial.h>

#define UNIT_FEE 5.00

#define WIFI_SSID "iot"


#define WIFI_PASS "dgp25008"

#define butt A4
#define SH 6
#define DS 4
#define ST 5
#define rly1 1
#define rly2 2
#define rly 3 3
#define rly4 4
#define rly 5 5

bool r1 = 1, r2 = 1, r3 = 1, r4 = 1, r5 = 1;

void setup() {
Serial.begin(115200);
gsm.begin(9600);
lcd.begin(16, 2, SERIAL);
randomSeed(analogRead(A7));

pinMode(butt, INPUT);
pinMode(SH, OUTPUT);
pinMode(DS, OUTPUT);
pinMode(ST, OUTPUT);

output(rly1, r1);
output(rly2, r2);
output(rly3, r3);
output(rly4, r4);
output(rly5, r5);

Serial.println((String)"CON=" + WIFI_SSID + "," + WIFI_PASS + ","); //GSMinit();


}

bool rechargeFlag, checker, cp, gridFlag;


int acVolt, wh1, wh2;
float amount, amp1, amp2;
byte ss, mm, hh;
byte setSS, setMM, setHH;
byte tSS, tMM, tHH;

void loop() {
char key = keypad.getKey();
acVolt = getVoltage(A6);
amp1 = getCurrent(A7) - 0.09;
amp2 = getCurrent(A5) - 0.09;
wh1 = acVolt * amp1;
wh2 = acVolt * amp2;
if (!rechargeFlag) amount -= ((wh1 * (hh + (mm / 60.0))) / 1000.0) * UNIT_FEE;
if (amount < 0) amount = 0;
if (wh1 < 0) wh1 = 0;
if (wh2 < 0) wh2 = 0;

if (!amount && !rechargeFlag && !checker) {


r1 = 1; r2 = 1; r3 = 1; r4 = 1;
25
output(rly1, r1);
output(rly2, r2);
output(rly3, r3);
output(rly4, r4);
checker = 1;
}
if (amount > 0) checker = 0;

if (r5 == 1) {
lcd.setCursor(0, 0);
lcd.print((String)acVolt + "V | " + amp1 + "A ");
lcd.setCursor(0, 1);
lcd.print((String)wh1 + "W " + amount + "TK ");
}
else {
lcd.setCursor(0, 0);
lcd.print((String)"GRID: " + acVolt + "V ");
lcd.setCursor(0, 1);
lcd.print((String)amp2 + "A " + wh2 + "W ");
}

if (gridFlag == 1) {
if (tSS == setSS && tMM == setMM && tHH == setHH) {
tSS = 0; tMM = 0; tHH = 0;
r5 = !r5;
output(rly5, r5);
}
}

if (digitalRead(butt)) {
rechargeFlag = !rechargeFlag;
lcd.clear();
rechargeFlag ? lcd.print("FREE Mode ON") : lcd.print("FREE Mode OFF"); delay(1000);
lcd.clear();
}

if (ss % 10 == 0) {
checkServer();
String link = "WEB=0,http://kitsware.com/projects/energymeter/update_machine.php?"; link += (String)"ac1=" + acVolt + "&";
link += (String)"ac2=" + acVolt + "&";
link += (String)"amp1=" + amp1 + "&";
link += (String)"amp2=" + amp2 + "&";
link += (String)"wh1=" + wh1 + "&";
link += (String)"wh2=" + wh2 + "&";
link += (String)"blnc=" + amount + "&";
link += (String)"time=" + setHH + ":" + setMM + ":" + setSS;
Serial.println(link);
delay(1500);
}

checkSMS();
if (key >= '1' && key < '6') OTPMode(key - 49);
if (key >= 'A') setupTimer();
runClock();
}

void checkServer() {
Serial.println("WEB=1,http://kitsware.com/projects/energymeter/stat_machine.php"); while (!Serial.available());
if (Serial.available()) {
String rx = Serial.readString();
action(rx);
}
}

void action(String & rx) {

26
if (rx.indexOf("l1=1") != -1) r1 = 0;
else if (rx.indexOf("l1=0") != -1) r1 = 1;
if (rx.indexOf("l2=1") != -1) r2 = 0;
else if (rx.indexOf("l2=0") != -1) r2 = 1;
if (rx.indexOf("l3=1") != -1) r3 = 0;
else if (rx.indexOf("l3=0") != -1) r3 = 1;
if (rx.indexOf("l4=1") != -1) r4 = 0;
else if (rx.indexOf("l4=0") != -1) r4 = 1;
if (rx.indexOf("l5=1") != -1) r5 = 0;
else if (rx.indexOf("l5=0") != -1) r5 = 1;

output(rly1, r1);
output(rly2, r2);
output(rly3, r3);
output(rly4, r4);
output(rly5, r5);

String link = "WEB=0,http://kitsware.com/projects/energymeter/update_machine.php?"; link += (String)"l1=" + !r1 + "&";


link += (String)"l2=" + !r2 + "&";
link += (String)"l3=" + !r3 + "&";
link += (String)"l4=" + !r4 + "&";
link += (String)"l5=" + !r5;
Serial.println(link);
delay(1500);
}

void OTPMode(byte b) {
String password = "";
lcd.clear();
lcd.print("Sending OTP..");
for (byte i = 0; i < 6; i++) password += (char)(random(10) + 48);
Serial.println((String)"PASS=" + password);
sendSMS(NUM, (String)"OTP is: " + password);
lcd.setCursor(0, 1);
lcd.print("DONE.");
delay(1000);
lcd.clear();
lcd.print("Enter OTP:");

byte x = 0;
String pass = "";
while (1) {
char key = keypad.waitForKey();
if (key == '*' || key == '#') break;
lcd.setCursor(x, 1);
lcd.print(key);
pass += key;
x++;
if (x == 6) break;
}
if (pass == password) {
lcd.clear();
lcd.print((String)"Added " + (rechrgAmount[b]) + "TK"); amount += rechrgAmount[b];
lcd.setCursor(0, 1);
lcd.print((String)"Balnc: " + amount + "TK"); delay(2000);
lcd.clear();
}
else {
lcd.clear();
lcd.print("WRONG OTP!!");
delay(1000);
}
}

void setupTimer() {

27
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("SET TIMER:[HH]");
delay(200);

int x = 0;
String val = "";
while (1) {
char key = keypad.waitForKey();
if (key == 'B') break;
lcd.setCursor(x, 1);
lcd.print(key);
delay(500);
val += key;
x++;
}
setHH = val.toInt();

lcd.clear();
lcd.setCursor(0, 0);
lcd.print("SET TIMER:[MM]");
delay(200);

x = 0;
val = "";
while (1) {
char key = keypad.waitForKey();
if (key == 'B') break;
lcd.setCursor(x, 1);
lcd.print(key);
delay(500);
val += key;
x++;
}
setMM = val.toInt();

lcd.clear();
lcd.setCursor(0, 0);
lcd.print("SET TIMER:[SS]"); delay(200);

x = 0;
val = "";
while (1) {
char key = keypad.waitForKey(); if (key == 'B') break;
lcd.setCursor(x, 1);
lcd.print(key);
delay(500);
val += key;
x++;
}
setSS = val.toInt();
lcd.clear();
tSS = 0; tMM = 0; tHH = 0;
if (setSS || setMM || setHH) gridFlag = 1; else gridFlag = 0;
}

void runClock() {
static long ct = millis();
if (millis() - ct > 1000) {
ss++;
cp = 0;
if (ss == 60) {
ss = 0;
mm++;
if (mm == 60) {

28
hh++;
mm = 0;
}
}
tSS++;
if (tSS == 60) {
tSS = 0;
tMM++;
if (tMM == 60) {
tHH++;
tMM = 0;
}
}
ct = millis();
}
}

void GSMinit() {
lcd.clear();
lcd.print("GSM Powering UP"); lcd.setCursor(0, 1);
lcd.print("Please wait...");
delay(15000);

gsm.print("AT\r\n");
delay(1000);
gsm.print("ATE0\r\n");
delay(1000);
gsm.print("AT+CMGF=1\r\n"); delay(1000);
gsm.print("AT+CNMI=1,2,0,0,0\r\n");
delay(1000);
lcd.clear();
}

void sendSMS(String number, String msg) {


lcd.clear();
lcd.print("Sending SMS...");
lcd.setCursor(0, 1);
lcd.print("Please wait...");

gsm.print("AT+CMGF=1\r\n");
delay(200);
gsm.print((String)"AT+CMGS=\"" + number + "\"\r\n"); delay(200);
gsm.print(msg);
gsm.write(0x1A);
gsm.print("\r\n");
delay(3000);

lcd.clear();
}

void checkSMS() {
String sms = "";
if (gsm.available()) {
sms = gsm.readString();
if (sms.indexOf("+CMT:") == -1) {
if (sms.indexOf("INFO") != -1) {
String msg = "IoT Energy Meter";
msg += (String)"\nAC Volt: " + acVolt;
msg += (String)"\nAmp 1: " + amp1;
msg += (String)"\nAmp 2: " + amp1;
msg += (String)"\nWh 1: " + wh1;
msg += (String)"\nWh 2: " + wh2;
msg += (String)"\nBalance: " + amount;
msg += (String)"\nTime: " + setHH + ":" + setMM + ":" + setSS; sendSMS(NUM, msg);
}

29
else if (sms.indexOf("##") != -1) action(sms);
}
}
}

int getVoltage(byte pin) {


float result;
int readValue;
int maxValue = 0;
int minValue = 1024;

for (int i = 0; i < 500; i++) {


readValue = analogRead(pin);
if (readValue > maxValue) maxValue = readValue; if (readValue < minValue) minValue = readValue; checkSMS();
}
result = ((maxValue - minValue) * 6400.0) / 1024.0; return (result / 2.0) * 0.707;
}
double getCurrent(byte pin) {
float result;
int readValue;
int maxValue = 0;
int minValue = 1024;
const int mVperAmp = 185;
double VRMS = 0;
double AmpsRMS = 0;

for (int i = 0; i < 500; i++) {


readValue = analogRead(pin);
if (readValue > maxValue) maxValue = readValue;
if (readValue < minValue) minValue = readValue;
checkSMS();
}
result = ((maxValue - minValue) * 5.0) / 1024.0;
VRMS = (result / 2.0) * 0.707;
AmpsRMS = (VRMS * 1000.0) / mVperAmp;
return AmpsRMS;
}

void output(uint8_t pin, bool state) {


static long val = 0;
bitWrite(val, 7 - pin, state);
for (int i = 0; i < 8; i++) {
digitalWrite(DS, bitRead(val, i));
digitalWrite(SH, 1);
digitalWrite(SH, 0);
}
digitalWrite(ST, 1);
digitalWrite(ST, 0);
}

Device = 16C73B

Config FOSC_HS, WDTE_OFF, PWRTE_OFF, CP_ALL, BOREN_OFF

;**** End of Fuse Configurator Settings ****


;------------------------------------------------------------------------------- Xtal 20
Declare LCD_RSPin PORTB.2
Declare LCD_ENPin PORTB.3
Declare LCD_DTPin PORTB.4
Declare LCD_Interface 4
Declare Hserial_Baud = 115200
Declare Hserial_RCSTA = %10010000
Declare Hserial_TXSTA = %00100100
Declare Hserial_Clear = On
Cls

30
ADCON1 = 7
TRISA = 0 : PORTA = 0

Symbol rly1 = PORTA.3


Symbol rly2 = PORTA.2
Symbol rly3 = PORTA.1
Symbol rly4 = PORTA.0

Dim x As Byte
Dim temp[3] As Byte
Dim second As Byte
Dim minute As Word
Dim a_sec_r2 As Word
Dim a_sec_r3 As Word
Dim a_sec_r4 As Word
Dim m_sec_r1 As Word
Dim m_sec_r2 As Word
Dim m_sec_r3 As Word
Dim m_sec_r4 As Word
Dim g_sec_r1 As Word
Dim g_sec_r2 As Word
Dim g_sec_r3 As Word
Dim g_sec_r4 As Word
Dim mode As Byte
Dim t_stop As Bit
Dim r1_done As Bit
Dim r2_done As Bit
Dim r3_done As Bit
Dim r4_done As Bit
Dim msg[20] As Byte
Clear

'----------------------------- AUTO MODE


Dim a_r1_sec As 10
Dim a_r2_sec As 10
Dim a_r3_sec As 10
Dim a_r4_sec As 10
'------------------------------
a_sec_r2 = a_r2_sec + a_r1_sec
a_sec_r3 = a_r3_sec + a_sec_r2
a_sec_r4 = a_r4_sec + a_sec_r3

Print $fe, $48, 0,17,10,4,10,17,0,0 '0


Print $fe, $40, 1,2,20,9,2,20,8,0 '1

Include "keypad4x4.inc"

main:
Print At 1,1,"Time Management."
Print At 2,1, Dec2 minute, ":", Dec2 second
If second = 60 Then
second = 0
Inc minute
EndIf
If rly1 = 0 Then Print At 2,7, 1 : Else : Print At 2,7, 0 If rly2 = 0 Then Print At 2,8, 1 : Else : Print At 2,8, 0 If rly3 = 0 Then
Print At 2,9, 1 : Else : Print At 2,9, 0 If rly4 = 0 Then Print At 2,10, 1 : Else : Print At 2,10, 0
If mode = 0 Then
Print At 2,12, "AUTO "
If second = a_r1_sec Then rly1 = 0 : rly2 = 0 : rly3 = 0 : rly4 = 1 If second = a_sec_r2 Then rly1 = 0 : rly2 = 0 : rly3 = 1 : rly4 =
1 If second = a_sec_r3 Then rly1 = 0 : rly2 = 1 : rly3 = 1 : rly4 = 1 If second = a_sec_r4 Then rly1 = 1 : rly2 = 1 : rly3 = 1 : rly4
= 1 If second = 50 Then rly1 = 0 : rly2 = 0 : rly3 = 0 : rly4 = 0 : second = 0
ElseIf mode = 1 Then
Print At 2,12, "Man. "

31
If second = m_sec_r1 Then rly1 = 1
If second = m_sec_r2 Then rly2 = 1
If second = m_sec_r3 Then rly3 = 1
If second = m_sec_r4 Then
rly4 = 1
DelayMS 2000
rly1 = 0 : rly2 = 0 : rly3 = 0 : rly4 = 0 : second = 0
EndIf
ElseIf mode = 2 Then
Print At 2,12, "GSM. "
If second = g_sec_r1 Then rly1 = 1
If second = g_sec_r2 Then rly2 = 1
If second = g_sec_r3 Then rly3 = 1
If second = g_sec_r4 Then
rly4 = 1
DelayMS 2000
rly1 = 0 : rly2 = 0 : rly3 = 0 : rly4 = 0 : second = 0
EndIf
EndIf
GoSub capture_key
If key_value = "A" Then
mode = 0
rly1 = 0 : rly2 = 0 : rly3 = 0 : rly4 = 0
EndIf
If key_value = "B" Then
mode = 1
rly1 = 0 : rly2 = 0 : rly3 = 0 : rly4 = 0
GoSub manual_set
GoTo main

Receive_SMS:
Clear msg
HSerIn 1000, over, [Wait("+CMT"), Wait(13,10), Str msg] g_sec_r1 = (msg[2] - 48) * 100 + (msg[3] - 48) * 10 + (msg[4] - 48)
g_sec_r2 = (msg[7] - 48) * 100 + (msg[8] - 48) * 10 + (msg[9] - 48) g_sec_r3 = (msg[12] - 48) * 100 + (msg[13] - 48) * 10 +
(msg[14] - 48) g_sec_r4 = (msg[17] - 48) * 100 + (msg[18] - 48) * 10 + (msg[19] - 48) PORTA = $ff
Cls
Print At 1,1,"R1: ", Dec3 g_sec_r1, " R2: ", Dec3 g_sec_r2 Print At 2,1,"R3: ", Dec3 g_sec_r3, " R4: ", Dec3 g_sec_r4
DelayMS 2000
Cls
second = 0
g_sec_r2 = g_sec_r2 + g_sec_r1
g_sec_r3 = g_sec_r3 + g_sec_r2
g_sec_r4 = g_sec_r4 + g_sec_r3
mode = 2
rly1 = 0 : rly2 = 0 : rly3 = 0 : rly4 = 0
over:
Return

manual_set:
Cls
Print At 1,1,"Manual Setup:"
DelayMS 1000
Print At 2,1,"Relay 1:"
For x = 0 To 2
GoSub read_key
Print At 2,x+10, key_value
temp[x] = key_value - 48
Next
m_sec_r1 = temp[0] * 100 + temp[1] * 10 + temp[2] Cls
Print At 1,1,"Relay 1:", Dec3 m_sec_r1, "sec" Print At 2,1,"*:Confirm #:Back"
While 1 = 1
GoSub capture_key
If key_value = "*" Then GoSub setup2 If key_value = "#" Then GoSub manual_set If key_value = "D" Then Cls : GoSub
main Wend
setup2:

32
Cls
Print At 1,1,"Manual Setup:"
Print At 2,1,"Relay 2:"
For x = 0 To 2
GoSub read_key
Print At 2,x+10, key_value
temp[x] = key_value - 48
Next
m_sec_r2 = temp[0] * 100 + temp[1] * 10 + temp[2] Cls
Print At 1,1,"Relay 2:", Dec3 m_sec_r2, "sec" Print At 2,1,"*:Confirm #:Back"
While 1 = 1
GoSub capture_key
If key_value = "*" Then GoSub setup3 If key_value = "#" Then GoSub setup2 If key_value = "D" Then Cls : GoSub main
Wend
setup3:
Cls
Print At 1,1,"Manual Setup:"
Print At 2,1,"Relay 3:"
For x = 0 To 2
GoSub read_key
Print At 2,x+10, key_value
temp = key_value - 48
Next
m_sec_r3 = temp[0] * 100 + temp[1] * 10 + temp[2] Cls
Print At 1,1,"Relay 3:", Dec3 m_sec_r3, "sec" Print At 2,1,"*:Confirm #:Back"
While 1 = 1
GoSub capture_key
If key_value = "*" Then GoSub setup4 If key_value = "#" Then GoSub setup3 If key_value = "D" Then Cls : GoSub main
Wend
setup4:
Cls
Print At 1,1,"Manual Setup:"
Print At 2,1,"Relay 4:"
For x = 0 To 2
GoSub read_key
Print At 2,x+10, key_value
temp[x] = key_value - 48
Next
m_sec_r4 = temp[0] * 100 + temp[1] * 10 + temp[2] Cls
Print At 1,1,"Relay 4:", Dec3 m_sec_r4, "sec" Print At 2,1,"*:Confirm #:Back"
While 1 = 1
GoSub capture_key
If key_value = "*" Then GoSub done If key_value = "#" Then GoSub setup4 If key_value = "D" Then Cls : GoSub main
Wend
done:
Cls
rly1 = 0 : rly2 = 0 : rly3 = 0 : rly4 = 0 : second = 0 m_sec_r2 = m_sec_r2 + m_sec_r1
m_sec_r3 = m_sec_r3 + m_sec_r2
m_sec_r4 = m_sec_r4 + m_sec_r3
Print At 2,1,"Done.."
DelayMS 1000
Cls
GoSub main

33

You might also like