Sunday, February 27, 2011

Digital Watch With Microcontrol

A complete range of Digital Clock is shown in Figure 1, equipped with 4 pieces of 7 segment LED display to display the time, consists of dozens of hours numbers, hours, tens of minutes and unit minutes. SW1 and SW2 button is used to set the display time, when SW1 is pressed on the display clock rate will increase every second, while SW2 is used to adjust the display digit minutes in the same way.

12 MHz crystal and capacitors C1 and C2 form a series of working frequency oscillator generating AT89C2051, this series is a series of raw, meaning that form the oscillator circuit is always like this for all series AT89C51, except for purposes other crystal values are probably different.

The combination of capacitors C3 and R8 detainees is also a standard circuit, this component is used to form a series of 'power on reset', meaning the circuit will automatically reset every time AT89C2051 AT89C2051 begin receiving power source.

Looking at the circuit in Figure 1, it can not explain how this digital clock works, because the series was just part-timer button and the display of time, 'Clock' is actually a program stored in the ROM that is in the IC AT89C2051
System 7 segment display


To display the time used 4 of 7 segment LED display which is formed with IC2 and IC3 (each IC contains two digit display), thereby to display 4 pieces required 28 digit LED, if the LED is dinyala-28-put out in the normal way , then the required 28 switch and the circuit becomes very complicated. Common method used is a seven segment display systems that are multiplex as apparent in Figure 1, while Figure 2 shows the details of this display system.

Each display digit is formed by 7 pieces of LED (Light Emitting Diode), each diode segment is marked as 'a' through 'g', the anode of the seven LEDs that have linked them together in the IC. Cathode segment 'a' of tens of hours numbers associated with the cathode segment 'a' of hours numbers and so on. Similarly, the segment 'b'; segment 'c' and so forth.
Segment switch Q10 .. Q16 is used to determine which segment will be lit, for example to form the number 1 then switch p11 (section b) and switch P12 (section c) in the 'on' position. While Scalar Digits used to determine which digit display is used, for example number 1 was to be shown on the display dozens of hours, then the scalar position in Q1.
If the 'on' position on the switch Digits rotates from Q1, Q2, Q3 and Q4 then go back to Q1 and so quickly, then the number 1 above shall appear on all display digits!
Next, suppose before changing switch positions Digit combination Scalar Fields set first, then the number that appear in the 7 segment display system can be set properly.
Shown in Figure 1 is formed with the foot switch section P1.0 to P1.6 AT89C2051 feet, while the switch Digit formed with a PNP transistor and a prisoner, each of which is controlled by foot to foot P3.3 P3.0.
The process of setting the display system as discussed above, is governed by AT89C2051 through discount programs are usually named as ScanDisplay as follows:
1 ScanDisplay:
2 MOV P1,RuasJam10
3 MOV P3,#%11110111
4 ACALL TungguSebentar
5 ;
6 MOV P1,RuasJam1
7 MOV P3,#%11111011
8 ACALL TungguSebentar
9 ;
10 MOV P1,RuasMenit10
11 MOV P3,#%11111101
12 ACALL TungguSebentar
13 ;
14 MOV P1,RuasMenit1
15 MOV P3,#%11111110
16 ACALL TungguSebentar
17 SJMP ScanDisplay

Discount program above can be explained as follows: RuasJam10, RuasJam1, RuasMenit10 and RuasMenit1 is a place to accommodate a combination of variable segments of digits to be displayed, the contents of this variable will be changed in other parts of the program in accordance with the changing times. The contents of these variables is fed directly to Port 1 (lines 2, 6, 10 and 14 at discount program above), to control the switch segment.

Digits switch is formed by PNP transistors, so for him on the required voltage '0 'on one foot Port 3, as shown in line 3, 7, 22 and 15. Note the position of the number '0 'on the fourth line, it would seem '0' is air-'jalan 'from left to right which is equivalent to rotating switch Digits'on' from Q1 to Q4.

TungguSebentar is a sub-routine which serves to delay time (delay), so the numbers can appear suspended just before the switch. At line 17, flow switch back to the program in line 1, so that the pieces of this program will work continuously without stopping displaying numbers.

Basically, Digital Clock is a system of counter (counter)-story, starting from the counter counts up minutes from 0 to 59 and overflow back to 0, and enumerators hours from 0 to 23 which counts up every time there is an abundance of enumerators minutes, this can be realized with following programs:
1 JamDigital:
2 INC Menit
3 MOV A,Menit
4 CJNE A,#60,Keluar
5 MOV Menit,#0
6 INC JAM
7 MOV A,Jam
8 CJNE A,#24,Keluar
9 MOV Jam,#0
10 Keluar:
11 RET

Minutes and hours on a piece of this program, is a variable that serves as an enumerator enumerators minutes and hours. JamDigital sub-routine will be executed once every minute, so that changes in variable values and variable Hours Minutes exactly reflect changing times.

INTERUPSI TIMER

After forming the sub-routine JamDigital above, the next question is how to sub-routines that can actually run only once every minute, for this purpose use the timer facility owned AT89C2051.

Digital Clock made ScanDisplay always run the program continuously without stopping, to use traditional facilities of the timer interrupt, the program above ScanDisplay paused every 50 milli seconds, then move the string enumerator AT89AT2051 20 and counter 60, counter 20 will overflow once per second , and counter 60 will overflow once per minute. In the event of overflow of counter 60, AT89C2051 will run a sub-routine JamDigital above.
1 TimerInterrupt:
2 MOV TL0,#-50000
3 MOV TH0,#>-50000/256
4 DJNZ Pencacah20,Terus
5 MOV Pencacah20,#20
6 DJNZ Pencacah60,Terus
7 MOV Pencacah60,#60
8 ACALL JamDigital
9 Terus:
10 RETI

Rows 2 and 3 above are maintained for routine TimerInterrupt AT89C2051 run every 20 milli seconds, line 4 to 7 is a string of counter 20 and counter 60, while counter 60 overflow at line 8 AT89C2051 run a sub-routine JamDigital.

In order for this timer interrupt mechanism can work like what was expected, at the beginning of the program added the following program snippet:

1 ANL TMOD,#%11110000
2 ORL TMOD,#000001
3 MOV TL0,#-50000
4 MOV TLH,#-50000/256
5 SETB ET0
6 SETB EA
7 SETB TR0
Rows 1 and 2 determine the working mode of Timer 0, Line 3 and 4 are set for routine TimerInterrupt AT89C2051 run every 20 milli seconds, line 5 activate interrupt Timer 0, line 6 AT89C2051 and activate the system interrupt line 7 run Timer 0

No comments:

Post a Comment