You are on page 1of 11

A Lab Project Report

On
“DIGITAL CLOCK”

Submitted as a part of
“DIGITAL SIGNAL PROCESSING LAB”
Submitted by

17311A04U5
ABU HURERA

Under the Supervision of

“Miss P.LAVANYA”

(Signature)

Department of Electronics & Communication Engineering

Sreenidhi Institute of Science & Technology


(An Autonomous Institution affiliated to JNTUH)
Yamnampet , Ghatkesar , Hyderabad – 501 301.

1
Contents page no.

Abstract 3

1. Introduction/ Objective 4

2. Background Theory 4

3. Block diagram/flow chart/algorithm 5

4. Description of Matlab Functions 6

5. Program with comments 7

6. Result 11

7. Future Score 11

8. Conclusion 11

2
DIGITAL CLOCK

1.ABSTRACT:

A digital clock is a type of clock that displays the time digitally (i.e. in numerals or other
symbols) as opposed to an analog clock, where the time is indicated by the positions of rotating
hands. Digital clocks are often associated with electronic drives, but the "digital" description
refers only to the display, not to the drive mechanism. (Both analog and digital clocks can be
driven either mechanically or electronically, but "clockwork" mechanisms with digital displays
are rare).

Digital clocks typically use the 50 or 60 hertz oscillation of AC power or a 32,768 hertz crystal
oscillator as in a quartz clock to keep time. Most digital clocks display the hour of the day in 24-
hour format in the United States and a few other countries, a commonly-used hour sequence
option is 12-hour format (with some indication of AM or PM). Some timepieces, such as
many digital watches, can be switched between 12-hour and 24-hour modes. Emulations of
analog-style faces often use an LCD screen, and these are also sometimes described as "digital".

Uses the inbuilt clock function to get the system time .Using this ,some conditional statements
are used to determine what sections of the display need to be fully colored in order to display the
correct digits .the display is created using patches and the sections of the digits are switched on
or off by controlling the alpha values of the patches.

KEYWORDS:
1. disp
2. circle
3. figure
4. outerposition
5. position
6. Xticks(ticks)
7. Facealpha
8. Drawnow

3
2.BACKGROUND THEORY:
The first digital pocket watch was the invention of Austrian engineer Josef Pallweber who
created his "jump-hour" mechanism in 1883. Instead of a conventional dial, the jump-hour
featured two windows in an enamel dial, through which the hours and minutes are visible on
rotating discs. The second hand remained conventional. By 1885 Pallweber mechanism was
already on the market in pocket watches by Cortebert and IWC; arguably contributing to the
subsequent rise and commercial success of IWC. The principles of Pallweber jump-hour
movement had appeared in wristwatches by the 1920s (Cortébert) and are still used today
(Chronoswiss Digiteur). While the original inventor didn't have a watch brand at the time, his
name has since been resurrected by a newly established watch manufacturer.[1]

Plato clocks used a similar idea but a different layout. These spring-wound pieces consisted of a
glass cylinder with a column inside, affixed to which were small digital cards with numbers
printed on them, which flipped as time passed. The Plato clocks were introduced at the St. Louis
World Fair in 1904, produced by Ansonia Clock Company. Eugene Fitch of New York patented
the clock design in 1903.[2] 13 years earlier Josef Pallweber had patented the same invention
using digital cards (different from his 1885 patent using moving disks) in Germany (DRP No.
54093).[3] The German factory Aktiengesellschaft für Uhrenfabrikation Lenzkirch made such
digital clocks in 1893 and 1894.[4]

The earliest patent for a digital alarm clock was registered by D.E Protzmann and others on
October 23, 1956, in the United States. Protzmann and his associates also patented another
digital clock in 1970, which was said to use a minimal amount of moving parts. Two side-plates
held digital numerals between them, while an electric motor and cam gear outside controlled
movement.[2]

In 1970, the first digital wristwatch with an LED display was mass-produced. Called the Pulsar,
and produced by the Hamilton Watch Company, this watch was hinted at two years prior when
the same company created a prototype digital watch for Kubrick's 2001: A Space
Odyssey.[5] Throughout the 1970s, despite the initial hefty cost of digital watches, the popularity
of said devices steadily rose.

Over the years, many different types of digital alarm clocks have been developed.

4
To represent the time, most digital clocks use a seven-segment LED, VFD, or LCD for each of
four digits. They generally also include other elements to indicate whether the time is AM or
PM, whether or not an alarm is set, and so on.

If people find difficulty in setting the time in some designs of digital clocks in electronic devices
where the clock is not a critical function, they may not be set at all, displaying the default after
powered on, 00:00 or 12:00.[6][7]

Because they run on electricity, digital clocks often need to be reset whenever the power is cut
off, even for a very brief period of time. This is a particular problem with alarm clocks that have
no "battery" backup, because a power outage during the night usually prevents the clock from
triggering the alarm in the morning.

To reduce the problem, many devices designed to operate on household electricity incorporate
a battery backup to maintain the time during power outages and during times of disconnection
from the power supply. More recently, some devices incorporate a method for automatically
setting the time, such as using a broadcast radio time signal from an atomic clock, getting the
time from an existing satellite television or computer connection, or by being set at the factory
and then maintaining the time from then on with a quartz movement powered by an internal
rechargeable battery. Commercial digital clocks are typically more reliable than consumer
clocks. Multi-decade backup batteries can be used to maintain time during power loss

3.ALGORITHM

STEP 1: Defines initial patch coordinates for the digits in hour section.

STEP 2: Defines patch coordinates for the other digits based on the first digit.

STEP 3: Create circle to separate hours, minutes, seconds.

STEP 4: Create initial patches for display.

STEP 5: Create patches for digits.

STEP 6: Define axis co ordinates, scale, figure properties

STEP 7: Determine hours, minutes. seconds digits

STEP 8: Update digits and make dots on every alternate second.

5
4.DESCRIPTION OF MATLAB FUNCTIONS
1. disp(1).topcenter = It defines intial patch coordinates for digits of hour sectionof the left digit
.Example 1: disp(1).topcenter : [0 5 4 1 0;0 0 -1 -1 0];
It displays at top center
Example 2 : disp(1).midcenter = [0 0.5 4.5 5 4.5 0.5 0;-6 -5.5 -5.5 -6 -6.5 -6.5 -6];
It displays at the mid center
Circle: circle is used to plot a circle with a given radius and center so that we can separate hours
,minutes and seconds in the clock.
Example: circle(1,i) = R * cos(theta) + 12.5;
circle(2,i) = R * sin(theta) - 3.5;
theta = theta + ( 2* pi) / n;
i = i + 1;
figure: h = figure(n) finds a figure in which the number property is equal to n ,and makes it the
current figure. If no figure exits with that property value, matlab creates a new figure and sets its
number property to n.
Example: h = figure(1);
4.Outerposition: outer boundary of the axes,including the title,labels,and a marin.it specifies the
form as [left bottom width height].The left and bottom values indicates the distance from the
lower left corner of the figure to the lower left corner of the outer boundary. The width and
height values indicates the outer boundary dimensions.
Example: set(h,'Color',[1 1 1],'OuterPosition',[0 0 450 265],'Resize','off')
5.position:It specifies this property as a vector of the form[left bottom width height]
Example: axes('Position',[0.025 0.015 0.75 0.5])
6.Xticks(ticks):It sets the x-axis tick values ,which are the locations along the x-axis where the
tick mark appear.
Example: set(gca,'XTick',[],'YTick',[],'XColor',[1 1 1],'YColor',[1 1 1],'ZColor',[1 1 1])
7.Facealpha:It is used to create the patch objects which are transparent
Example: set(circle(1:4),'FaceAlpha',1)

6
5.PROGRAM:

clc

clear all

close all

disp(1).topcenter = [0 5 4 1 0;0 0 -1 -1 0];


disp(1).midcenter = [0 0.5 4.5 5 4.5 0.5 0;-6 -5.5 -5.5 -6 -6.5 -6.5 -6];
disp(1).botcenter = [0 1 4 5 0;-12 -11 -11 -12 -12];
disp(1).topleft = [0 1 1 0 0;-0.5 -1.5 -4.5 -5.5 -0.5];
disp(1).botleft = [0 1 1 0 0;-6.5 -7.5 -10.5 -11.5 -6.5];
disp(1).topright = [5 5 4 4 5;-0.5 -5.5 -4.5 -1.5 -0.5];
disp(1).botright = [5 5 4 4 5;-6.5 -11.5 -10.5 -7.5 -6.5];
disp_increment = [0 6 14 20 28 34];
for i = 2:6
disp(i) = disp(1);
disp(i).topcenter(1,:) = disp(i).topcenter(1,:) + disp_increment(i);
disp(i).midcenter(1,:) = disp(i).midcenter(1,:) + disp_increment(i);
disp(i).botcenter(1,:) = disp(i).botcenter(1,:) + disp_increment(i);
disp(i).topleft(1,:) = disp(i).topleft(1,:) + disp_increment(i);
disp(i).botleft(1,:) = disp(i).botleft(1,:) + disp_increment(i);
disp(i).topright(1,:) = disp(i).topright(1,:) + disp_increment(i);
disp(i).botright(1,:) = disp(i).botright(1,:) + disp_increment(i);
end
R = 0.5;
theta = 0;
i = 1;
n = 72;
circle = zeros(8,71);
while theta <= 2 * pi - 0.1
circle(1,i) = R * cos(theta) + 12.5;
circle(2,i) = R * sin(theta) - 3.5;

7
theta = theta + ( 2* pi) / n;
i = i + 1;
end
circle(3,:) = circle(1,:);
circle(4,:) = circle(2,:) - 5;
circle(5,:) = circle(1,:) + 14;
circle(6,:) = circle(2,:);
circle(7,:) = circle(5,:);
circle(8,:) = circle(4,:);
h = figure(1);
set(h,'Color',[1 1 1],'OuterPosition',[0 0 450 265],'Resize','off')
axes('Position',[0.025 0.015 0.75 0.5])
count = 1;
for i = 1:6
digit(count) = patch(disp(i).topcenter(1,:),disp(i).topcenter(2,:),'k','EdgeAlpha',0);
count = count + 1;
digit(count) = patch(disp(i).midcenter(1,:),disp(i).midcenter(2,:),'k','EdgeAlpha',0);
count = count + 1;
digit(count) = patch(disp(i).botcenter(1,:),disp(i).botcenter(2,:),'k','EdgeAlpha',0);
count = count + 1;
digit(count) = patch(disp(i).topleft(1,:),disp(i).topleft(2,:),'k','EdgeAlpha',0);
count = count + 1;
digit(count) = patch(disp(i).botleft(1,:),disp(i).botleft(2,:),'k','EdgeAlpha',0);
count = count + 1;
digit(count) = patch(disp(i).topright(1,:),disp(i).topright(2,:),'k','EdgeAlpha',0);
count = count + 1;
digit(count) = patch(disp(i).botright(1,:),disp(i).botright(2,:),'k','EdgeAlpha',0);
count = count + 1;
end
for i = 1:4
circle(i) = patch(circle(i * 2 - 1,:),circle(i * 2,:),'k','EdgeAlpha',0);

8
end
axis equal
axis([-1 40 -13 1])
set(gca,'XTick',[],'YTick',[],'XColor',[1 1 1],'YColor',[1 1 1],'ZColor',[1 1 1])
count = 1;
while count ~= 0
C = clock;
for i = 1:42
set(digit(i),'FaceAlpha',1)
end
cur_digit(1) = floor(C(4) / 10);
cur_digit(2) = C(4) - (cur_digit(1) * 10);
cur_digit(3) = floor(C(5) / 10);
cur_digit(4) = C(5) - (cur_digit(3) * 10);
C(6) = round(C(6));
cur_digit(5) = floor(C(6) / 10);
cur_digit(6) = C(6) - (cur_digit(5) * 10);
if cur_digit(5) == 6
cur_digit(5) = 0;
end
for i = 1:6
if cur_digit(i) == 1
set(digit(-6 + (i * 7):-2 + (i * 7)),'FaceAlpha',0.15)
elseif cur_digit(i) == 2
set(digit(-3 + (i * 7)),'FaceAlpha',0.15)
set(digit(i * 7),'FaceAlpha',0.15)
elseif cur_digit(i) == 3
set(digit(-3 + (i * 7):-2 + (i * 7)),'FaceAlpha',0.15)
elseif cur_digit(i) == 4
set(digit(-6 + (i * 7)),'FaceAlpha',0.15)
set(digit(-4 + (i * 7)),'FaceAlpha',0.15)

9
set(digit(-2 + (i * 7)),'FaceAlpha',0.15)
elseif cur_digit(i) == 5
set(digit(-2 + (i * 7):-1 + (i * 7)),'FaceAlpha',0.15)
elseif cur_digit(i) == 6
set(digit(-1 + (i * 7)),'FaceAlpha',0.15)
elseif cur_digit(i) == 7
set(digit(-5 + (i * 7):-2 + (i * 7)),'FaceAlpha',0.15)
elseif cur_digit(i) == 9
set(digit(-2 + (i * 7)),'FaceAlpha',0.15)
elseif cur_digit(i) == 0
set(digit(-5 + (i * 7)),'FaceAlpha',0.15)
end
end
if (cur_digit(6) == 1)||(cur_digit(6) == 3)||(cur_digit(6) == 5)||(cur_digit(6) == 7)||(cur_digit(6)
== 9)
set(circle(1:4),'FaceAlpha',0.15)
else
set(circle(1:4),'FaceAlpha',1)
end
Drawnow
end

10
6.RESULT

7.FUTURE SCOPE

As we now that times plays major role in our day to day life activities. There are different types
of clocks like digital and analog clocks which represents the time. Every software which needs
system time can use the code to access to system time. It is used in home automation. In alarm
clocks.

8.CONCLUSION

As time is precious this codes use in many application. It uses the in built clock function to get
the system time. In this the display is created using patches and the sections of the digits are
switched ‘on’ or ’off’’ by controlling the alpha values of the patches.

11

You might also like