Professional Documents
Culture Documents
DEPATMENT OF MECHATRONICS
PIC Microcontroller
Propeller Clock
SUPERSIED BY
Dr. Mohammed Aqel
DECEMBER 2016
SEMESTER I 2016/2017
i
ACKNOWLEDGEMENT
Praise and thanks to Allah first and foremost whose blessing enabled us to
accomplish this project.
We wish to express my deepest appreciation to our Dr. Mohammed Aqel
and for relentless guidance, helpful suggestion, close supervision and moral
encouragement to complete this project.
A special thanks to our parents and to all our teachers I have had.
Our sincerely thanks to all those whom directly or indirectly help us to
complete this project.
ii
ABSTRACT
iii
TABLE OF CONTENTS
TITLE PAGE
Propeller clock 1
1. Introduction 2
2. Objectives 2
3. Requirement 2
3.1 Software 2
3.2 Hardware 2
4. Background 3
4.2 DC motor 4
4.3 led 5
5. Design 5
6. Code 8
7. Conclusion 9
iv
TABLE OF FIQURE
v
PROPLLER
CLOCK
1
1. Introduction
In this project, our aim is to make Propeller Clock that contains a dc motor
12 V, row of a seven yellow leds, and Pic16f84a that it is programed on micro
C program that will be shown in the next pages that when the motor is rotating
the microcontroller keeps switching leds off and on, one after another, very
rapidly. Due to the slow response of the human eye, we get the impression that
the lights are on all together and we can read or display the digital clock.
2. Object of project
3. Project Requirement
3.1 Software:
1. Micro C program: use to write the code.
2. Proteus: use to make simulation to the circuit.
3. K150 software: use to write code on PIC 16f84a.
3.2 Hardware
1. Programmer for the Microcontroller.
2. pic 16f84a.
3. leds.
4. Resistance (220 ohm,10K ohm).
5. Crystal 4Mhz, capacitor(33pf).
6. Power supply.
7. Wires.
2
4. Background
4.1 PIC16F84A
3
As you can see, it is an 18 pin IC. Below are the pin descriptions:
Pin 5: Vss – This is the ground pin of the IC and must be connected to the
negative terminal of the battery.
Pin 14: Vdd – This is the supply pin of the IC and must be connected to the
positive terminal of the battery.
Pin 4: MCLR – Memory Clear. This is a active low pin.
Pins 15&16: Oscillator in/out – here you connect a crystal oscillator. Maximum
frequency you can use is 20MHz. You can use a 4MHz crystal also. The higher
the frequency of crystal used, the faster the controller
Pins 1,2,3,6,7,8,9,10,11,12,13,17&18: These are the 13 I/O pins. They are
grouped into two groups. Port A which contains 5 pins (17,18,1,2&3) and Port B
which contains 8 pins (6,7,8,9,10,11,12&13)
As mentioned earlier, these 13 I/O pins can be individually configured either as
input or output and each pin can supply (source) or it can absorb(sink) a
maximum of 25mA current.
4.2 DC Motor
DC motors seem quite simple. Apply a voltage to both terminals, and it will spin. 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. By referring Figure 3.5, 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.
4
Figure 2: Diagram of DC motor component.
4.3 LED
A led (light-emitting diode) is a semiconductor light source. LEDs are used as
indicator lamps in many devices, and are increasingly used for lighting.
Introduced as a practical electronic component in 1962.Early LEDs emitted
low-intensity red light, but modern versions are available across the visible,
ultraviolet and infrared wavelengths, with very high brightness.
5. Design:
5.1 Design of propeller clock project.
5
5.3 Design circuit at proteus.
First, we have to make a design on proteus for the circuit to test it and
make it ready for PCB printing, the figure below show the proteus design
and connection and the PCB layout of the circuit.
6
5.4 The project after manufacturing.
7
6 Code:
int i ; int j ; int d1 ; int d2 ; int d3 ; int d4 ; int d5 ; // identify variable will used.
const int number[11][5]= { //identify array that contain the shape of number.
{0,0,231,0,0}, // the shape of " : " .
{62,65,65,65,62}, // the shape of number zero "0"
{0,64,127,66,0 },// the shape of number one"1"
{70,73,81,97,66 },// the shape of number two "2"
{49,75,69,65,33} , // the shape of number three "3"
{16,127,18,20,24} , // the shape of number four "4"
{57,69,69,69,39} , // the shape of number fife "5"
{48,73,73,74,60} , // the shape of number six "6"
{3,5,9,113,1} , // the shape of number seven "7"
{54,73,73,73,54} , // the shape of number eight "8"
{30,41,73,73,6},// the shape of number nine "9"
};
void print_number(int x) { //Function for printing the shape of number.
for(i=0;i<5;i++) { portb=number[x][i] ; delay_us(270) ; }
portb=0 ; delay_us(300) ;}
void main() {
trisb=0; // make portb as output
d1 = 2 ; d2 = 0 ; d3 = 3 ; d4 = 1 ;d5 = 1 ;//give initial value of variable that will
display the initial number of clock.
while(1) {
for(j=0 ; j<25 ; j++ ) {
print_number(d5) ;//will display the first digit of minutes.
print_number(d4) ;//will display the second digit of minutes.
print_number(d2) ; //will display the shape of " : ".
print_number(d3) ; //will display the first digit of hours.
print_number(d1) ; //will display the second digit of hours.
delay_ms(20) ;} ++d5;
if(d5==11){++d4;d5=1;}// increase the second digit of minutes every 10 minutes.
if(d4==7){++d3;d4=1;} // increase the first digit of hour every 60 minutes.
if(d3==11){++d1;d3=1;} // increase the second digit of hour every 10 hours.
if(d1==2&&d3==4){d5=1;d4=1;d3=1;d1=1;}} // if the clock be 12:59 will make it to
initial state.
8
7 Conclusion
After the final, we learn how to make project from first to final, learn how to
face problem during designing and solve it, learn how to apply the science
that we learn to make project.
We hope we will be successful in view of our project and we take Excellent
degree.