Académique Documents
Professionnel Documents
Culture Documents
A Project report Submitted in partial fulfillment of the requirement for the award of the degree of
BACHELOR OF TECHNOLOGY in
2012-2013
DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING SWARNANDHRA ENGINEERING COLLEGE (Approved by AICTE, Affiliated to JNTU Kakinada) PALAKOL ROAD, NARSAPUR -- 534 275, West Godavari Dt., A.P.
1|Page
SWARNANDHRA ENGINEERING COLLEGE (Approved by AICTE, Affiliated to JNTUK, Kakinada) PALAKOL ROAD, NARSAPUR -- 534 275, West Godavari Dt., A.P. DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING BONAFIED CERTIFICATE
BASED
is the bonafied Work Submitted by in partial fulfillment of the requirement for the award of the degree of BACHELOR OF TECHNOLOGY in ELECTRONICS & COMMUNICATION ENGINEERING
SOLAR
TRACKER
Internal Guide
External Examiner
2|Page
ACKNOWLEDGEMENT
W e e x p r e s s o u r d e e p s e n s e o f g r a t i t u d e t o Ms. N.V.P. LAKSHMI ASST.PROF, for her constant guidance throughout our mini project work.
We are grateful to Mr. A. KARNA RAO for his valuable suggestions and guidance given by him during the execution of this mini project work.
We
would
like
to
thank V.V.S.NAIDU,
Head
of
the Department
First of all we are highly indebted to PROF. G. JAGADESH KUMAR, Principal for giving us the permission to carry out this mini project.
We express our heartfelt thanks to S.RAMESH BABU, secretary & correspondent, SWARNANDHRA ENGINEERING COLLEGE, Narsapur, for giving us the opportunity for the successful completion of this project.
We would like to thank the Teaching & Non-teaching s t a f f of ECE department, SWARNANDHRA ENGINEERING COLLEGE for sharing their knowledge with us.
We acknowledge with gratitude the unflagging support and patience of our Parents for their guidance and encouragement during this dissertation work. With Sincere Regards
3|Page
ABSTRACT
Solar energy is rapidly gaining notoriety as an important means of expanding renewable energy resources. As such, it is vital that those in engineering fields understand the technologies associated with this area. In remote areas the sun is a cheap source of electricity because instead of hydraulic generators it uses solar cells to produce electricity. While the output of solar cells depends on the intensity of sunlight and the angle of incidence. This project includes the design and construction of a microcontroller-based solar panel tracking system. Solar tracking allows more energy to be produced because the solar array is able to remain aligned to the sun. This system builds upon topics learned in this course. To make solar energy more viable, the efficiency of solar array systems must be maximized. A feasible approach for maximizing the efficiency of solar array systems is sun tracking. This is a system that controls the movement of a solar array so that it is constantly aligned towards the direction of the sun. Solar modules are devices that cleanly convert sunlight into electricity and offer a practical solution to the problem of power generation in remote areas. The solar tracker designed and constructed in this project offers a reliable and affordable method of aligning a solar module with the sun in order to maximize its energy output. Automatic Sun Tracking System is a hybrid hardware/software prototype, which automatically provides best alignment of solar panel with the sun, to get maximum output (electricity) ideate the design. Problems and possible improvements will also be presented
4|Page
ABSTRACT
Solar energy is rapidly gaining notoriety as an important means of expanding renewable energy resources. As such, it is vital that those in engineering fields understand the technologies associated with this area. In remote areas the sun is a cheap source of electricity because instead of hydraulic generators it uses solar cells to produce electricity. While the output of solar cells depends on the intensity of sunlight and the angle of incidence. This project includes the design and construction of a microcontroller-based solar panel tracking system. Solar tracking allows more energy to be produced because the solar array is able to remain aligned to the sun. This system builds upon topics learned in this course. To make solar energy more viable, the efficiency of solar array systems must be maximized. A feasible approach for maximizing the efficiency of solar array systems is sun tracking. This is a system that controls the movement of a solar array so that it is constantly aligned towards the direction of the sun. Solar modules are devices that cleanly convert sunlight into electricity and offer a practical solution to the problem of power generation in remote areas. The solar tracker designed and constructed in this project offers a reliable and affordable method of aligning a solar module with the sun in order to maximize its energy output. Automatic Sun Tracking System is a hybrid hardware/software prototype, which automatically provides best alignment of solar panel with the sun, to get maximum output (electricity) ideate the design. Problems and possible improvements will also be presented
5|Page
TABLE OF CONTENTS
TITLE Acknowledgment Abstract List of Figures List of Tables CHAPTER 1: INTRODUCTION CHAPTER 2: PROJECT OVERVIEW
2.1 Objective 2.2 Block Diagram Explanation 2.3 Micro Controller 2.4 Power Supply 2.5 Relay 2.6 Sensor
PAGE NO.
3.3.1 Types Of Rectifiers 3.3.2 Full-Wave Rectifier 3.3.3 Bridge Rectifier 3.4 Filter 3.4.1 Capacitor Filter 3.5 Regulator 3.5.1 78xx 3.5.2features 3.6 LDR
CHAPTER 4. MICROCONTROLLER
4.1 Introduction 4.2 Introduction To 8051microcontroller 4.3 Introduction To Atmel Microcontroller 4.4 Memory Organization 4.4.1 Program Memory 4.4.2 Data Memory 4.5 Registers 4.5.1 Sfrs (Special Function Registers) 4.5.2 Sbuf Register 4.5.3 Scon (Serial Control) Register 4.6 Pin Description
7|Page
4.5 Timers 4.5.1 Basic Registers Of The Timer 4.5.2 Timer 0 Registers 4.5.3 Timer 1 Registers1 4.5.4 Tmod (Timer Mode) Register 4.5.5 Tcon Register 4.7 Interrupts 4.7.1 Six Interrupts In The 8051 4.8 8051/52 Interrupt Priority Upon Reset
8|Page
6.1.1 Crystalline Silicon Modules 6.1.2 Thin-Film Modules 6.1.3 Rigid Thin-Film Modules 6.1.4 Flexible Thin-Film Modules 6.1.5 Module Embedded Electronics 6.1.6 Module Performance And Lifetime 6.2 Turn Over 6.2.1 Top Ten Producers 6.2.2 Price
CHAPTER 8. STANDARDS
8.1 Devices With Photovoltaic Modules
Embedded C Coding
9|Page
CHAPTER 1 INTRODUCTION
Energy is the primary and most universal measure of all kinds of work by human beings and the energy is directly proportional to the progress of the mankind. With ever growing population, improvement in the living standard of the humanity, industrialization of the developing countries, the global demand for energy increases day by day. The primary source of energy is fossil fuel, however the finiteness of fossil fuel resources and large scale environmental degradation caused by their widespread use, particularly global warming, urban air pollution and acid rain, strongly suggests that harnessing of nonconventional, renewal and environmental friendly
10 | P a g e
As the sources of conventional energy deplete day by day, resorting to alternative sources of energy like solar and wind energy has become need of the hour. Solar powered lighting systems are already available in rural as well as urban areas. These include solar lanterns, solar home lightning system, solar street lights, solar garden lights and solar power packs. All of them consist of four components; solar photovoltaic module, rechargeable battery, solar charge controller and load. In the solar powered lightning systems, the solar charge controller plays an important role as the systems overall success depends mainly on it. It is considered as an indispensible link between the solar panel, battery and load.
11 | P a g e
CHAPTER 2 OVERVIEW
2.1 OBJECTIVE: The main aim of this embedded application is to design a data acquisition using Solar Panel and AT89c51 Micro controller.
LCD UNIT
LDR AT89C51/s52
L293D
DC
Figure2.1:Block diagram
MOTOR
2.2 BLOCK DIAGRAM EXPLINATION In the above block diagram we can see the block of LDR, MICRO CONTROLLER, relay and POWER SUPPLY. Let us discuses about each block in detail.
12 | P a g e
2.3 MICRO CONTROLLER In this project work the micro-controller is plays major role. Micro-
controllers were originally used as components in complicated process-control systems. However, because of their small size and low price, Micro-controllers are now also being used in regulators for individual control loops. In several areas Micro-controllers are
now outperforming their analog counterparts and are cheaper as well. 2.4 POWER SUPPLY A variable regulated power supply, also called a variable bench power supply, is one where you can continuously adjust the output voltage to your requirements. Varying the output of the power supply is the recommended way to test a project after having double checked parts placement against circuit drawings and the parts placement guide. This type of regulation is ideal for having a simple variable bench power supply. Actually this is quite important because one of the first projects a hobbyist should undertake is the construction of a variable regulated power supply. While a dedicated supply is quite handy e.g. 5V or 12V, it's much handier to have a variable supply on hand, especially for testing. Most digital logic circuits and processors need a 5 volt power supply. To use these parts we need to build a regulated 5 volt source. Usually you start with an unregulated power supply ranging from 9 volts to 24 volts DC (A 12 volt power supply is included with the Beginner Kit and the Microcontroller Beginner Kit). To make a 5 volt power supply, we use a LM7805 voltage regulator IC. The LM7805 is simple to use. You simply connect the positive lead of your unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative lead to the Common pin and then when you turn on the power, you get a 5 volt supply from the Output pin. 2.5 RELAY A relay is an electrically operated switch. Many relays use an electromagnet to operate a switching mechanism, but other operating principles are also used. Relays find applications
13 | P a g e
where it is necessary to control a circuit by a low-power signal, or where several circuits must be controlled by one signal. The first relays were used in long distance telegraph circuits, repeating the signal coming in from one circuit and re-transmitting it to another 2.6 SENSOR: LDRs or Light Dependent Resistors are very useful especially in light/dark sensor circuits. Normally the resistance of an LDR is very high, sometimes as high as 1000 000 ohms, but when they are illuminated with light resistance drops dramatically.
14 | P a g e
The power supplies are designed to convert high voltage AC mains electricity to a suitable low voltage supply for electronics circuits and other devices. A power supply can by broken down into a series of blocks, each of which performs a particular function. A d.c power supply which maintains the output voltage constant irrespective of a.c mains fluctuations or load variations is known as Regulated D.C Power Supply 3.2 TRANSFORMER: A transformer is an electrical device which is used to convert electrical power from one electrical circuit to another without change in frequency. Transformers convert AC electricity from one voltage to another with little loss of power. Transformers work only with AC and this is one of the reasons why mains electricity is AC. Step-up transformers increase in output voltage, step-down transformers decrease in output voltage. Most power supplies use a step-down transformer to reduce the dangerously high mains voltage to a safer low voltage. The input coil is called the primary and the output coil is called the secondary. There is no electrical connection between the two coils; instead they are linked by an alternating magnetic field created in the soft-iron core of the transformer. The two lines in the middle of the circuit symbol represent the core. Transformers waste very little power so the
power out is (almost) equal to the power in. Note that as voltage is stepped down current is stepped up. The ratio of the number of turns on each coil, called the turns ratio, determines the ratio of the voltages. A step-down transformer has a large number of turns on its primary (input) coil which is connected to the high voltage mains supply, and a small number of turns on its secondary (output) coil to give a low output voltage.
15 | P a g e
3.3 RECTIFIER: A circuit which is used to convert a.c to dc is known as RECTIFIER. The process of conversion a.c to d.c is called rectification
3.3.1 TYPES OF RECTIFIERS: Half wave Rectifier Full wave rectifier 1. Centre tap full wave rectifier. 2. Bridge type full bridge rectifier. 3.3.2 Full-wave Rectifier: From the above comparison we came to know that full wave bridge rectifier as more advantages than the other two rectifiers. So, in our project we are using full wave bridge rectifier circuit. 3.3 Bridge Rectifier: A bridge rectifier makes use of four diodes in a bridge arrangement to achieve full-wave rectification. This is a widely used configuration, both with individual diodes wired as shown and with single component bridges where the diode bridge is wiredinternally.
16 | P a g e
Figure 3.1 Bridge Rectifier 3.4 Filter: A Filter is a device which removes the a.c component of rectifier output but allows the d.c component to reach the load
3.4.1 Capacitor Filter: We have seen that the ripple content in the rectified output of half wave rectifier is 121% or that of full-wave or bridge rectifier or bridge rectifier is 48% such high percentages of ripples is not acceptable for most of the applications. Ripples can be removed by one of the following methods of filtering.
(a) A capacitor, in parallel to the load, provides an easier by pass for the ripples voltage though it due to low impedance. At ripple frequency and leave the d.c.to appears the load.
17 | P a g e
(b) An inductor, in series with the load, prevents the passage of the ripple current (due to high impedance at ripple frequency) while allowing the d.c (due to low resistance to d.c)
section filter,
multiple section filter etc. which make use of both the properties mentioned in (a) and (b) above. Two cases of capacitor filter, one applied on half wave rectifier and another with full wave rectifier. Filtering is performed by a large value electrolytic capacitor connected across the DC supply to act as a reservoir, supplying current to the output when the varying DC voltage from the rectifier is falling. The capacitor charges quickly near the peak of the varying DC, and then discharges as it supplies current to the output. Filtering significantly increases the average DC voltage to almost the peak value (1.4 RMS value).
3.5 Regulator: Voltage regulator ICs is available with fixed (typically 5, 12 and 15V) or variable output voltages. The maximum current they can pass also rates them. Negative voltage regulators are available, mainly for use in dual supplies. Most regulators include some automatic protection from excessive current ('overload protection') and overheating ('thermal protection'). Many of the fixed voltage regulator ICs have 3 leads and look like power transistors, such as the 7805 +5V 1A regulator shown on the right. The LM7805 is simple to use. You simply connect the positive lead of your unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative lead to the Common pin and then when you turn on the power, you get a 5 volt supply from the output pin.
18 | P a g e
3.5.1 78XX: The Bay Linear LM78XX is integrated linear positive regulator with three terminals. The LM78XX offer several fixed output voltages making them useful in wide range of applications. When used as a zener diode/resistor combination replacement, the LM78XX usually results in an effective output impedance improvement of two orders of magnitude, lower quiescent current. The LM78XX is available in the TO-252, TO-220 & TO-263packages,
3.5.2 Features: Output Current of 1.5A Output Voltage Tolerance of 5% Internal thermal overload protection Internal Short-Circuit Limited No External Component Output Voltage 5.0V, 6V, 8V, 9V, 10V,12V, 15V, 18V, 24V Offer in plastic TO-252, TO-220 & TO-263 Direct Replacement for LM78XX
19 | P a g e
3.6 LDR: LDRs or Light Dependent Resistors are very useful especially in light/dark sensor circuits. Normally the resistance of an LDR is very high, sometimes as high as 1000 000 ohms, but when they are illuminated with light resistance drops dramatically. The animation opposite shows that when the torch is turned on, the resistance of the LDR falls, allowing current to pass through it. An LDR (Light dependent resistor), as its name suggests, offers resistance in response to the ambient light. The resistance decreases as the intensity of incident light increases, and vice versa. In the absence of light, LDR exhibits a resistance of the order of mega-ohms which decreases to few hundred ohms in the presence of light. It can act as a sensor, since a varying voltage drop can be obtained in accordance with the varying light. It is made up of cadmium sulphide (CdS). An LDR has a zigzag cadmium sulphide track. It is a bilateral device, i.e., conducts in both directions in same fashion. When a light level of 1000 lux (bright light) is directed towards it, the resistance is 400R (ohms).When a light level of 10 lux (very low light level) is directed towards it, the resistance has risen dramatically to 10.43M (10430000 ohms). This is an example of a light sensor circuit : When the light level is low the resistance of the LDR is high. This prevents current from flowing to the base of the transistors. Consequently the LED does not light. However, when light shines onto the LDR its resistance falls and current flows into the base of the first transistor and then the second transistor. The LED lights. The preset resistor can be turned up or down to increase or decrease resistance, in this way it can make the circuit more or less sensitive.
20 | P a g e
CHAPTER 4 MICROCONTROLLER
4.1 INTRODUCTION:
A Micro controller consists of a powerful CPU tightly coupled with memory RAM, ROM or EPROM), various I / O features such as Serial ports, Parallel Ports, Timer/Counters, Interrupt Controller, Data Acquisition interfaces-Analog to Digital Converter (ADC), Digital to Analog Converter (ADC), everything integrated onto a single Silicon Chip. It does not mean that any micro controller should have all the above said features on chip, Depending on the need and area of application for which it is designed, The ON-CHIP features present in it may or may not include all the individual section said above. Any microcomputer system requires memory to store a sequence of instructions making up a program, parallel port or serial port for communicating with an external system, timer / counter for control purposes like generating time delays, Baud rate for the serial port, apart from the controlling unit called the Central Processing Unit.
In 1981,Intel corporation introduced an 8 bit microcontroller called the 8051.This microcontroller had 128 bytes of RAM,4K bytes of on-chip ROM, two timers, one serial port and 4 ports(each 8-bits wide)all on single chip. At that time it was also referred to as a system on a chip.
21 | P a g e
The major Features of 8-bit Micro controller ATMEL 89C51: 8 Bit CPU optimized for control applications Extensive Boolean processing (Single - bit Logic) Capabilities. On - Chip Flash Program Memory On - Chip Data RAM Bi-directional and Individually Addressable I/O Lines Multiple 16-Bit Timer/Counters Full Duplex UART Multiple Source / Vector / Priority Interrupt Structure On - Chip Oscillator and Clock circuitry. On - Chip EEPROM One Serial communication port
Block Diagram
The P89C51 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, two 16-bit timer/counters, five vector two-level interrupt architecture, a full duplex serial port, and on-chip oscillator and clock circuitry. In addition, the P89C51 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and interrupt system to continue functioning. The Power-down Mode saves the RAM contents but freezes the oscillator disabling all other chip functions until the next hardware reset.
23 | P a g e
Internal data memory addresses are always 1 byte wide, which implies an address space of only 256bytes. However, the addressing modes for internal RAM can infact accommodate 384 bytes. Direct addresses higher than 7FH access one memory space and indirect addresses higher than 7FH access a different memory space. Thus, Figure.7 shows the Upper 128 and SFR space occupying the same block of addresses, 80H through FFH, although they are physically separate entities. The lowest 32 bytes are grouped into 4 banks of 8 registers. Program instructions call out these registers as R0 through R7.
The next 16 bytes above the register banks form a block of bit-addressable memory space. The microcontroller instruction set includes a wide selection of single-bit instructions, and these instructions can directly address the 128 bits in this area. These bit addresses are 00H through 7FH. All of the bytes in the Lower 128 can be accessed by either direct or indirect addressing.
4.5 REGISTERS:
In the CPU, registers are used to store information temporarily. That information could be a byte of data to be processed, or an address pointing to the data to be fetched. The vast majority of 8051 registers are 8bit registers. In the 8051 there is only one data type: 8bits. The 8bits of a register are should in the diagram from the MSB (most significant bit) D7 to the LSB (least significant bit) D0. With an 8-bit data type, any data larger than 8bits must be broken into 8-bit chunks before it is processed.
D7 D6 D5 D4 D3 D2 D1 D0
The most widely used registers of the 8051 are A(accumulator), B, R0, R1, R2, R3, R4, R5, R6, R7, DPTR(data pointer), and PC(program counter). All of the above registers are 8-bits, except DPTR and the program counter. The accumulator, register A, is used for all arithmetic and logic instructions.
24 | P a g e
The moment a byte is written into SBUF, it is framed with the start and stop bits and transferred serially via the TXD pin. Similarly, when the bits are received serially via RXD, the 8051 defames it by eliminating the stop and start bits, making a byte out of the data received, and then placing it in the SBUF.
25 | P a g e
The SCON register is an 8-bit register used to program the start bit, stop bit, and data bits of data framing, among other things. The following describes various bits of the SCON register.
Serial port mode specifier Serial port mode specifier Used for multiprocessor communication. (make it 0.) Set/cleared by software to enable/disable reception Not widely used Not widely used Transmit interrupt flag. Set by hardware at the beginning Of the stop bit in mode 1. Must be cleared by software.
RI
SCON.0
Receive interrupt flag. Set by hardware halfway through the stop bit time mode 1. Must be cleared by software.
Note: Make SM2, TB8, and RB8=0. SM0, SM1 SM0 and SM1 are D7 and D6 of the SCON register, respectively. These two bits determine the framing of data by specifying the number of bits per character and the start and stop bits. They take the following combinations.
26 | P a g e
SM0 0 0 1 1
SM1 0 1 0 1
FUNCTION
Serial Mode 0 Serial Mode 1, 8-bit data, 1 stop bit, 1 start bit Serial Mode 2 Serial Mode 3
In the 4 serial modes, only mode 1 is of interest to us. In the SCON register, when serial mode 1 is chosen, the data framing is 8 bits, 1 stop bit, and 1 start bit, which makes it compatible with the COM port of IBM/compatible PCs. More importantly, serial mode 1 allows the baud rate to be variable and is set by Timer 1 of the 8051. In serial mode 1, for each character a total of 10 bits are transferred, where the first bit is the start bit, followed by 8 bits of data, and finally 1 stop bit.
27 | P a g e
PIN CONFIGURATION:
Ports 0, 1, 2 and 3
As shown in pin diagram, the four ports P0, P1, P2, and P3 each use of 8 pins, making the 8-bit ports. All the ports upon Reset are configured as input, since P0-P3 have FFH on them.
28 | P a g e
Port 0
Port 0 occupies a total of 8 pins (pins 32-33). It can be used for input or output. Port0 is also designated as AD0-AD7, allowing it to be used for both address and data. When connecting an 8051/31 to an external memory, port 0 provides both address and data. The 8051 multiplexes address and data through port 0 to save pins. ALE=0, it provides data D0D7, but when ALE=1, it has address A0-A7. Therefore, ALE is used for demultiplexing address address and data with the help of a 74LS373 latch. In the 8051-based systems where there is no external memory connection, the pins of P0 must be connected externally to a 10k ohm pull-up resistor. This is due to the fact that P0 is an Open drain, Unlike P1, P2, P3. Open drain is a term used for Mos chips in the same way that open collector is used for TTL chips. In many systems usig the 8751, 89C51, or DS89C4x0 chips, we normally connect P0 to pull-up resistors. With external pull-up resistors connected to P0, it can be used as a simple I/O port, just like P1 and P2. In contrast to Port 0, ports p1, p2, and p3 do not need any pull-up resistors since they already have pull-up resistors internally. Upon reset, ports p1, p2, ad p3 are configured as input ports.
Port 1
Port 1 occupies a total of 8-pins (pins1-8). It can be used as input or output. In contrast to port 0, this port does not need any pull-up resistors since it already has pull-up resistors internally. Upon reset, port1 is configured as an input port.
Port 2
Port 2 occupies a total 8 pins (pins 21-28). It can be used as input or output. However, in 8031-based systems, port2 is also designated as A8-A15, indicating its dual function. Since an 8051/31 is capable of accessing 64K bytes of external memory, it needs a path for the 16 bits of the address. While P0 provides the lower 8 bits via A0-A7, it is the job of p2 is used for the upper 8 bits of the 16-bit address, and it cannot be used for I/O. Just like P1, port 2 does not need any pull-up resistors since it already has pull-up resistors internally. Upon reset, port2 is configured as an input port.
29 | P a g e
Port 3
Port 3 occupies a total of 8 pins (pins 10-17). It can be used as input or output. P3 does not need any pull-up resistors, just as P1 and P2 did not. Although Port 3 is configured as an input port upon reset, this is not the way it is most commonly used. Port 3 has the additional function of providing some extremely important signals such as interrupts. The below table provides these alternate functions of P3. This is information applies to both 8051 and 8031 chips.
RST
Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device.
ALE/PROG
Prior to each reading from external memory, the microcontroller will set the lower address byte (A0-A7) on P0 and immediately after that activates the output ALE. Upon receiving signal from the ALE pin, the external register (74HCT373 or 74HCT375 circuit is usually embedded ) memorizes the state of P0 and uses it as an address for memory chip. In the second part of the microcontrollers machine cycle, a signal on this pin stops being emitted and P0 is used now for data transmission (Data Bus). In this way, by means of only one additional (and cheap) integrated circuit, data multiplexing from the port is performed. This port at the same time used for data and address transmission.
PSEN
Program Store Enable is the read strobe to external program memory. When the AT89C51 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory.
30 | P a g e
EA/VPP
External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming, for parts that require 12-volt VPP.
4.5 TIMERS
On-chip timing/counting facility has proved the capabilities of the microcontroller for implementing the real time application. These includes pulse counting, frequency measurement, pulse width measurement, baud rate generation, etc,. Having sufficient number of timer/counters may be a need in a certain design application. The 8051 has two timers/counters. They can be used either as timers to generate a time delay or as counters to count events happening outside the microcontroller. Let discuss how these timers are used to generate time delays and we will also discuss how they are been used as event counters.
31 | P a g e
Both Timer 0 and Timer 1 are 16 bits wide. Since the 8051 has an 8-bit architecture, each 16-bit timer is accessed as two separate registers of low byte and high byte.
The 16-bit register of Timer 0 is accessed as low byte and high byte. the low byte register is called TL0(Timer 0 low byte)and the high byte register is referred to as TH0(Timer 0 high byte).These register can be accessed like any other register, such as A,B,R0,R1,R2,etc.for example, the instruction MOV TL0, #4Fmoves the value 4FH into TL0,the low byte of Timer 0.These registers can also be read like any other register.
32 | P a g e
MSB
LSB
TF1
TR1
TF0
TR0
IE1
IT1
IE0
IT0
4.7 INTERRUPTS:
In the interrupts method, whenever any device needs its service, the device notifies the microcontroller by sending it an interrupts signal. Upon receiving an interrupt signal, the microcontroller interrupts whatever it is doing and serves the device. The program associated with the interrupts is called the interrupt service routine (ISR).or interrupt handler.
33 | P a g e
Highest to Lowest Priority External Interrupt 0 Timer Interrupt 0 External Interrupt 1 Timer Interrupt 1 Serial Communication Timer 2(8052 only) (INT0) (TF0) (INT1) (TF1) (RI+TI) TF2
34 | P a g e
35 | P a g e
36 | P a g e
37 | P a g e
Computers can transfer data in two ways: parallel and serial. In parallel data transfers, often 8 or more lines (wire conductors) are used to transfer data to a device that is only a few feet away. An example of parallel transfers a printers and hard disks; each uses cables with many wire strips. Although in such cases a lot of data can be transferred in a short amount of time by using many wires in parallel, the distance cannot be great. To transfer to a device located many meters away, the serial method is used. In serial communication, the data is sent one bit at a time, in contrast to parallel communication, in which the data is sent a byte or more at a time. Serial communication of the 8051 is the topic of this chapter. The 8051 has serial communication capability built into it, there by making possible fast data transfer using only a few wires.
If data is to be transferred on the telephone line, it must be converted from 0s and 1s to audio tones, which are sinusoidal-shaped signals. This conversion is performed by a peripheral device called a modem, which stands for modulator/demodulator. Serial data communication uses two methods, asynchronous and synchronous. The synchronous method transfers a block of data at a time, while the asynchronous method transfers a single byte at a time. In data transmission if the data can be transmitted and received, it is a duplex transmission. This is in contrast to simplex transmissions such as with printers, in which the computer only sends data. Duplex transmissions can be half or full duplex, depending on whether or not the data transfer can be simultaneous.
38 | P a g e
asynchronous method, each character is placed between start and stop bits. This is called framing. In the data framing for asynchronous communications, the data, such as ASCII characters, are packed between a start bit and a stop bit. The start bit is always one bit, but the stop bit can be one or two bits. The start bit is always a 0 (low) and the stop bit (s) is 1 (high).
39 | P a g e
(11.0592MHz/12=921.6KHz). the 8051s serial communication UART circuitry divides the machine cycle frequency of 921.6khz divided by 32 once more before it is used by Timer 1 to set the Baud rate. Therefore, 921.6 kHz divided by 32 gives 28,800 Hz. This is the number well use to find the Timer 1 value to set baud rate. Baud rate TH1(Decimal) TH1(Hex) 9600 4800 2400 1200 -3 -6 -12 -24 FD FA F4 E8
NOTE: XTAL=11...592MHz
5.4 MAX-232:
The MAX232 from Maxim was the first IC which in one package contains the necessary drivers (two) and receivers (also two), to adapt the RS-232 signal voltage levels to TTL logic. It became popular, because it just needs one voltage (+5V) and generates the necessary RS-232 voltage levels (approx. -10V and +10V) internally. This greatly simplified the design of circuitry. Circuitry designers no longer need to design and build a power supply
40 | P a g e
with three voltages (e.g. -12V, +5V, and +12V), but could just provide one +5V power supply, e.g. with the help of a simple 78x05 voltage converter. The MAX232 has a successor, the MAX232A. The ICs are almost identical, however, the MAX232A is much more often used (and easier to get) than the original MAX232, and the MAX232A only needs external capacitors 1/10th the capacity of what the original MAX232 needs. The MAX232 and MAX232A were once rather expensive ICs, but today they are cheap. It has also helped that many companies now produce clones (ie. Sipex). The original manufacturer (and now some clone manufacturers, too) offers a large series of similar ICs, with different numbers of receivers and drivers, voltages, built-in or external capacitors, etc. E.g. The MAX232 and MAX232A need external capacitors for the internal voltage pump, while the MAX233 has these capacitors built-in. The MAX233 is also between three and ten times more expensive in electronic shops than the MAX232A because of its internal capacitors. It is also more difficult to get the MAX233 than the garden variety MAX232A.
TX and RX
There are not enough drivers/receivers in the MAX232 to also connect the DTR, DSR, and DCD signals. Usually these signals can be omitted when e.g. communicating with a PC's serial interface. If the DTE really requires these signals either a second MAX232 is needed,
41 | P a g e
or some other IC from the MAX232 family can be used (if it can be found in consumer electronic shops at all). An alternative for DTR/DSR is also given below.Maxim's data sheet explains the MAX232 family in great detail, including the pin configuration and how to connect such an IC to external circuitry. This information can be used as-is in own design to get a working RS-232 interface. Maxim's data just misses one critical piece of information: How exactly to connect the RS-232 signals to the IC. So here is one possible example In addition one can directly wire DTR (DB9 pin 4) to DSR (DB9 pin 6) without going through any circuitry. This gives automatic (brain dead) DSR acknowledgment of an incoming DTR signal. Sometimes pin 6 of the MAX232 is hard wired to DCD (DB9 pin 1). This is not recommended. Pin 6 is the raw output of the voltage pump and inverter for the -10V voltage. Drawing currents from the pin leads to a rapid breakdown of the voltage, and as a consequence to a breakdown of the output voltage of the two RS-232 drivers. It is better to use software which doesn't care about DCD, but does hardware-handshaking via CTS/RTS only. The circuitry is completed by connecting five capacitors to the IC as it follows. The MAX232 needs 1.0F capacitors, the MAX232A needs 0.1F capacitors. MAX232 clones show similar differences. It is recommended to consult the corresponding data sheet. At least 16V capacitor types should be used. If electrolytic or tantalic capacitors are used, the polarity has to be observed. The first pin as listed in the following table is always where the plus pole of the capacitor should be connected to. The 5V power supply is connected to
42 | P a g e
5.4.2Description/ordering information:
The MAX232 is a dual driver/receiver that includes a capacitive voltage generator to supply EIA-232 voltage levels from a single 5-V supply. Each receiver converts EIA-232 inputs to 5-V TTL/CMOS levels. These receivers have a typical threshold of 1.3 V and a typical hysteresis of 0.5 V, and can accept -V inputs. Each driver converts TTL/CMOS input levels into EIA-232 levels. The
driver, receiver, and voltage-generator functions are available as cells in the Texas Instruments Lin ASIC
43 | P a g e
A solar panel or photovoltaic module, is composed of individual PV cells. This crystallinesilicon panel has an aluminium frame and glass on the front.
Solar panels on the International Space Station A solar panel (also solar module, photovoltaic module or photovoltaic panel) is a packaged, connected assembly of photovoltaic cells. The solar panel can be used as a
44 | P a g e
component of a larger photovoltaic system to generate and supply electricity in commercial and residential applications. Because a single solar panel can produce only a limited amount of power, many installations contain several panels. A photovoltaic system typically includes an array of solar panels, an inverter, and sometimes a battery and interconnection wiring.
Polycrystalline PV cells connected in a solar panel. Solar panels use light energy (photons) from the sun to generate electricity through the photovoltaic effect. The structural (load carrying) member of a module can either be the top layer or the back layer. The majority of modules use wafer-based crystalline silicon cells or thin-film cells based on cadmium telluride or silicon. The conducting wires that take the current off the panels may contain silver, copper or other non-magnetic conductive transition metals. The cells must be connected electrically to one another and to the rest of the system. Cells must also be protected from mechanical damage and moisture. Most solar panels are rigid, but semi-flexible ones are available, based on thin-film cells. Electrical connections are made in series to achieve a desired output voltage and/or in parallel to provide a desired current capability. Separate diodes may be needed to avoid reverse currents, in case of partial or total shading, and at night. The p-n junctions of mono-crystalline silicon cells may have adequate reverse current characteristics that these are not necessary. Reverse currents waste power and can also lead to overheating of shaded cells. Solar cells become less efficient at higher temperatures and installers try to provide good ventilation behind solar panels.
45 | P a g e
Some recent solar panel designs include concentrators in which light is focused by lenses or mirrors onto an array of smaller cells. This enables the use of cells with a high cost per unit area (such as gallium arsenide) in a cost-effective way.[citation needed] Depending on construction, photovoltaic panels can produce electricity from a range of frequencies of light, but usually cannot cover the entire solar range (specifically, ultraviolet, infrared and low or diffused light). Hence much of the incident sunlight energy is wasted by solar panels, and they can give far higher efficiencies if illuminated with monochromatic light. Therefore, another design concept is to split the light into different wavelength ranges and direct the beams onto different cells tuned to those ranges. This has been projected to be capable of raising efficiency by 50%. Currently the best achieved sunlight conversion rate (solar panel efficiency) is around 21% in commercial products, typically lower than the efficiencies of their cells in isolation. The energy density of a solar panel is the efficiency described in terms of peak power output per unit of surface area, commonly expressed in units of watts per square foot (W/ft2). The most efficient mass-produced solar panels have energy density values of greater than 13 W/ft2 (140 W/m2).
6.1.2Thin-film modules
Third generation solar cells are advanced thin-film cells. They produce high-efficiency conversion at low cost.
46 | P a g e
If the substrate is an insulator (e.g. polyester or polyimide film) then monolithic integration can be used. If it is a conductor then another technique for electrical connection must be used. The cells are assembled into modules by laminating them to a transparent colourless fluoropolymer on the front side (typically ETFE or FEP) and a polymer suitable for bonding to the final substrate on the other side. The only commercially available (in MW quantities) flexible module uses amorphous silicon triple junction (from Unisolar). So-called inverted metamorphic (IMM) multijunction solar cells made on compoundsemiconductor technology are just becoming commercialized in July 2008. The University of Michigan's solar car that won the North American Solar Challenge in July 2008 used IMM thin-film flexible solar cells. The requirements for residential and commercial are different in that the residential needs are simple and can be packaged so that as solar cell technology progresses, the other base line equipment such as the battery, inverter and voltage sensing transfer switch still need to be compacted and unitized for residential use. Commercial use, depending on the size of the service will be limited in the photovoltaic cell arena, and more complex parabolic reflectors and solar concentrators are becoming the dominant technology. The global flexible and thin-film photovoltaic (PV) market, despite caution in the overall PV industry, is expected to experience a CAGR of over 35% to 2019, surpassing 32 GW according to a major new study by IntertechPira
47 | P a g e
Nominal voltage refers to the voltage of the battery that the module is best suited to charge; this is a leftover term from the days when solar panels were used only to charge batteries. The actual voltage output of the panel changes as lighting, temperature and load conditions change, so there is never one specific voltage at which the panel operates. Nominal voltage allows users, at a glance, to make sure the panel is compatible with a given system. Open circuit voltage or VOC is the maximum voltage that the panel can produce when not connected to an electrical circuit or system. VOC can be measured with a meter directly on an illuminated panel's terminals or on its disconnected cable. The peak power rating, kWp, is the maximum output according under standard test conditions (not the maximum possible output). Solar panels must withstand heat, cold, rain and hail for many years. Many crystalline silicon module manufacturers offer a warranty that guarantees electrical production for 10 years at 90% of rated power output and 25 years at 80%.
The "solar tree", a symbol of Gleisdorf, Austria In 2010, 15.9 GW of solar PV system installations were completed, with solar PV pricing survey and market research company PVinsights reporting growth of 117.8% in solar PV installation on a year-on-year basis. With over 100% year-on-year growth in PV system installation, PV module makers dramatically increased their shipments of solar panels in 2010. They actively expanded their capacity and turned themselves into gigawatt GW players. According to PVinsights, five of the top ten PV module companies in 2010 are GW players. Suntech, First Solar, Sharp, Yingli and Trina Solar are GW producers now, and most of them doubled their shipments in 2010.[7]
48 | P a g e
6.2.2 Price
Average pricing information divides in three pricing categories: those buying small quantities (modules of all sizes in the kilowatt range annually), mid-range buyers (typically up to 10 MWp annually), and large quantity buyers (self explanatoryand with access to the lowest prices). Over the long termand only in the long-termthere is clearly a systematic reduction in the price of cells and modules. For example in 1998 it was estimated that the quantity cost per watt was about $4.50, which was 33 times lower than the cost in 1970 of $150 Following to RMI, Balance-of-System (BoS) elements, this is, non-module cost of nonmicroinverter solar panels (as wiring, converters, racking systems and various components) make up about half of the total costs of installations. Also, standardizing technologies could encourage greater adoption of solar panels and, in turn, economies of scale
49 | P a g e
Pole mounts, which are driven directly into the ground or embedded in concrete. Foundation mounts, such as concrete slabs or poured footings Ballasted footing mounts, such as concrete or steel bases that use weight to secure the solar panel system in position and do not require ground penetration. This type of mounting system allows for decommissioning or relocation of solar panel systems with no ground excavation.
Pole mounts, which are attached directly to the roof structure and may use additional rails for attaching the panel racking or frames. Ballasted footing mounts, such as concrete or steel bases that use weight to secure the panel system in position and do not require through penetration. This mounting method allows for decommissioning or relocation of solar panel systems with no adverse effect on the roof structure.
50 | P a g e
A ground mounted A roof mounted solar A roof mounted solar solar panel system panel system installed Technicians installing panel system installed installation using using flat roof precast photovoltaic panels on on a sloped roof using precast concrete concrete ballasted a roof mounted rack. pole mounts and rails. ballasted footings. footings.
51 | P a g e
CHAPTER 8. Standards
Standards generally used in photovoltaic panels:
IEC 61215 (crystalline silicon performance), 61646 (thin film performance) and 61730 (all modules, safety) ISO 9488 Solar energyVocabulary. UL 1703 UL 1741 CE mark Electrical Safety Tester (EST) Series (EST-460, EST-22V, EST-22H, EST-110).
Solar cell phone : Sharp announced that its first solar-powered cell phone would be released in summer, 2009 Solar lamp Solar notebook: IUNIKA makes the first Solar Powered Netbook, the Gyy. Solar-pumped laser Solar vehicle Solar plane
Space stations and various spacecraft employ, or have employed photovoltaic panels to generate power.
Soyuz spacecraft International Space Station Skylab space laboratory Mir space station
52 | P a g e
KEIL SOFTWARE TOOL (STEPS) 1. 2. Click on the Keil uVision Icon on DeskTop The following fig will appear
3. 4.
Click on the Project menu from the title bar Then Click on New Project
53 | P a g e
5. Save the Project by typing suitable project name with no extension in u r own folder sited in either C:\ or D:\
6. 7. 8.
Then Click on Save button above. Select the component for u r project. i.e. Atmel Click on the + Symbol beside of Atmel
54 | P a g e
9.
10. 11.
55 | P a g e
12.
13. 14.
Now your project is ready to USE Now double click on the Target1, you would get another option
15.
Click on the file option from menu bar and select new
56 | P a g e
16.
The next screen will be as shown in next page, and just maximize it by
17. 18.
Now start writing program in either in C or ASM For a program written in Assembly, then save it with extension .
57 | P a g e
19. Source
Now right click on Source group 1 and click on Add files to Group
20. appear.
Now you will get another window, on which by default C files will
58 | P a g e
Now select as per your file extension given while saving the file Click only one time on option ADD Now Press function key F7 to compile. Any error will appear if so
24.
25.
26.
Then Click OK
27.
Now Click on the Peripherals from menu bar, and check your required
28.
60 | P a g e
29. 30.
Now keep Pressing function key F11 slowly and observe. You are running your program successfully
61 | P a g e
Click on the Keil u Vision Icon on Desktop Click on the Project menu from the title bar Then Click on New Project Save the Project by typing suitable project name with no extension in u
r own folder sited in either C:\ or D:\ 35. 36. 37. 38. 39. 40. 41. 42. Then Click on Save button above. Select the component for u r project. i.e. Atmel Click on the + Symbol beside of Atmel Select AT89C51 Then Click on OK Then Click either YES or NOmostly NO Now your project is ready to USE Now double click on the Target1, you would get another option Click on the file option from menu bar and select new The next screen will be as shown in next page, and just maximize it by Now start writing program in either in C or ASM For a program written in Assembly, then save it with extension . Now right click on Source group 1 and click on Add files to Group Now you will get another window, on which by default C files will
asm and for C based program save it with extension .C 47. Source 48. appear. 49. 50. 51. Now select as per your file extension given while saving the file Click only one time on option ADD Now Press function key F7 to compile. Any error will appear if so
happen.If the file contains no error, then press Control+F5 simultaneously. 52. 53. The new window is as follows Then Click OK
62 | P a g e
Now Click on the Peripherals from menu bar, and check your required
Drag the port a side and click in the program file. Now keep Pressing function key F11 slowly and observe. You are running your program successfully
Embedded C: Data Types: U people have already come across the word Data types in C- Language. Here also the functionality and the meaning of the word is same except a small change in the prefix of their labels. Now we will discuss some of the widely used data types for embedded Cprogramming.
Data Types unsigned char signed char unsigned int signed int sbit Bit Sfr
Data Range/Usage 0-255 -128 to +127 0 to 65535 -32,768 to +32,767 SFR bit addressable only RAM bit addressable only RAM only addresses 80-FFH
Sbit (single bit): The sbit data type is widely used and designed specifically to access single bit addressable registers. It allows access to the single bits of the SFR registers.
63 | P a g e
Flash magic :
Flash Magic is Windows software from that microcontroller is easyly programmed using In-System Programming technology to all the ISP feature empowered devices.
After installing the software when we click on the icon of the software the window will open on the screen as shown in figure. We need to change the device and have to select the device 89V51RD2 , and then we set to erase all flash option on the flash magic window.
If we need to verify the proper dumping of the program in the microcontroller then we need to set the verify after program option.
64 | P a g e
Loading of hex file : after selecting device we load the hex file in the given block by using the browse option on the FLASH MAGIC window..
Programming of device : after loading the file next step is dumping of code in microcontroller. For that we first connect the computers serial port to your controller board through serial cable. Then after give the power supply to the controller board.. Now its time to dump the code in controller.. Press the start option on your flash magic window.. then your microcontroller will be programmed in few seconds..
PROGRAM CODE:
#include<reg52.h> #include<intrins.h> #include "lcd.h" void _nop_(void); #define delay_us _nop_(); //generates 1 microsecond sbit buzzer=P0^7; sbit PULSE =P3^2; sbit sw=P0^1; sbit sbit sbit sbit void void void void void void sck dout din cs = = = = P3^4; P3^5; P3^6; P3^7;
integer_lcd(int); timer(unsigned int); init_lcd(void); cmd_lcd(unsigned char); write_lcd(unsigned char); delay_ms(unsigned int);
unsigned char txrxbyte(unsigned char); unsigned char byte1,byte2,byte3; float dcode1,dcode2,dcode3; float vref=4.096,output,output1,output2,output3; unsigned int i,j,k;
65 | P a g e
unsigned int num1=0; unsigned int test1=0,test2=0,test; unsigned int cnt,max_cnt; int counter=0,n; bit flag=0; void transmit(unsigned char *); void integer_lcd1(int); void delay_micro(unsigned int); sbit WIRE=P0^0; void integer_lcd(int); unsigned int str[],a; void main(void) { unsigned int p=0,t=0; init_lcd(); display_lcd("ICU "); cmd_lcd(0xc0); display_lcd("MONITORING"); delay_ms(1000); cmd_lcd(0x01); while(1) { cs=0; byte1=txrxbyte(0x06); byte2=txrxbyte(0x00); byte3=txrxbyte(0x00); i=(byte2&0x0f); i=(i<<8|byte3); output1=(((vref*i)/4096)); output1=(output1*1000); cs=1; delay_ms(10); cs=0; byte1=txrxbyte(0x06); byte2=txrxbyte(0x40); byte3=txrxbyte(0x00); i=(byte2&0x0f); i=(i<<8|byte3); output2=(((vref*i)/4096)); output2=output2*1000; cs=1; delay_ms(10); cs=0; byte1=txrxbyte(0x06); byte2=txrxbyte(0x80);
66 | P a g e
byte3=txrxbyte(0x00); i=(byte2&0x0f); i=(i<<8|byte3); output3=(((vref*i)/4096)); output3=(output3*1000); cs=1; cmd_lcd(0x80); integer_lcd(output1); delay_ms(1000); cmd_lcd(0xc0); integer_lcd(output2); display_lcd(" "); integer_lcd(output3); delay_ms(1000); } }
void transmit(unsigned char *t_data) { while(*t_data!='\0') { SBUF = *t_data; while(!TI); TI=0; t_data++; delay_ms(30); } } void integer_lcd1(int n) { unsigned char c[6]; unsigned int i=0; if(n<0) { SBUF='-'; n=-n; while(!TI); TI=0; } if(n==0) { SBUF='0'; while(!TI); TI=0; } while(n>0) {
67 | P a g e
c[i++]=(n%10)+48; n/=10; } while(i-->=1) { SBUF=c[i]; while(!TI); TI=0; } } unsigned char txrxbyte( unsigned char d) { char mask=0x80; unsigned char i,c=0x00; for(i=0;i<8;i++) { sck=1; if(d&mask) {din=1;} else {din=0;} sck=0; if(dout==1) {c=c|mask;} mask=mask>>1; } return c; }
#include<reg52.h> #include<intrins.h> #include "lcd.h" void _nop_(void); #define delay_us _nop_(); //generates 1 microsecond //#define motor P0 sbit sbit sbit sbit sck dout din cs = = = = P3^4; P3^5; P3^6; P3^7;
68 | P a g e
void write_lcd(unsigned char); void delay_ms(unsigned int); unsigned char txrxbyte(unsigned char); unsigned char byte1,byte2,byte3; float vref=4.096,output,output1,output2,output3; void integer_lcd(int); //unsigned char mor=0,noon=0,eve=0; void main(void) { unsigned char i; init_lcd(); display_lcd("SOLAR "); cmd_lcd(0xc0); display_lcd("TRACKING SYSTEM"); delay_ms(1000); cmd_lcd(0x01); while(1) { cs=0; byte1=txrxbyte(0x06); byte2=txrxbyte(0x00); byte3=txrxbyte(0x00); i=(byte2&0x0f); i=(i<<8|byte3); output1=(((vref*i)/4096)); output1=(output1*1000); cs=1; delay_ms(10); cs=0; byte1=txrxbyte(0x06); byte2=txrxbyte(0x40); byte3=txrxbyte(0x00); i=(byte2&0x0f); i=(i<<8|byte3); output2=(((vref*i)/4096)); output2=output2*1000; output2=output2; cs=1; delay_ms(10); /* cs=0; byte1=txrxbyte(0x06); byte2=txrxbyte(0x80); byte3=txrxbyte(0x00);
69 | P a g e
i=(byte2&0x0f); i=(i<<8|byte3); output3=(((vref*i)/4096)); output3=output3*1000; cs=1; delay_ms(10); */ cmd_lcd(0x01); integer_lcd(output1); cmd_lcd(0x89); integer_lcd(output2); cmd_lcd(0xc0); integer_lcd(output3); delay_ms(1000); /* if(output1<300&&mor==0) { mor=1; for(i=0;i<4;i++) { motor=0x01; //for CCW direction "C639" delay_ms(12); motor=0x02; delay_ms(12); motor=0x04; delay_ms(12); motor=0x08; delay_ms(20); } } if(output2<300&&mor==1&&noon==0) { noon=1; for(i=0;i<4;i++) { motor=0x01; //for CCW direction "C639" delay_ms(12); motor=0x02; delay_ms(12); motor=0x04; delay_ms(12); motor=0x08; delay_ms(20); } } if(output3<400&&noon==1&&eve==0) { eve=1; for(i=0;i<4;i++) { motor=0x01; //for CCW direction "C639" delay_ms(12); motor=0x02; delay_ms(12); motor=0x04;
70 | P a g e
delay_ms(12); motor=0x08; delay_ms(20); } } if(output3>400&&output2>400&&output1>400&&eve==1) { eve=0; for(i=0;i<12;i++) { motor=0x08; //for CW direction "C639" delay_ms(12); motor=0x04; delay_ms(12); motor=0x02; delay_ms(12); motor=0x01; delay_ms(12); } } /*for(i=0;i<12;i++) { motor=0x01; //for CCW direction "C639" delay_ms(12); motor=0x02; delay_ms(12); motor=0x04; delay_ms(12); motor=0x08; delay_ms(20); } delay_ms(1000); for(i=0;i<12;i++) { motor=0x08; //for CW direction "C639" delay_ms(12); motor=0x04; delay_ms(12); motor=0x02; delay_ms(12); motor=0x01; delay_ms(12); } delay_ms(1000);*/ /*for(i=0;i<12;i++) { motor=0x01; //for CCW direction "C639" delay_ms(12); motor=0x02; delay_ms(12); motor=0x04; delay_ms(12);
71 | P a g e
motor=0x08; delay_ms(20); } delay_ms(1000); for(i=0;i<12;i++) { motor=0x08; //for CW direction "C639" delay_ms(12); motor=0x04; delay_ms(12); motor=0x02; delay_ms(12); motor=0x01; delay_ms(12); } delay_ms(1000);*/ } }
unsigned char txrxbyte( unsigned char d) { char mask=0x80; unsigned char i,c=0x00; for(i=0;i<8;i++) { sck=1; if(d&mask) {din=1;} else {din=0;} sck=0; if(dout==1) {c=c|mask;} mask=mask>>1; } return c; }
#include<reg52.h> #include<intrins.h> #include "lcd.h" void _nop_(void); sbit motor = P0^0; sbit rev = P0^1; #define delay_us _nop_(); //generates 1 microsecond
72 | P a g e
sbit sbit sbit sbit void void void void void void
= = = =
integer_lcd(int); timer(unsigned int); init_lcd(void); cmd_lcd(unsigned char); write_lcd(unsigned char); delay_ms(unsigned int);
unsigned char txrxbyte(unsigned char); unsigned char byte1,byte2,byte3; float dcode1,dcode2,dcode3; float vref=4.096,output,output1,output2,output3; unsigned int i,j,k; unsigned char mor=0,noon=0,eve=0; void delay_micro(unsigned int); void integer_lcd(int); void main(void) { unsigned int p=0,t=0; init_lcd(); display_lcd("SOLAR ENERGY "); cmd_lcd(0xc0); display_lcd("TRACKING SYSTEM"); delay_ms(1000); while(1) { cs=0; byte1=txrxbyte(0x06); byte2=txrxbyte(0x00); byte3=txrxbyte(0x00); i=(byte2&0x0f); i=(i<<8|byte3); output1=(((vref*i)/4096)); output1=(output1*1000); cs=1; delay_ms(10); cs=0; byte1=txrxbyte(0x06); byte2=txrxbyte(0x40);
73 | P a g e
byte3=txrxbyte(0x00); i=(byte2&0x0f); i=(i<<8|byte3); output2=(((vref*i)/4096)); output2=output2*1000; cs=1; delay_ms(10); cs=0; byte1=txrxbyte(0x06); byte2=txrxbyte(0x80); byte3=txrxbyte(0x00); i=(byte2&0x0f); i=(i<<8|byte3); output3=(((vref*i)/4096)); output3=(output3*1000); cs=1; /* cmd_lcd(0x01); integer_lcd(output1); delay_ms(1000); cmd_lcd(0xc0); integer_lcd(output2); display_lcd(" "); integer_lcd(output3); delay_ms(1000); */ if(output1>4000&&mor==0) { mor=1; noon=0; motor=1; rev=0; cmd_lcd(0x01); display_lcd("MORNING"); delay_ms(1000); motor=1; rev=1; init_lcd(); display_lcd("SOLAR ENERGY "); cmd_lcd(0xc0); display_lcd("TRACKING SYSTEM"); delay_ms(1000); } if(output2>4000&&mor==1&&noon==0) { noon=1; motor=1; rev=0; cmd_lcd(0x01); display_lcd("NOON"); delay_ms(1000); motor=1; rev=1; init_lcd(); display_lcd("SOLAR ENERGY "); cmd_lcd(0xc0);
74 | P a g e
display_lcd("TRACKING SYSTEM"); delay_ms(1000); } if(output3>4000&&noon==1&&eve==0) { eve=1; motor=1; rev=0; cmd_lcd(0x01); display_lcd("EVENING"); delay_ms(1000); motor=1; rev=1; init_lcd(); display_lcd("SOLAR ENERGY "); cmd_lcd(0xc0); display_lcd("TRACKING SYSTEM"); delay_ms(1000); } if(output3<4000&&output2<4000&&output1<4000&&eve==1) { eve=0; mor=0; motor=0; rev=1; init_lcd(); display_lcd("SOLAR ENERGY "); cmd_lcd(0xc0); display_lcd("TRACKING SYSTEM"); delay_ms(3000); motor=1; rev=1; } } }
void transmit(unsigned char *t_data) { while(*t_data!='\0') { SBUF = *t_data; while(!TI); TI=0; t_data++; delay_ms(30); } } void integer_lcd1(int n) { unsigned char c[6];
75 | P a g e
unsigned int i=0; if(n<0) { SBUF='-'; n=-n; while(!TI); TI=0; } if(n==0) { SBUF='0'; while(!TI); TI=0; } while(n>0) { c[i++]=(n%10)+48; n/=10; } while(i-->=1) { SBUF=c[i]; while(!TI); TI=0; } } unsigned char txrxbyte( unsigned char d) { char mask=0x80; unsigned char i,c=0x00; for(i=0;i<8;i++) { sck=1; if(d&mask) {din=1;} else {din=0;} sck=0; if(dout==1) {c=c|mask;} mask=mask>>1; } return c; }
76 | P a g e
CHAPTER 10
Bibliography
The 8051 Micro controller Architecture, Programming & Applications -Kenneth J.Ayala
77 | P a g e
78 | P a g e