Вы находитесь на странице: 1из 72

PHOTOVOLTAIC SYSTEM MANAGEMENT

FOR SMART HOME ENERGY MANAGEMENT SYSTEM

1
CONTENT

 ABSTRACT
 INTRODUCTION
 LITERATURE SURVEY
 EXISTING SYSTEM
 PROPOSED SYSTEM
 BLOCK DIAGRAM
 WORKING PRINCIPLE
 HARDWARE REQUIREMENTS
 SOFTWARE REQUIREMENTS
 APPLICATION
 CONCLUSION
 REFERENCES

2
ABSTRACT

This project describes a photovoltaic (PV) system management scheme. A typical


PV system installed in home monitors only the status values at the inverter. It has
difficulty in localizing failures in the PV system for maintenance. To overcome this, we
propose an LCD display. The smart device application displays the status of the whole
PV system. A user can easily localize failures in the PV system for better performance
and maintenance. The proposed scheme enhances a PV system management and can
create synergy with smart home energy management system. This project will enable
user to conserve energy in home lighting system by using solar panel with protection.
This project consists of energy source by means of the solar panel Photovoltaic panel and
converts solar energy directly into electrical energy. The electrical energy is given to
charge the controller.

3
CHAPTER - I

1.1 INTRODUCTION:

Now-a-days increasing the energy consumption has become a primary concern,


the rising cost and the exhaustible nature of fossil fuel, and the worsening global interest
in renewable energy sources increase of fossil fuel resources and the need of reducing
CO2 emissions, grid connected renewable power systems have gained outstanding
interest. Energy is considered as an important mechanism in a country for the
development, but in the current situation, the energy consumption is insufficient and the
price is increasing. PV cells convert the energy from sunlight into DC electricity wind
turbine convert the energy from wind into electricity. PV offer added advantages over
other renewable energy sources in that they give off little noise and require practically
little maintenance. Solar power sources provide a realistic from of power generation. The
electricity grid to accommodate higher percentage of renewable energy would need large
quantities of conventional back up power and huge energy storage. These would be
necessary to compensate for natural variations for power generated depending on the time
of day, season and other factors such as the amount of sunlight at any given time.
Photovoltaic (PV) power generation has great importance as an alternative to
conventional power sources; PV installations (in scales ranging from domestic uses to
large solar farms) involves a significant investment that should be cared to preserve its
safety and profitability. However, a PV array can keep working in a fault state as a
seeming normal behavior with power losses. Therefore, PV fault diagnosis becomes
important to performing fast maintenance and to improving power generation. In case
any fault occurs in solar panel, then it will automatically display in LCD. In the system,
the output of the renewable sources cannot feed the load directly because their voltage
fluctuations are so large that they will damage the concerned load. So first, it needs to be
conditioned, for that generally inverter are used.

4
CHAPTER - II

2. LITERATURE SURVEY:

2.1 Electric Energy Management in the Smart Home

Smart home may be defined as a well-designed structure with sufficient access to


assets, communication, controls, data, and information technologies for enhancing the
occupants’ quality of life through comfort, convenience, reduced costs, and increased
connectivity. The idea has been widely acknowledged for decades, but few people have
ever seen a smart home, and fewer still have occupied one. A commonly cited reason for
this slow growth has been the exorbitant cost associated with upgrading existing building
stock to include “smart” technologies such as network connected appliances .However,
consumers have historically been willing to incur significant costs for new
communication technologies, such as cellular telephones, broadband internet
connections, and television services. It presents the changes in US mean monthly income
by quintiles and overall consumer spending on communication services.

This information may indicate that consumers are not averse to significantly
changing their spending habits with the advent of new technologies. According to the US
Bureau of Labor Statistics, the average homeowner spent approximately 11% more on
entertainment (including cell phone and internet services). Data indicate that consumers
are willing to spend more on hybrid vehicles than on similarly sized traditional vehicles
for reasons other than economic payback. Diverse motivations can lead to the same end
goal. For instance, a consumer may purchase a hybrid vehicle to decrease carbon
emissions, reduce dependency on foreign oil, save money, or simply as a status symbol.
Regardless, driving a hybrid vehicle contributes to a more sustainable energy future by
reducing oil consumption and greenhouse gas emissions. Similarly, marketing or societal
influences may motivate consumers to invest in smart home technologies. The authors

5
contend that cost and the lack of perceived value have combined to slow the adoption of
smart homes. However, the perceived value of a smart home is likely to vary across
populations.

2.2 Efficient Energy Management System with Solar Energy

As decaying of fossil fuels and scarcity of electricity generating resources, an


alternate methods for generating electricity are highlighted and these methods uses
renewable sources like solar power, wind power, tidal energy and so on. Many research
companies concentrate on the elemental technologies to generate the power but the
energy generated from these resources is not sufficient as the growth of power demands
and need efficient and intelligent distribution system to distribute the energy. The
intelligent energy distribution management system is developed and the results of
managing the distribution of energy, which is generated from renewable resources, are
used effectively as presented and discussed. An increasing Global warming, currently
occurring on this 4.6 billion years old earth, is a very critical issue to be addressed by the
modern society that has been enjoying economic growth by consumption of fossil
energies Since the Industrial Revolution in Great Britain, much carbon dioxide (CO2) has
been emitted as a result of the combustion of petroleum and coal. In the past 200 years,
the carbon dioxide concentration in the atmosphere has increased by as much as 25%.

Now the entire earth is, so to speak, situ three of the most prominent issues facing
the world today are escalating climate change, energy security and meeting the increasing
global demand for electrical energy generated from renewable sources. The renewable
energy is growing technology for meeting the demands of energy consumption to solve
the problems of fossil fuels and at the same time reduce the pollution in the atmosphere.
In case of fossil fuels once it is used that cannot regenerated means it is converted into
electricity and is used by consumers. Where as in case of renewable sources the energy
generated is unlimited. Hence, the importance of renewable energy is becoming a great
technology and today the world seeing to develop these technologies. Now a day many
companies are seeing that to increase the efforts on development of renewable sources by
6
constructing smart grids having sustainable growth and connecting those smart grids to
the commercial electricity grids. In this paper, introduced an efficient energy distribution
system to distribute the energy generated from the renewable sources. In order to meet
the current problems the energy generated from the renewable sources to maintain it
constant, it was connected to a battery and inverter. In this research, we have
implemented a prototype system for the ideas. The preliminary tests show that this
approach is promising for real applications.

2.3 Energy Storage Management in Grid Connected Solar Photovoltaic


System

The penetration of renewable sources in the power system network in the power
system has been increasing in the recent years. One of the solutions being proposed to
improve the reliability and performance of these systems is to integrate energy storage
device into the power system network. This paper discusses the modeling of photovoltaic
and status of the storage device such as lead acid battery for better energy management in
the system. The dynamic switching process performed the energy management for the
grid-connected system. The renewable energy sources (RES) are clean with low
environmental impact than the conventional energy source. RES such as wind, solar,
biomass, hydro and geothermal are available in nature as a non-depleting source. The
solar Photovoltaic (PV) cell is an electronic device that essentially converts the solar
energy of sunlight into electric energy or electricity. Photovoltaic system consists of
many cells, panels and array. The large-scale PV plants are used for electricity generation
that is fed into the grid and load. Such system, typically consist of one or more PV panels
a DC/AC power Converter/Inverter. Additionally such system could also include
maximum power point (MPP) and storage devices.

The electricity generated is either stored, used directly for self-consumption or is


fed into large electricity grids. Interconnections of panel or array, predict the output
voltage or current or power and it is a variable that depends upon the sunlight. The
converters may be used to regulate voltage and current at the load to control the power
7
flow. There are many advantages of using solar Photovoltaic as a source for generating
power, such as clean energy, no pollution and maximum power at peak hours. The
modeling of solar PV system is to obtain maximum power for load requirements.
Therefore energy storage system is very important for balancing the system or energy
management of the system. A grid connected/stand-alone solar PV system essentially
consist of utility, PV array as primary sources, storage device as external leveling agents
to sink/sources the primary source power and load. Hence power flow management is
required to balance the power flow among these sources which controls the bidirectional
converter connected to battery so that the battery can be charged or discharged. The
power flow management controller is based on the state of charge of the battery. The
battery storage technology will play a major role in the reliable and economic operations
of grid connected solar photovoltaic system. The cost of the electricity was reduced or
maintains constant by the usage of energy storage devices and it required less
maintenance, life of the battery depends upon the frequent charging and discharging with
the specified limit. The modeling of photovoltaic system to regulate the power and
voltage, for the grid connected system, in order to reduce the fluctuation in the system.

2.4 An Efficient Energy Management and Household Appliances Scheduling


for Residential Customers using Embedded System

Intensive efforts have been made recently in transforming the power grid into
smart grid by means of incorporating extensive information and communication
infrastructures. In this paper a versatile stochastic optimization approach has been
proposed for smart grid, to suffice the residential customers in an efficient energy
management comprising high penetration of renewable and distributed energy sources,
market based online electricity pricing, large scale storage of energy and high quality
demand side management, mitigating monetary expense. The terminology Boost
converter used in this paper increases the throughput of solar panel voltage.

Smart energy meter, an added advantage of the proposed system provides a two
way communication between the utility board and residential unit. The simulation results
8
indicate an appreciable tradeoff between storage capacity and cost saving. This proposed
energy consumption scheduling algorithm ensures, generating scheduling solutions
within 10 seconds for fast household appliance applications. The electrical power grid is
by nature is a complex adaptive system and it regards with significant amount of
uncertainties The existing grid faces some sensitive problems which are major factors of
concern. They can be specifically mentioned as follows: limited delivery system. High
cost of power outage and power quality interruption. Inefficiency at managing peak load.
Increase in global warming and hazardous emissions. This negative impact of global
warming and greenhouse effects is indeed a curse to the entire existence of life on earth.

2.5 Automating Energy Management in Green Homes


Green homes powered fully or partially by renewable sources such as solar are
becoming more widely adopted, however energy management strategies in these
environments are lacking. This project presents the first results of a study that explores
home automation techniques for achieving better utilization of energy generated by
renewable technologies. First, using a network of off-the-shelf sensing devices, we
observe that energy generation and consumption in an off-grid home is both variable and
predictable. Moreover, we find that reactive energy management techniques are
insufficient to prevent critical battery situations. We then present a recommendation-
based system for helping users to achieve better utilization of resources.

Our study demonstrates the feasibility of three recommendation components: an


early warning system that allows users of renewable technologies to make more
conservative decisions when energy harvested is predicted to be low; a task rescheduling
system that advises users when high-power appliances such as clothes dryers should be
run to optimize overall energy utilization; and an energy conservation system that
identifies sources of energy waste and recommends more conservative usage. Homes that
derive part or all of their energy from renewable sources, such as solar and wind, are
becoming more widely adopted.

9
2.6 Home Energy Management Systems in Future Smart Grids
We present a detailed review of various Home Energy Management Schemes
(HEM,s). HEM, will increase savings, reduce peak demand and Pto Average Ratio
(PAR). Among various applications of smart grid technologies, home energy
management is probably the most important one to be addressed. Various steps have been
taken by utilities for efficient energy consumption. New pricing schemes like Time of
Use (ToU), Real Time Pricing (RTP), Critical Peak Pricing (CPP), Inclining Block Rates
(IBR) etc have been devised for future smart grids. Home appliances and/or distributed
energy resources coordination (Local Generation) along with different pricing schemes
leads towards efficient energy consumption. This paper addresses various communication
and optimization based residential energy management schemes and different
communication and networking technologies involved in these schemes.

Smart grid is the integration of advanced information, communication and


networking technologies in traditional electric grid to make it smarter and faster in
making decisions. This integration will bring more automation, reliability of electrical
services, safety of electrical equipment’s and hence an increase in consumer comfort
level. With the advent of smart grid several emerging techniques and technologies have
been proposed in past decade by researchers across the globe. Smart meters, bidirectional
communication, advanced metering infrastructure (AMI), home automation and home
area networks (HAN,s) are the techniques and technologies addressed by various
researchers. Traditional electric power grid has been serving humanity for the last one
century. Population has increased, the traditional grid has worn out thus addition of more
and more electric equipments bring instability to the traditional electric power grid. Smart
grid has applications in generation, transmission, distribution, and consumption of
electrical energy.

2.7 An Efficient Approach for Home Energy Management System


Wireless Sensor Network (WSN) is used in the home appliances, an Extension of
the Smart Grid. Here, the In Home Energy Management (IHEM) is developed to reduce

10
real time pricing and energy expense. IHEM allow communication between the consumer
and controller through Wireless Sensor Home Area Network (WSHAN). Main idea of In
Home Energy Management (IHEM) application is to find solution for Optimization based
Residential Energy Management (OREM) scheme and also to reduce the cost of energy
usage at home. Comparison of IHEM and OREM is carried to reduce energy expense to
ensure efficient demand supply. Evaluation is done based on the performance of IHEM
under the presence of local energy generation capability, real-time pricing, and for
prioritized appliances to determine the cost of energy expense. A smart grid delivers
electricity from suppliers to consumers using digital technology with two-way
communications to control appliances at consumers' homes to save energy, reduce cost
and increase reliability and transparency. Using wireless Sensor Networks (WSNs) has
many benefits, including unmetered access to information, support for mobility, reduced
cost and complexity associated with wiring and maintenance, and support for
interoperability. While many of these benefits apply to the grid, there are a number of
challenges that remain.

The milestone in the process of transition from the traditional grid to the smart
grid is the integration of information and communication technologies (ICT) to the power
grid. The advances in ICT can be employed to increase automation, integrate distributed
renewable resources, secure the grid infrastructure, adopt electric vehicles (EVs), and
enable efficient demand-side energy management. First, it has been hard to handle the
large number of residential units without communication, sensors, and efficient
automation tools. Second, the impact of demand response programs has been considered
to be relatively small when compared with their implementation cost. However in the
smart grid, smart meters, low-cost sensors, smart appliances, and communications set the
stage for novel residential energy management techniques that involve communications
and interaction between consumers, devices, and the grid. Residential energy
management, smart appliances, WSHANs, and their integration to smart grid applications
are becoming popular topics as the governments and the utilities are urging for migration

11
to the smart grid. In this paper, we introduce the OREM and the IHEM schemes to reduce
the share of the appliances in the energy bills and to reduce their contribution to the peak
load. We show that the IHEM application decreases the contribution of the appliances to
the energy bill, significantly.

12
CHAPTER – III

SYSTEM ANALYSIS

3.1 Existing System:

The thermal power stations are causing pollution, which severely affects mankind
and nature. These power stations result in causing many diseases. Also natural resources
like coal, oil, radio-active materials etc. will get extinct in near future. The other existing
power generating systems like Hydro-Electricity power generating plant cannot afford
much power, as it is season based, although it causes less pollution.

3.1.1 Disadvantage:

 It effects environments
 More pollution
 Less efficient
 Limited capacity

13
3.2 Proposed System:

All the natural wastage energies are used for production of Electricity. Thus, the
Electrical Power or Electricity is available with a minimum cost and pollution free to
anywhere in the world at all times. This project will expose a novel step in the generation
of electricity and availability of natural resources without disturbing the ecological
balance. This project describes a novel and developing Electrical Power Generation
mechanism by photovoltaic Solar Energy. The solar energy is used to store in the battery.
Then it will be used to run the electrical loads. This solar power generating system is
suitable for Industries and domestic areas.

3.2.1 Advantage:

 Solar photovoltaic (SPV) systems can also increase the reliability of the system
 It can also reduce the noises
 Less cost
 High efficient

14
CHAPTER - IV

4.1 BLOCK DIAGRAM:

15
4.2 WORKING PRINCIPLE:

The input 230V AC voltage applied to the step down transformer it step down into
12v Ac. The switch is connected with secondary side of step down transformer. Bridge
rectifier is converting AC into pulsating DC of 12V.In Bridge Rectifier analog input is
connected to the switch and positive, negative edge is connected to the ceramic capacitor.
Ceramic capacitor is connected for noise rectification.1000uf Ceramic capacitor is used
to filter the harmonics in the power supply line. Capacitor is connected to the voltage
regulator. The 7805 voltage regulator has 3 pins. First pin is 12v input pin, second pin is
ground pin and third pin is 5v output pin. Input 5v is given to PIC 16F877a
microcontroller. Here power generating through renewable energy like solar. The aim of
this project is to design and implement a power generation system using solar energy.
Here two solar panels is used for power generation. The Solar panel receives solar
energy. The received energy are low voltage, so boost converter will increase the voltage.
Filter is used to avoid the harmonics in that power. Then this power will store in a
battery. Rectifier is used to convert ac to dc. 1000mf capacitor is used to filter the
harmonics in that stored power. Microcontroller runs only 5v. So, voltage regulator IC
7805 is used to regulate 12v to 5v. Then 5v input gives to microcontroller. Inverter is
used to convert dc to ac. Switch is used to on the electrical load. In case any problem
occurs in the battery, then it cannot to run the load. Therefore, here gives a solution for
that problem. When battery fails, automatically relay activates the TNEB power supply
will give the power to run the load.

16
CHAPTER - V

HARDWARE & SOFTWARE REQUIREMENT

5.1 HARDWARE REQUIREMENTS

1) Power Supply

2) Switch

3) Rectifier

4) 1000 mf Capacitor

5) Voltage Regulator IC 7805

6) LCD Display

7) PIC Microcontroller 16F877A

8) Solar panel

9) Boost Converter

10) Relay

11) Light

12) Inverter Unit

13) 12V Dc Batttery

14) TNEB

17
CHAPTER-VI

6. HARDWARE DESCRIPTION:

6.1 Power Supply

A power supply is an electronic device that supplies electric energy to an electrical


load. The primary function of a power supply is to convert one form of electrical energy
to another and, as a result, power supplies are sometimes referred to as electric power
converters. Some power supplies are discrete, stand-alone devices, whereas others are
built into larger devices along with their loads. Examples of the latter include power
supplies found in desktop computers and consumer electronics devices.
Every power supply must obtain the energy it supplies to its load, as well as any
energy it consumes while performing that task, from an energy source. Depending on its
design, a power supply may obtain energy from various types of energy sources,
including electrical energy transmission systems, energy storage devices such as a
batteries and fuel cells, electromechanical systems such as generators and alternators,
solar power converters, or another power supply.
All power supplies have a power input, which receives energy from the energy
source, and a power output that delivers energy to the load. In most power supplies the
power input and output consist of electrical connectors or hardwired circuit connections,
though some power supplies employ wireless energy transfer in lieu of galvanic
connections for the power input or output. Some power supplies have other types of
inputs and outputs as well, for functions such as external monitoring and control.
6.2 Switch

18
A switch is an electrical component that can break an electrical circuit,
interrupting the current or diverting it from one conductor to another. the mechanism of a
switch may be operated directly by a human operator to control a circuit (for example, a
light switch or a keyboard button), may be operated by a moving object such as a door-
operated switch, or may be operated by some sensing element for pressure, temperature
or flow. A relay is a switch that is operated by electricity. Switches are made to handle a
wide range of voltages and currents; very large switches may be used to isolate high-
voltage circuits in electrical substations.

6.3 Rectifier

A rectifier is an electrical device that converts alternating current (AC), which


periodically reverses direction, to direct current (DC), which flows in only one direction.
The process is known as rectification. Physically, rectifiers take a number of forms,
including vacuum tube diodes, mercury-arc valves, copper and selenium oxide
rectifiers, semiconductor diodes, silicon-controlled rectifiers and other silicon-based
semiconductor switches. Historically, even synchronous electromechanical switches and
motors have been used. Early radio receivers, called crystal radios, used a "cat's whisker"
of fine wire pressing on a crystal of galena (lead sulfide) to serve as a point-contact
rectifier or "crystal detector".

Rectifiers have many uses, but are often found serving as components of
DC power supplies and high-voltage direct current power transmission systems.
Rectification may serve in roles other than to generate direct current for use as a source of
power. As noted, detectors of radio signals serve as rectifiers. In gas heating
systems flame rectification is used to detect presence of a flame.

Because of the alternating nature of the input AC sine wave, the process of
rectification alone produces a DC current that, though unidirectional, consists of pulses of
current. Many applications of rectifiers, such as power supplies for radio, television and
computer equipment, require a steady constant DC current (as would be produced by

19
a battery). In these applications the output of the rectifier is smoothed by an electronic
filter (usually a capacitor) to produce a steady current.

A more complex circuitry device that performs the opposite function, converting
DC to AC, is called an inverter.

6.4Capacitor

A capacitor (originally known as a condenser) is a passive two-terminal electrical


component used to store energy electrostatically in an electric field. The forms of
practical capacitors vary widely, but all contain at least two electrical conductors (plates)
separated by a dielectric (i.e. insulator). The conductors can be thin films, foils or sintered
beads of metal or conductive electrolyte, etc. The "non conducting" dielectric acts to
increase the capacitor's charge capacity. A dielectric can be glass, ceramic, plastic film,
air, vacuums, paper, mica, oxide layer etc. Capacitors are widely used as parts of
electrical circuits in many common electrical devices. Unlike a resistor, an ideal capacitor
does not dissipate energy. Instead, a capacitor stores energy in the form of an electrostatic
field between its plates.

When there is a potential difference across the conductors (e.g., when a capacitor
is attached across a battery), an electric field develops across the dielectric, causing
positive charge +Q to collect on one plate and negative charge −Q to collect on the other
plate. If a battery has been attached to a capacitor for a sufficient amount of time, no
current can flow through the capacitor. However, if a time-varying voltage is applied
across the leads of the capacitor, a displacement current can flow.

6.5 Voltage Regulator IC 7805

20
Fig. 1 Voltage Regulator IC 7805

7805 is a voltage regulator integrated circuit. It is a member of 78xx series of fixed


linear voltage regulator ICs. The voltage source in a circuit may have fluctuations and
would not give the fixed voltage output. The voltage regulator IC maintains the output
voltage at a constant value.

6.5.1 Pin Description:

6.6 LCD Display

LCD (Liquid Crystal Display) screen is an electronic display module and find a
wide range of applications. A 16x2 LCD display is very basic module and is very
commonly used in various devices and circuits. These modules are preferred overseven
segments and other multi segment LEDs. The reasons being: LCDs are economical;
easily programmable; have no limitation of displaying special & even custom
characters (unlike in seven segments).

21
Fig.2 LCD Display

A 16x2 LCD means it can display 16 characters per line and there are 2 such lines.
In this LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers,
namely, Command and Data.
The command register stores the command instructions given to the LCD. A
command is an instruction given to LCD to do a predefined task like initializing it,
clearing its screen, setting the cursor position, controlling display etc. The data register
stores the data to be displayed on the LCD. The data is the ASCII value of the character
to be displayed on the LCD.

Pin Description:

22
6.7 PIC MICROCONTROLLER

The PIC microcontroller family is manufactured by Microchip Technology Inc.


Currently they are one of the most popular microcontrollers, used in many commercial
and industrial applications. Over 120 million devices are sold each year. The
programmability and the versatile applications for which a PIC microcontroller can be
used have made it a first choice in small scale applications and project work.

The PIC microcontroller architecture is based on a modified Harvard RISC


(Reduced Instruction set Computer) instruction set with dual-bus architecture, providing
fast and flexible design with an easy migration path from only 6 pins to 80 pins, and from
384 bytes to 128 kilobytes of program memory. PIC microcontrollers are available with
different specifications depending on:

6.7.2 Memory Type

 Flash

23
 OTP (One-time-programmable)
 ROM (Read-only-memory)
 ROM less
 Input - Output (I/O) Pin Count
 4–18 pins
 20–28 pins
 32–44 pins
 45 and above pins

All PIC microcontrollers offer the following features

 RISC instruction set with only handful of instructions to learn


 Digital I/O
 On chip timer
 Power-on-reset
 Power-saving sleep mode
 High source and sink current
 Direct indirect and relative addressing modes
 External clock interface
 RAM data memory
 EPROM or flash program memory

Some devices offer the following additional features

• Analog input channel

• Analog comparators

• Additional timer circuit

• EEPROM data memory

24
• External and internal interrupts

• Internal oscillator

• PWM output

• USART serial interface.

6.7.3 PIN AND PACKAGE

There are three package types are available: DIP, PLCC, and QFP. This book
assumes that we all use the DIP because of its best fit to breadboard or proto-board.

Fig. 3 Pin diagram of PIC 16F877A

25
6.7.4 PIC 16F877A (Architecture of PIC16F877A)

26
Fig. 4 Architecture of 16F877A

6.7.5 Memory organization

There are three memory blocks in each of these PIC micro MCUs. The Program
Memory and Data Memory have separate buses so that concurrent access can occur.

27
6.7.5.1 Program memory organization

The PIC16F87X devices have a 13-bit program counter capable of addressing an


8K x 14 program memory space. The PIC16F877/876 devices have 8K x 14 words of
FLASH program memory and the PIC16F873/874 devices have 4K x 14. Accessing a
location above the physically implemented address will cause a wraparound. The reset
vector is at 0000h and the interrupt vector is at 0004h.

Fig. 5 Program memory and Stack memory

6.7.5.2 Data memory organization

28
The data memory is partitioned into multiple banks which contain the General
Purpose Registers and the Special Function Registers. Bits RP1 (STATUS<6>) and RP0
(STATUS<5>) are the bank select bits.

Table 1 Register bank selection

Each bank extends up to 7Fh (128 bytes). The lower locations of each bank are
reserved for the Special Function Registers. Above the Special Function Registers are
General Purpose Registers, implemented as static RAM.

6.7.5.3 General purpose register file

The register file can be accessed either directly or indirectly through the File
Select Register FSR.

6.7.6 Special function registers

The Special Function Registers are registers used by the CPU and peripheral
modules for controlling the desired operation of the device. These registers are
implemented as static RAM. The Special Function Registers can be classified into two
sets; core (CPU) and peripheral.

6.7.6.1 Status register

The STATUS register contains the arithmetic status of the ALU, the RESET status
and the bank select bits for data memory. The STATUS register can be the destination for
any instruction, as with any other register.

29
If the STATUS register is the destination for an instruction that affects the Z, DC
or C bits, then the write to these three bits is disabled. These bits are set or cleared
according to the device logic. The TO and PD bits are not writable, therefore, the result
of an instruction with the STATUS register as destination may be different than intended.

6.7.6.2 OPTION_REG register

The OPTION_REG Register is a readable and writable register, which contains


various control bits to configure the TMR0 prescaler/WDT postscaler (single assignable
register known also as the prescaler), the External INT Interrupt, TMR0 and the weak
pull-ups on PORTB.

6.7.6.3 INTCON register

The INTCON Register is a readable and writable register, which contains various
enable and flag bits for the TMR0 register overflow, RB Port change and External
RB0/INT pin interrupts.

6.7.6.4 PIE1 register

The PIE1 register contains the individual enable bits for the peripheral interrupts.

6.7.6.5 PIR1 register

The PIR1 register contains the individual flag bits for the peripheral interrupts.

6.7.6.6 PIE2 register

The PIE2 register contains the individual enable bits for the CCP2 peripheral
interrupt, the SSP bus collision interrupt, and the EEPROM write operation interrupt.

30
6.7.6.7 PIR2 register

The PIR2 register contains the flag bits for the CCP2 interrupt, the SSP bus
collision interrupt and the EEPROM write operation interrupt.

6.7.6.8 PCON register

The Power Control (PCON) Register contains flag bits to allow differentiation
between a Power-on Reset (POR), a Brown-out Reset (BOR), a Watch-dog Reset (WDT)
and an external MCLR Reset.

6.8 Solar Panel

Although solar is becoming more popular everyday people still don’t know how
solar panels work. Certain competing energy concerns have campaigns to discredit and
confused consumers on how solar energy is generated. There are many considerations in
regards to solar and distinctions between residential and industrial, between being off the
grid and connecting the grid. This simple guide will outline how Solar Panels Work.
Here’s a quick “how solar panels work” guide to the steps that it takes to turn sunlight
into electricity using solar panels: Every day, light hits your roof’s solar panels with
photons (particles of sunlight). The panel converts those photons into electrons of direct
current (“DC”) electricity. Naturally, the sunnier it is, the more energy is produced by the
panels. Those produced electrons flow out of the panel and into an inverter and other
electrical safety devices The inverter converts that “DC” power into alternating current
or “AC” power. AC power is the kind of electric juice that your television, computer, and
toasters use when plugged into the wall outlet. A bi-directional meter keeps track of the
all the power your solar system produces. Any solar energy that you don’t use
immediately will go back into the grid through the meter. Then at night or on cloudy
days, that extra solar juice is credited back to your bill. So, net metering is similar to
having a virtual battery-backup system (we explain more about grid-tied solar home solar

31
systems later). Solar panels that can avoid shade, can maximize sun coverage will
produce the most solar energy power.

6.9Boost Converter

A boost converter (step-up converter) is a DC-to-DC power converter with an


output voltage greater than its input voltage. It is a class of switched-mode power supply
(SMPS) containing at least two semiconductors (a diode and a transistor) and at least one
energy storage element, a capacitor, inductor, or the two in combination. Filters made of
capacitors (sometimes in combination with inductors) are normally added to the output of
the converter to reduce output voltage ripple. The basic schematic of a boost converter.
The switch is typically a MOSFET, IGBT, or BJT.

Fig.6 Schematic of a boost converter

6.10Relay

A relay is an electrically operated switch. Many relays use an electromagnet to


mechanically operate a switch, but other operating principles are also used, such assolid-
state relays. Relays are used where it is necessary to control a circuit by a low-power
signal (with complete electrical isolation between control and controlled circuits), or
where several circuits must be controlled by one signal. The first relays were used in long
distance telegraph circuits as amplifiers: they repeated the signal coming in from one
circuit and re-transmitted it on another circuit. Relays were used extensively in telephone
exchanges and early computers to perform logical operations.

32
A type of relay that can handle the high power required to directly control an
electric motor or other loads is called a contactor. Solid-state relays control power circuits
with no moving parts, instead using a semiconductor device to perform switching. Relays
with calibrated operating characteristics and sometimes multiple operating coils are used
to protect electrical circuits from overload or faults; in modern electric power systems
these functions are performed by digital instruments still called "protective relays".

6.11 Light

Light is electromagnetic radiation within a certain portion of the electromagnetic


spectrum. The word usually refers to visible light, which is visible to the human eye and
is responsible for the sense of sight. Visible light is usually defined as
having wavelengths in the range of 400–700nanometres (nm), or 4.00 × 10−11 to 7.00 ×
10−11 m, between the infrared(with longer wavelengths) and the ultraviolet (with shorter
wavelengths). This wavelength means a frequency range of roughly 430–
750 terahertz(THz).

The main source of light on Earth is the Sun. Sunlight provides the energy that
green plants use to create sugars mostly in the form of starches, which release energy into
the living things that digest them. This process of photosynthesis provides virtually all the
energy used by living things. Historically, another important source of light for humans
has been fire, from ancient campfires to modern kerosene lamps. With the development
of electric lights & power systems, electric lighting has effectively replaced firelight.
Some species of animals generate their own light, a process called bioluminescence. For
example, fireflies use light to locate mates, and vampire squids use it to hide themselves
from prey.

The primary properties of visible light are intensity, propagation direction, frequency
or wavelength spectrum, and polarization, while its speed in a vacuum, 299 792 458
meters per second, is one of the fundamental constants of nature. Visible light, as with all

33
types of electromagnetic radiation (EMR), is experimentally found to always move at this
speed in vacuum.

6.12 Inverter Unit

A power inverter, or inverter, is an electronic device or circuitry that


changes direct current (DC) to alternating current (AC). The input voltage, output
voltage and frequency, and overall power handling depend on the design of the specific
device or circuitry. The inverter does not produce any power; the power is provided by
the DC source. A power inverter can be entirely electronic or may be a combination of
mechanical effects (such as a rotary apparatus) and electronic circuitry. Static
inverters do not use moving parts in the conversion process. Electroshock
weapons and Tasers have a DC/AC inverter to generate several tens of thousands of V
AC out of a small nine V DC battery. First the 9 V DC is converted to 400–2000 V AC
with a compact high frequency transformer, which is then rectified and temporarily
stored in a high voltage capacitor until a pre-set threshold voltage is reached. When the
threshold (set by way of an airgap or TRIAC) is reached, the capacitor dumps its entire
load into a pulse transformer which then steps it up to its final output voltage of 20–60
kV. A variant of the principle is also used in electronic flash and bug zappers, though
they rely on a capacitor-based voltage multiplier to achieve their high voltage.

6.13 12V DC Batttery

An electric battery is a device consisting of one or more electrochemical cells that


convert stored chemical energy into electrical energy. Each cell contains a positive
terminal, or cathode, and a negative terminal, or anode. Electrolytes allow ions to move
between the electrodes and terminals, which allows current to flow out of the battery to
perform work.

Primary (single-use or "disposable") batteries are used once and discarded; the
electrode materials are irreversibly changed during discharge. Common examples are the
34
alkaline battery used for flashlights and a multitude of portable devices. Secondary
(rechargeable batteries) can be discharged and recharged multiple times; the original
composition of the electrodes can be restored by reverse current. Examples include the
lead-acid batteries used in vehicles and lithium ion batteries used for portable electronics.

Batteries come in many shapes and sizes, from miniature cells used to power
hearing aids and wristwatches to battery banks the size of rooms that provide standby
power for telephone exchanges and computer data centers. According to a 2005 estimate,
the worldwide battery industry generates US$48 billion in sales each year, with 6%
annual growth. Batteries have much lower specific energy (energy per unit mass) than
common fuels such as gasoline. This is somewhat offset by the higher efficiency of
electric motors in producing mechanical work, compared to combustion engines.

35
CHAPTER-VII

7. SOFTWARE REQUIREMENTS

1) Proteus Software: For schematic circuit design, PCB design and simulation.

2) Keil μvision Software: Keil provides a broad range of development tools like ANSI c
compiler, macro assemblers, debuggers and simulators, IDE, the real-time operating
systems and evaluation boards for 8051, arm.

3) Embedded-C: C is the most widely used programming language for embedded


processors/controllers. Assembly is also used but mainly to implement those portions of
the code where very high timing accuracy, code size efficiency, etc. are prime
requirements.

7.1 Proteus Software:

Proteus is software for microprocessor simulation, schematic capture, and printed


circuit board (PCB) design. It is developed by Lab center Electronics. The XGame
Station Micro Edition was designed using Lab center’s Proteus schematic entry and PCB
layout tools.

7.1.1 System Components:

 ISIS Schematic Capture - a tool for entering designs.


 PROSPICE Mixed mode SPICE simulation - industry standard SPICE3F5
simulator combined with a digital simulator.
 ARES PCB Layout - PCB design system with automatic component placer, rip-up
and retry auto-router and interactive design rule checking.

36
 VSM - Virtual System Modeling lets co simulate embedded software for popular
micro-controllers alongside hardware design.

7.1.2 Introduction to Proteus:

Proteus professional is a software combination of ISIS schematic capture program and


ARES PCB layout program. This is a powerful and integrated development environment.
Tools in this suit are very easy to use and these tools are very useful in education and
professional PCB designing. As professional PCB designing software with integrated
space based auto router, it provides features such as fully featured schematic capture,
highly configurable design rules, interactive SPICE circuit simulator, extensive support
for power planes, industry standard CADCAM & ODB++ output and integrated 3D
viewer.

Up to know we have discussed about the basics and software description. Now
we are entering into the designing section. Run the ISIS professional program by clicking
the icon on the desktop, then this splash screen will appear.

7.1.3 Language features

At first sight, Proteus may appear similar to Basic because of its straight syntax,
but similarities are limited to the surface:

Proteus has a fully functional, procedural approach; variables are untyped, do not
need to be declared, can be local or public and can be passed by value or by reference;

All the typical control structures are available (if-then-else; for-next; while-loop;
repeat-until; switch-case);

New functions can be defined and used as native functions.

Data types supported by Proteus are only three: integer numbers, floating point
numbers and strings.

37
Access to advanced data structures (files, arrays, queues, stacks, AVL trees, sets
and so on) takes place by using handles, i.e. integer numbers returned by item creation
functions.

Type declaration is unnecessary: variable type is determined by the function applied –


Proteus converts on the fly every variable when needed and holds previous data
renderings, to avoid performance degradation caused by repeated conversions.

The main features of this language are:

Fully functional, procedural language;

Multi-language support: Proteus is available in several languages (keywords and


messages);

No data types: all variables can be used as integer numbers, floating point numbers or
strings; variables are interpreted according to the functions being applied – Proteus keeps
different representations of their values between calls, to decrease execution time in case
of frequent conversions between one type and the other;

No pre-allocated structures: all data used by Proteus are dynamically allocated at


execution time; there are no limits on: recursion, maximum data size, number of
variables, etc.

No operators: Proteus is a completely functional language – there are no operators; thus,


there is no ambiguity when evaluating expressions and parentheses are not needed;

Large library of predefined functions: Proteus is not a toy-language, it comes with


hundreds of library functions ready to be used for working on strings, dates, numbers, for
sorting, searching and so on;

38
CHAPTER - VIII

8. CIRCUIT DIAGRAM:

Solar Panel 1 Solar Panel 2

12V DC GND 5V DC

R1
TR1 1k

BOOST CONVERTER
BR1 U2
P 7805
240v
STEP DOWN C3 1 3
AC VI VO
D1
12V AC 25v/1ooomf GND
T/F pwr Led
INPUT 12V DC
2

C1
U1
13 33
OSC1/CLKIN RB0/INT
33pf X1 14
OSC2/CLKOUT RB1
34
CRYSTAL 35 R3
RB2
2 36
C2 RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4
RA2/AN2/VREF-/CVREF RB5
38 330 Ohm
5 39
RA3/AN3/VREF+ RB6/PGC
6 40
33pf 7
RA4/T0CKI/C1OUT
RA5/AN4/SS/C2OUT
RB7/PGD
15 D2
8
RC0/T1OSO/T1CKI
16 12+
9
RE0/AN5/RD
RE1/AN6/WR
RC1/T1OSI/CCP2
RC2/CCP1
17 NC LED
10 18
R2
RE2/AN7/CS RC3/SCK/SCL
23 ELECTRICAL LOAD
1
RC4/SDI/SDA
24 I/P COM
MCLR/Vpp/THV RC5/SDO
RC6/TX/CK
25 RELAY
1K 26
11
RC7/RX/DT GND NO
VDD RD0/PSP0
19
20
RD1/PSP1
21
RD2/PSP2
VSS RD3/PSP3
22
P
12 27
RV1 LCD DISPLAY RD4/PSP4
RD5/PSP5
28
29
RD6/PSP6
30
RD7/PSP7 240V AC
PIC16F877A
VDD
VSS

VEE

RW

1K
RS

D0
D1
D2
D3
D4
D5
D6
D7
E

N
1
2
3

4
5
6

7
8
9
10
11
12
13
14

Battery

Inverter
L1
12V

Rectifier
TNEB AC Supply

39
CHAPTER-IX

9. CONCLUSION:

In this project, a renewable energy based solar power system, will be highly
effective in all places, especially in commercial areas where need of electricity is more. It
causes no effect on nature i.e. pollution free. It is also useful to minimize power supply
load i.e. cut power charge. By using this system, we can save electricity charge because
very less maintenance. The designing of this equipment is done in such a way that it is
very compact and acts as user friendly. When it is manufactured in a large scale, cost of
this integrated natural resources power generation system is affordable. Therefore, it is
the most reliable renewable power or electricity resources with less expenditure.

9.1APPLICATION:

 Estimate and decompose the total power consumption


 Increase the power generation
 Solar-power generating system is suitable for Industries and domestic areas.

40
CODING
#define MX_PIC
#define MX_USES_UINT8 1
#define MX_USES_SINT16 0
#define MX_USES_CHAR 0
#define MX_USES_FLOAT 0
#define MX_USES_SINT32 0
#define MX_USES_BOOL 1
#define MX_USES_UINT16 1
#define MX_USES_UINT32 0
//Defines for microcontroller
#define P16F877A
#define FC_CAL_PIC
#define MX_ADC
#define MX_ADC_TYPE_1
#define MX_ADC_BITS_10
#define MX_EE
#define MX_EE_TYPE2
#define MX_EE_SIZE 256
#define MX_SPI_1
#define MX_SPI_1_MISO_PORT portc
#define MX_SPI_1_MISO_TRIS trisc
#define MX_SPI_1_MISO_PIN 4
#define MX_SPI_1_MOSI_PORT portc
#define MX_SPI_1_MOSI_TRIS trisc
#define MX_SPI_1_MOSI_PIN 5
#define MX_SPI_1_CLK_PORT portc
#define MX_SPI_1_CLK_TRIS trisc

41
#define MX_SPI_1_CLK_PIN 3
#define MX_SPI_1_SS_PORT portc
#define MX_SPI_1_SS_TRIS trisc
#define MX_UART_1
#define MX_UART_1_TX_PORT portc
#define MX_UART_1_TX_TRIS trisc
#define MX_UART_1_TX_PIN 6
#define MX_UART_1_RX_PORT portc
#define MX_UART_1_RX_TRIS trisc
#define MX_UART_1_RX_PIN 7
#define MX_I2C
#define MX_MI2C
#define MX_I2C_1
#define MX_I2C_1_SDA_PORT portc
#define MX_I2C_1_SDA_TRIS trisc
#define MX_I2C_1_SDA_PIN 4
#define MX_I2C_1_SCL_PORT portc
#define MX_I2C_1_SCL_TRIS trisc
#define MX_I2C_1_SCL_PIN 3
#define MX_PWM
#define MX_PWM_CNT 2
#define MX_PWM_PSCA1
#define MX_PWM_PSCA4
#define MX_PWM_PSCA16
#define MX_PWM_1_PORT portc
#define MX_PWM_1_TRIS trisc
#define MX_PWM_1_PIN 2
#define MX_PWM_2_PORT portc

42
#define MX_PWM_2_TRIS trisc
#define MX_PWM_2_PIN 1
//Functions
#define MX_CLK_SPEED 20000000
#ifdef _BOOSTC
#include <system.h>
#endif
#ifdef HI_TECH_C
#include <pic.h>
#endif
//Configuration data
#ifdef _BOOSTC
#pragma DATA 0x2007, 0x3f3a
#endif
#ifdef HI_TECH_C
__CONFIG(0x3f3a);
#endif
//Macro function declarations
//Variable declarations
#define FCV_FALSE (0)
#define FCV_TRUE (1)
MX_UINT16 FCV_CON1 = (0x0);
MX_UINT16 FCV_NUM = (0xa);
MX_UINT16 FCV_SW;
MX_UINT16 FCV_TH;
MX_UINT16 FCV_DIS;
MX_UINT16 FCV_SW1;
MX_UINT16 FCV_ADC;

43
MX_UINT16 FCV_SEC = (0x0);
MX_UINT16 FCV_NUM1 = (0xf);
MX_UINT16 FCV_CON = (0x0);
//ADC(0): //Defines:
/**** Macro Substitutions ****
a = Unique Reference
b = Which ADC Channel
c = Acquisition time
d = Conversion Speed
e = VRef+ Option
f = VRef Voltage x 0.01V
******************************/
//Common Defines
#define ADC_1_MX_ADC_CHANNEL 1
#define ADC_1_MX_ADC_ACTIME 40
#define ADC_1_MX_ADC_CONVSP 3
#define ADC_1_MX_ADC_VREFOP 0
#define ADC_1_MX_ADC_VREFVOL 500
#ifndef MX_ADC_CHANNEL_1
#define MX_ADC_CHANNEL_1 //Inform CAL ADC channel 1 is now in use.
#endif
#ifndef MX_ADC_REF //Inform CAL ADC peripheral is
now in use
#define MX_ADC_REF
#endif
extern void FC_CAL_Enable_ADC (MX_UINT8 Channel, MX_UINT8 Conv_Speed,
MX_UINT8 Vref, MX_UINT8 T_Charge);
extern MX_UINT16 FC_CAL_Sample_ADC (MX_UINT8 Sample_Mode);
extern void FC_CAL_Disable_ADC (void);

44
//ADC(0): //Macro function declarations
void FCD_ADC0_SampleADC();
MX_UINT8 FCD_ADC0_ReadAsByte();
MX_UINT16 FCD_ADC0_ReadAsInt();
MX_FLOAT FCD_ADC0_ReadAsVoltage();
void FCD_ADC0_ReadAsString(MX_CHAR* FCR_RETVAL, MX_UINT8
FCR_RETVAL_SIZE);
void FCD_ADC0_ADC_RAW_Configure_Channel();
MX_UINT8 FCD_ADC0_ADC_RAW_Sample_Channel_Byte();
MX_UINT16 FCD_ADC0_ADC_RAW_Sample_Channel_Int();
MX_UINT8 FCD_ADC0_ADC_RAW_Average_Channel_Byte(MX_UINT8 NumSamples,
MX_UINT8 DelayUs);
MX_UINT16 FCD_ADC0_ADC_RAW_Average_Channel_Int(MX_UINT8 NumSamples,
MX_UINT8 DelayUs);
void FCD_ADC0_ADC_RAW_Disable_Channel();
//LCDDisplay(0): //Defines:
/**** Macro Substitutions ****
a = Unique Component Reference Number
b = D1 Port Letter
c = D2 Port Letter
d = D3 Port Letter
e = D4 Port Letter
f = RS Port Letter
g = E Port Letter
h = Data 1_Pin
i = Data 2 Pin
j = Data 3 Pin
k = Data 4 Pin
l = RS Pin

45
m = Enable Pin
n = Row Count
o = Column Count
******************************/
//component connections
#define LCD_2__PORT0 portb
#define LCD_2__PORT1 portb
#define LCD_2__PORT2 portb
#define LCD_2__PORT3 portb
#define LCD_2__PORT4 portb
#define LCD_2__PORT5 portb
#define LCD_2__TRIS0 trisb
#define LCD_2__TRIS1 trisb
#define LCD_2__TRIS2 trisb
#define LCD_2__TRIS3 trisb
#define LCD_2__TRIS4 trisb
#define LCD_2__TRIS5 trisb
#define LCD_2__BIT0 5
#define LCD_2__BIT1 4
#define LCD_2__BIT2 3
#define LCD_2__BIT3 2
#define LCD_2__RS 7
#define LCD_2__E 6
#define LCD_2__ROWCNT 2
#define LCD_2__COLCNT 16
#ifdef _BOOSTC
#define LCD_2__DELAY delay_10us(10)
#endif

46
#ifdef _C2C_
#define LCD_2__DELAY delay_us(100)
#endif
#ifdef HI_TECH_C
#define LCD_2__DELAY __delay_us(120)
#endif
#ifndef LCD_2__DELAY
#define LCD_2__DELAY delay_us(100)
#endif
//LCDDisplay(0): //Macro function declarations
void FCD_LCDDisplay0_RawSend(MX_UINT8 in, MX_UINT8 mask);
void FCD_LCDDisplay0_Start();
void FCD_LCDDisplay0_Clear();
void FCD_LCDDisplay0_PrintASCII(MX_UINT8 Character);
void FCD_LCDDisplay0_Command(MX_UINT8 in);
void FCD_LCDDisplay0_Cursor(MX_UINT8 x, MX_UINT8 y);
void FCD_LCDDisplay0_PrintNumber(MX_SINT16 Number);
void FCD_LCDDisplay0_PrintString(MX_STRING String, MX_UINT8 MSZ_String);
void FCD_LCDDisplay0_ScrollDisplay(MX_UINT8 Direction, MX_UINT8 Num_Positions);
void FCD_LCDDisplay0_ClearLine(MX_UINT8 Line);
void FCD_LCDDisplay0_RAM_Write(MX_UINT8 nIdx, MX_UINT8 d0, MX_UINT8 d1,
MX_UINT8 d2, MX_UINT8 d3, MX_UINT8 d4, MX_UINT8 d5, MX_UINT8 d6, MX_UINT8
d7);
//LED(0): //Defines:
/**** Macro Substitutions ****
a = Unique Reference
b = LED Port Letter
c = LED Pin Number
d = LED Active Polarity

47
******************************/
#define LED_3__LED_PORT portd
#define LED_3__LED_TRIS trisd
#define LED_3__LED_PIN 2
#define LED_3__LED_POLE 1
//LED(0): //Macro function declarations
void FCD_LED0_LEDOn();
void FCD_LED0_LEDOff();
//LED(1): //Defines:
/**** Macro Substitutions ****
a = Unique Reference
b = LED Port Letter
c = LED Pin Number
d = LED Active Polarity
******************************/
#define LED_4__LED_PORT portd
#define LED_4__LED_TRIS trisd
#define LED_4__LED_PIN 3
#define LED_4__LED_POLE 1
//LED(1): //Macro function declarations
void FCD_LED1_LEDOn();
void FCD_LED1_LEDOff();
//SWITCH(0): //Defines:
/**** Macro Substitutions ****
a = Unique Reference
b = Switch Port Letter
c = Switch Pin Number
d = Switch Polarity Control

48
e = Switch Debounce Delay Value (us)
******************************/
#define Switch_5_SW_PORT portc
#define Switch_5_SW_TRIS trisc
#define Switch_5_SW_PIN 3
#define Switch_5_SW_POLE 0
#define Switch_5_SW_DELAY 0 * 1000
//SWITCH(0): //Macro function declarations
MX_UINT8 FCD_SWITCH0_ReadState();
void FCD_SWITCH0_WaitUntilHigh();
void FCD_SWITCH0_WaitUntilLow();
//SWITCH(1): //Defines:
/**** Macro Substitutions ****
a = Unique Reference
b = Switch Port Letter
c = Switch Pin Number
d = Switch Polarity Control
e = Switch Debounce Delay Value (us)
******************************/
#define Switch_6_SW_PORT portd
#define Switch_6_SW_TRIS trisd
#define Switch_6_SW_PIN 0
#define Switch_6_SW_POLE 0
#define Switch_6_SW_DELAY 0 * 1000
//SWITCH(1): //Macro function declarations
MX_UINT8 FCD_SWITCH1_ReadState();
void FCD_SWITCH1_WaitUntilHigh();
void FCD_SWITCH1_WaitUntilLow();

49
//Definitions for RS232 UART slot allocation
#ifndef MX_UART_REF1
#define MX_UART_REF1
#define RS232_8_MX_UART_UREF 1
#define MX_UART_CHANNEL_1 1
#define MX_UART_TX_PIN_1 0
#define MX_UART_TX_PORT_1 porta
#define MX_UART_TX_TRIS_1 trisa
#define MX_UART_RX_PIN_1 0
#define MX_UART_RX_PORT_1 porta
#define MX_UART_RX_TRIS_1 trisa
#define MX_UART_FLOWEN_1 0
#define MX_UART_CTS_PIN_1 4
#define MX_UART_CTS_PORT_1 portc
#define MX_UART_CTS_TRIS_1 trisc
#define MX_UART_RTS_PIN_1 0
#define MX_UART_RTS_PORT_1 portc
#define MX_UART_RTS_TRIS_1 trisc
#define MX_UART_BAUD_1 9600
#define MX_UART_DBITS_1 8
#define MX_UART_RETURN_1 0
#define MX_UART_ECHO_1 0
#define MX_UART_INT_1 0
#else
#ifndef MX_UART_REF2
#define MX_UART_REF2
#define RS232_8_MX_UART_UREF 2
#define MX_UART_CHANNEL_2 1

50
#define MX_UART_TX_PIN_2 0
#define MX_UART_TX_PORT_2 porta
#define MX_UART_TX_TRIS_2 trisa
#define MX_UART_RX_PIN_2 0
#define MX_UART_RX_PORT_2 porta
#define MX_UART_RX_TRIS_2 trisa
#define MX_UART_FLOWEN_2 0
#define MX_UART_CTS_PIN_2 4
#define MX_UART_CTS_PORT_2 portc
#define MX_UART_CTS_TRIS_2 trisc
#define MX_UART_RTS_PIN_2 0
#define MX_UART_RTS_PORT_2 portc
#define MX_UART_RTS_TRIS_2 trisc
#define MX_UART_BAUD_2 9600
#define MX_UART_DBITS_2 8
#define MX_UART_RETURN_2 0
#define MX_UART_ECHO_2 0
#define MX_UART_INT_2 0
#else
#ifndef MX_UART_REF3
#define MX_UART_REF3
#define RS232_8_MX_UART_UREF 3
#define MX_UART_CHANNEL_3 1
#define MX_UART_TX_PIN_3 0
#define MX_UART_TX_PORT_3 porta
#define MX_UART_TX_TRIS_3 trisa
#define MX_UART_RX_PIN_3 0
#define MX_UART_RX_PORT_3 porta

51
#define MX_UART_RX_TRIS_3 trisa
#define MX_UART_FLOWEN_3 0
#define MX_UART_CTS_PIN_3 4
#define MX_UART_CTS_PORT_3 portc
#define MX_UART_CTS_TRIS_3 trisc
#define MX_UART_RTS_PIN_3 0
#define MX_UART_RTS_PORT_3 portc
#define MX_UART_RTS_TRIS_3 trisc
#define MX_UART_BAUD_3 9600
#define MX_UART_DBITS_3 8
#define MX_UART_RETURN_3 0
#define MX_UART_ECHO_3 0
#define MX_UART_INT_3 0
#else
#ifndef MX_UART_REF4
#define MX_UART_REF4
#define RS232_8_MX_UART_UREF 4
#define MX_UART_CHANNEL_4 1
#define MX_UART_TX_PIN_4 0
#define MX_UART_TX_PORT_4 porta
#define MX_UART_TX_TRIS_4 trisa
#define MX_UART_RX_PIN_4 0
#define MX_UART_RX_PORT_4 porta
#define MX_UART_RX_TRIS_4 trisa
#define MX_UART_FLOWEN_4 0
#define MX_UART_CTS_PIN_4 4
#define MX_UART_CTS_PORT_4 portc
#define MX_UART_CTS_TRIS_4 trisc

52
#define MX_UART_RTS_PIN_4 0
#define MX_UART_RTS_PORT_4 portc
#define MX_UART_RTS_TRIS_4 trisc
#define MX_UART_BAUD_4 9600
#define MX_UART_DBITS_4 8
#define MX_UART_RETURN_4 0
#define MX_UART_ECHO_4 0
#define MX_UART_INT_4 0
#endif
#endif
#endif
#endif
//LED(2): //Defines:
/**** Macro Substitutions ****
a = Unique Reference
b = LED Port Letter
c = LED Pin Number
d = LED Active Polarity
******************************/
#define LED_9__LED_PORT portc
#define LED_9__LED_TRIS trisc
#define LED_9__LED_PIN 5
#define LED_9__LED_POLE 1
//LED(2): //Macro function declarations
void FCD_LED2_LEDOn();
void FCD_LED2_LEDOff();
//ADC(0): //Macro implementations
void FCD_ADC0_SampleADC()

53
{
//unused
}
void FCD_LCDDisplay0_Start()
{
FC_CAL_Bit_Low_DDR(LCD_2__PORT0, LCD_2__TRIS0, LCD_2__BIT0);
FC_CAL_Bit_Low_DDR(LCD_2__PORT1, LCD_2__TRIS1, LCD_2__BIT1);
FC_CAL_Bit_Low_DDR(LCD_2__PORT2, LCD_2__TRIS2, LCD_2__BIT2);
FC_CAL_Bit_Low_DDR(LCD_2__PORT3, LCD_2__TRIS3, LCD_2__BIT3);
FC_CAL_Bit_Low_DDR(LCD_2__PORT4, LCD_2__TRIS4, LCD_2__RS);
FC_CAL_Bit_Low_DDR(LCD_2__PORT5, LCD_2__TRIS5, LCD_2__E);
Wdt_Delay_Ms(12);
FCD_LCDDisplay0_RawSend(0x33, 0);
Wdt_Delay_Ms(2);
FCD_LCDDisplay0_RawSend(0x33, 0);
Wdt_Delay_Ms(2);
FCD_LCDDisplay0_RawSend(0x32, 0);
Wdt_Delay_Ms(2);
FCD_LCDDisplay0_RawSend(0x2c, 0);
Wdt_Delay_Ms(2);
FCD_LCDDisplay0_RawSend(0x06, 0);
Wdt_Delay_Ms(2);
FCD_LCDDisplay0_RawSend(0x0c, 0);
Wdt_Delay_Ms(2);
//clear the display
FCD_LCDDisplay0_RawSend(0x01, 0);
Wdt_Delay_Ms(2);
FCD_LCDDisplay0_RawSend(0x02, 0);

54
Wdt_Delay_Ms(2);
}
void FCD_LCDDisplay0_Clear()
{
FCD_LCDDisplay0_RawSend(0x01, 0);
Wdt_Delay_Ms(2);
FCD_LCDDisplay0_RawSend(0x02, 0);
Wdt_Delay_Ms(2);
}
void FCD_LCDDisplay0_PrintASCII(MX_UINT8 Character)
{
FCD_LCDDisplay0_RawSend(Character, 0x10);
}
void FCD_LCDDisplay0_Command(MX_UINT8 in)
{
FCD_LCDDisplay0_RawSend(in, 0);
Wdt_Delay_Ms(2);
}
void FCD_LCDDisplay0_Cursor(MX_UINT8 x, MX_UINT8 y)
{
#if (LCD_2__ROWCNT == 1)
y=0x80;
#endif
#if (LCD_2__ROWCNT == 2)
if (y==0)
y=0x80;
else
y=0xc0;

55
#endif
#if (LCD_2__ROWCNT == 4)
if (y==0)
y=0x80;
else if (y==1)
y=0xc0;
#if (LCD_2__COLCNT == 16)
else if (y==2)
y=0x90;
else
y=0xd0;
#endif
#if (LCD_2__COLCNT == 20)
else if (y==2)
y=0x94;
else
y=0xd4;
#endif
#endif
FCD_LCDDisplay0_RawSend(y+x, 0);
Wdt_Delay_Ms(2);
}
void FCD_LCDDisplay0_PrintNumber(MX_SINT16 Number)
{
MX_SINT16 tmp_int;
MX_UINT8 tmp_byte;
if (Number < 0)
{

56
FCD_LCDDisplay0_RawSend('-', 0x10);
Number = 0 - Number;
}
tmp_int = Number;
if (Number >= 10000)
{
tmp_byte = tmp_int / 10000;
FCD_LCDDisplay0_RawSend('0' + tmp_byte, 0x10);
while (tmp_byte > 0)
{
tmp_int = tmp_int - 10000;
tmp_byte--;
}
}
if (Number >= 1000)
{
tmp_byte = tmp_int / 1000;
FCD_LCDDisplay0_RawSend('0' + tmp_byte, 0x10);
while (tmp_byte > 0)
{
tmp_int = tmp_int - 1000;
tmp_byte--;
}
}
if (Number >= 100)
{
tmp_byte = tmp_int / 100;
FCD_LCDDisplay0_RawSend('0' + tmp_byte, 0x10);

57
while (tmp_byte > 0)
{
tmp_int = tmp_int - 100;
tmp_byte--;
}
}
#if (LCD_2__ROWCNT == 2)
rowcount=40;
#endif
#if (LCD_2__ROWCNT == 4)
#if (LCD_2__COLCNT == 16)
rowcount=16;
#endif
#if (LCD_2__COLCNT == 20)
rowcount=20;
#endif
#endif
//Start at beginning of the line
FCD_LCDDisplay0_Cursor (0, Line);
//Send out spaces to clear line
for (count = 0; count < rowcount; count++)
FCD_LCDDisplay0_RawSend(' ', 0x10);
//Move back to the beginning of the line.
FCD_LCDDisplay0_Cursor (0, Line)
}
void FCD_LCDDisplay0_RAM_Write(MX_UINT8 nIdx, MX_UINT8 d0, MX_UINT8 d1,
MX_UINT8 d2, MX_UINT8 d3, MX_UINT8 d4, MX_UINT8 d5, MX_UINT8 d6, MX_UINT8
d7)
{

58
//set CGRAM address
FCD_LCDDisplay0_RawSend(64 + (nIdx << 3), 0);
delay_ms(2);
//write CGRAM data
FCD_LCDDisplay0_RawSend(d0, 0x10);
FCD_LCDDisplay0_RawSend(d1, 0x10);
FCD_LCDDisplay0_RawSend(d2, 0x10);
FCD_LCDDisplay0_RawSend(d3, 0x10);
FCD_LCDDisplay0_RawSend(d4, 0x10);
FCD_LCDDisplay0_RawSend(d5, 0x10);
FCD_LCDDisplay0_RawSend(d6, 0x10);
FCD_LCDDisplay0_RawSend(d7, 0x10);
//Clear the display
FCD_LCDDisplay0_RawSend(0x01, 0);
delay_ms(2);
FCD_LCDDisplay0_RawSend(0x02, 0);
delay_ms(2);
}
//LED(0): //Macro implementations
void FCD_LED0_LEDOn()
{
#if( LED_3__LED_POLE == 1)
//Active high polarity
FC_CAL_Bit_High_DDR( LED_3__LED_PORT , LED_3__LED_TRIS , LED_3__LED_PIN );
#else
//Active low polarity
FC_CAL_Bit_Low_DDR( LED_3__LED_PORT , LED_3__LED_TRIS , LED_3__LED_PIN );
#endif
}

59
void FCD_LED0_LEDOff()
{
#if( LED_3__LED_POLE == 1)
//Active high polarity
FC_CAL_Bit_Low_DDR( LED_3__LED_PORT , LED_3__LED_TRIS , LED_3__LED_PIN
);
#else
//Active low polarity
FC_CAL_Bit_High_DDR( LED_3__LED_PORT , LED_3__LED_TRIS , LED_3__LED_PIN );
#endif
}
//LED(1): //Macro implementations
void FCD_LED1_LEDOn()
{
#if( LED_4__LED_POLE == 1)
//Active high polarity
FC_CAL_Bit_High_DDR( LED_4__LED_PORT , LED_4__LED_TRIS , LED_4__LED_PIN );
#else
//Active low polarity
FC_CAL_Bit_Low_DDR( LED_4__LED_PORT , LED_4__LED_TRIS , LED_4__LED_PIN );
#endif
}
void FCD_LED1_LEDOff()
{
#if( LED_4__LED_POLE == 1)
//Active high polarity
FC_CAL_Bit_Low_DDR( LED_4__LED_PORT , LED_4__LED_TRIS , LED_4__LED_PIN
);
#else
//Active low polarity
FC_CAL_Bit_High_DDR( LED_4__LED_PORT , LED_4__LED_TRIS , LED_4__LED_PIN );

60
#endif
}
//SWITCH(0): //Macro implementations
MX_UINT8 FCD_SWITCH0_ReadState()
{
MX_UINT8 switchval, old_switchval;
#if Switch_5_SW_DELAY > 0
MX_UINT16 del_count = 0;
#endif
FC_CAL_Bit_In_DDR( Switch_5_SW_PORT , Switch_5_SW_TRIS , Switch_5_SW_PIN );
switchval = FC_CAL_Bit_In( Switch_5_SW_PORT , Switch_5_SW_PIN );
//Convert pin to input
old_switchval = switchval;
#if Switch_5_SW_DELAY > 0
while (del_count < Switch_5_SW_DELAY)
//Debounce input
{
delay_us(1);
FC_CAL_Bit_In_DDR( Switch_5_SW_PORT , Switch_5_SW_TRIS , Switch_5_SW_PIN );
switchval = FC_CAL_Bit_In( Switch_5_SW_PORT , Switch_5_SW_PIN );
//Sample input
if (switchval == old_switchval) //Is
switch the same state?
del_count = del_count + 1; //Increment
counter
else
del_count = 0; //Else
reset counter
old_switchval = switchval;
//Update the old state
}

61
#endif
#if Switch_5_SW_POLE == 0
if (switchval)
//Invert logic if required
switchval = 0;
else
switchval = 1;
#endif
return (switchval);
//Return state of switch as least significant bit
}
void FCD_SWITCH0_WaitUntilHigh()
{
MX_UINT8 switchval, old_switchval;
#if Switch_5_SW_DELAY > 0
MX_UINT16 del_count = 0;
#endif
//Call Component Macro
//Call Component Macro: SW=ReadState()
FCV_SW = FCD_SWITCH0_ReadState();
//Call Component Macro
//Call Component Macro: SW1=ReadState()
FCV_SW1 = FCD_SWITCH1_ReadState();
//Decision
//Decision: SW = 0?
if (FCV_SW == 0)
{
//Calculation
//Calculation:

62
// CON = 1
FCV_CON = 1;
} else {

//Decision
//Decision: SW1 = 0?
if (FCV_SW1 == 0)
{
//Calculation
//Calculation:
// CON1 = 1
FCV_CON1 = 1;
// } else {
}
}
//Decision
//Decision: CON1 = 1?
if (FCV_CON1 == 1)
{
//Call Component Macro
//Call Component Macro: Cursor(0, 1)
FCD_LCDDisplay0_Cursor(0, 1);
//Decision
//Decision: SEC = 1?
if (FCV_SEC == 1)
{
//Call Component Macro
//Call Component Macro: LEDOff()

63
FCD_LED0_LEDOff();

} else {
//Call Component Macro
//Call Component Macro: LEDOn()
FCD_LED0_LEDOn();
}
//Call Component Macro
//Call Component Macro: PrintString("TIME:")
FCD_LCDDisplay0_PrintString("TIME:", 5);
//Call Component Macro
//Call Component Macro: PrintNumber(NUM1)
FCD_LCDDisplay0_PrintNumber(FCV_NUM1);
//Call Component Macro
//Call Component Macro: PrintString(" ")
FCD_LCDDisplay0_PrintString(" ", 1);
//Calculation
//Calculation:
// NUM1 = NUM1 - 1
FCV_NUM1 = FCV_NUM1 - 1;
//Delay
//Delay: 1 s
delay_s(1);
//Decision
//Decision: NUM1 = 0?
if (FCV_NUM1 == 0)
{
//Decision

64
//Decision: SEC = 1?
if (FCV_SEC == 1)
{
//Calculation
//Calculation:
// SEC = 0
// CON1 = 0
// NUM1 = 15
FCV_SEC = 0;
FCV_CON1 = 0;
FCV_NUM1 = 15;
//Call Component Macro
//Call Component Macro: LEDOff()
FCD_LED1_LEDOff();
//Call Component Macro
//Call Component Macro: LEDOff()
FCD_LED0_LEDOff();
//Call Component Macro
//Call Component Macro: ClearLine(1)
FCD_LCDDisplay0_ClearLine(1);
//Delay
//Delay: 1 s
delay_s(1);
//Goto Connection Point
//Goto Connection Point: [A]: A
goto FCC_Main_A;
// } else {
}

65
//Call Component Macro
//Call Component Macro: PrintString("TIME:")
FCD_LCDDisplay0_PrintString("TIME:", 5);
//Call Component Macro
//Call Component Macro: PrintNumber(NUM)
FCD_LCDDisplay0_PrintNumber(FCV_NUM);
//Call Component Macro
//Call Component Macro: PrintString(" ")
FCD_LCDDisplay0_PrintString(" ", 1);
//Calculation
//Calculation:
// NUM = NUM - 1
FCV_NUM = FCV_NUM - 1;
//Delay
//Delay: 1 s
delay_s(1);
//Decision
//Decision: NUM = 0?
if (FCV_NUM == 0)
{
//Decision
//Decision: SEC = 1?
if (FCV_SEC == 1)
{
//Calculation
//Calculation:
// SEC = 0
// CON = 0

66
// NUM = 10
FCV_SEC = 0;
FCV_CON = 0;
FCV_NUM = 10;
//Call Component Macro
//Call Component Macro: LEDOff()
FCD_LED1_LEDOff();
//Call Component Macro
//Call Component Macro: LEDOff()
FCD_LED0_LEDOff();
//Call Component Macro
//Call Component Macro: ClearLine(1)
FCD_LCDDisplay0_ClearLine(1);
//Delay
//Delay: 1 s
delay_s(1);
//Goto Connection Point
//Goto Connection Point: [A]: A
goto FCC_Main_A;
// } else {
}
//Calculation
//Calculation:
// NUM = 10
// SEC = 1
FCV_NUM = 10;
FCV_SEC = 1;
//Call Component Macro

67
//Call Component Macro: LEDOn()
FCD_LED1_LEDOn();

//Call Component Macro


//Call Component Macro: LEDOff()
FCD_LED0_LEDOff();
// } else {
}
// } else {
}
//Call Component Macro
//Call Component Macro: Cursor(0, 0)
FCD_LCDDisplay0_Cursor(0, 0);
//Call Component Macro
//Call Component Macro: PrintString("Solar panel:")
FCD_LCDDisplay0_PrintString("Solar panel:", 3);
//Call Component Macro
//Call Component Macro: PrintNumber(0)
FCD_LCDDisplay0_PrintNumber(0);
} else {
//Call Component Macro
//Call Component Macro: Cursor(0, 0)
FCD_LCDDisplay0_Cursor(0, 0);
//Call Component Macro
//Call Component Macro: PrintString(":")
FCD_LCDDisplay0_PrintString("TNEB:", 3);
//Call Component Macro
//Call Component Macro: PrintNumber(dis)

68
FCD_LCDDisplay0_PrintNumber(FCV_DIS);
}
//Call Component Macro
//Call Component Macro: PrintString(" ")
FCD_LCDDisplay0_PrintString(" ", 1);
//Decision
//Decision: adc > 825?
if (FCV_ADC > 825)
{
//Call Component Macro
//Call Component Macro: Clear()
FCD_LCDDisplay0_Clear();
//Call Component Macro
//Call Component Macro: Cursor(0, 0)
FCD_LCDDisplay0_Cursor(0, 0);
//Delay
//Delay: 500 ms
delay_ms(255);
delay_ms(245);
//Call Component Macro
//Call Component Macro: SendRS232Char(26)
FCD_RS2320_SendRS232Char(26);
//Delay
//Delay: 1 s
delay_s(1);
//Loop
//Loop: While 1
while (1)

69
{
}
// } else {
}
}
mainendloop: goto mainendloop;
}
void MX_INTERRUPT_MACRO(void)
{
}

70
REFERENCES:

[1] A.A.Salam, A.Mohamed and A.Hannan, “Technical challenges on microgrids" ARPN


Journal of engineering and applied sciences, Vol.3, No.6, December 2008.

[2] B. Delfino and F. Fornari, “Modeling and Control of an Integrated Fuel Cell-Wind
Turbine System,” in Proc. 2003 IEEE Bologna Power Tech Conf., pp. 23-26.

[3] A. Rowe and X. Li, “Mathematical Modeling of Proton Exchange Membrane Fuel
Cells,” Journal of Power Sources, pp. 82-96, 2001.

[4] S. M. Shaahid and M. A. Elhadidy, “Technical and Economic Assessment of Grid


independent Hybrid Photovoltaic-DieselBattery Power Systems for Commercial Loads in
Desert Environments,” Renewable and Sustainable Energy Reviews, vol. 11, pp. 1794-
1810, Oct. 2007.

[5] O. Ulleberg, "Stand-alone Power Systems for the Future: Optimal Design, Operation
and Control of Solar-Hydrogen Energy Systems," Ph.D. dissertation, Norwegian
University of Science and Technology, 1997.

[6] K. Sapru, N. T. Stetson, and S. R. Ovshinsky, "Development of a Small Scale


Hydrogen Production Storage System for Hydrogen Applications," in Proc. 1997 the
32nd Intersociety Conf., vol. 3, pp. 1947-1952.

[7] M. J. Khan and M. T. Iqbal, “Dynamic Modeling and Simulation of a Small


WindFuel Cell Hybrid Energy System,” Renewable Energy, pp. 421-439, 2005.

[8] D. B. Nelson, M. H. Nehrir, and C. Wang, “Unit Sizing and Cost Analysis of Stand
Alone Hybrid Wind/PV/FC Power Systems,” Renewable Energy, pp. 1641-1656, 2006.

[9] B. C. Kuo, Automatic control systems, 7th ed. New York: Prentice Hall Inc, 1995.

[10] Hung-Cheng Chen, Jian-Cong Qiu, and ChiaHao Liu “Dynamic Modeling and
Simulation of Renewable Energy Based Hybrid Power Systems,” DRPT, April 2008, pp.
2803-2809.

71
[11] Takyin Taky Chan, “Transient analysis of integrated solar/diesel hybrid power
system using MATLAB Simulink,” School of Electrical Engineering, Victoria
University.

[12] Guangming LI, Yuanrui CHEN, Tao LI “The Realization of Control Subsystem in
the Energy Management of Wind/Solar Hybrid Power System,” 3rd International
Conference on Power Electronics Systems and Applications, 2009.

[13] Caisheng Wang, M.Hashem Nehrir, "Power Management of a standalone


Wind/PV/FC energy system," IEEE transactions on energy conversion, Vol.23, No.3,
September 2008.

72

Вам также может понравиться