Download as pdf or txt
Download as pdf or txt
You are on page 1of 90

Microcontroller based Solar Tracker with Stepper Motor Control

CHAPTER-1
INTRODUCTION
1.1 INTRODUCTION:

The purpose of this project is to design and construct a solar tracker system that
follows the sun direction for producing maximum out for solar powered applications.

Achieving balance between power consumption and power production is a bigger


challenge today. The best way to solve this imbalanced equation is to use solar energy as
efficiently as possible. The problem in the usage of solar energy is with solar cell panel
should be exposed maximum to the sun light. If the solar panel is fixed in a particular
direction then the sun light intensity varies from morning to evening. Moving the solar cell
panel in the direction of sun can increase the solar energy generated from the solar cell.

This project consists of few sun light sensors, limit switches and a motorized
mechanism for rotating the panel in the direction of sun. Microcontroller based control
system takes care of sensing sunlight and controlling the motorized mechanism. This
system works continuously without any interruption.

The main objectives of the project are:

1. Sun direction tracking to achieve maximum available energy.


2. Automatic system which needs no monitoring.
3. Stepper motor based mechanism to control the solar panel.

1.2 PROJECT OVERVIEW:

An embedded system is a combination of software and hardware to perform a


dedicated task. Some of the main devices used in embedded products are Microprocessors
and Microcontrollers.
Microprocessors are commonly referred to as general purpose processors as they
simply accept the inputs, process it and give the output. In contrast, a microcontroller not
only accepts the data as inputs but also manipulates it, interfaces the data with various
devices, controls the data and thus finally gives the result.

MLRITM, EEE Dept Page 01


Microcontroller based Solar Tracker with Stepper Motor Control

The project “Microcontroller based Automatic Solar Tracker using Stepper motor”
using PIC16F72 microcontroller is an exclusive project which is used to design and
construct a solar tracker system that follows the sun direction for producing maximum out
for solar powered applications like recharge the battery of a mobile phone, with a freely
available source of energy “solar energy”.

1.3 THESIS:

The thesis explains the implementation of “Microcontroller based Solar Tracker


with Stepper Motor Control” using PIC16F72 microcontroller. The organization of the
thesis is explained here with:

Chapter 1 Presents introduction to the overall thesis and the overview of the project. In
the project overview a brief introduction of solar cell, voltage regulator, Stepper motor and
its applications are discussed.

Chapter 2 Presents the topic embedded systems. It explains the about what is embedded
systems, need for embedded systems, explanation of it along with its applications.

Chapter 3 Presents the hardware description. It deals with the block diagram of the project
and explains the purpose of each block. In the same chapter the explanation of
microcontrollers, solar cell, power supplies and Stepper motor with driver are considered.

Chapter 4 Presents the software description. It explains the implementation of the project
using PIC C Compiler software.

Chapter 5 Presents the project description along with Stepper motor, LIMIT
SWITCHES,LDR and solar plate interfacing to microcontroller.

Chapter 6 Presents the advantages, disadvantages and applications of the project.

Chapter 7 Presents the results, conclusion and future scope of the project.

MLRITM, EEE Dept Page 2


Microcontroller based Solar Tracker with Stepper Motor Control

CHAPTER-2
EMBEDDED SYSTEMS
2.1 EMBEDDED SYSTEMS:

An embedded system is a computer system designed to perform one or a few


dedicated functions often with real-time computing constraints. It is embedded as part of a
complete device often including hardware and mechanical parts. By contrast, a general-
purpose computer, such as a personal computer (PC), is designed to be flexible and to meet
a wide range of end-user needs. Embedded systems control many devices in common use
today.

Embedded systems are controlled by one or more main processing cores that are
typically either microcontrollers or digital signal processors (DSP). The key characteristic,
however, is being dedicated to handle a particular task, which may require very powerful
processors. For example, air traffic control systems may usefully be viewed as embedded,
even though they involve mainframe computers and dedicated regional and national
networks between airports and radar sites. (Each radar probably includes one or more
embedded systems of its own.)

Since the embedded system is dedicated to specific tasks, design engineers can
optimize it to reduce the size and cost of the product and increase the reliability and
performance. Some embedded systems are mass-produced, benefiting from economies of
scale.

Physically embedded systems range from portable devices such as digital watches
and MP3 players, to large stationary installations like traffic lights, factory controllers, or
the systems controlling nuclear power plants. Complexity varies from low, with a single
microcontroller chip, to very high with multiple units, peripherals and networks mounted
inside a large chassis or enclosure.

MLRITM, EEE Dept Page 3


Microcontroller based Solar Tracker with Stepper Motor Control

In general, "embedded system" is not a strictly definable term, as most systems


have some element of extensibility or programmability. For example, handheld computers
share some elements with embedded systems such as the operating systems and
microprocessors which power them, but they allow different applications to be loaded and
peripherals to be connected. Moreover, even systems which don't expose programmability
as a primary feature generally need to support software updates. On a continuum from
"general purpose" to "embedded", large application systems will have subcomponents at
most points even if the system as a whole is "designed to perform one or a few dedicated
functions", and is thus appropriate to call "embedded". A modern example of embedded
system is shown in fig: 2.1.

Fig 2.1:A modern example of embedded system

Labeled parts include microprocessor (4), RAM (6), flash memory (7).Embedded
systems programming is not like normal PC programming. In many ways, programming
for an embedded system is like programming PC 15 years ago. The hardware for the system
is usually chosen to make the device as cheap as possible. Spending an extra dollar a unit
in order to make things easier to program can cost millions. Hiring a programmer for an
extra month is cheap in comparison.

MLRITM, EEE Dept Page 4


Microcontroller based Solar Tracker with Stepper Motor Control

2.1.1 HISTORY:

In the earliest years of computers in the 1930–40s, computers were sometimes


dedicated to a single task, but were far too large and expensive for most kinds of tasks
performed by embedded computers of today. Over time however, the concept
of programmable controllers evolved from traditional electromechanical sequencers, via
solid state devices, to the use of computer technology.

One of the first recognizably modern embedded systems was the Apollo Guidance
Computer, developed by Charles Stark Draper at the MIT Instrumentation Laboratory. At
the project's inception, the Apollo guidance computer was considered the riskiest item in
the Apollo project as it employed the then newly developed monolithic integrated circuits
to reduce the size and weight. An early mass-produced embedded system was the
Autonetics D-17 guidance computer for the Minuteman Missile, released in 1961. It was
built from transistor logic and had a hard disk for main memory. When the Minuteman II
went into production in 1966, the D-17 was replaced with a new computer that was the
first high-volume use of integrated circuits.

2.1.2 TOOLS:

Embedded development makes up a small fraction of total programming. There's


also a large number of embedded architectures, unlike the PC world where 1 instruction
set rules, and the UNIX world where there's only 3 or 4 major ones. This means that the
tools are more expensive. It also means that they're lowering featured, and less
developed. On a major embedded project, at some point you will almost always find a
compiler bug of some sort.
Debugging tools are another issue. Since you can't always run general programs
on your embedded processor, you can't always run a debugger on it. This makes fixing
your program difficult. Special hardware such as JTAG ports can overcome this issue in
part. However, if you stop on a breakpoint when your system is controlling real world
hardware (such as a motor), permanent equipment damage can occur by doing embedded
programming.

MLRITM, EEE Dept Page 5


Microcontroller based Solar Tracker with Stepper Motor Control

2.1.3 RESOURCES:

To save costs, embedded systems frequently have the cheapest processors that can
do the job. This means your programs need to be written as efficiently as possible. When
dealing with large data sets, issues like memory cache misses that never matter in PC
programming can hurt you. Luckily, this won't happen too often- use reasonably efficient
algorithms to start, and optimize only when necessary. Of course, normal profilers won't
work well, due to the same reason debuggers don't work well.
Memory is also an issue. For the same cost savings reasons, embedded systems
usually have the least memory they can get away with. That means their algorithms must
be memory efficient (unlike in PC programs, you will frequently sacrifice processor time
for memory, rather than the reverse). It also means you can't afford to leak memory.
Embedded applications generally use deterministic memory techniques and avoid the
default "new" and "malloc" functions, so that leaks can be found and eliminated more
easily. Other resources programmers expect may not even exist. For example, most
embedded processors do not have hardware FPUs (Floating-Point Processing Unit). These
resources either need to be emulated in software, or avoided altogether.

2.1.4 REAL TIME ISSUES:

Embedded systems frequently control hardware, and must be able to respond to


them in real time. Failure to do so could cause inaccuracy in measurements, or even
damage hardware such as motors. This is made even more difficult by the lack of resources
available. Almost all embedded systems need to be able to prioritize some tasks over
others, and to be able to put off/skip low priority tasks such as UI in favor of high priority
tasks like hardware control.

MLRITM, EEE Dept Page 6


Microcontroller based Solar Tracker with Stepper Motor Control

2.2 NEED FOR EMBEDDED SYSTEMS:

The uses of embedded systems are virtually limitless, because every day new
products are introduced to the market that utilizes embedded computers in novel ways. In
recent years, hardware such as microprocessors, microcontrollers, and FPGA chips have
become much cheaper. So when implementing a new form of control, it's wiser to just buy
the generic chip and write your own custom software for it. Producing a custom-made chip
to handle a particular task or set of tasks costs far more time and money. Many embedded
computers even come with extensive libraries, so that "writing your own software"
becomes a very trivial task indeed. From an implementation viewpoint, there is a major
difference between a computer and an embedded system. Embedded systems are often
required to provide Real-Time response. The main elements that make embedded systems
unique are its reliability and ease in debugging.
2.2.1 DEBUGGING:

Embedded debugging may be performed at different levels, depending on the


facilities available. From simplest to most sophisticate they can be roughly grouped into
the following areas:
• Interactive resident debugging, using the simple shell provided by the embedded
operating system (e.g. Forth and Basic)
• External debugging using logging or serial port output to trace operation using
either a monitor in flash or using a debug server like the Remedy Debugger which
even works for heterogeneous multi core systems.
• An in-circuit debugger (ICD), a hardware device that connects to the
microprocessor via a JTAG or Nexus interface. This allows the operation of the
microprocessor to be controlled externally, but is typically restricted to specific
debugging capabilities in the processor.
• An in-circuit emulator replaces the microprocessor with a simulated equivalent,
providing full control over all aspects of the microprocessor.

MLRITM, EEE Dept Page 7


Microcontroller based Solar Tracker with Stepper Motor Control

• A complete emulator provides a simulation of all aspects of the hardware, allowing


all of it to be controlled and modified and allowing debugging on a normal PC.
• Unless restricted to external debugging, the programmer can typically load and run
software through the tools, view the code running in the processor, and start or stop
its operation. The view of the code may be as assembly code or source-code.
Because an embedded system is often composed of a wide variety of elements, the
debugging strategy may vary. For instance, debugging a software(and microprocessor)
centric embedded system is different from debugging an embedded system where most of
the processing is performed by peripherals (DSP, FPGA, co-processor). An increasing
number of embedded systems today use more than one single processor core. A common
problem with multi-core development is the proper synchronization of software execution.
In such a case, the embedded system design may wish to check the data traffic on the busses
between the processor cores, which requires very low-level debugging, at signal/bus level,
with a logic analyzer, for instance.

2.2.2 RELIABILITY:

Embedded systems often reside in machines that are expected to run continuously
for years without errors and in some cases recover by them if an error occurs. Therefore
the software is usually developed and tested more carefully than that for personal
computers, and unreliable mechanical moving parts such as disk drives, switches or buttons
are avoided.
Specific reliability issues may include:
• The system cannot safely be shut down for repair, or it is too inaccessible to repair.
Examples include space systems, undersea cables, navigational beacons, bore-hole
systems, and automobiles.
• The system must be kept running for safety reasons. "Limp modes" are less
tolerable. Often backups are selected by an operator. Examples include aircraft
navigation, reactor control systems, safety-critical chemical factory controls, train
signals, engines on single-engine aircraft.

MLRITM, EEE Dept Page 8


Microcontroller based Solar Tracker with Stepper Motor Control

2.3 EXPLANATION OF EMBEDDED SYSTEMS:

2.3.1 SOFTWARE ARCHITECTURE:

There are several different types of software architecture in common use.

• Simple Control Loop:

In this design, the software simply has a loop. The loop calls subroutines, each of
which manages a part of the hardware or software.

• Interrupt Controlled System:

Some embedded systems are predominantly interrupt controlled. This means that
tasks performed by the system are triggered by different kinds of events. An interrupt
could be generated for example by a timer in a predefined frequency, or by a serial port
controller receiving a byte. These kinds of systems are used if event handlers need low
latency and the event handlers are short and simple.

Usually these kinds of systems run a simple task in a main loop also, but this task
is not very sensitive to unexpected delays. Sometimes the interrupt handler will add
longer tasks to a queue structure. Later, after the interrupt handler has finished, these
tasks are executed by the main loop. This method brings the system close to a
multitasking kernel with discrete processes.

2.3.2 STAND ALONE EMBEDDED SYSTEM:

These systems takes the input in the form of electrical signals from transducers or
commands from human beings such as pressing of a button etc.., process them and
produces desired output. This entire process of taking input, processing it and giving
output is done in standalone mode. Such embedded systems comes under stand alone
embedded systems.

Eg: microwave oven, air conditioner etc..

MLRITM, EEE Dept Page 9


Microcontroller based Solar Tracker with Stepper Motor Control

2.3.3 REAL-TIME EMBEDDED SYSTEMS:

Embedded systems which are used to perform a specific task or operation in a


specific time period those systems are called as real-time embedded systems. There are
two types of real-time embedded systems.

• Hard Real-time embedded systems:

These embedded systems follow an absolute dead line time period i.e.., if the
tasking is not done in a particular time period then there is a cause of damage to the entire
equipment.

• Soft Real Time embedded systems:

These embedded systems follow a relative dead line time period i.e.., if the task is
not done in a particular time that will not cause damage to the equipment.

2.3.4 NETWORK COMMUNICATION EMBEDDED SYSTEMS:

A wide range network interfacing communication is provided by using embedded


systems.

Whenever a person comes near the door, it captures the image of a person and
sends to the desktop of your computer which is connected to internet. This gives an
alerting message with image on to the desktop of your computer, and then you can open
the door lock just by clicking the mouse. Fig: 2.2 show the network communications in
embedded systems.

MLRITM, EEE Dept Page 10


Microcontroller based Solar Tracker with Stepper Motor Control

CHAPTER-3
HARDWARE DESCRIPTION
3.1 INTRODUCTION TO HARDWARE:

In this chapter the block diagram of the project and design aspect of independent
modules are considered.

FIG 3.1: Block diagram of construction of Microcontroller based solar tracker


with Stepper motor control
The main blocks of this project are:

1. Micro controller (PIC16F72)

2. Reset button
MLRITM, EEE Dept Page 11
Microcontroller based Solar Tracker with Stepper Motor Control

3. Crystal oscillator

4. Regulated power supply (RPS)

5. LED indicators

6. Solar cell/plate

7. Stepper motor

8. Limit Switches

9. LDR

3.2 MICROCONTROLLER:

3.2.1 INTRODUCTION TO MICROCONTROLLER:

A Microcontroller is a programmable digital processor with necessary peripherals.


Both microcontrollers and microprocessors are complex sequential digital circuits meant
to carry out job according to the program / instructions. Sometimes analog input/output
interface makes a part of microcontroller circuit of mixed mode (both analog and digital
nature).

1. A smaller computer

2. On-chip RAM, ROM, I/O ports...

Example: Motorola’s 6811, Intel’s 8051, Zilog’s Z8 and PIC 16X

3.2.2 MEMORY TYPES:

In a microcontroller, two types of memory are found. They are, program memory and data
memory respectively. Program memory is also known as 'control store' and 'firm ware'. It
is non-volatile i.e, the memory content is not lost when the power goes off. Non-volatile
memory is also called Read Only Memory (ROM). There are various types of ROM.

1. Mask ROM: Some microcontrollers with ROM are programmed while they are still
in the factory. This ROM is called Mask ROM. Since the microcontrollers with

MLRITM, EEE Dept Page 12


Microcontroller based Solar Tracker with Stepper Motor Control

Mask ROM are used for specific application, there is no need to reprogram them.
Some times, this type of manufacturing reduces the cost for bulk production.

2. Reprogrammable program memory (or) Erasable PROM (EPROM):


Microcontrollers with EPROM were introduced in late 1970's. These devices are
electrically programmable but are erased with UV radiation.

In the unprogrammed state, the 'float' does not have any charge and the MOSFET is in
the OFF state. The charge in the 'float' remains for a long time (typically over 30 years).
The charge can be removed by exposing the float to UV radiation. For UV erasable version,
the packaging is done in a ceramic enclosure with a glass window.

This memory is similar to EEPROM but the cells in a FLASH memory are bussed
so that they can be erased in a few clock cycles. Hence the reprogramming is faster.

Different Data memory types:

1. Random access memory (RAM)

2. Read only memory (ROM)

Random access memory (RAM): Data will disappear after power down.

• Static RAM (SRAM): each bit is a flip-flop, fast but expensive.


• Dynamic RAM (DRAM): each bit is a small capacitor, and is needed to be
recharged regularly, slower but cheap. To be used as primary memory in a
computer.

Data memory can be classified into the following categories

• Bits

• Registers

• Variable RAM

• Program counter stack


MLRITM, EEE Dept Page 13
Microcontroller based Solar Tracker with Stepper Motor Control

Microcontroller can have ability to perform manipulation of individual bits in certain


registers (bit manipulation). This is a unique feature of a microcontroller, not available in
a microprocessor.

Eight bits make a byte. Memory bytes are known as file registers.

Registers are some special RAM locations that can be accessed by the processor very
easily.

➢ Static RAM (SRAM) memory cell:

This consists of two CMOS inverters connected back to front, so as to form a latch.
Processor stacks store/save the data in a simple way during program execution. Processor
stack is a part of RAM area where the data is saved in a Last in First out (LIFO) fashion
just like a stack of paper on a table. Data is stored by executing a 'push' instruction and data
is read out using a 'pop' instruction.

FIG 3.2: SRAM Memory Cell

MLRITM, EEE Dept Page 14


Microcontroller based Solar Tracker with Stepper Motor Control

3.2.3 INTERNAL STRUCTURE OF A MICROCONTROLLER:

FIG 3.3: Internal Structure of a Microcontroller

At times, a microcontroller can have external memory also (if there is no internal
memory or extra memory interface is required). Early microcontrollers were manufactured
using bipolar or NMOS technologies. Most modern microcontrollers are manufactured
with CMOS technology, which leads to reduction in size and power loss. Current drawn
by the IC is also reduced considerably from 10mA to a few micro Amperes in sleep mode
(for a microcontroller running typically at a clock speed of 20MHz).

MLRITM, EEE Dept Page 15


Microcontroller based Solar Tracker with Stepper Motor Control

3.2.4 PIC MICROCONTROLLERS:

PIC stands for Peripheral Interface Controller given by Microchip Technology to


identify its single-chip microcontrollers. These devices have been very successful in 8-bit
microcontrollers. The main reason is that Microchip Technology has continuously
upgraded the device architecture and added needed peripherals to the microcontroller to
suit customers' requirements.

➢ Low - end PIC Architectures:

Microchip PIC microcontrollers are available in various types. When PIC


microcontroller MCU was first available from General Instruments in early 1980's, the
microcontroller consisted of a simple processor executing 12-bit wide instructions with
basic I/O functions. These devices are known as low-end architectures. They have limited
program memory and are meant for applications requiring simple interface functions and
small program & data memories. Some of the low-end device numbers are

12C5XX
16C5X
16C505

➢ Mid range PIC Architectures

Mid range PIC architectures are built by upgrading low-end architectures with more
number of peripherals, more number of registers and more data/program memory. Some
of the mid-range devices are

16C6X
16C7X
16F87X

Program memory type is indicated by an alphabet.

C = EPROM

F = Flash

RC = Mask ROM

MLRITM, EEE Dept Page 16


Microcontroller based Solar Tracker with Stepper Motor Control

Popularity of the PIC microcontrollers is due to the following factors.

1. Speed: Harvard Architecture, RISC architecture, 1 instruction cycle = 4 clock


cycles.

2. Instruction set simplicity: The instruction set consists of just 35 instructions (as
opposed to 111 instructions for 8051).

3. Power-on-reset and brown-out reset: Brown-out-reset means when the power


supply goes below a specified voltage (say 4V), it causes PIC to reset; hence
malfunction is avoided.

A watch dog timer (user programmable) resets the processor if the software/program ever
malfunctions and deviates from its normal operation.

4. PIC microcontroller has four optional clock sources:

➢ Low power crystal

➢ Mid range crystal

➢ High range crystal

➢ RC oscillator (low cost).

5. Programmable timers and on-chip ADC.

6. Up to 12 independent interrupt sources.

7. Powerful output pin control (25 mA (max.) current sourcing capability per pin.)

8. EPROM/OTP/ROM/Flash memory option.

9. I/O port expansion capability.

10. Brown-out-reset means when the power supply goes below a specified voltage (say
4V), it causes PIC to reset; hence malfunction is avoided.

MLRITM, EEE Dept Page 17


Microcontroller based Solar Tracker with Stepper Motor Control

3.2.5 PIC MICROCONTROLLER CLOCK:

Relation between instruction cycles and clock cycles for PIC microcontrollers:

FIG 3.4: Instruction cycle

Instructions that do not require modification of program counter content get executed

➢ Memory unit:

Memory is part of the microcontroller whose function is to store data.


It is enough to know the designation of the drawer and so its contents will be known to us
for sure.

FIG 3.5: Memory Unit

MLRITM, EEE Dept Page 18


Microcontroller based Solar Tracker with Stepper Motor Control

Memory components are exactly like that. For a certain input we get the contents
of a certain addressed memory location and that's all. Two new concepts are brought to us:
addressing and memory location. Memory consists of all memory locations, and addressing
is nothing but selecting one of them. This means that we need to select the desired memory
location on one hand, and on the other hand we need to wait for the contents of that location.
Besides reading from a memory location, memory must also provide for writing onto it.
This is done by supplying an additional line called control line. We will designate this line
as R/W (read/write). Control line is used in the following way: if r/w=1, reading is done,
and if opposite is true then writing is done on the memory location.

Memory is the first element, and we need a few operation of our microcontroller.

➢ Central Processing Unit:

Let add 3 more memory locations to a specific block that will have a built in
capability to multiply, divide, subtract, and move its contents from one memory location
onto another. The part we just added in is called "central processing unit" (CPU). Its
memory locations are called registers.

FIG 3.6: CPU

Registers are therefore memory locations whose role is to help with performing
various mathematical operations or any other operations with data wherever data can be
found. Look at the current situation. We have two independent entities (memory and CPU)
MLRITM, EEE Dept Page 19
Microcontroller based Solar Tracker with Stepper Motor Control

which are interconnected, and thus any exchange of data is hindered, as well as its
functionality.

➢ Bus:

That "way" is called "bus". Physically, it represents a group of 8, 16, or more wires
there are two types of buses: address and data bus. The first one consists of as many lines
as the amount of memory we wish to address and the other one is as wide as data, in our
case 8 bits or the connection line. First one serves to transmit address from CPU memory,
and the second to connect all blocks inside the microcontroller.

FIG 3.7: Bus connecting between Memory and CPU

As far as functionality, the situation has improved, but a new problem has also
appeared: we have a unit that's capable of working by itself, but which does not have any
contact with the outside world, or with us! In order to remove this deficiency, let's add a
block which contains several memory locations whose one end is connected to the data bus,
and the other has connection with the output lines on the microcontroller which can be
seen as pins on the electronic component.

MLRITM, EEE Dept Page 20


Microcontroller based Solar Tracker with Stepper Motor Control

➢ Input-output unit:

Those locations we've just added are called "ports". There are several types of ports :
input, output or bidirectional ports. When working with ports, first of all it is necessary to
choose which port we need to work with, and then to send data to, or take it from the port.

FIG 3.8: Input-Output unit

When working with it the port acts like a memory location. Something is simply being
written into or read from it, and it could be noticed on the pins of the microcontroller.

➢ Serial communication:

Beside stated above we've added to the already existing unit the possibility of
communication with an outside world. Once the transfer starts, we lower the transmission
line to logical "0" for a period of time (which we will designate as T), so the receiving side
will know that it is receiving data, and so it will activate its mechanism for reception. The
protocol we've just described is called in professional literature NRZ (Non-Return to Zero).

FIG 3.9: Serial Unit

MLRITM, EEE Dept Page 21


Microcontroller based Solar Tracker with Stepper Motor Control

➢ Analog to Digital Converter:

As the peripheral signals usually are substantially different from the ones that
microcontroller can understand (zero and one), they have to be converted into a pattern
which can be comprehended by a microcontroller. This task is performed by a block for
analog to digital conversion or by an ADC. This block is responsible for converting an
information about some analog value to a binary number and for follow it through to a
CPU block so that CPU block can further process it.

FIG 3.10: Analog to Digital converter

Finally, the microcontroller is now completed, and all we need to do now is to assemble it
into an electronic component where it will access inner blocks through the outside pins.
The picture below shows what a microcontroller looks like inside.

FIG 3.11: Inside of a Microcontroller

MLRITM, EEE Dept Page 22


Microcontroller based Solar Tracker with Stepper Motor Control

3.2.6 PHYSICAL CONFIGURATION OF INTERIOR OF MICROCONTROLLER:

FIG 3.12: Center section of a microcontroller.

For a real application, a microcontroller alone is not enough. Beside a


microcontroller, we need a program that would be executed, and a few more elements
which make up a interface logic towards the elements of regulation (which will be
discussed in later chapters).

MLRITM, EEE Dept Page 23


Microcontroller based Solar Tracker with Stepper Motor Control

The program adds the contents of two memory locations, and views their sum on
port A. The first line of the program stands for moving the contents of memory location
"A" into one of the registers of central processing unit. As we need the other data as well,
we will also move it into the other register of the central processing unit. As it is the most
commonly used language in programming microcontrollers it will be discussed in a later
chapter. Programs in C language are easier to be written, easier to be understood, but are
slower in executing from assembler programs. Basic is the easiest one to learn, and its
instructions are nearest a man's way of reasoning, but like C programming language it is
also slower than assembler. In any case, before you make up your mind about one of these
languages you need to consider carefully the demands for execution speed, for the size of
memory and for the amount of time available for its assembly.

➢ PIC16F belongs to a class of 8-bit microcontrollers of RISC architecture.

Its general structure is shown on the following map representing basic blocks.

➢ Program memory (FLASH)-

It is used for storing a written program. Since memory made in FLASH technology can
be programmed and cleared more than once, it makes this microcontroller suitable for
device development.

➢ EEPROM:

Data memory that needs to be saved when there is no supply.


It is usually used for storing important data that must not be lost if power supply suddenly

➢ RAM:

Data memory used by a program during its execution. In RAM are stored all inter-
results or temporary data during run-time.

➢ PORT-A and PORT-B are physical connections between the microcontroller and
the outside world.

Port A has five, and port B has eight pins.

MLRITM, EEE Dept Page 24


Microcontroller based Solar Tracker with Stepper Motor Control

➢ FREE-RUN TIMER:

FREE-RUN TIMER is an 8-bit register inside a microcontroller that works


independently of the program. On every fourth clock of the oscillator it increments its value
until it reaches the maximum (255), and then it starts counting over again from zero. As
we know the exact timing between each two increments of the timer contents, timer can be
used for measuring time which is very useful with some devices.

FIG 3.13: PIC16F84 Microcontroller outline

TCY0 reads in instruction MOVLW 55h (it doesn't matter to us what instruction
was executed, because there is no rectangle pictured on the bottom).
TCY1 executes instruction MOVLW 55h and reads in MOVWF PORTB.

TCY2 executes MOVWF PORTB and reads in CALL SUB_1.

TCY3 executes a call of a subprogram CALL SUB_1, and reads in instruction BSF
PORTA, BIT3. As this instruction is not the one we need, or is not the first instruction of
a subprogram SUB_1 whose execution is next in order, instruction must be read in again.
TCY4 instruction cycle is totally used up for reading in the first instruction from a
subprogram at address SUB_1.
MLRITM, EEE Dept Page 25
Microcontroller based Solar Tracker with Stepper Motor Control

3.2.7 CLOCK GENERATOR-OSCILLATOR:

Oscillator circuit is used for providing a microcontroller with a clock. Clock is


needed so that microcontroller could execute a program or program instructions.

Types of oscillators:

PIC16F can work with four different configurations of an oscillator

This is important because you need to mention the type of oscillator when buying
a microcontroller.

Crystal oscillator is kept in metal housing with two pins where you have written
down the frequency at which crystal oscillates. One ceramic capacitor of 30pF whose
other end is connected to the ground needs to be connected with each pin.

Oscillator and capacitors can be packed in joint case with three pins. Such element
is called ceramic resonator and is represented in charts like the one below.

FIG 3.14: Connecting the quartz oscillator to give clock to a microcontroller

➢ RC Oscillator

In applications where great time precision is not necessary, RC oscillator offers


additional savings during purchase. Resonant frequency of RC oscillator depends on
supply voltage rate, resistance R, capacity C and working temperature. It should be
mentioned here that resonant frequency is also influenced by normal variations in process
parameters, by tolerance of external R and C components, etc.

MLRITM, EEE Dept Page 26


Microcontroller based Solar Tracker with Stepper Motor Control

FIG 3.15: RC Oscillator

Above diagram shows how RC oscillator is connected with PIC16F84. With value of
resistor R being below 2.2k, oscillator can become unstable, or it can even stop the
oscillation. With very high value of R (ex.1M) oscillator becomes very sensitive to noise
and humidity. It is recommended that value of resistor R should be between 3 and 100k.
Even though oscillator will work without an external capacitor (C=0pF), capacitor above
20pF should still be used for noise and stability. No matter which oscillator is being used,
in order to get a clock that microcontroller works up on, a clock of the oscillator must be
divided by 4. Oscillator clock divided by 4 can also be obtained on OSC2/CLKOUT pin,
and can be used for testing or synchronizing other logical circuits.

FIG 3.16: Relationship between a clock and a number of instruction cycles

Following a supply, oscillator starts oscillating. Oscillation at first has an unstable period
and amplitude, but after some period of time it becomes stabilized.

MLRITM, EEE Dept Page 27


Microcontroller based Solar Tracker with Stepper Motor Control

FIG 3.17: Signal of an oscillator clock after receiving the supply of a microcontroller

To prevent such inaccurate clock from influencing microcontroller's performance,


we need to keep the microcontroller in reset state during stabilization of oscillator's clock.
Diagram above shows a typical shape of a signal which microcontroller gets from the
quartz oscillator. It is recommended that value of resistor R should be between 3 and 100k.
Even though oscillator will work without an external capacitor (C=0pF), capacitor above
20pF should still be used for noise and stability.

3.2.8 RESET:

Reset is used for putting the microcontroller into a 'known' condition. That
practically means that microcontroller can behave rather inaccurately under certain
undesirable conditions. In order to continue its proper functioning it has to be reset,
meaning all registers would be placed in a starting position. Reset is not only used when
microcontroller doesn't behave the way we want it to, but can also be used when trying out
a device as an interrupt in program execution, or to get a microcontroller ready when
loading a program.

In order to prevent from bringing a logical zero to MCLR pin accidentally (line
above it means that reset is activated by a logical zero), MCLR has to be connected via
resistor to the positive supply pole. Resistor should be between 5 and 10K. This kind of
resistor whose function is to keep a certain line on a logical one as a preventive, is called a
pull up.
MLRITM, EEE Dept Page 28
Microcontroller based Solar Tracker with Stepper Motor Control

FIG 3.18: Internal Reset Circuit

Microcontroller PIC16F84 knows several sources of reset:


a) Reset during power on, POR (Power-On Reset)
b) Reset during regular work by bringing logical zero to MCLR microcontroller's pin.
c) Reset during SLEEP regime
d) Reset at watchdog timer (WDT) overflow
e) Reset during at WDT overflow during SLEEP work regime.
The most important reset sources are a) and b). The first one occurs each time a
power supply is brought to the microcontroller and serves to bring all registers to a starting
position initial state.

Reset at supply voltage drop below the permissible (Brown-out Reset). Impulse for
resetting during voltage voltage-up is generated by microcontroller itself when it detects
an increase in supply Vdd (in a range from 1.2V to 1.8V). That impulse lasts 72ms which
is enough time for an oscillator to get stabilized. These 72ms are provided by an internal
PWRT timer which has its own RC oscillator. Microcontroller is in a reset mode as long
as PWRT is active. To solve this problem we need to make sure that microcontroller is in
a reset state each time supply falls below the approved limit.

If, according to electrical specification, internal reset circuit of a microcontroller


can not satisfy the needs, special electronic components can be used which are capable of
generating the desired reset signal. Beside this function, they can also function in watching
over supply voltage.

MLRITM, EEE Dept Page 29


Microcontroller based Solar Tracker with Stepper Motor Control

3.3 MICROCONTROLLER (PIC16F72):

The PIC16F72 CMOS FLASH-based 8-bit microcontroller is upward compatible


with PIC16C72/72A and PIC16F872devices. It features 200 ns instruction execution, self
programming, an ICD, 2 Comparators, 5 channels of 8-bit Analog-to-Digital (A/D)
converter, 2 capture/compare/PWM functions, a synchronous serial port that can be
configured as either 3-wire SPI or 2-wire I2C bus, a USART, and a Parallel Slave Port.
High-Performance RISC CPU
• High performance RISC CPU
• Only 35 single word instructions to learn
• All single cycle instructions except for program branches which are two-cycle
• Operating speed: DC - 20 MHz clock input DC - 200 ns instruction cycle
• 2K x 14 words of Program Memory
• 128 x 8 bytes of Data Memory (RAM)
• Pin out compatible to the PIC16C72/72A and PIC16F872
• Interrupt capability
• Eight level deep hardware stack
• Direct, Indirect and Relative Addressing modes

3.3.1 PERIPHERAL FEATURES:


• Timer0: 8-bit timer/counter with 8-bit prescaler
• Timer1: 16-bit timer/counter with prescaler, can be incremented during SLEEP via
external crystal/clock
• Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler
• Capture, Compare, PWM(CCP) module
- Capture is 16-bit, max resolution is 12.5 ns
- Compare is 16-bit, max resolution is 200 ns
- PWM max resolution is 10-bit
• 8-bit, 5-channel Analog-to-Digital converter
• Synchronous Serial Port (SSP) with SPI (Master mode) and I2C (Slave)
• Heat sink/Source Current: 25 Ma

MLRITM, EEE Dept Page 30


Microcontroller based Solar Tracker with Stepper Motor Control

3.3.2 CMOS TECHNOLOGY:

• Low power, high speed CMOS FLASH technology


• Fully static design
• Wide operating voltage range: 2.0V to 5.5V
• Industrial temperature range
• Low power consumption:
- < 0.6 mA typical @ 3V, 4 MHz
- 20 μA typical @ 3V, 32 kHz

- < 1 μA typical standby current


3.3.3 MAJOR BLOCKS OF PIC MICROCONTROLLER:
➢ Crystal oscillator:
The crystal oscillator speed that can be connected to the PIC microcontroller range
from DC to 20Mhz. Using the CCS C compiler normally 20Mhz oscillator will be used
and the price is very cheap. The 20 MHz crystal oscillator should be connected with about
22pF capacitor. Please refer to my circuit schematic.
There are 5 input/output ports on PIC microcontroller namely port A, port B, port
C, port D and port E. Each port has different function. Most of them can be used as I/O
port.
➢ Clock / instruction cycle:
Clock is microcontroller's main starter, and is obtained from an external component
called an "oscillator". If we want to compare a microcontroller with a time clock, our
"clock" would then be a ticking sound we hear from the time clock. In that case, oscillator
could be compared to a spring that is wound so time clock can run. Also, force used to
wind the time clock can be compared to an electrical supply.
Clock from the oscillator enters a microcontroller via OSC1 pin where internal
circuit of a microcontroller divides the clock into four even clocks Q1, Q2, Q3, and Q4
which do not overlap. These four clocks make up one instruction cycle (also called machine
cycle) during which one instruction is executed.

MLRITM, EEE Dept Page 31


Microcontroller based Solar Tracker with Stepper Motor Control

FIG 3.19: Clock/Instruction Cycle


➢ Pipelining:
Instruction cycle consists of cycles Q1, Q2, Q3 and Q4. Cycles of calling and
executing instructions are connected in such a way that in order to make a call, one
instruction cycle is needed, and one more is needed for decoding and execution. However,
due to pipelining, each instruction is effectively executed in one cycle. If instruction causes
a change on program counter, and PC doesn't point to the following but to some other
address (which can be the case with jumps or with calling subprograms), two cycles are
needed for executing an instruction. This is so because instruction must be processed again,
but this time from the right address. Cycle of calling begins with Q1 clock, by writing into
instruction register (IR). Decoding and executing begins with Q2, Q3 and Q4 clocks.

FIG 3.20: Instruction pipeline Flow

MLRITM, EEE Dept Page 32


Microcontroller based Solar Tracker with Stepper Motor Control

3.3.4 PIN DESCRIPTION:


PIC16F72 has a total of 28 pins. DIP is an abbreviation for Dual In Package.

FIG 3.21: Pin diagram of MICROCONTROLLER (PIC16F72)


Pins on PIC16F72 microcontroller have the following meaning:
There are 28 pins on PIC16F72. Most of them can be used as an IO pin. Others
are already for specific functions. These are the pin functions.
1. MCLR – to reset the PIC
2. RA0 – port A pin 0
3. RA1 – port A pin 1
4. RA2 – port A pin 2
5. RA3 – port A pin 3
6. RA4 – port A pin 4
7. RA5 – port A pin 5
8. VSS – ground
9. OSC1 – connect to oscillator
10. OSC2 – connect to oscillator
11. RC0 – port C pin 0 VDD – power supply
12. RC1 – port C pin 1
13. RC2 – port C pin 2
14. RC3 – port C pin 3
MLRITM, EEE Dept Page 33
Microcontroller based Solar Tracker with Stepper Motor Control

15. RC4 - port C pin 4


16. RC5 - port C pin 5
17. RC6 - port C pin 6
18. RC7 - port C pin 7
19. VSS - ground
20. VDD – power supply
21. RB0 - port B pin 0
22. RB1 - port B pin 1
23. RB2 - port B pin 2
24. RB3 - port B pin 3
25. RB4 - port B pin 4
26. RB5 - port B pin 5
27. RB6 - port B pin 6
28. RB7 - port B pin 7

By utilizing all of this pin so many application can be done such as:
1. LCD – connect to Port B pin.
2. LED – connect to any pin declared as output.
3. Relay and Motor - connect to any pin declared as output.
4. External EEPROM – connect to I2C interface pin – RC3 and RC4 (SCL and SDA)
5. LDR, Potentiometer and sensor – connect to analogue input pin such as RA0.
6. GSM modem dial up modem – connect to RC6 and RC7 – the serial communication
interface using RS232 protocol.
3.3.5 PORTS:

Term "port" refers to a group of pins on a microcontroller which can be accessed


simultaneously, or on which we can set the desired combination of zeros and ones, or read
from them an existing status. Physically, port is a register inside a microcontroller which
is connected by wires to the pins of a microcontroller. Ports represent physical connection
of Central Processing Unit with an outside world. Microcontroller uses them in order to
monitor or control other components or devices. Due to functionality, some pins have
twofold roles like PA4/TOCKI for instance, which is in the same time the fourth bit of port
A and an external input for free-run counter. Selection of one of these two pin functions is
done in one of the configuration registers. An illustration of this is the fifth bit T0CS in
OPTION register. By selecting one of the functions the other one is disabled.

All port pins can be designated as input or output, according to the needs of a device
that's being developed. In order to define a pin as input or output pin, the right combination
MLRITM, EEE Dept Page 34
Microcontroller based Solar Tracker with Stepper Motor Control

of zeros and ones must be written in TRIS register. If the appropriate bit of TRIS register
contains logical "1", then that pin is an input pin, and if the opposite is true, it's an output
pin. Every port has its proper TRIS register. Thus, port A has TRISA, and port B has TRISB.
Pin direction can be changed during the course of work which is particularly fitting for
one-line communication where data flow constantly changes direction.

➢ PORTB and TRISB:

PORTB have adjoined 8 pins. The appropriate register for data direction is TRISB.
Setting a bit in TRISB register defines the corresponding port pin as input, and resetting a
bit in TRISB register defines the corresponding port pin as output.

FIG 3.22: PORTB and TRISB pin

MLRITM, EEE Dept Page 35


Microcontroller based Solar Tracker with Stepper Motor Control

Each PORTB pin has a weak internal pull-up resistor (resistor which defines a line to logic
one) which can be activated by resetting the seventh bit RBPU in OPTION register. These
'pull-up' resistors are automatically being turned off when port pin is configured as an
output. When a microcontroller is started, pull-ups are disabled.

➢ PORTA and TRISA

PORTA have 5 adjoining pins. The corresponding register for data direction is
TRISA at address 85h. Like with port B, setting a bit in TRISA register defines also the
corresponding port pin as input, and clearing a bit in TRISA register defines the
corresponding port pin as output.

It is important to note that PORTA pin RA4 can be input only. On that pin is also
situated an external input for timer TMR0. Whether RA4 will be a standard input or an
input for a counter depends on T0CS bit (TMR0 Clock Source Select bit). This pin enables
the timer TMR0 to increment either from internal oscillator or via external impulses on
RA4/T0CKI pin.

Example shows how pins 0, 1, 2, 3, and 4 are designated input, and pins 5, 6, and 7 outputs.
After this, it is possible to read the pins RA2, RA3, RA4, and to set logical zero or one to
pins RA0 and RA1.

MLRITM, EEE Dept Page 36


Microcontroller based Solar Tracker with Stepper Motor Control

FIG 3.23: PORTA and TRISA pin

3.3.6 MEMORY ORGANISATION:

PIC16F72 has two separate memory blocks, one for data and the other for program.
EEPROM memory with GPR and SFR registers in RAM memory make up the data block,
while FLASH memory makes up the program block.

➢ Program memory:

Program memory has been carried out in FLASH technology which makes it
possible to program a microcontroller many times before it's installed into a device, and
even after its installment if eventual changes in program or process parameters should
occur. The size of program memory is 1024 locations with 14 bits width where locations
zero and four are reserved for reset and interrupt vector.
MLRITM, EEE Dept Page 37
Microcontroller based Solar Tracker with Stepper Motor Control

➢ Data memory:

Data memory consists of EEPROM and RAM memories. EEPROM memory


consists of 256 eight bit locations whose contents are not lost during loosing of power
supply. EEPROM is not directly addressable, but is accessed indirectly through EEADR
and EEDATA registers. As EEPROM memory usually serves for storing important
parameters (for example, of a given temperature in temperature regulators) , there is a strict
procedure for writing in EEPROM which must be followed in order to avoid accidental
writing. RAM memory for data occupies space on a memory map from location 0x0C to
0x4F which comes to 68 locations. Locations of RAM memory are also called GPR
registers which is an abbreviation for General Purpose Registers. GPR registers can be
accessed regardless of which bank is selected at the moment.

3.3.7 APPLICATIONS:
PIC16F72 perfectly fits many uses, from automotive industries and controlling
home appliances to industrial instruments, remote sensors, electrical door locks and safety
devices. It is also ideal for smart cards as well as for battery supplied devices because of
its low consumption.
EEPROM memory makes it easier to apply microcontrollers to devices where
permanent storage of various parameters is needed (codes for transmitters, motor speed,
receiver frequencies, etc.). Low cost, low consumption, easy handling and flexibility make
PIC16F72 applicable even in areas where microcontrollers had not previously been
considered (example: timer functions, interface replacement in larger systems, coprocessor
applications, etc.).
In System Programmability of this chip (along with using only two pins in data
transfer) makes possible the flexibility of a product, after assembling and testing have been
completed. This capability can be used to create assembly-line production, to store
calibration data available only after final testing, or it can be used to improve programs on
finished products.

MLRITM, EEE Dept Page 38


Microcontroller based Solar Tracker with Stepper Motor Control

3.4 REGULATED POWER SUPPLY:

3.4.1 INTRODUCTION:
Power supply is a supply of electrical power. A device or system that
supplies electrical or other types of energy to an output load or group of loads is called
a power supply unit or PSU. The term is most commonly applied to electrical energy
supplies, less often to mechanical ones, and rarely to others.
A power supply may include a power distribution system as well as primary
or secondary sources of energy such as

• Conversion of one form of electrical power to another desired form and voltage,
typically involving converting AC line voltage to a well-regulated lower-

voltage DC for electronic devices. Low voltage, low power DC power supply units

are commonly integrated with the devices they supply, such as computers and
household electronics.
• Batteries.
• Chemical fuel cells and other forms of energy storage systems.
• Solar power.
• Generators or alternators.

MLRITM, EEE Dept Page 39


Microcontroller based Solar Tracker with Stepper Motor Control

Fig 3.24: Regulated Power Supply

The basic circuit diagram of a regulated power supply (DC O/P) with led
connected as load

Fig 3.25: Circuit diagram of Regulated Power Supply with Led connection

MLRITM, EEE Dept Page 40


Microcontroller based Solar Tracker with Stepper Motor Control

The components mainly used in above figure are

• 230V AC MAINS
• TRANSFORMER
• BRIDGE RECTIFIER(DIODES)
• CAPACITOR
• VOLTAGE REGULATOR(IC 7805)
• RESISTOR
• LED(LIGHT EMITTING DIODE)
The detailed explanation of each and every component mentioned above is as follows:
3.4.2 TRANSFORMERS:

A transformer is a device that transfers electrical energy from one circuit to another
through inductively coupled conductors without changing its frequency. A
varying current in the first or primary winding creates a varying magnetic flux in the
transformer's core, and thus a varying magnetic field through the secondary winding. This
varying magnetic field induces a varying electromotive force (EMF) or "voltage" in the
secondary winding. This effect is called mutual induction.

If a load is connected to the secondary, an electric current will flow in the secondary
winding and electrical energy will be transferred from the primary circuit through the
transformer to the load. This field is made up from lines of force and has the same shape
as a bar magnet.

If the current is increased, the lines of force move outwards from the coil. If the
current is reduced, the lines of force move inwards.

If another coil is placed adjacent to the first coil then, as the field moves out or in,
the moving lines of force will "cut" the turns of the second coil. As it does this, a voltage
is induced in the second coil. With the 50 Hz AC mains supply, this will happen 50 times
a second. This is called MUTUAL INDUCTION and forms the basis of the transformer.
MLRITM, EEE Dept Page 41
Microcontroller based Solar Tracker with Stepper Motor Control

The input coil is called the PRIMARY WINDING; the output coil is the
SECONDARY WINDING.

Fig 3.26: Step-Down Transformer

The voltage induced in the secondary is determined by the TURNS RATIO.

For example, if the secondary has half the primary turns; the secondary will have
half the primary voltage.

Another example is if the primary has 5000 turns and the secondary has 500 turns,
then the turn’s ratio is 10:1.

To aid magnetic coupling between primary and secondary, the coils are wound on
a metal CORE. Since the primary would induce power, called EDDY CURRENTS, into
this core, the core is LAMINATED. This means that it is made up from metal sheets
insulated from each other. Transformers to work at higher frequencies have an iron dust
core or no core at all.

Some transformers have an electrostatic screen between primary and secondary.


This is to prevent some types of interference being fed from the equipment down into the
mains supply, or in the other direction. Transformers are sometimes used for IMPEDANCE
MATCHING.We can use the transformers as step up or step down.

MLRITM, EEE Dept Page 42


Microcontroller based Solar Tracker with Stepper Motor Control

➢ Step Up transformer:

In case of step up transformer, primary windings are every less compared to secondary
winding.Because of having more turns secondary winding accepts more energy, and it
releases more voltage at the output side.

➢ Step down transformer:

Incase of step down transformer, Primary winding induces more flux than the
secondary winding, and secondary winding is having less number of turns because of that
it accepts less number of flux, and releases less amount of voltage.

3.4.3 BATTERY POWER SUPPLY:

A battery is a type of linear power supply that offers benefits that traditional line-
operated power supplies lack: mobility, portability and reliability. A battery consists of
multiple electrochemical cells connected to provide the voltage desired. Fig: 3.3.5 shows
Hi-Watt 9V battery

Fig 3.27: Hi-Watt 9V Battery

The most commonly used dry-cell battery is the carbon-zinc dry cell battery. Dry-
cell batteries are made by stacking a carbon plate, a layer of electrolyte paste, and a zinc
plate alternately until the desired total voltage is achieved.

MLRITM, EEE Dept Page 43


Microcontroller based Solar Tracker with Stepper Motor Control

3.4.4 RECTIFIERS :

A rectifier is an electrical device that converts alternating current (AC) to direct


current (DC), a process known as rectification. Rectifiers have many uses including as
components of power supplies and as detectors of radio signals. Rectifiers may be made of
solid-state diodes, vacuum tube diodes, mercury arc valves, and other components.

A device that it can perform the opposite function (converting DC to AC) is known
as an inverter.

When only one diode is used to rectify AC (by blocking the negative or positive
portion of the waveform), the difference between the term diode and the term rectifier is
merely one of usage, i.e., the term rectifier describes a diode that is being used to convert
AC to DC. Almost all rectifiers comprise a number of diodes in a specific arrangement for
more efficiently converting AC to DC than is possible with only one diode. Before the
development of silicon semiconductor rectifiers, vacuum tube diodes and copper (I) oxide
or selenium rectifier stacks were used.

➢ Bridge full wave rectifier:

The Bridge rectifier circuit is shown in fig:3.3.7, which converts an ac voltage to dc


voltage using both half cycles of the input ac voltage. The Bridge rectifier circuit is shown
in the figure. The circuit has four diodes connected to form a bridge. The load resistance is
connected between the other two ends of the bridge.

For the positive half cycle of the input ac voltage, diodes D1 and D3 conduct, whereas
diodes D2 and D4 remain in the OFF state. The conducting diodes will be in series with
the load resistance RL and hence the load current flows through RL. For the negative half
cycle of the input ac voltage, diodes D2 and D4 conduct whereas, D1 and D3 remain OFF.
The conducting diodes D2 and D4 will be in series with the load resistance RL and hence
the current flows through RL in the same direction as in the previous half cycle. Thus a bi-
directional wave is converted into a unidirectional wave.

MLRITM, EEE Dept Page 44


Microcontroller based Solar Tracker with Stepper Motor Control

Input Output

Fig 3.28: Bridge rectifier: a full-wave rectifier using 4 diodes

➢ DB107:

Now -a -days Bridge rectifier is available in IC with a number of DB107. In our


project we are using an IC in place of bridge rectifier.

Features:

• Good for automation insertion


• Polarity symbols molded on body
• Mounting position: Any
• Weight: 1.0 gram

Fig 3.29: DB107

MLRITM, EEE Dept Page 45


Microcontroller based Solar Tracker with Stepper Motor Control

3.4.5 FILTERS:

Electronic filters are electronic circuits, which perform signal-processing functions,


specifically to remove unwanted frequency components from the signal, to enhance wanted
ones.

Introduction to Capacitors:

The Capacitor or sometimes referred to as a Condenser is a passive device, and one


which stores energy in the form of an electrostatic field which produces a potential (static
voltage) across its plates. In its basic form a capacitor consists of two parallel conductive
plates that are not connected but are electrically separated either by air or by an insulating
material called the Dielectric. When a voltage is applied to these plates, a current flows
charging up the plates with electrons giving one plate a positive charge and the other plate
an equal and opposite negative charge. This flow of electrons to the plates is known as
the Charging Current and continues to flow until the voltage across the plates (and hence
the capacitor) is equal to the applied voltage Vcc. At this point the capacitor is said to be
fully charged and this is illustrated below. The construction of capacitor and an electrolytic
capacitor are shown in figures 3.10 and 3.11 respectively.

Fig 3.30:Construction Of a Capacitor

MLRITM, EEE Dept Page 46


Microcontroller based Solar Tracker with Stepper Motor Control

Fig 3.31:Electrolytic Capaticor

Units of Capacitance:

Microfarad (μF) 1μF = 1/1,000,000 = 0.000001 = 10-6 F

Nanofarad (nF) 1nF = 1/1,000,000,000 = 0.000000001 = 10-9 F

Pico farad (pF) 1pF = 1/1,000,000,000,000 = 0.000000000001 = 10-12 F

Operation of Capacitor:

Think of water flowing through a pipe. If we imagine a capacitor as being a storage


tank with an inlet and an outlet pipe, it is possible to show approximately how an electronic
capacitor works.

First, let's consider the case of a "coupling capacitor" where the capacitor is used to
connect a signal from one part of a circuit to another but without allowing any direct current
to flow.

If the current flow is alternating between zero and a maximum, our "storage tank"
capacitor will allow the current waves to pass through.
MLRITM, EEE Dept Page 47
Microcontroller based Solar Tracker with Stepper Motor Control

3.4.6 REGULATION:

The process of converting a varying voltage to a constant regulated voltage is called


as regulation. For the process of regulation we use voltage regulators.

➢ Voltage Regulator:

A voltage regulator (also called a ‘regulator’) with only three terminals appears to
be a simple device, but it is in fact a very complex integrated circuit. It converts a varying
input voltage into a constant ‘regulated’ output voltage. Voltage Regulators are available
in a variety of outputs like 5V, 6V, 9V, 12V and 15V. The LM78XX series of voltage
regulators are designed for positive input. For applications requiring negative input, the
LM79XX series is used. Using a pair of ‘voltage-divider’ resistors can increase the output
voltage of a regulator circuit.

It is not possible to obtain a voltage lower than the stated rating. You cannot use a
12V regulator to make a 5V power supply. Voltage regulators are very robust. These can
withstand over-current draw due to short circuits and also over-heating. In both cases, the
regulator will cut off before any damage occurs. The only way to destroy a regulator is to
apply reverse voltage to its input. Reverse polarity destroys the regulator almost instantly.
Fig: 3.3.11 shows voltage regulator.

Fig 3.32: Voltage Regulator

MLRITM, EEE Dept Page 48


Microcontroller based Solar Tracker with Stepper Motor Control

3.4.7 RESISTORS:

A resistor is a two-terminal electronic component that produces a voltage across its


terminals that is proportional to the electric current passing through it in accordance with
Ohm's law:

V = IR

Resistors can be made to control the flow of current, to work as Voltage dividers,
to dissipate power and it can shape electrical waves when used in combination of other
components. Basic unit is ohms.

Theory of operation:

➢ Ohm's law:

The behavior of an ideal resistor is dictated by the relationship specified in Ohm's


law:

V = IR

Ohm's law states that the voltage (V) across a resistor is proportional to the current
(I) through it where the constant of proportionality is the resistance (R).

Fig 3.33: Resistor Fig 3.34: Color Bands In Resistor

MLRITM, EEE Dept Page 49


Microcontroller based Solar Tracker with Stepper Motor Control

3.5. LED:

A light-emitting diode (LED) is a semiconductor light source. LED’s are used as


indicator lamps in many devices, and are increasingly used for lighting. Introduced as a
practical electronic component in 1962, early LED’s emitted low-intensity red light, but
modern versions are available across the visible, ultraviolet and infrared wavelengths, with
very high brightness. The internal structure and parts of a led are shown below.

Fig 3.35: Inside a LED Fig 3.36: Parts of a LED

3.5.1: WORKING OF A LED:

The structure of the LED light is completely different than that of the light bulb.
Amazingly, the LED has a simple and strong structure. The light-emitting semiconductor
material is what determines the LED's color. The LED is based on the semiconductor diode.

When a diode is forward biased (switched on), electrons are able to recombine with
holes within the device, releasing energy in the form of photons. This effect is called
electroluminescence and the color of the light (corresponding to the energy of the photon)
is determined by the energy gap of the semiconductor. An LED is usually small in area
(less than 1 mm2), and integrated optical components are used to shape its radiation pattern

MLRITM, EEE Dept Page 50


Microcontroller based Solar Tracker with Stepper Motor Control

and assist in reflection. LED’s present many advantages over incandescent light sources
including lower energy consumption, longer lifetime, improved robustness, smaller size,
faster switching, and greater durability and reliability. However, they are relatively
expensive and require more precise current and heat management than traditional light
sources. Current LED products for general lighting are more expensive to buy than
fluorescent lamp sources of comparable output. They also enjoy use in applications as
diverse as replacements for traditional light sources in automotive lighting (particularly
indicators) and in traffic signals. The compact size of LED’s has allowed new text and
video displays and sensors to be developed, while their high switching rates are useful in
advanced communications technology. The electrical symbol and polarities of led are
shown in fig: 3.4.3.

Fig 3.37: Electrical Symbol & Polarities of LED

LED lights have a variety of advantages over other light sources:

• High-levels of brightness and intensity


• High-efficiency
• Low-voltage and current requirements
• Low radiated heat

MLRITM, EEE Dept Page 51


Microcontroller based Solar Tracker with Stepper Motor Control

3.6.SOLAR CELL/PLATE:

A solar cell or photovoltaic cell is a device that converts solar energy into
electricity by the photovoltaic effect. Sometimes the term solar cell is reserved for
devices intended specifically to capture energy from sunlight, while the term photovoltaic
cell is used when the source is unspecified. Assemblies of cells are used to make solar
panel, solar modules, or photovoltaic arrays. Photovoltaic is the field of technology and
research related to the application of solar cells for solar energy.
Solar cell efficiencies vary from 6% for amorphous silicon-based solar cells to
40.7% with multiple-junction research lab cells and 42.8% with multiple dies assembled
into a hybrid package. Solar cell energy conversion efficiencies for commercially
available multi crystalline Si solar cells are around 14-19%.
Solar cells can also be applied to other electronics devices to make it self-power
sustainable in the sun. There are solar cell phone chargers, solar bike light and solar
camping lanterns that people can adopt for daily use.

3.6.1 EQUIVALENT CIRCUIT OF A SOLAR CELL:

FIG 3.38: Equivalent circuit of a solar cell

MLRITM, EEE Dept Page 52


Microcontroller based Solar Tracker with Stepper Motor Control

FIG 3.39: Schematic symbol of a solar cell

1. Photons in sunlight hit the solar panel and are absorbed by semi conducting materials,
such as silicon.

2. Electrons (negatively charged) are knocked loose from their atoms, allowing them to
flow through the material to produce electricity. Due to the special composition of solar
cells, only allow the electrons to move in a single direction. The complementary positive
charges that are also created (like bubbles) are called holes and flow in the direction
opposite of the electrons in a silicon solar panel.

3. An array of solar panels converts solar energy into a usable amount of direct current
(DC) electricity.

Solar battery chargers are better for the environment in a few ways. For one, with
them, batteries can be recharged, therefore no longer contributing to growing landfills.
Also, batteries have potentially harmful metals inside them – we do not want to be simply
throwing them out into landfills!

MLRITM, EEE Dept Page 53


Microcontroller based Solar Tracker with Stepper Motor Control

Also, if using batteries that can be recharged with a solar battery charger, a person
can stop wasting his or her money on the purchase of new batteries.

The batteries of cell phones, PDAs, laptops, mp3 players, and more can be
charged by solar battery chargers. This means that you do not have to rely on electricity
to charge these devices. This is especially good because most electricity is created by
non-sustainable, polluting methods.

Solar battery chargers are also good because they allow the users to charge
devices, even when no power outlets are around. This makes them especially useful when
working out in the field, traveling, hiking, and/or during an emergency.

FIG 3.40: SOLAR PANEL

A solar battery is one of the most important energy sources available to save
energy consumption, and serves as a spare source while normal power supply shuts
down. Systems using solar batteries have various scales from a few watts to a few
thousands of kilowatts, and also have various types. Conventionally, the solar battery has
been dominantly used in the form of a solar electricity generation plant where a large
number of solar batteries are arranged, or used for securing power supply.
MLRITM, EEE Dept Page 54
Microcontroller based Solar Tracker with Stepper Motor Control

3.6.2. WORKING OF A SOLAR PANEL:

Solar power systems employ photovoltaic cells to convert the radiant energy of
sunlight directly into electrical energy. Photovoltaic solar cells are semiconductor devices
which convert sunlight into electricity. Solar cells which utilize crystalline
semiconductors, such as silicon, offer the advantages of high performance and reliability.
Photovoltaic cells are silicon-base crystal wafers which produce a voltage between
opposite surfaces when light strikes one of the surfaces, which surface has a current
collecting grid thereon.

Typically, a plurality of solar cells are assembled and interconnected so as to form


a physically-integrated module, and then a number of such modules are assembled
together to form a solar panel. Several solar panels may be connected together to form a
larger array. In order to most efficiently use the electrical power generated by a
photovoltaic cell or photovoltaic array, it is desirable to maximize the power generated
by the photovoltaic cell or photovoltaic array, despite varying weather conditions.
Various sun tracking systems have been used to enhance the power generating efficiency
of the converging solar cell module.

3.6.3 APPLICATIONS OF SOLAR CELL:

Solar cells can also be applied to other electronics devices to make it self-power
sustainable in the sun. There are solar cell phone chargers, solar bike light and solar
camping lanterns that people can adopt for daily use.

Solar power plants can face high installation costs, although this has been
decreasing due to the learning curve. Developing countries have started to build solar
power plants, replacing other sources of energy generation.

MLRITM, EEE Dept Page 55


Microcontroller based Solar Tracker with Stepper Motor Control

3.7 VOLTAGE DIVIDER NETWORK:

In electronics, a voltage divider (also known as a potential divider) is a simple linear


circuit that produces an output voltage (Vout) that is a fraction of its input voltage (Vin).

The formula governing a voltage divider is similar to that for a current divider, but
the ratio describing voltage division places the selected impedance in the numerator, unlike
current division where it is the unselected components that enter the numerator.

A simple example of a voltage divider consists of two resistors in series or a


potentiometer. It is commonly used to create a reference voltage, and may also be used as
a signal attenuator at low frequencies.

Fig 3.41: Simple resistive voltage divider

A resistive divider is a special case where both impedances, Z1 and Z2, are purely resistive .

Substituting Z1 = R1 and Z2 = R2 into the previous expression gives:

As in the general case, R1 and R2 may be any combination of series/parallel resistors.

MLRITM, EEE Dept Page 56


Microcontroller based Solar Tracker with Stepper Motor Control

3.7.1 MOS VOLTAGE DIVIDER:

We can use the enhanced MOSFET as a nonlinear resistor while its gate and drain are
connected.

Example:

Resistive divider

As a simple example, if R1 = R2 then

As a more specific and/or practical example, if Vout=6V and Vin=9V (both commonly
used voltages), then:

And by solving using algebra, R2 must be twice the value of R1.

To solve for R1:

To solve for R2:

MLRITM, EEE Dept Page 57


Microcontroller based Solar Tracker with Stepper Motor Control

3.8 STEPPER MOTOR:

A stepper motor is an electro-mechanical 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.

Fig: 3.42: Stepper Motor Physical View

Stepper motor is a device which is used to convert the electrical pulses into
mechanical motion. Motion of the stepper motor will be step by step in the nature. The
interfacing of the stepper motor to the micro controller is showed below.

MLRITM, EEE Dept Page 58


Microcontroller based Solar Tracker with Stepper Motor Control

Fig 3.43: Stepper Motor physical view

Table 3.1: General specifications of stepper motor device

MLRITM, EEE Dept Page 59


Microcontroller based Solar Tracker with Stepper Motor Control

3.8.1 STEPPER MOTOR BASICS:

Fig 3.44: Stepper Motor Basic rotations

The above figure is the cross-section view of a single-stack variable-reluctance


motor. The stator core is the outer structure and has six poles or teeth. The inner device is
called the rotor and has four poles. Both the stator and rotor are made of soft steel. The
stator has three sets of windings as shown in the figure. Each set has two coils connected
in series. A set of windings is called a “phase”.

The motor above, using this designation, is a three-phase motor. Current is supplied
from the DC power source to the windings via the switches I, II, and, III. Starting with
state (1) in the upper left diagram, note that in state (1), the winding of Phase I is supplied
with current through switch I. This is called in technical terms, “phase I is excited”. Arrows

MLRITM, EEE Dept Page 60


Microcontroller based Solar Tracker with Stepper Motor Control

on the coil windings indicate the magnetic flux, which occurs in the air-gap due to the
excitation. In state I, the two stator.

Poles on phase I being excited are in alignment with two of the four rotor teeth.
This is an equilibrium state. Next, switch II is closed to excite phase II in addition to phase
I. Magnetic flux is built up at the stator poles of phase II in the manner shown in state (2),
the upper right diagram. A counter-clockwise torque is created due to the “tension” in the
inclined magnetic flux lines. The rotor will begin to move and achieve state (3), the lower
left diagram. In state (3) the rotor has moved 15°. When switch I is opened to de-energize
phase I, the rotor will travel another 15° and reach state (4). The angular position of the
rotor can thus be controlled in units of the step angle by a switching process. If the
switching is carried out in sequence, the rotor will rotate with a stepped motion; the
switching process can also control the average speed

➢ STEP ANGLE:

The step angle, the number of degrees a rotor will turn per step, is calculated
as follows:

MLRITM, EEE Dept Page 61


Microcontroller based Solar Tracker with Stepper Motor Control

3.8.2 TYPES OF STEPPER MOTOR:

(1) Unipolar stepper motor

(2) Bipolar stepper motor

➢ Unipolar stepper motor:

Fig 3.45: Unipolar Stepper Motor

Unipolar stepping motors with 5 or 6 wires are usually wired as shown in the
schematic in Figure 1, with a center tap on each of two windings. In use, the center taps of
the windings are typically wired to the positive supply, and the two ends of each winding
are alternately grounded to reverse the direction of the field provided by that winding. The
motor cross section shown in Figure 1 is of a 30 degree per step motor -- the difference
between these two motor types is not relevant at this level of abstraction. Motor winding
number 1 is distributed between the top and bottom stator pole, while motor winding
number 2 is distributed between the left and right motor poles. The rotor is a permanent
magnet with 6 poles, 3 south and 3 north, arranged around its circumference. For higher
angular resolutions, the rotor must have proportionally more poles. The 30 degree per step
motor in the figure is one of the most common permanent magnet motor designs, although
15 and 7.5 degree per step motors are widely available. As shown in the figure, the current
flowing from the center tap of winding 1 to terminal a causes the top stator pole to be a
north pole whiles the bottom stator pole is a south pole. This attracts the rotor into the
position shown. If the power to winding 1 is removed and winding 2 is energized, the rotor
will turn 30 degrees, or one step. To rotate the motor continuously, we just apply power to
the two windings in sequence. Assuming positive logic, where a 1 means turning on the
MLRITM, EEE Dept Page 62
Microcontroller based Solar Tracker with Stepper Motor Control

current through a motor winding, the following two control sequences will spin the motor
illustrated in Figure 1 clockwise 24 steps or 4 revolutions: two halves of each winding are
never energized at the same time. Both sequences shown above will rotate a permanent
magnet one step at a time. The top sequence only powers one winding at a time, as
illustrated in the figure above; thus, it uses less power. The bottom sequence involves
powering two windings at a time and generally produces a torque about 1.4 times greater
than the top sequence while using twice as much power.

➢ Bipolar stepper motor:

Fig 3.46: A bipolar stepper motor

Bipolar permanent magnet and hybrid motors are constructed with exactly the same
mechanism as is used on uni polar motors, but the two windings are wired more simply,
with no center taps. Thus, the motor itself is simpler but the drive circuitry needed to
reverse the polarity of each pair of motor poles is more complex. The schematic in Figure
2 shows how such a motor is wired, while the motor cross section shown here is exactly
the same as the cross section shown in Figure. The drive circuitry for such a motor requires
an H-bridge control circuit for each winding. Briefly, an H-bridge allows the polarity of
the power applied to each end of each winding to be controlled independently. The control
sequences for single stepping such a motor are shown below, using + and - symbols to
indicate the polarity of the power applied to each motor terminal:

To distinguish a bipolar permanent magnet motor from other 4 wire motors,


measure the resistances between the different terminals. It is worth noting that some
MLRITM, EEE Dept Page 63
Microcontroller based Solar Tracker with Stepper Motor Control

permanent magnet stepping motors have 4 independent windings, organized as two sets of
two. Within each set, if the two windings are wired in series, the result can be used as a
high voltage bipolar motor. If they are wired in parallel, the result can be used as a low
voltage bipolar motor. If they are wired in series with a center tap, the result can be used
as a low voltage Unipolar motor.

3.8.3 MOTOR CONTROL CIRCUTARY:

Fig 3.47: Magnetic Field Diagram

Current flowing through a coil produces a magnet field, which attracts a permanent
magnet rotor, which is connected to the shaft of the motor. The basic principle of stepper
control is to reverse the direction of current through the 2 coils of a stepper motor, in
sequence, in order to influence the rotor. Since there are 2 coils and 2 directions, that gives
us a possible 4-phase sequence. All we need to do is get the sequencing right and the motor
will turn continuously. You may wonder how the stepper can achieve such fine stepping
increments with only a 4-phase sequence. The internal arrangement of the motor is quite
complex- the winding and core repeating around the perimeter of the motor many
times. The rotor is advanced only a small angle, either forward or reverses, and the 4-phase
sequence is repeated many times before a complete revolution occurs.

MLRITM, EEE Dept Page 64


Microcontroller based Solar Tracker with Stepper Motor Control

Fig 3.48: Stepper Motor Basic Control Diagram

Let us return to the 4-phase sequence of reversing the current though the 2 coils. A
Bipolar stepper controller achieves the current reversal by reversing the polarity at the two
terminals of a coil. The Unipolar controller takes advantage of the center tap to achieve
the current reversal with a clever trick -- The other terminal is grounded to reverse the
current. Both terminals are never grounded at the same time, which would energize both
coils, achieving nothing but a waste of power.

3.8.4 CONCEPTUAL MODEL OF UNIPOLAR STEPPER MOTOR:

Fig 3.49: Conceptual Model of Unipolar Stepper Motor

MLRITM, EEE Dept Page 65


Microcontroller based Solar Tracker with Stepper Motor Control

With center taps of the windings wired to the positive supply, the terminals of each
winding are grounded. The rotor is guided in this manner from one winding to the next,
producing a continuous cycle

3.8.5 WAVE STEPPING:


The wave stepping sequence is shown below.
STEP L1 L2 L3 L4

1 H L L L

2 L H L L

3 L L H L
4 L L L H

Table 3.2: Wave Stepping


Wave stepping has less torque then full stepping. It is the least stable at higher speeds and
as low power consumption.
3.8.6 FULL STEPPING:

The full stepping sequence is shown below.

STEP L1 L2 L3 L4

1 H H L L
L H H L
2
3 L L H H

4 H L L H

Table 3.3: Full Stepping


Full stepping has the lowest resolution and is the strongest at holding its position. Clock-
wise and counter clockwise rotation is accomplished by reversing the step sequence.

MLRITM, EEE Dept Page 66


Microcontroller based Solar Tracker with Stepper Motor Control

3.8.7 HALF-STEPPING – A COMBINATION OF WAVE AND FULL STEPPING:

The half-step sequence is shown below.

STEP L1 L2 L3 L4
1 H L L L
2 H H L L
3 L H L L
4 L H H L
5 L L H L
6 L L H H
7 L L L H
8 H L L H

Table 3.4: Half Stepping

The half-step sequence has the most torque and is the most stable at higher speeds.
It also has the highest resolution of the main stepping methods. It is a combination of full
and wave stepping.

3.8.8 ADVANTAGES OF STEPPER MOTOR:

1. The rotation angle of the motor is proportional to the input pulse.


2. The motor has full torque at standstill (if the windings are energized)
3. The motors response to digital input pulses provides open-loop control, making the
motor simpler and l less costly to control.
3.8.9 DISADVANTAGES OF STEPPER MOTOR:

1. Resonances can occur if not properly controlled.

2. Not easy to operate at extremely high speeds.

MLRITM, EEE Dept Page 67


Microcontroller based Solar Tracker with Stepper Motor Control

3.9 LIMIT SWITCH:


Limit Switch are basic switches that have been encased to protect them from
external forces, water, oil, and dirt. Many models are available, such as those resistant to
head, cold, or corrosion, as well as high-precision models.

Fig 3.50: Limit switch

Limit Switches & Limit Switch Information: A mechanical limit switch interlocks
a mechanical motion or position with an electrical circuit. A good starting point for limit-
switch selection is contact arrangement. The most common limit switch is the single-pole
contact block with one NO and one NC set of contacts; however, limit switches are
available with up to four poles.

Limit switches also are available with time-delayed contact transfer. This type is
useful in detecting jams that cause the limit switch to remain actuated beyond a
predetermined time interval.

Other limit switch contact arrangements include neutral-position and two-step.


Limit switches feature a neutral-position or center-off type transfers one set of contacts
with movement of the lever in one direction. Lever movement in the opposite direction
transfers the other set of contacts. Limit switches with a two-step arrangement, a small
movement of the lever transfers one set of contacts, and further lever movement in the
same direction transfers the other set of contacts.

MLRITM, EEE Dept Page 68


Microcontroller based Solar Tracker with Stepper Motor Control

3.9.1 WORKING OF LIMIT SWITCH:

Limit switch is one type Of " Contact Sensor" , In that there is Normally Open
Contact & Normally Close Contact, In limit switch there is Plunger it is Directly Connected
to NO & NC Contact if we press the plunger NO contact become NC & NC contact become
NO, Working Principle same as Contactor ( DOL starter ) main difference is in contactor
There is Coil to attract the Plunger But In Limit Switch Plunger is Operated Mechanically.
Limit Switches is used mainly for Safety Purpose & to take Feed back for PLC in
Automation industries........

➢ Actuator heads: Fixed type with back and forward motion or rotary type.
➢ Casing: The limit switch assembly is enclosed in casings that have to conform to
NEMA standards. They can be made of plastic or metal.
➢ Torque force to operate (maximum and minimum): This attribute ensures that the
machine operator does not trip the limit switch due to accidental contact.
➢ Travel to operate: This refers to the maximum distance the actuator has to depress
before the limit switch operates.

3.9.2 APPLICATIONS OF LIMIT SWITCH:

Limit switches are used in automatic machine tools to control the carriage and toll
slide movement.

They are typically used in capstan and turret lathes, radial drills, milling and boring
machines, grinding machines, honing, gun drilling, crank shaft and cam grinding machines,
heat treatment equipment, machine door guards, etc.

They are also used in scissor lifts, conveyor systems, transfer machines, material
packing and handling equipment, elevators, escalators, hoists and cranes, industrial trucks
and tractors, cranes and hoists, overhead door limit switches, and general safety equipment.

MLRITM, EEE Dept Page 69


Microcontroller based Solar Tracker with Stepper Motor Control

3.10: LDR:

A photo resistor or light dependent resistor or cadmium sulfide (CdS) cell is a resistor
whose resistance decreases with increasing incident light intensity. It can also be referenced
as a photoconductor.

3.10.1 PHOTORESISTOR:

FIG 3.51: The symbol for a photo resistor

Fig 3.52: LDR

An LDR is made of a high-resistance semiconductor. If light falling on the device is


of high enough frequency, photons absorbed by the semiconductor give bound electrons
enough energy to jump into the conduction band. The resulting free electron (and its hole
partner) conduct electricity, thereby lowering resistance.

A photoelectric device can be either intrinsic or extrinsic. In intrinsic devices, the


only available electrons are in the valence band, and hence the photon must have enough

MLRITM, EEE Dept Page 70


Microcontroller based Solar Tracker with Stepper Motor Control

energy to excite the electron across the entire band gap. Extrinsic devices have impurities
added, which have a ground state energy closer to the conduction band - since the electrons
don't have as far to jump, lower energy photons (i.e. longer wavelengths and lower
frequencies) are sufficient to trigger the device.

3.10.2 LIGHT DEPENDENT RESISTOR – LDR:

Two cadmium sulphide (cds) photoconductive cells with spectral responses similar
to that of the human eye The cell resistance falls with increasing light intensity.
Applications include smoke detection, automatic lighting control, and batch counting and
burglar alarm systems.

FIG 3.53: LDR

Guide to source illuminations:

• Light source Illumination LUX


• Moonlight 0.1
• 60W Bulb at 1m 50
• 1W MES Bulb at 0.1m 100
• Fluorescent Lighting 500
• Bright Sunlight 30,000

MLRITM, EEE Dept Page 71


Microcontroller based Solar Tracker with Stepper Motor Control

➢ Sensitivity:

The sensitivity of a photo detector is the relationship between the light falling on the
device and the resulting output signal. In the case of a photocell, one is dealing with the
relationship between the incident light and the corresponding resistance of the cell.

3.10.3 RESISTANCE AS FUNCTION OF ILLUMINATION:

➢ Spectral Response:

FIG 3.54: Spectral response

MLRITM, EEE Dept Page 72


Microcontroller based Solar Tracker with Stepper Motor Control

Like the human eye, the relative sensitivity of a photoconductive cell is dependent
on the wavelength (color) of the incident light. Each photoconductor material type has its
own unique spectral response curve or plot of the relative response of the photocell versus
wavelength of light.

➢ Dimensions:

3.10.4 TYPICAL APPLICATION CIRCUITS:

MLRITM, EEE Dept Page 73


Microcontroller based Solar Tracker with Stepper Motor Control

The internal components of a photoelectric control for a typical American streetlight:

The photo resistor is facing rightwards, and controls whether current flows through
the heater which opens the main power contacts. At night, the heater cools, closing the
power contacts, energizing the street light. The heater/bimetal mechanism provides a built-
in time-delay.

A photo resistor or light dependent resistor or cadmium sulfide (CdS) cell is a resistor
whose resistance decreases with increasing incident light intensity. It can also be referenced
as a photoconductor.

MLRITM, EEE Dept Page 74


Microcontroller based Solar Tracker with Stepper Motor Control

Fig 3.55: Diagram of testing of LDR:

A photo resistor is made of a high resistance semiconductor. If light falling on the


device is of high enough frequency, photons absorbed by the semiconductor give bound
electrons enough energy to jump into the conduction band. The resulting free electron (and
its whole partner) conducts electricity, thereby lowering resistance.

A photoelectric device can be either intrinsic or extrinsic. An intrinsic semiconductor


has its own charge carriers and is not an efficient semiconductor, e.g. silicon. In intrinsic
devices the only available electrons are in the valence band, and hence the photon must
have enough energy to excite the electron across the entire band gap. Extrinsic devices
have impurities, also called do pants, and added whose ground state energy is closer to the
conduction band; since the electrons do not have as far to jump, lower energy photons (i.e.,
longer wavelengths and lower frequencies) are sufficient to trigger the device. If a sample
of silicon has some of its atoms replaced by phosphorus atoms (impurities), there will be
extra electrons available for conduction. This is an example of an extrinsic semiconductor.

MLRITM, EEE Dept Page 75


Microcontroller based Solar Tracker with Stepper Motor Control

3.10.5: APPLICATIONS OF LDR:

Photo resistors come in many different types. Inexpensive cadmium sulfide


cells can be found in many consumer items such as camera light meters, street
lights, clock radios, alarms, and outdoor clocks.They are also used in some
dynamic compressors together with a small incandescent lamp or light emitting
diode to control gain reduction.

Lead sulfide (PbS) and indium antimonide (InSb) LDR’s (light dependent resistor)
are used for the mid infrared spectral region. Ge:Cu photoconductors are among the best
far-infrared detectors available, and are used for infrared astronomy and infrared
spectroscopy.

Photoconductive cells are used in many different types of circuits and Applications.

➢ Analog Applications:

• Camera Exposure Control


• Auto Slide Focus - dual cell
• Photocopy Machines - density of toner
• ·Colorimetric Test Equipment
➢ Digital Applications:

• Automatic Headlight Dimmer


• Night Light Control
• Oil Burner Flame Out
• Street Light Control
• Absence / Presence (beam breaker)
• Position Sensor

MLRITM, EEE Dept Page 76


Microcontroller based Solar Tracker with Stepper Motor Control

CHAPTER-4
SOFTWARE SIMULATION
This project is implemented using following software’s:
• Express PCB – for designing circuit
• PIC C compiler - for compilation part
• Proteus 7 (Embedded C) – for simulation part

4.1 EXPRESS PCB:

Breadboards are great for prototyping equipment as it allows great flexibility to


modify a design when needed; however the final product of a project, ideally should have
a neat PCB, few cables, and survive a shake test. Not only is a proper PCB neater but it is
also more durable as there are no cables which can yank loose.

Express PCB is a software tool to design PCBs specifically for manufacture by the
company Express PCB (no other PCB maker accepts Express PCB files). It is very easy to
use, but it does have several limitations.

• It can be likened to more of a toy then a professional CAD program.


• It has a poor part library (which we can work around)
• It cannot import or export files in different formats
• It cannot be used to make prepare boards for DIY production

Express PCB has been used to design many PCBs (some layered and with surface-
mount parts. Print out PCB patterns and use the toner transfer method with an Etch
Resistant Pen to make boards. However, Express PCB does not have a nice print layout.
Here is the procedure to design in Express PCB and clean up the patterns so they print
nicely.

MLRITM, EEE Dept Page 77


Microcontroller based Solar Tracker with Stepper Motor Control

4.1.1 PREPARING EXPRESS PCB FOR FIRST USE:

Express PCB comes with a less then exciting list of parts. So before any project is
started head over to Audio logic and grab the additional parts by morsel, ppl, and tangent,
and extract them into your Express PCB directory. At this point start the program and get
ready to setup the workspace to suit your style.

Click View -> Options. In this menu, setup the units for “mm” or “in” depending
on how you think, and click “see through the top copper layer” at the bottom. The standard
color scheme of red and green is generally used but it is not as pleasing as red and blue.

4.1.2 THE INTERFACE:

When a project is first started you will be greeted with a yellow outline. This yellow
outline is the dimension of the PCB. Typically after positioning of parts and traces, move
them to their final position and then crop the PCB to the correct size. However, in designing
a board with a certain size constraint, crop the PCB to the correct size before starting.

Fig 4.1: Tool bar necessary for the interface

• The select tool: It is fairly obvious what this does. It allows you to move and
manipulate parts. When this tool is selected the top toolbar will show buttons to
move traces to the top / bottom copper layer, and rotate buttons.
• The zoom to selection tool: does just that.
• The place pad: button allows you to place small soldier pads which are useful for
board connections or if a part is not in the part library but the part dimensions are

MLRITM, EEE Dept Page 78


Microcontroller based Solar Tracker with Stepper Motor Control

available. When this tool is selected the top toolbar will give you a large selection
of round holes, square holes and surface mount pads.
• The place component: tool allows you to select a component from the top toolbar
and then by clicking in the workspace places that component in the orientation
chosen using the buttons next to the component list. The components can always
be rotated afterwards with the select tool if the orientation is wrong.
• The place trace: tool allows you to place a solid trace on the board of varying
thicknesses. The top toolbar allows you to select the top or bottom layer to place
the trace on.
• The Insert Corner in trace: button does exactly what it says. When this tool is
selected, clicking on a trace will insert a corner which can be moved to route around
components and other traces.
• The remove a trace button is not very important since the delete key will achieve
the same result.

4.1.3 DESIGN CONSIDERATIONS:

Before starting a project there are several ways to design a PCB and one must be
chosen to suit the project’s needs.

Single sided, or double sided?

When making a PCB you have the option of making a single sided board, or a
double sided board. Single sided boards are cheaper to produce and easier to etch, but
much harder to design for large projects. If a lot of parts are being used in a small space
it may be difficult to make a single sided board without jumper over traces with a cable.
While there’s technically nothing wrong with this, it should be avoided if the signal
travelling over the traces is sensitive (e.g. audio signals).

MLRITM, EEE Dept Page 79


Microcontroller based Solar Tracker with Stepper Motor Control

4.2 PIC COMPLIER:


PIC compiler is software used where the machine language code is written and
compiled. After compilation, the machine source code is converted into hex code which
is to be dumped into the microcontroller for further processing. PIC compiler also
supports C language code.
It’s important that you know C language for microcontroller which is commonly
known as Embedded C. As we are going to use PIC Compiler, hence we also call it PIC
C. The PCB, PCM, and PCH are separate compilers. PCB is for 12-bit opcodes, PCM is
for 14-bitopcodes, and PCH is for 16-bit opcode PIC microcontrollers. Due to many
similarities, all three compilers are covered in this reference manual. Features and
limitations that apply to only specific microcontrollers are indicated within. These
compilers are specifically designed to meet the unique needs of the PIC microcontroller.
This allows developers to quickly design applications software in a more readable, high-
level language. When compared to a more traditional C compiler, PCB, PCM, and PCH
have some limitations. As an example of the limitations, function recursion is not
allowed.
This is due to the fact that the PIC has no stack to push variables onto, and also
because of the way the compilers optimize the code. The compilers can efficiently
implement normal C constructs, input/output operations, and bit twiddling operations. All
normal C data types are supported along with pointers to constant arrays, fixed point
decimal, and arrays of bits.
PIC C is not much different from a normal C program. If you know assembly,
writing a C program is not a crisis. So you have to make sure that your program or main
file should never exit. This can be done with the help of simple while (1) or for (;;) loop
as they are going to run infinitely.
We have to add header file for controller you are using, otherwise you will not be
able to access registers related to peripherals.

#include <16F877A.h> // header file for PIC 16F877A//

MLRITM, EEE Dept Page 80


Microcontroller based Solar Tracker with Stepper Motor Control

4.3 PROTEUS:

Proteus is software which accepts only hex files. Once the machine code is
converted into hex code, that hex code has to be dumped into the microcontroller and this
is done by the Proteus. Proteus is a programmer which itself contains a microcontroller in
it other than the one which is to be programmed. This microcontroller has a program in it
written in such a way that it accepts the hex file from the pic compiler and dumps this hex
file into the microcontroller which is to be programmed.

It’s important that you know C language for microcontroller which is commonly
known as Embedded C. As we are going to use PIC Compiler, hence we also call it PIC C.
The PCB, PCM, and PCH are separate compilers. PCB is for 12-bit opcodes, PCM is for
14-bitopcodes, and PCH is for 16-bit opcode PIC microcontrollers. Due to many
similarities, all three compilers are covered in this reference manual. Features and
limitations that apply to only specific microcontrollers are indicated within. These
compilers are specifically designed to meet the unique needs of the PIC microcontroller.
This allows developers to quickly design applications software in a more readable, high-
level language. When compared to a more traditional C compiler, PCB, PCM, and PCH
have some limitations. As an example of the limitations, function recursion is not allowed.

Proteus is a programmer which itself contains a microcontroller in it other than the


one which is to be programmed. This microcontroller has a program in it written in such a
way that it accepts the hex file from the pic compiler and dumps this hex file into the
microcontroller which is to be programmed.

MLRITM, EEE Dept Page 81


Microcontroller based Solar Tracker with Stepper Motor Control

4.4 PROCEDUTRAL STEPS FOR COMPILATION, SIMULATION


AND DUMPING:

PROGRAM CODE:

The program code which is dumped in the microcontroller of our project is shown
below.

#include <16F72.h>

#include <string.h>

#include <dc motor.h>

#fuses HS,NOWDT,PROTECT,brownout,put

#use delay (clock=20000000)

void main()
{
int i = 0;

output_high(PIN_C3);
delay_ms(1000);
output_low(PIN_C3);
delay_ms(1000);
output_high(PIN_C3);
delay_ms(1000);
output_low(PIN_C3);

MLRITM, EEE Dept Page 82


Microcontroller based Solar Tracker with Stepper Motor Control

while(1)
{
if(!input(PIN_A0))
{
forward();
}
if(!input(PIN_A1))
{
forward();
}
if(!input(PIN_A2))
{
forward();
}
if(!input(PIN_A3))
{
forward();
}

if(!input(PIN_A5)) //Reverse
{
reverse();
}
delay_ms(700);
}
}

MLRITM, EEE Dept Page 83


Microcontroller based Solar Tracker with Stepper Motor Control

CHAPTER-5
PROJECT DESCRIPTION

In this chapter, schematic diagram and interfacing of PIC16F72 microcontroller with


each module is considered.

Fig 5.1: Schematic diagram of Microcontroller based solar tracker with Stepper
motor control
The above schematic diagram of Microcontroller based solar tracker with Stepper
motor control using microcontroller and explains the interfacing section of each
component with micro controller and solar cell. Crystal oscillator connected to 9th and 10th
pins of micro controller and regulated power supply is also connected to micro controller
and LED’s also connected to micro controller through resistors.

MLRITM, EEE Dept Page 84


Microcontroller based Solar Tracker with Stepper Motor Control

The detailed explanation of each module interfacing with microcontroller is as


follows:

5.1 Interfacing crystal oscillator and reset button with micro controller:

It explains crystal oscillator and reset button which are connected to micro
controller. The two pins of oscillator are connected to the 9th and 10th pins of micro
controller; the purpose of external crystal oscillator is to speed up the execution part of
instructions per cycle and here the crystal oscillator having 20 MHz frequency. The 1st
pin of the microcontroller is referred as MCLR ie.., master clear pin or reset input pin is
connected to reset button or power-on-reset.

MLRITM, EEE Dept Page 85


Microcontroller based Solar Tracker with Stepper Motor Control

Fig 5.2: Crystal oscillator and reset input interfacing with micro controller

MLRITM, EEE Dept Page 86


Microcontroller based Solar Tracker with Stepper Motor Control

Fig 5.3: View of Microcontroller based solar tracker with stepper motor control

MLRITM, EEE Dept Page 87


Microcontroller based Solar Tracker with Stepper Motor Control

CHAPTER-6
ADVANTAGES AND DISADVANTAGES

6.1 ADVANTAGES:

1. Conservation of Non Renewable energy sources.


2. Maximum output can be obtained.
3. Efficient and low cost design.
4. Low power consumption.

6.2 DISADVANTAGES:

1. Periodic Monitoring and Maintenance is required.

6.3 APPLICATIONS:

1. This energy can be utilized for simple house hold appliances.


2. This energy can be stored and utilized as backup power supply mainly in industries.

MLRITM, EEE Dept Page 88


Microcontroller based Solar Tracker with Stepper Motor Control

CHAPTER-7
CONCLUSION AND FUTURE SCOPE
7.1 CONCLUSION:

Integrating features of all the hardware components used have been developed in
it. Presence of every module has been reasoned out and placed carefully, thus contributing
to the best working of the unit. Secondly, using highly advanced IC’s with the help of
growing technology, the project has been successfully implemented. Thus the project has
been successfully designed and tested.

7.2 FUTURE SCOPE:

Our project “Microcontroller based Solar Tracker with Stepper Motor Control” is
mainly intended to design and construct a solar tracker system that follows the sun
direction for producing maximum out for solar powered applications.

This project consists of few sun light sensors and a motorized mechanism for
rotating the panel in the direction of sun. Microcontroller based control system takes care
of sensing sunlight and controlling the motorized mechanism. This system works
continuously without any interruption.

The main controlling device of the project is Microcontroller to which LDR’s and
stepper motor with panel setup to its shaft are interfaced. The Microcontroller gets input
from LDR sensors regarding the direction of sun and controller process this information
and controls the movement of solar panel attached to Stepper motor with driver. The
Microcontroller is programmed using powerful Embedded C language.

This project can be extended in a way such that the output from the solar plate is
increased. This can be done by increasing the dimensions of the solar plate.

MLRITM, EEE Dept Page 89


Microcontroller based Solar Tracker with Stepper Motor Control

REFERENCES

The sites which were used while doing this project:

1. www.allaboutcircuits.com

2. www.microchip.com

3.IEEE paper-:Model Based Design Controller for the Stepper MotoCalinRusu ,Iulian
Birou, EniköSzokeTechnical University of Cluj,Dept. ofElectrical Drives and Robots.

4.IEEE paper-: Stepper Motor Drives for Robotic Applications-Benetta Aranjo,Prashant


Kumar Soori, and Puja Talukder.

5.Anoymous, 1998a. High performance micro-controllers, Data Sheet, Microchip


Technology Inc.

6.Anoymous, 1998b. National Semicon. Data Sheet, pp:1024-28.

7.Davies, 1993. P.A.. Sun-Tracking Mechanism Using Equatorial and Ecliptic Axes. Solar
Energy, v.50, 6:487-489.

8.Harakawa, T., Tujimoto, T. 2001. A proposal of efficiency improvement with solar power
generation system. Industrial Electronics Society, 2001. IECON.

9.The 27th Annual Conference of the IEEE, 1:523-8. Konar, A., Mandal,. A. K. 1991.
Microprocessor Based Automatic Sun Tracker. IEE Proc.-A. Vol. 138, 4:237-1.

10.Koyuncu, B., Balasubramanian, K. 1991. A micro-processor controlled automatic sun


tracker. IEEE Trans. on Consumer Elects., Vol. 37, 4 : 913-7.

MLRITM, EEE Dept Page 90

You might also like