Solar Tracking System
Solar Tracking System
1.1 INTRODUCTION
In years to come the need for energy will increase manifold while the reserve of
conventional energy will deplete in rapid pace. To meet the growing demand of energy
harnessing of non-conventional / renewable energy is the necessity. Among all the
available non-conventional sources, solar energy is the most abandunt and uniformly
distributed. Though the technology of trapping the solar energy is in existence the
process can be in proved to increase efficiency and make it cost-effective.
1.3 MOTIVATION
1.5 METHEDOLOGY
This project is designed with solar panels, LDR, ADC, Microcontroller, Stepper
Motor and its driving circuit.
In this project three LDRs are fixed on the solar panel at three distinct points. LDR
(Light Dependant Resistor) varies the resistance depending upon the light fall. The
varied resistance is converted into an analog voltage signal.
The analog voltage signal is then fed to an ADC. ADC is nothing but analog to digital
converter which receives the two LDR voltage signals and converts them to
corresponding digital signal. Then the converted digital signal is given as the input of the
microcontroller. Microcontroller receives the two digital signals from the ADC and
compares them. The LDR signals are not equal except for normal incidence of sunlight.
When there is a difference between LDR voltage levels the microcontroller programme
drives the stepper motor towards normal incidence of sunlight.
2
Fig 2.1 : General Block diagram of the Tracking system.
Fig 2.1 shows the general block diagram of the tracking system.
In this system the sun's light is tracked in order to generate power very
effectively. For that purpose 3 LDR’s are used for sensing the light from the sun. Here 3
LDR’s are used so that the sun's path can be divided into 3 columns of 180° (East-West).
The LDR outputs have been compared and the sun’s angle is traced. Hence the solar
panel is moved towards the sun’s angle with the help of microcontroller by using stepper
motor. In this operation the signal from the light sensor is given to the signal conversion
circuit and then it is filtered before passing into the microcontroller.
2.1 INTRODUCTION
A microcontroller (or MCU) is a computer-on-a-chip used to control electronic
devices. It is a type of microprocessor emphasizing self-sufficiency and cost-
effectiveness, in contrast to a general-purpose microprocessor (the kind used in a PC). A
typical microcontroller contains all the memory and interfaces needed for a simple
application, whereas a general purpose microprocessor requires additional chips to
provide these functions. A highly integrated chip that contains all the components
comprising a controller . Typically this includes a CPU, RAM, some form of ROM, I/O
ports, and timers. Unlike a general-purpose computer, which also includes all of these
components, a microcontroller is designed for a very specific task – to control a
particular system. As a result, the parts can be simplified and reduced, which cuts down
on production costs.
5
Fig 2.1: Pin out of AT89S8252
2.3.6 Pin Description
Port 0
Port 0 is an 8-bit open drain bi-bidirectional I/O port. As an output port, each pin can
sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high
impedance inputs. Port 0 can also be configured to be the multiplexed low-order
address/data bus during accesses to external program and data memory. In this mode,
P0 has internal pull-ups. Port 0 also receives the code bytes during Flash programming
and outputs the code bytes during program verification. External pull-ups are required
during program verification.
Port 1
Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output
buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins
that are externally being pulled low will source current (IIL) because of the internal
pull-ups.
Some Port 1 pins provide additional functions. P1.0 and P1.1 can be configured to be
the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2 trigger input
(P1.1/T2EX), respectively. Furthermore, P1.4, P1.5, P1.6, and P1.7 can be configured
as the SPI slave port select, data input/output and shift clock input/output pins as shown
in the following table. Port 1 also receives the low-order address bytes during Flash
programming and verification.
6
Port 2
Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output
buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins
that are externally being pulled low will source current (IIL) because of the internal
pull-ups.
Port 2 emits the high-order address byte during fetches from external program
memory and during accesses to external data memory that uses 16-bit addresses
(MOVX @ DPTR). In this application, Port 2 uses strong internal pull-ups when
emitting 1s. During accesses to external data memory that uses 8-bit addresses (MOVX
@ RI), Port 2 emits the contents of the P2 Special Function Register.
Port 2 also receives the high-order address bits and some control signals during
Flash programming and verification.
Port 3
Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output
buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins
that are externally being pulled low will source current (IIL) because of the pull-ups.
Port 3 receives some control signals for Flash programming and verification. Port 3
also serves the functions of various special features of the AT89S8252, as shown in the
following table.
RST
Reset input. A high on this pin for two machine cycles while the oscillator is running
resets the device.
ALE/PROG
Address Latch Enable is an output pulse for latching the low byte of the address during
accesses to external memory. This pin is also the program pulse input (PROG) during
Flash programming.
In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency
and may be used for external timing or clocking purposes. Note, however, that one
ALE pulse is skipped during each access to external data memory.
If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With
the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the
pin is weakly pulled high. Setting the ALE-disable bit has no effect if the
microcontroller is in external execution mode.
PSEN
7
Program Store Enable is the read strobe to external program memory. When the
AT89S8252 is executing code from external program memory, PSEN is acti-vated
twice each machine cycle, except that two PSEN activations are skipped during each
access to external data memory.
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 when 12-
volt pro-gramming is selected.
XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.
XTAL2
Output from the inverting oscillator amplifier .
8
RCAP2L) are the Capture/Reload registers for Timer 2 in 16-bit capture mode or 16-bit
auto-reload mode.
9
Table 4: WMCON—Watchdog and Memory Control Register
SPI Registers Control and status bits for the Serial Peripheral Interface are contained in
registers SPCR and SPSR . The SPI data bits are contained in the SPDR register.
Writing the SPI data register during serial data transfer sets the Write Collision bit,
WCOL, in the SPSR register. The SPDR is double buffered for writing and the values
in SPDR are not changed by Reset.
Interrupt Registers The global interrupt enable bit and the individual interrupt enable
bits are in the IE register. In addition, the individual interrupt enable bit for the SPI is in
the SPCR register. Two priorities can be set for each of the six interrupt sources in the
IP register.
Dual Data Pointer Registers To facilitate accessing both internal EEPROM and exter-
nal data memory, two banks of 16-bit Data Pointer Registers are provided: DP0 at SFR
address locations 82H-83H and DP1 at 84H-85H. Bit DPS = 0 in SFR WMCON selects
DP0 and DPS = 1 selects DP1. The user should ALWAYS initialize the DPS bit to the
appropriate value before accessing the respective Data Pointer Register.
Power Off Flag The Power Off Flag (POF) is located at bit_4 (PCON.4) in the PCON
SFR. POF is set to “1” during power up. It can be set and reset under software control
and is not affected by RESET.
Interrupts
The AT89S8252 has a total of six interrupt vectors: two external interrupts (INT0 and
INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. These
interrupts are all shown in Figure 2.2.
10
Table 5: Interrupt Enable (IE) Register
Each of these interrupt sources can be individually enabled or disabled by setting or
clearing a bit in Special Function Register IE. IE also contains a global disable bit, EA,
which disables all interrupts at once.
Note that Table 5 shows that bit position IE.6 is unimplemented. In the AT89C51, bit
position IE.5 is also unimplemented. User software should not write 1s to these bit
positions, since they may be used in future AT89 products.
11
Data’s are stored in source address and moved to destination addresses. The ways
by which data’s are represented are addressing modes.
There are four types of addressing modes used to access the data, namely
1. Immediate addressing mode
2. Direct addressing mode
3. Register addressing mode
4. Indirect addressing mode
When 8051 executes the immediate data move, the program counter is
automatically incremented to point to the byte following the opcode byte in the
program memory. Whatever the data found there is copied to the destination.
This addressing mode can also be used to load the information to data pointer
register (DPTR).
Although DPTR is a 16bit register it can be accessed as a two 8 bit registers
namely DPL &DPH.
Eg: MOV DPTR, #1234H ; this copy the immediate data 1234h to DPTR.
MOV DPL, #34H ; this copy the immediate data 34h to the lower
byte .
MOV DPH, #45H ; this copy the immediate data 45h to the upper byte
Eg: MOV R0, 49H ; this saves the content of RAM location 40h in R0
MOV 23H, R4 ; saves the content of R4 in RAM location 23h.
13
Table 2.1: A list of the Atmel 8051 Arithmetic Instructions.
14
Table 2.2: A list of the Atmel 8051 Logical Instructions
2.4.4 Data Transfers
Table 2.3 shows the menu of instructions that are available for moving data
around within the internal memory spaces, and the addressing modes that can be
used with each one. With a 12 MHz clock and X1 mode, all of these instructions
execute in either1 or 2 μs.
The MOV <dest>, <src> instruction allows data to be transferred between any
two internal RAM or SFR locations without going through the Accumulator.
Remember the Upper 128 bytes of data RAM can be accessed only by indirect, and
SFR space only by direct
addressing. Note that in all 8051 devices, the stack resides in on-chip RAM, and
grows upwards.
The PUSH instruction first increments the Stack Pointer (SP), then copies the
byte into the stack. PUSH and POP use only direct addressing to identify the byte
being saved or restored, but the stack itself is accessed by indirect addressing using
the SP register.
15
Table 2.3: Atmel 8051 Data Transfer Instructions that Access Internal Data
Memory Space.
STEPPER MOTOR
3.1 INTRODUCTION
A stepper motor is an electromechanical device which converts electrical pulses into
discrete mechanical movements. The shaft or spindle of a stepper motor rotates in
discrete step increments when electrical command pulses are applied to it in the proper
sequence. The motors rotation has several direct relationships to these applied input
pulses. The sequence of the applied pulses is directly related to the direction of motor
shafts rotation. The speed of the motor shafts rotation is directly related to the
frequency of the input pulses and the length of rotation is directly related to the number
of input pulses applied.
Disadvantages
1. Resonances can occur if not properly controlled.
16
2. Not easy to operate at extremely high speeds.
1) Variable-reluctance (VR)
This type of stepper motor has been around for a long time. It is probably the easiest
to understand from a structural point of view. Figure 3.1 shows a cross section of a
typical V.R. stepper motor. This type of motor consists of a soft iron multi-toothed
rotor and a wound stator. When the stator windings are energized with DC current
the poles become magnetized. Rotation occurs when the rotor teeth are attracted to
the energized stator poles.
Half Step Drive combines both wave and full step (1&2 phases on) drive
modes. Every second step only one phase is energized and during the other steps one
phase on each stator. The stator is energized according to the sequence AB ® B ® AB
® A ® AB ® B ® AB ® A and the rotor steps from position 1 ® 2 ® 3 ® 4 ® 5 ® 6
® 7 8. This results in angular movements that are half of those in 1- or 2-phases-on
drive modes. Half stepping can reduce a phenomena referred to as resonance which
can be experienced in 1- or 2- phases-on drive modes.
20
Fig 3.5: Unipolar and bipolar wound
stepper motors.
The excitation sequences for the above drive modes are summarized in Table 3.1.In
Micro-stepping Drive the currents in the windings are continuously varying to be able
to break up one full step into many smaller discrete steps. More information on micro-
stepping can be found in the micro-stepping chapter.
DESCRIPTION
The ADC interface consists of a NOR gate crystal oscillator, a CMOS clock divider which
feeds 768kHz as the input clock to the ADC regulator (723) to connect the +12V to +5V
required by the IC, a stable voltage reference (LM 336) and buffer (which provides the 5V
A multi-turn cermet adjustment of the reference voltage. The channel selects, ALE, start
conversion and out enable lines are interfaced through port lines (connect a flat cable from
the PPI-8255 connector on the trainer to the connector CI in the interface).
Port lines Description
PA0-PA7 Connected data lines D0-D7
PB0 Channel select line A
PB1 Channel select line B
PB2 Channel select line C
*PB5 Ale to latch address
*PB6 Start conversion
*PB7 Input enable
PC0 End of conversion signal
Note – Since PB5,PB6 & PB7 are inverted, the signal at the output of the port lines will be
the complement of the signals required by the IC.
2.2 A conversion can be done in the Polled mode or Interrupt mode
2.2.1 In the Polled mode
1) Program the 8255 to mode zero, control byte’99’.
2) Do a dummy read to clear the f/f output pin status.
3) Setup the address of the channel required to be converted (the 10 ways reliamate
provides a means of applying voltages to the IC).
CAUTION: Ensure that the interface is always provided with +5 volts & +12 volts i.e.,
the interface should not have its power removed while being connected to an active
signal.
22
4) Toggle the ALE at the port output from 1 to 0 and back to 1.
5) Toggle the STRT the port output from 1 to 0 and back to 1.
6) Monitor the f/f output at C1/5- port; line PCO- when it goes to zero conversion is
completed.
7) Read the converted value at port A- the process of reading clears the pending
status.
23
J22 to J23 ; CLK 1 is used
J1 to J2 ; for interrupt function (OUT 1 is inverted and
; connected to C 2/9, an interrupt pin in
J5 to J6 ; for local astable clock and
J7 to J8 ; high or low frequency
J7 to J10 ;
2.4.3 A small program enclosed shows the interface is used with an 85 M trainer
A flat cable is used to connect the interface .The connectors C1 & C2 in the interface
should be respectively connected to the connectors P3 & P2 on the SDA 85M trainer.
In case of SDA 86 connectors C1 & C2 should be connected to the connectors CN3 &
CN2 respectively. The 8253 timer 2 is programmed to operate in the square-wave
mode. The output pin should show a low frequency compared to the astable output at
jumper J5, when monitored on an oscilloscope or a logic probe, only when the key is
depressed (i.e. The gate input to the 8253 is made high).
Timer interface:
1. Connect P2 on the 85M trainer kit (take care of pin 1 or the cable and the kit) to the
connector C2 on the Interface through a flat cable.
2. Enter the program as per the listing given in appendix
3. Now execute the program,
GO< STARTING ADDRESS> <EXEC>
Press the KEY on the interface, you will observe square wave on the CRO through the
points 1 &2 of the 6 way count provided on the interface.
To change the period of the waveform.
Key in the delay parameter in the address field display. The count should be above
20.( e.g. 30,40 etc)
After entering the delay, press the EXEC key on the kit & press the button on the
interface and observe changed waveform.
The waveform can be observed until the RESET key is pressed.
25
CIRCUIT DIAGRAMS
BASIC MICROCONTROLLER CONNECTIONS:
26