Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

DIGITAL CLOCK USING JK FLIP FLOPS COUNTERS.. IT SHOULD ALSO INCLUDE STATE MACHIN

ID: 3823993 • Letter: D

Question

DIGITAL CLOCK USING JK FLIP FLOPS COUNTERS.. IT SHOULD ALSO INCLUDE STATE MACHINE AND SEVEN SEGMENT DISPLAY WITH EXPLLANATION. IT WILL ALSO INCLUDE A DECODER/GATE LEVEL.

Design a digital clock according to the following specifications: The clock will display time in the standard 12 hour format HH:MM with an indicator for AM/PM. Your clock will use a 7-segment display unit.

The project must include:

1. A “black box” style design of the clock control unit and display as an overview.

2. Each part of the control unit should show the circuit design, including the state machine, state tables, flip-flop design and simplifications.

3. The implementation for the display unit should be specified (gate level / decoder)

4. The design of the unit should be clearly labelled and the connection(s) between components should be clearly marked.

5. A document explaining your implementation and the connections between components must be included. You may choose the flip-flops and the 7-segment implementation, but all details of the implementations must be included in the documentation and in the final design of the clock unit.

Explanation / Answer

//DIGITAL CLOCK IN C//

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>

void main()
{
int gdriver = DETECT, gmode, errorcode;
int i=0, a[5], j;
struct time t;
initgraph(&gdriver, &gmode, "");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s ", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
while(!kbhit())
{
gettime(&t);
if(t.ti_hour>12)
{
t.ti_hour = t.ti_hour-12;
outtextxy(550,150,"PM");
}
else
{
outtextxy(550,150,"AM");
}
a[0]=t.ti_hour/10;
a[1]=t.ti_hour%10;
a[2]=t.ti_min/10;
a[3]=t.ti_min%10;
a[4]=t.ti_sec/10;
a[5]=t.ti_sec%10;
circle(240,150,2);
circle(240,160,2);
circle(390,150,2);
circle(390,160,2);
for(i=0;i<6;i++)
{
switch(a[i])
{
case 0:
{
line(105+i*75,100,145+i*75,100);
line(100+i*75,105,100+i*75,145);
line(100+i*75,155,100+i*75,195);
line(105+i*75,200,145+i*75,200);
line(150+i*75,155,150+i*75,195);
line(150+i*75,105,150+i*75,145);
break;
}
case 1:
{
line(150+i*75,155,150+i*75,195);
line(150+i*75,105,150+i*75,145);
break;
}
case 2:
{
line(105+i*75,100,145+i*75,100);
line(100+i*75,155,100+i*75,195);
line(105+i*75,200,145+i*75,200);
line(150+i*75,105,150+i*75,145);
line(105+i*75,150,145+i*75,150);
break;
}
case 3:
{
line(105+i*75,100,145+i*75,100);
line(105+i*75,200,145+i*75,200);
line(150+i*75,155,150+i*75,195);
line(150+i*75,105,150+i*75,145);
line(105+i*75,150,145+i*75,150);
break;
}
case 4:
{
line(100+i*75,105,100+i*75,145);
line(150+i*75,155,150+i*75,195);
line(150+i*75,105,150+i*75,145);
line(105+i*75,150,145+i*75,150);
break;
}
case 5:
{
line(105+i*75,100,145+i*75,100);
line(100+i*75,105,100+i*75,145);
line(105+i*75,200,145+i*75,200);
line(150+i*75,155,150+i*75,195);
line(105+i*75,150,145+i*75,150);
break;
}
case 6:
{
line(105+i*75,100,145+i*75,100);
line(100+i*75,105,100+i*75,145);
line(100+i*75,155,100+i*75,195);
line(105+i*75,200,145+i*75,200);
line(150+i*75,155,150+i*75,195);
line(105+i*75,150,145+i*75,150);
break;
}
case 7:
{
line(105+i*75,100,145+i*75,100);
line(150+i*75,155,150+i*75,195);
line(150+i*75,105,150+i*75,145);
break;
}
case 8:
{
line(105+i*75,100,145+i*75,100);
line(100+i*75,105,100+i*75,145);
line(100+i*75,155,100+i*75,195);
line(105+i*75,200,145+i*75,200);
line(150+i*75,155,150+i*75,195);
line(150+i*75,105,150+i*75,145);
line(105+i*75,150,145+i*75,150);
break;
}
case 9:
{
line(105+i*75,100,145+i*75,100);
line(100+i*75,105,100+i*75,145);
line(105+i*75,200,145+i*75,200);
line(150+i*75,155,150+i*75,195);
line(150+i*75,105,150+i*75,145);
line(105+i*75,150,145+i*75,150);
break;
}
}
}
delay(700);
cleardevice();
}
closegraph();
}

Program functions
The program requires the egavga.bgi graphics file to be stored in the same folder as the executable file. When the program is run, the graphics system is initialised by loading a graphics driver from the system’s hard disk. The main functions used in the program for digital clock display are described below.

gdriver and gmode.GRAPHIC DRIVER AND GRAPHIC MODE set by the system automatically

gettime( ) extracts the current time from the real-time system clock as structure time t,Here ‘t’ is the structure variable, which is used to access the hour element (ti_hour), minute element (ti_min) and second element (ti_sec).

kbhit( ). returns a non-zero value when a key is pressed.

delay( ).required time delay in milliseconds.

closegraph( ). switches the screen from graphics mode back to text mode.