Вы находитесь на странице: 1из 19

M Rickey's World (http://www.8051projects.

net/)
L Register (../../signup.php) Login * (/login.php)
Discussion in "Project Addition or Changes
(../../plugins/forum/forum_viewforum.php?37)" started by
adambose1990 (/user35707.html) @ Oct 11, 2011.
adambose1990 (../../user35707.html)
[ Fresher ]
f (http://www.facebook.com/sharer.php?
u=http://www.8051projects.net&t=Rickey%27s+World+of+Microcontrollers)
V (https://twitter.com/intent/tweet?
text=Rickey%27s+World+of+Microcontrollers&url=http://www.8051projects.net)
m
_
(https://plus.google.com/share?
url=http://www.8051projects.net)
w
Home
(http://www.8051projects.net/)

News
(http://www.8051projects.net/news.php)
@
Discussion Forum
@
Tutorials
(http://www.8051projects.net/microcontroller-
tutorials/)

O
Downloads
(http://www.8051projects.net/download.html)

LCD Pinouts
(http://www.8051projects.net/lcdpinouts.html)
+
Jet Engine
(http://www.8051projects.net/jetengine/)

Games
(http://www.8051projects.net/arcade.html)
|
More

Home (http://www.8051projects.net/)
Discussion Forums (/forum.html)
Project Development (/forum.html#project-development)
Project Addition or Changes (../../plugins/forum/forum_viewforum.php?
37)
w
Search ...
Digital Clock using 89s52/89c52
10/11/2011 (Tue Oct 11 2011, 08:02 AM) #1 (http://www.8051projects.net/forum-t51244.html#post_51244)
Hi guys, here is a simple project I have done in
89s52 IC of 8051 series. Making a Digital Clock.
Components required:
1 microcontroller 89C52(89S52 will also do)
2 ceramic capacitors-22pF
1 switch(button for reset purpose)
1 electrolytic capacitor-10uF,25V
1 crystal oscillator-11.0592MHz
16x2 LCD display
1 resistor-10k

D
Software you will need:
The programming of the microcontroller is done using
keil compiler. Port 2 is output port, This LCD is in 8bit
mode.
Details of LCD you can have here.
http://www.mikroe.com/eng/chapters/view/17/chapter-4-
examples/
(http://www.mikroe.com/eng/chapters/view/17/chapter-4-
examples/)
Circuit Diagram:
The detail explanation of the code is done below:
1. //main.c
2. #include
3. #include "lcd.h"
4.
5. void ms_delay(int time)
6. {
7. unsigned int i,j;
8. for(i=0;i
But before that you have to make lcd.h
file. Its codes are given also here.
This Header is specially made for this
program.
//lcd.h
9. #ifndef __LCD_H__
10. #define __LCD_H__
11.
12. #define LCD_data P2
13.
14.
15. void _LCD_busy(void);
16. void _LCD_sdelay(void);
17. void _LCD_poweron(void);
18. void _LCD_command(unsigned char);
19. void _LCD_senddata(unsigned char);
20. void _LCD_sendstring(unsigned char *);
21. void _LCD_putnum(int, int);
22. void _LCD_init(void);
23. void _LCD_clear(void);
24.
25. sbit LCD_rs=P1^0;
26. sbit LCD_rw=P1^1;
27. sbit LCD_en=P1^2;
28.
29. void LCD_busy()
30. {
31. unsigned char i,j;
32. for(i=0;i<50;i++)
33. for(j=0;j<255;j++);
34. }
35.
36. void LCD_sdelay()
37. {
38. unsigned char i;
39. for(i=0;i<50;i++);
40. }
41.
42. void LCD_poweron()
43. {
44. unsigned int i;
45. for (i=0;i<22500; i++);
46. }
47.
48. void LCD_command(unsigned char var)
49. {
50. LCD_data = var; //Function set
: 2 Line, 8-bit, 5x8 dots
51. LCD_rs = 0; //Selected comm
and register
52. LCD_rw = 0; //We are writin
g in instruction register
53. LCD_en = 1; //Enable H->L
54. LCD_en = 0;
55. LCD_busy(); //Wait for LCD
to process the command
56. }
57.
58. void LCD_putnum(int number,int width)// L
CD_putnum: Implementing integer value fro
m -99999 to 99999
59. {
60. unsigned char digit;
61.
62. if (number < 0)
63. {
64. LCD_senddata('-');
65. LCD_sdelay();
66. number = -1 * number;
67. }
68.
69. switch (width)
70. {
71. case 5:
72. digit = '0';
73. while(number >= 1
0000) // Keep Looping for
larger than 10
74. {
75. digit++;
// Increase ASCII charact
er
76. number -= 10000;
// Subtract number wit
h 10
77. }
78. LCD_senddata(digi
t); // Put the Second digi
t
79. LCD_sdelay();
80. case 4:
81. digit = '0';
82. while(number >= 1
000) // Keep Looping for l
arger than 10
83. {
84. digit++;
// Increase ASCII charact
er
85. number -= 1000;
// Subtract number with
10
86. }
87. LCD_senddata(digi
t); // Put the Second digi
t
88. LCD_sdelay();
89. case 3:
90. digit = '0';
91. while(number >= 1
00) // Keep Looping for la
rger than 10
92. {
93. digit++;
// Increase ASCII charact
er
94. number -= 100;
// Subtract number with
10
95. }
96. LCD_senddata(digi
t); // Put the Second digi
t
97. LCD_sdelay();
98. case 2:
99. digit = '0';
100. while(number >= 1
0) // Keep Looping for lar
ger than 10
101. {
102. digit++;
// Increase ASCII charact
er
103. number -= 10;
// Subtract number with 1
0
104. }
105. LCD_senddata(digi
t); // Put the Second digi
t
106. LCD_sdelay();
107. case 1:
108. LCD_senddata('0'
+ number); // Put the First dig
it
109. LCD_sdelay();
110. }
111. }
112.
113. void LCD_sendstring(unsigned char *var)
114. {
115. while(*var) //till stri
ng ends
116. LCD_senddata(*var++); //send char
acters one by one
117. }
118.
119. void LCD_senddata(unsigned char var)
120. {
121. P2 = var; //Function set: 2 Li
ne, 8-bit, 5x7 dots
122. LCD_rs = 1; //Selected data
register
123. LCD_rw = 0; //We are writin
g
124. LCD_en = 1; //Enable H->L
125. LCD_en = 0;
126. //LCD_busy(); //Wait for LC
D to process the command
127. }
128.
129. void LCD_init(void)
130. {
131. LCD_data = 0x38; //Function set:
2 Line, 8-bit, 5x8 dots
132. LCD_rs = 0; //Selected comm
and register
133. LCD_rw = 0; //We are writin
g in data register
134. LCD_en = 1; //Enable H->L
135. LCD_en = 0;
136. LCD_busy(); //Wait for LCD
to process the command
137. LCD_data = 0x0C; //Display on,
Curson blinking off command
138. LCD_rs = 0; //Selected comm
and register
139. LCD_rw = 0; //We are writin
g in data register
140. LCD_en = 1; //Enable H->L
141. LCD_en = 0;
142. LCD_busy(); //Wait for LCD
to process the command
143. LCD_data = 0x01; //Clear LCD
144. LCD_rs = 0; //Selected comm
and register
145. LCD_rw = 0; //We are writin
g in data register
146. LCD_en = 1; //Enable H->L
147. LCD_en = 0;
148. LCD_busy(); //Wait for LCD
to process the command
149. LCD_data = 0x06; //Entry mode,
auto increment with no shift
150. LCD_rs = 0; //Selected comm
and register
151. LCD_rw = 0; //We are writin
g in data register
152. LCD_en = 1; //Enable H->L
153. LCD_en = 0; //Enable H->L
154. LCD_busy();
155. }
156.
157. void LCD_clear(void)
158. {
159. LCD_data = 0x01; //Clear LCD
160. LCD_rs = 0; //Selected comma
nd register
161. LCD_rw = 0; //We are writing
in data register
162. LCD_en = 1; //Enable H->L
163. LCD_en = 0;
164. LCD_busy();
165. }
166.
167.
168. void LCD_gotoxy(int x, int y)//x=0..16, y
= 0..1
169. {
170. int dr;
171. if (y==0)
172. dr=x+0x80;
173. if (y==1)
174. dr=x+0xC0;
175. LCD_data = dr; //Function set: 2
Line, 8-bit, 5x8 dots
176. LCD_rs = 0; //Selected command
register
177. LCD_rw = 0; //We are writing i
n instruction register
178. LCD_en = 1; //Enable H->L
179. LCD_en = 0;
180. LCD_busy();
adambose1990 (../../user35707.html)
[ Fresher ]
majoka (../../user22104.html)
181. }
182.
183. #endif
Thanks a lot...
For any quarries you can contact adambose19
90@gmail.com (http://adambose1990@gmail.com
)
10/11/2011 (Tue Oct 11 2011, 08:09 AM) #2 (http://www.8051projects.net/forum-t51244.html#post_51245)


desktop.rar
(../../files/public/1318334954_35707_FT51244_desktop.rar)
You can download the following attachents
.Hex file
.H file
.C file
.DSN file
They are all in rar file. Extract them all.
Attachment

(../../files/public/1318334954_35707_FT51244_desktop.rar)
Forum Staff
ajay_bhargav (../../user1.html)
Site Owner
adambose1990 (../../user35707.html)
[ Fresher ]
10/11/2011 (Tue Oct 11 2011, 12:05 PM) #3 (http://www.8051projects.net/forum-t51244.html#post_51248)
@ adambose1990
good efforts
use timer for clock that will be more accurate as compare to
looping
10/13/2011 (Thu Oct 13 2011, 11:51 AM) #4 (http://www.8051projects.net/forum-t51244.html#post_51281)
good work adambose
and i completely agree with Majoka, you must use timers for
tick generation. I will be much more accurate
10/14/2011 (Fri Oct 14 2011, 12:31 PM) #5 (http://www.8051projects.net/forum-t51244.html#post_51313)
@Ajay Bhargav yes surely, This project is not accurate only
because of the tick generation, it lags a few second in an RTC
hour, I surely will follow your advice, thanks........:)
ajay_bhargav (../../user1.html)
Site Owner
adambose1990 (../../user35707.html)
[ Fresher ]
ajay_bhargav (../../user1.html)
Site Owner
11/1/2011 (Tue Nov 01 2011, 04:20 PM) #6 (http://www.8051projects.net/forum-t51244.html#post_51590)
Additional advice for error free timers; use timer in free
running mode so that you dont have to do load operation for
timers. This way your timer will always overflow at perfect
intervals, no matter how late your ISR is serviced
Also use 12Mhz for best results with above method.
11/3/2011 (Thu Nov 03 2011, 08:04 AM) #7 (http://www.8051projects.net/forum-t51244.html#post_51660)
Thanks a lot Ajay sir...:)
11/6/2011 (Sun Nov 06 2011, 02:17 AM) #8 (http://www.8051projects.net/forum-t51244.html#post_51696)
You're welcome good luck for your Final Year
jamewhite86 (../../user37264.html)
[ Fresher ]
adambose1990 (../../user35707.html)
[ Fresher ]
C Get Social
2/10/2012 (Fri Feb 10 2012, 05:26 AM) #9 (http://www.8051projects.net/forum-t51244.html#post_53471)
Its a good and lot of information on your site and good
collection of information for digital 8051. thanks for sharing
the information.
2/10/2012 (Fri Feb 10 2012, 06:15 AM) #10 (http://www.8051projects.net/forum-t51244.html#post_53472)
Hi jamewhite86, To know more digital 8051, have a look into
this site : www.rsatechbook.webs.com
(http://www.rsatechbook.webs.com)
There is a lot not only about 8051, but also about AVR and PIC
unique projects...... Have a good day...
http://rsatechbook.webs.com/
(http://rsatechbook.webs.com/)
Q RSS Feeds
Information
Powered by e107 Forum System
m RSS 1.0 (../../rss-8051microcontroller.html?8.1.51244)
m RSS 2.0 (../../rss-8051microcontroller.html?8.2.51244)
m RDF (../../rss-8051microcontroller.html?8.3.51244)
m Recent
@ Conversation
Comments Members
Downloads
Electronic Voting machine with Managed Control Unit (Project
Report Included) (../../download.php?view.205) by: Shivani, Geetika
Gupta, Vibhore Aggarwal, Megha Singh in: 8051 Projects
(../../download.php?list.4)
2 weeks ago (Sat May 17 2014, 10:16 AM)
LED Scrolling message Display using 8051 (../../download.php?
view.253) by: Pratik Suthar in: 8051 Projects (../../download.php?
list.4)
3 weeks ago (Thu May 08 2014, 06:58 AM)
Smart Home using GSM, Bluetooth and Android (with project
report and ppt) (../../download.php?view.252) by: Gaurav
Khadasane in: AVR Projects (../../download.php?list.7)
1 month ago (Wed Apr 30 2014, 04:00 PM)
Arduino based GPS data Logger (../../download.php?view.251) by:
Santosh Mishra in: AVR Projects (../../download.php?list.7)
2 months ago (Mon Mar 31 2014, 06:25 AM)
Metro Train Prototype Project with Project Report
(../../download.php?view.250) by: Gaurav Sharma in: 8051 Projects
(../../download.php?list.4)
2 months ago (Wed Mar 26 2014, 07:07 AM)
Downloads
Name
Email
Type your message here ...


14 hours ago (Sat May 31 2014, 10:43 PM) ExperimenterUK
(/user.php?id.9602)
Reminder.. this is a chat box. Create a thread for questions
18 hours ago (Sat May 31 2014, 07:00 PM) 1
2 days ago (Fri May 30 2014, 04:17 AM) Abdulhabib
Hi, I want to make a wifi wireless and or RF 14 channel
remote control system with range of about 100 meters,
could you please help me and direct me to a circuet
diagram, so i can make that, thank you,
6 days ago (Mon May 26 2014, 04:46 PM) fix
can anyone write me code for microwave aplication in
assembly language?
6 days ago (Mon May 26 2014, 01:49 PM) knight killer
can u suggest an outline on how to proceed for coding in
the following project: REMOTE NOTICE BOARD USING GSM
WITH SMS.The notice board will be led matrix of 7*26.
thank you.
7 days ago (Sun May 25 2014, 06:21 PM) antenh zewdu
i found a source code from internet. but i there are errors
with: #include <dimmer1.c> and #include <dimmer2.c> #
include <temperature.c> and # include <lcdb.c> i want
library files of these plz help i am also attaching the code
aur project report - See more at:
http://www.8051projects.net/t58382/project-addition-or-
changes/need-library-files-for-
code.htm#sthash.sYCt9G1Y.dpuf
1 week ago (Sun May 25 2014, 05:48 AM) faezah
the 12 volt DC motor wont work with the digital IR
sensor..if any one can assist me..kindly reply here.ill send u
my program though

Q
@
^

Вам также может понравиться