Академический Документы
Профессиональный Документы
Культура Документы
BACHELOROF TECHNOLOGY
IN
ELECTRICAL ENGINEERING
By
Brijesh Patel
(14bee021)
May 2018
CERTIFICATE
This is to certify that the Major Project Report entitled “Design of the propeller
clock” submitted by Mr./Ms. Brijesh Mrugeshkumar Patel (14bee021) towards the
partial fulfillment of the requirements for the award of degree in Bachelor of
Technology in the field of Electrical Engineering of Nirma University is the record of
work carried out by him/her under our supervision and guidance. The work submitted
has in our opinion reached a level required for being accepted for examination. The
results embodied in this major project work to the best of our knowledge have not been
submitted to any other University or Institution for award of any degree or diploma.
Date:
Acknowledgement (i)
Abstract (ii)
Chapter 1: Introduction
1.1. Persistence of Vision
1.2. Background Review and Design Considerations
1.3. Resolution and Colors
Chapter 3: DESCRIPTION
3.1 Dc motor
3.2 Microcontroller
3.3 LED Module
3.4 Interrupt Module
3.5 Mechanical assembly
This is to certify that Brijesh Mrugeshkumar Patel (14bee021), a student of B.Tech. in Electrical
engineering from Institute of Technology, Nirma University worked as a project trainee during
Jan,2018 to . During this period he/she was found regular and had done his/her project on
“Design of the propeller clock”, under my supervision.
He/she has worked with utmost dedication and high level of engineering and analytical
competence.
Date:
(Signature)
Prof. Chintan Mehta
1. INTRODUCTION
Persistence of vision (POV) refers to a phenomenon whereby the human retina retains an after-
image of anything it sees for a short time (approximately one twenty-fifth of a second). This
phenomenon renders a person unable to distinguish between different images viewed in quick
succession. By taking advantage of this phenomenon, it should be possible to produce an
electronic display that appears to have a significantly higher resolution than its hardware would
ordinarily dictate, by physically and rapidly moving the display hardware in space and modifying
the display output based on its current physical position. If the display hardware is moved fast
enough, the eye should perceive the visual output from the hardware at multiple physical
positions simultaneously, giving the perception of a two- or three-dimensional display even
though the physical hardware consists of just a one-dimensional “wand” of LEDs. The aim of
this project is to design and manufacture such a system.
There are many “persistence of vision displays” in existence, both commercial and non-
commercial. Appendix A shows a number of examples. These persistence of vision displays
differ vastly in size, shape and capabilities1, but all share the ability to physically move a number
of LEDs rapidly in physical space. The Figures show just three examples of possible POV
display shapes. In Figure 2, a small number of LEDs are oscillated from side to side in order to
produce a two-dimensional arc display. This would commonly be used for displaying text, such
as a digital clock . In Figure 3, rotation is used rather than oscillation in order to produce the
perception of a circular display. This could be used to display text, images, video or any other
visual media. Figure 4 is an example of a three-dimensional POV display: a one-dimensional
array of LEDs are still used but these are rotated about an axis parallel to, rather than
perpendicular to, the LEDs in order to produce a cylindrical display (alternatively a sphere could
be produced by curving the line of LEDs). A three-dimensional display has the added benefit of
being viewable from any direction around the system.
The resolution of a POV display is partially dictated by the number of LEDs physically present
in the system. However, due to the persistence of vision phenomenon caused by physical
movement of the LEDs, the perceived resolution in the direction(s) of motion is much greater
than the actual number of LEDs present. For example, if a column of 50 LEDs arranged
vertically were to be rapidly moved left and right in twodimensional space, and the output of
these LEDs were changed 100 times between the left-most and rightmost points of movement
(and the complete sweep from one side to the other were completed before the after-image had
disappeared from the retina), the effective (perceived) resolution of the display would be 100px
by 50px rather than the 1px by 50px resolution that the system hardware would suggest. In other
words, the resolution in any directions of physical movement is dictated by the number of times
the LED output is modified by software within one twenty-fifth of a second. Simple POV
displays can use single-colour LEDs in order to produce their text, images or other media. This
has the advantage of being significantly easier to wire and program, while limiting the
information/media that can be displayed. At the other end of the spectrum, full-colour (RGB)
LEDs are available with three input channels in order to produce eight colours initially.
2. PROJECT OBJECTIVES
The aim of this project will be to design and implement a “persistence of vision display”, as
defined above. The display will physically consist of a one- or two-dimensional array of LEDs,
but these LEDs will be moved rapidly in physical space in order to produce the illusion of a
three-dimensional display when viewed from any of a number of angles. This movement will be
in a rotating, rather than oscillating, fashion, and should be implemented using a motor. A
microprocessor should be used to receive and/or compute images to be displayed.
Power will need to be transferred into the rotating body in order to light the LEDs: a means to
achieve this will need to be considered. If the microprocessor is not mounted within the rotating
portion of the system, a means for transferring the LED data into the rotating body will also need
to be considered. The system should be capable of rotating safely at 24 revolutions per second
(1440 RPM) in order to achieve a smooth virtual image. The system display should, however, be
capable of running independently of this revolution speed: in other words, the system must have
some means of determining its current speed in order that fluctuations in the RPM do not ruin the
perceived effect.
The display should be capable of displaying text and low-resolution images such as shapes and
cartoon characters: in order to achieve this the perceived display resolution should be a minimum
of 32px by 32px. Ideally the resolution will be greater than this, but this will be dependent on a
number of hardware considerations which will be investigated during the course of the project. If
time and software/hardware considerations permit, the system could be extended in order to
display photographs, animations, video, and/or include interactivity such as basic games that
respond to user input.
The system must be able to interface with a PC in order to receive images for display: this would
ideally take place over a wireless link and allow the system to receive images on-the-fly whilst
rotating, but at a minimum could just be achieved by a physical connection to a PC when the
display is not moving.
The finished product could be used in the advertising industry, to display company logos, details
or animations in a novel way. Alternatively, the product could be used as an entertainment
product in much the same way as large television displays could be used at various entertainment
events. Again, the novelty of the device would be a key factor here, as well as the potentially
reduced cost of the lower number of LEDs required.
3. DESCRIPTION:
The Main Part of the propeller display is Microcontroller AT89S52.We can also use the others
like ATMega32A, 8051, PIC microcontrollers but here I am using this because of its low cost.
The IR LED, which is stationary, is fixed on the base of rotating assembly. When the IR rays
sent by the IR LED falls on the photo diode, which is placed on the rotating PCB,it will generate
a low pulse on the interrupt pin of microcontroller which results in the generation of desired
pattern. We are making use of internal program execution EA(external access) pin has to be
made high with the help of VCC.A reset circuit is provided for the reset of microcontroller. The
anodes of LEDs are joined together and connected to 5v supply. Logic 0 level at the output of
port0 will result in illumination of LED.
3.1 DC Motor:
DC motors, apply a voltage to both terminals, and it will spins. DC motors are non- polarized
which means that it can reverse voltage so the motor will rotate in two directions, forward and
backward. Typical DC motors are rated from about 6V -12V. The larger ones are often 24V or
more but for the purpose of this project, it is necessary to use 6V-12V range motor. Voltage is
directly related to motor torque. The more voltage supplied, the higher the torque will be
produce.Specifications of most DC motors show high revolutions per minute (rpm) and low
torque. The DC motor is popular in a number of drive applications due to its simple operation
and control. In figure it has 2 main parts which is rotor and stator. Stator is the part where the
permanent magnet situated and used to generate the magnetic field and it is static. Rotor is the
rotary part in the motor and contains block of core and wire loops. It also called the armature.
3.2 Microcontroller:
In this project AT89S52 micro-controller is used which consists of 40pins that are dedicated to
various functions. Out of the 40 pins, a total of 32 pins are set aside for four ports P0, P1, P2, and
P3 where each port takes 8 pins. The rest of the pins are designated as GND, Vcc, XTAL1,
XTAL2, RST, EA, and PSEN. The micro-controller (AT89S52) has an on -chip oscillator but
requires and external clock to run it. Often a quartz oscillator is connected to inputs XTAL1 (pin
19) and XTAL2 (pin 18).We can also use the crystal oscillator The quartz oscillator connected to
XTAL1and XTAL2 also needs two capacitors 33pF.The RST pin (9th pin) is an input and is
active high. Upon applying a high pulse to this pin, the micro -controller will reset and terminate
all activities. This is often referred to as a power-on reset. Vcc is used to power up the entire
micro-controller, which is pin 40 and GND is pin 20. Here port P1 is used as output port to
which LEDs are connected.
2. Variables declarations:
More precisely, this part is dedicated to ‘Global Variables’ declarations. Variables
declared in this place can be used anywhere in the code. Usually in microcontroller
programs, variables are declared as global variables instead of local variables, unless your
are running short of RAM memory and want to save some space, so we use local
variables, whose values will be lost each time you switch from a function to another. To
summarize, global variables as easier to use and implement than local variables, but they
consume more memory space.
3. Functions’ body:
Here you group all your functions. Those functions can be simple ones that can be called
from another place in your program, as they can be called from an ‘interrupt vector’. In
other words, the sub-programs to be executed when an interrupt occurs is also written in
this place.
4. Initialization:
The particularity of this part is that it is executed only one time when the microcontroller
was just subjected to a ‘RESET’ or when power is just switched ON, then the processor
continue executing the rest of the program but never executes this part again. This
particularity makes it the perfect place in a program to initialize the values of some
constants, or to define the mode of operation of the timers, counters, interrupts, and other
features of the microcontroller.
5. Infinite loop
An infinite loop in a microcontroller program is what is going to keep it alive, because a
processor have to be allays running for the system to function, exactly like a heart have to
be always beating for a person to live. Usually this part is the core of any program, and
it’s from here that all the other functions are called and executed.
Here is a very simple but complete example program to blink a LED. Actually it is the source
code of the example project that we are going to construct in the next part of the tutorial, but for
now it is important to concentrate on the programming to summarize the notions discussed
above.
After including basic headers for the SFR definitions of the 8952 microcontroller (REGX52.h)
and for mathematical functions (math.h), a function named ‘delay’ is created, which is simple a
function to create a delay controlled via the parameter ‘y’. Then comes the main function, with
an infinite loop (the condition for that loop to remain will always be satisfied as it is ’1′). Inside
that loop, the pin number 0 of port 1 is constantly turned ON and OFF with a delay of
approximately one second.
You will prompted to choose a name for your new project, Create a separate folder where all
the files of your project will be stored, chose a name and click save. The following window
will appear, where you will be asked to select a device for Target ‘Target 1′: From the list at
the left, seek for the brand name NXP, then under NXP, select 89c51. You will notice that a
brief description of the device appears on the right. Leave the two upper check boxes
unchecked and click OK. The P89V51RD2 will be called your ‘Target device’, which is the
final destination of your source code. You will be asked whether to ‘copy standard 8051
startup code‘ click No.
Click File, New, and something similar to the following window should appear. The box
named ‘Text1′ is where your code should be written later.
Now you have to click ‘File, Save as’ and chose a file name for your source code ending
with the letter ‘.c’. You can name is ‘code.c’ for example, and click save. Then you have to
add this file to your project work space at the left as shown in the following screen shot:
After right-clicking on ‘source group 1‘, click on ‘Add files to group…‘, then you will be
prompted to browse the file to add to ‘source group 1′, chose the file that you just saved,
eventually ‘code.c’ and add it to the source group. You will notice that the file is added to
the project tree at the left.
In some versions of this software you have to turn ON manually the option to generate HEX
files. make sure it is turned ON, by right-clicking on target 1, Options for target ‘target 1′,
then under the ‘output‘ tab, by checking the box ‘generate HEX file‘. This step is very
important as the HEX file is the compiled output of your project that is going to be
transferred to the micro-controller.
You can then start to write the source code in the window titled ‘code.c’ then before testing
your source code, you have to compile your source code, and correct eventual syntax errors.
In KEIL IDE, this step is called ‘rebuild all targets’ and has this icon: .
You can use the output window to track eventual syntax errors, but also to check the FLASH
memory occupied by the program (code = 49) as well as the registers occupied in the RAM (data
= 9). If after rebuilding the targets, the ‘output window’ shows that there is 0 error, then you are
ready to test the performance of your code. In KEIL, like in most development environment, this
step is called Debugging, and has this icon: . After clicking on the debug icon, you will
notice that some part of the user interface will change, some new icons will appear, like the
run icon circled in the following figure:
You can click on the ‘Run’ icon and the execution of the program will start. In our example,
you can see the behavior of the pin 0 or port one, but clicking on ‘peripherals, I/O ports, Port
1′. You can always stop the execution of the program by clicking on the stop button ( )
and you can simulate a reset by clicking on the ‘reset’ button
Most microcontrollers come with a set of ‘ADD-ONs’ called peripherals, to enhance the
functioning of the microcontroller, to give the programmer more options, and to increase the
overall performance of the controller. Those features are principally the timers, counters,
interrupts, Analog to digital converters, PWM generators, and communication buses like
UART, SPI or I2C. The P89V51RD2 is not the most equipped micro-controller in terms of
peripherals, but never the less, the available features are adequate to a wide range of
applications, and it is one of the easiest to learn on the market.
Figure below shows a simplified diagram of the main peripherals present in the
P89V51RD2 and their interaction with the CPU and with the external I/O pins. You can
notice that there are three timers/Counters. We use the expression “Timer/Counter” because
this unit can be a counter when it counts external pulses on its corresponding pin, and it can
be a timer when it counts the pulses provided by the main clock oscillator of the
microcontroller. Timer/Counter two is a special counter that does not behave like the two
others, because it have a couple of extra functionality.
The serial port, using a UART (Universal Asynchronous Receive Transmit) protocol can be used
in a wide range of communication applications. With the UART provided in the P89V51RD2
you can easily communicate with a serial port equipped computer, as well as communicate with
another microcontroller. This last application, called Multi-processor communication, is quite
interesting, and can be easily implemented with two P89V51RD2 microcontrollers to build a
very powerful multi-processor controllers.
If all the peripherals described above can generate interrupt signals in the CPU according to
some specific events, it can be useful to generate an interrupt signal from an external device
that may be a sensor or a Digital to Analog converter. For that purpose there are two
External Interrupt sources (INT0 and INT1).
As you noticed in figure, in the P89V51RD2, there are two external interrupt sources, one
connected to the pin P3.2 and the other to P3.3. They are configured using a number of SFRs
(Special Function Registers). Most of those SFRs are shared by other peripherals as you
shall see in the rest of the tutorial.
The first register you have to configure (by turning On or Off the right bits) is the IE
register, shown in figure 16. IE stands for ‘Interrupt Enable’, and it is used to allow
different peripherals to cause software interruption. To use any of the interrupts, the bit EA
(Enable ALL) must be set to 1, then, you have enable each one of the interrupts to be used
with its individual enable bit. For the external interrupts, the two bits EX0 and EX1 are used
for External Interrupt 0 and External Interrupt 1.
Using the C programming language under KEIL, it is extremely simple to set those bits,
simply by using their name as any global variables, using the following syntax:
EA = 1;
EX0 = 1;
EX1 = 1;
The rest of the bits of IE register are used for other interrupt sources like the 3 timers
overflow (ETx) and the serial interface (ES).
Similarly, you have to set the bits IT0 and IT1 in the TCON register, shown in figure 4.2.B. The
bits IT0/IT1 are used to configure the type of signal on the corresponding pins (P3.2/P3.3) that
generated an interrupt according to the following table:
If IT0 or IT1 is set to 0, an interruption will keep reoccurring as long as P3.2 or P3.3 is set to
0. This mode isn’t easy to manage, and most programmers tends to use external interrupts
triggered by a falling edge (transition from 1 to 0).
Again, this register is ‘bit addressable’ meaning you can set or clear each bit individually
using their names, like in the following example:
IT0 = 1;
IT1 = 1;
1. Timer: Counting internal clock pulses, which are fixed with time, hence, we can say that it
is very precise timer, whose resolution depends on the frequency of the main CPU clock
(note that CPU clock equals the crystal frequency over 12).
2. Counter: Counting external pulses (on the corresponding I/O pin), which can be provided
by a rotational encoder, an IR-barrier sensor, or any device that provide pulses, whose
number would be of some interest.
Sure, the CPU of a microcontroller could provide the required timing or counting, but the
timer/counter peripheral relieves the CPU from that redundant and repetitive task, allowing it to
allocate maximum processing power for more complex calculations.
So, like any other peripheral, a Timer/Counter can ask for an interruption of the program,
which – if enabled – occurs when the counting registers of the Timer/Counter are full and
overflow. More precisely, the interruption will occur at the same time the counting register
will be reinitialized to its initial value.
So to control the behavior of the timers/counters, a set of SFR are used, most of them have
already been seen at the top of this tutorial.
The TCON register is also shared between more than one peripherals. It can be used to
configure timers or, as you saw before, external interrupts. The following table shows the
names and definitions of the concerned bits of the TCON register
TR1 Timer/counter 1 RUN bit, set it to 1 to enable the timer to count, 0 to stop counting.
TR0 Timer/counter 0 RUN bit, set it to 1 to enable the timer to count, 0 to stop counting.
As the IE register, TCON is also bit-addressable, so you can set its bit using its names, like
we did before. Example:
TR0 = 1;
Propeller LED Display
Before explaining the TMOD register, let us agree and make it clear that the register IS
NOT BIT-ADDRESSABLE, meaning you have to write the 8 bits of the register in a single
instruction, by coding those bits into a decimal or hexadecimal number, as you shall see
later.
So, as you can see in figure 16, the TMOD register can be divided into two similar set of
bits, each group being used to configure the mode of operation of one of the two timers.
For the given Timer/Counter, the corresponding bits of TMOD can be defined as in the
following table:
G If you want to use the timers to capture external events’s length, set it to 1, and the timer 1/0 will stop counting when
External Interrupt 1/0 pin is low (set to 0 V). Note that this feature involves both a timer and an external interrupt, It
you’re responsibility to write the code to manage the operation of those two peripherals.
C/T’ Set to 1 to use the timer/counter 1/0 as a Counter, counting external events on P3_4/P3_5, cleared to 0 to use it as
timer, counting the main oscillator frequency divided by 12.
M1
Timer MODE: Those two last bits combine as 2 bit word that defines the mode of operation, defined as the table below.
M0
Timer/counter will count up from the value initially stored in TH0/1 to 255, and then overflow
back to 0.
If used as timer, pulses from the processor are divided by 32 (after being divided by 12). The result
is the main oscillator frequency divided by 384.
Timer/counter will count up from the 16 bit value initially stored in TH0/1 and TL0/1 to 65535,
and then overflow back to 0.
If used as timer, pulses from the processor are only divided by 12.
If used as counter, external pulses are not divided, but the maximum frequency that can be
accurately counted equals the oscillator frequency divided by 24.
TL0/1 is used for counting, forming an 8 bit timer/counter. TH0/1 is used to hold the value to
be restored in TL upon overflow.
Timer/counter will count up from the 8 bit value initially stored in TL0/1 and to 255, and
then overflow, setting the value of TH0/1 in TL0/1. This is called the auto-reload function.
1 0 2
If an interrupt is enabled, an interrupt will occur upon overflow.
If used as timer, pulses from the processor are only divided by 12.
If used as counter, external pulses are not divided, but the maximum frequency that can be accurately
counted equals the oscillator frequency divided by 24.
Timer modes 1 and 2 are the most used in 8051 microcontroller projects, since
they offer a wide range of possible customization.
Main routine:
1. Load proper value in IE register, so that the interrupts INT0 and T0 are enabled. (IE = 83H)
2. Offer higher priority to the INT0 (External) interrupt. (IP = 01H)
3. Configure timer 1 as 16-bit timer, and timer 0 as 8-bit auto reload mode timer. ( TMOD =
12H)
4. INT0 should be configured as edge interrupt. (IT0 = 1)
5. Configure port 3 as input port. (P3 = 0FFH)
6. Move input string to the video RAM area. (call ‘ramc’ function)
7. Start the timers.
8. Initiate an infinite loop.
Interrupt Routines:
(a)External Interrupt:
1.Stop the timers.
2.Move th1 and tl1 into convenient registers.
3.Divide this 16 bit value by our total number of segments.
4.Subtract the answer from 256, and load the result in th0.
5.Now, reset the video RAM pointer and character segment pointers to their initial respective
positions.
6. Start the timers.
7. Return from interrupt.