Maker Pro
Maker Pro

Zany Clock

eleeng

May 24, 2013
7
Joined
May 24, 2013
Messages
7
A microcontroller-based clock is passé. But this project is different. Instead of the usual display showing the digits on an LCD or LED display, this project shows the seconds, minutes, and hours
scrolling past a marker, which is why it is titled Zany Clock! Its block diagram is shown below.
untitled3.bmp

Design Specifications
The objective of this project is to design a microcontroller-based clock with an unusual display that shows the time scrolling past a marker. The project is battery operated so that it can be portable and can work even in the absence of mains power.

Design Description
Figure 4-16 shows the schematic diagram of the project. It uses a Tiny861 microcontroller and a Nokia display to show the time. The microcontroller uses an external crystal of 7.3728 MHz to generate the system clock frequency. The same system clock frequency is used to maintain and manage real time. The project is battery powered with a 9V battery (four 1.5V batteries could also be used). The battery voltage is regulated with a LP2950-3.3V regulator to power
the microcontroller as well as the Nokia display. The circuit shows additional components such as an op-amp and a connector for a condenser mic, but these components are not associated with the
clock project. These components are for a different project. The system has two switches, S1 and S2, which are used to set the time and to scroll the display. The clock maintains seconds, minutes,
hours, and days of the week. However, only three items can be seen at any given point, due to the limited size of the display. Switch S2 is used to scroll through all these components.
untitled4.bmp

Fabrication
The board layout in EAGLE, along with the schematic, can be downloaded from here.
The board is routed in the component (top) layer with a few jumpers in the solder (bottom) layer. The component side and solder side of the board are shown in Figures 4-17 and 4-18, respectively. Two working demonstrations are shown in Figures 4-19 and 4-20.

Forthe entire project, read the source page: url removed
 
Last edited by a moderator:

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
It looks rather hard to read. A display with higher resolution and/or greyscale and/or colour would be a lot better.
 

eleeng

May 24, 2013
7
Joined
May 24, 2013
Messages
7
Fabrication
The board is routed in the component (top) layer with a few jumpers in the solder (bottom) layer. The component side and solder side of the board are shown in Figures 4-17 and 4-18, respectively. Two working demonstrations are shown in Figures 4-19 and 4-20.
1.bmp

2.bmp

The code runs at a clock frequency of 7.3728 MHz. The controller is programmed using STK500 in ISP programming mode. To run the device on an external clock, CKSEL fuses must be programmed to “1101” before programming the controller. Certain parts of the code are common to previous projects involving the use of the NOKIA 3310;
thus, we have included the LCD library in our project, thereby eliminating the need to write the LCD interfacing code all over again. The functions related to interfacing the LCD and displaying data on the LCD are taken directly from this library.
Now to generate the display pattern as a timeline, we have created two functions: boxes and centerline. The former draws the outer boundary of time quantities on the zero, second, and fourth page, whereas the latter draws a centerline used to view the elapsing time. The centerline has X coordinates of 41 and 42, and is present on every page. Data related to seconds, minutes, and hours is stored in a constant array table in program memory. A particular character or digit requires 12 columns for display, and the table consists of
60 such characters, thus requiring a total of 720 columns. Similarly, table2 contains data related to days. The display block of each day requires 18 columns; thus, the total size of the
array is 18 x 7 = 126.
TIMER0 is initialized with a frequency of 7200 Hz, obtained by prescaling the system frequency by 1,024, and the overflow interrupt is enabled by setting TOIE0 bit in TIMSK register. Further prescaling is achieved with the software as shown in the code segment of the ISR:
Code:
ISR(TIMER0_OVF_vect)
//timer interrupt service routine
{
TCNT0L=(255-225);
count++;
if(count==8)
//software prescaling by 8
{
count=0;
if(s.c==0)//sec count
s.c=1;
if(m.c<20)//min count
m.c++;
if(h.c<1200)//hour count
h.c++;
if(d.c<19200)//day count
d.c++;
}
}
In this routine, the timer register is initialized such that the timer counts 225 and not 255 when it overflows. The timer runs at a frequency of 7,200 Hz; thus, an overflow interrupt occurs at 225/7,200 sec. Now the main content of the ISR is executed when count reaches a value of 8. This means that the content is executed every 225 x 8/7,200 of a second, which is nothing but one-quarter of a second.
A particular second elapses when its 12 columns surpass the timeline or centerline. Thus, on every eighth timer interrupt, that is, on one-quarter of a second, three columns should surpass the timeline.
This is done in the main loop of the program. An infinite while loop keeps the track of seconds to be displayed on the LCD. In this infinite loop there are four functions from the rtc library. These are seconds(), minutes(), hours(), and days(). Out of these, seconds() is explained next:
Code:
if(s.end!=723)
//if end is not equal to the end
//limit of table1
{
cursorxy(0,s.row);
//put cursor on the seconds page
for(i=s.start;i //write contents from start to end
{
column=pgm_read_byte((table1+i));
writedata(column);
}
centerline(); //display centerline
if(s.c==1) //check count
{
s.start+=3;
s.end+=3;
s.c=0;
}
}
else if(s.end==723)
//if end reaches the limit of table1
{
centerline();
cursorxy(0,s.row);
for(i=s.start;i<(s.end-3);i++)
//display contents from start
{
column=pgm_read_byte((table1+i));
writedata(column);
}
for(i=0;i //display from the first element
//of table 1
{
column=pgm_read_byte((table1+i));
writedata(column);
}
centerline(); //timeline
if(s.c==1) //check count
{
s.start+=3;
s.x+=3;
s.c=0;
}
if(s.x==84)
//check if start has reached end
//or not
{
s.end=84;
s.start=0;
s.x=3;
}
}
Every display quantity, be it seconds, minutes, hours, or days, has its set of variables defined in rtcpara structure. These variables are defined as:
■ start Starting X-coordinate of the data to be displayed.
■ end End value of the X-coordinate of the data to be displayed.
■ x X offset used to display data from the beginning of the PROGMEM table when end reaches its limiting value.
■ c Count of the corresponding quantity. This count is incremented in the ISR noted earlier.
■ row Represents the page or the bank of the corresponding quantity.
In the previous routine, the first part is executed when s.end is not equal to the limiting value, that is, 723. Then data is printed on s.row page from s.start to s.end, which is 84 columns apart; hence, data is printed on the full page. Then centerline or timeline is flashed to view the elapsing time, and the s.c is checked. If s.c is found equal to 1, s.start and s.end are incremented by 3 and s.c is made 0 again. The second part is executed when s.end reaches its limiting value. At first, data is printed from s.start to s.end – 3 (because s.end was incremented by 3 in the first part) on the s.row page. Then data is printed from the start of the PROGMEM table to s.x. This continues until s.x reaches a value of 84. At this point, s.start is made equal to 0 and s.end is made equal to 84. Similar
checking on s.c is performed as in the first part, and centerline is flashed. Minutes, hours, and days are manipulated and displayed using similar routines defined in rtc.c. Apart from this, the code consists of initial time setting through hardware switches and using the pin change interrupt to toggle between displaying days or seconds.

Working
To use the clock, simply power up and set the time. Then you see the seconds fly by on the screen. The minutes scroll slower compared to the seconds, and the hours are even slower. Press S2 to see the day of the week. Press S2 again to get back to the original display.
 
Last edited by a moderator:
Top