04/06/2012
Logic Brigade
Propeller Clock using 8051 microcontroller » Logic Brigade
Reducing Gapes, Building Bridges…
Propeller Clock using 8051 microcontroller August 13th, 2009 by admin
Leave a reply »
First of its kind, made using the at89s52 microcontroller. This propeller clock is mechanically scanned and displays the time in digital format. Made from scrap it can be used anywhere and everywhere and the most amazing fact about this clock is it’s crystal clear display. It just took three days to complete this clock. This clock consists of just 8 bright red LEDS which are rotated to show the display. Have a look at the screenshots ,these were taken during the development stage of the clock. Now , take a look at how we proceeded and ended up making this clock a success. propeller clock
First this was just an idea we saw one day on the internet ,it was Bob Blick who made it first using the PIC 16C84, but I was not having the same microcontroller so I decided making the same from the 8051 microcontrollers. Firstly select a high speed motor, you can select the one from your old tape recorders, that would be sufficient enough to drive this clock.
logicbrigade.com/?p=50
1/9
04/06/2012
Propeller Clock using 8051 microcontroller » Logic Brigade
Schematic
Then coming to the circuitry part our clock just consist of the at89S52 microcontroller ,8 bright red led, a perforated PCB, 8 resistances (220 Ω), a photo diode, an infrared transmitter, a motor,a pull up ladder,a 10µf cap, 12 volt battery . The clock is on a spinning piece of pcb, but it must get power so to give the required power a 9 volt battery is applied which works very fine as u can see the results are super fine. The circuit can be made either by designing the pcb or it can be made on a zero pcb as we have done , because doing it on a zero pcb was very much easy.Firstly a 20 pin socket for the AT89C2051 was attatched,then connecting the power supplies leds and resistances. The circuit is very easy as it took me only 2 hours and by evening the clock was running. For the leds I used the 220 ohms resisors for proper brightness. A crystal of 11.0592 Mhz was selected to provide the clock to the microcontroller. Connect the motor properly between the pcb so as to maintain the centre of gravity so that the clock does not wobble and the display is crystal clear. So much done, now only thing left is programming the microcontroller. I used the at89s52 microcontroller which belongs to the 8051 family of microcontrollers.so I used the kiel compiler to write the program code. The code is written in c language and the code finally burned to the controller and the clock is running.
Software For programming the microcontroller you will require a programmer.
logicbrigade.com/?p=50
2/9
04/06/2012
Propeller Clock using 8051 microcontroller » Logic Brigade
You can use a parallel port programmer or make a serial port programmer as per your requirements and availability. Use keil compiler to compile the code. Code have no logic to set the clock variable it will be updated soon. we are also looking for scrolling message display. Now as we see what runs this clock….yes the code. Firstly we generated the look up table for the digits we want to display on our clock . These values will be stored in a double dimensional array and timely called to generate the display. The clock works using interrupts and timers. The external interrupt used tells the microcontroleer that a single revolution is completed and tells the timer to generate the display and then stop after displaying. One timer i.e. the timer 1 is used to generate the clock internally And the external interrupt call the values of this timer everytime to display the time. We also use priority , that is priorities are assigned to the interrupts and timers. Timer1 keeps the count of the time and timer0 performs the task of displaying maintaining appropriate frames that would be displayed and create a persistence of vision. Here is the CODE #include
const unsigned char code flook [][5] = { { 0x3E, 0x51, 0x49, 0x45, 0x3E }, // 0 { 0x00, 0x42, 0x7F, 0x40, 0x00 }, // 1 { 0x42, 0x61, 0x51, 0x49, 0x46 }, // 2 { 0x21, 0x41, 0x45, 0x4B, 0x31 }, // 3
k*
{ 0x18, 0x14, 0x12, 0x7F, 0x10 }, // 4 { 0x27, 0x45, 0x45, 0x45, 0x39 }, // 5 { 0x3C, 0x4A, 0x49, 0x49, 0x30 }, // 6 { 0x01, 0x71, 0x09, 0x05, 0x03 }, // 7 { 0x36, 0x49, 0x49, 0x49, 0x36 }, // 8 { 0x06, 0x49, 0x49, 0x29, 0x1E } // 9
logicbrigade.com/?p=50
3/9
04/06/2012
Propeller Clock using 8051 microcontroller » Logic Brigade
}; const unsigned char code colon[]={0x00,0x18,0x00}; unsigned char a,b,c,d,e,f; bit tog; void Int0(void) interrupt 0 using 2 { EX0=0;
// Avoid another INT1* until we are completely finished...
TH0=0xA4; TR0=1;
// Start timer 0
} void timer0(void) interrupt 1 using 3 { static unsigned char i,k; k++; if(k==12) { k=0; if(i<5)
//hours ten digit
{ P0=~(flook[f][i]); i++; } else if(i==5)//space { P0=0xFF; i++; } else if(i<11)//space { P0=~(flook[(e%10)][i-6]); logicbrigade.com/?p=50
4/9
04/06/2012
Propeller Clock using 8051 microcontroller » Logic Brigade
i++; } else if(i<14)//colon { if(tog==1) { P0=~(colon[i-11]); } else { P0=0xFF; } i++; } else if(i<19)//min tens { P0=~(flook[d][i-14]); i++; } else if(i==19)//space { P0=0xFF; i++; } else if(i<25)//min one { P0=~(flook[c][i-20]); i++; } else if(i<28)//colon
logicbrigade.com/?p=50
5/9
04/06/2012
Propeller Clock using 8051 microcontroller » Logic Brigade
{ if(tog==1) { P0=~(colon[i-25]); } else { P0=0xFF; } i++; } else if(i<33)//sec tens { P0=~(flook[b][i-28]); i++; } else if(i==33)//space { P0=0xFF; i++; } else if(i<39)//sec ones { P0=~(flook[a][i-34]); i++; } else {TR0=0; P0=0xFF; EX0=1; i=0; logicbrigade.com/?p=50
6/9
04/06/2012
Propeller Clock using 8051 microcontroller » Logic Brigade
} } } void delay() { int fi,fj; for(fi=0;fi<160;fi++) { for(fj=0;fj<1250;fj++) ; } } void main() { TMOD=0x02; TH0=0xA4; EX0
= 1;
/* External interrupt 0 enable
*/
IT0
= 1;
/* External interrupt 0 Edge sesitive
*/
ET0
= 1;
/* Enable Timer 0 interrupts
*/
PT0
= 1;
/* Timer 0 high priority
*/
PX0
= 1;
/* External interrupt 0 high priority
*/
/*----------------------------------------------Configure INT0 (external interrupt 0) to generate an interrupt on the falling-edge of /INT0 (P3.2). Enable the EX0 interrupt and then enable the global interrupt flag. -----------------------------------------------*/ EX0 = 1;
// Enable EX0 Interrupt
EA = 1;
// Enable Global Interrupt Flag
P0=0xFF;
logicbrigade.com/?p=50
7/9
04/06/2012
Propeller Clock using 8051 microcontroller » Logic Brigade
P3=0xFF; a=0;
//sec one's
b=0;
//sec ten's
c=0;
//min one's
d=0;
//min ten's
e=0;
//hr one's
f=0;
//hr ten's
tog=0; while(1) { delay(); tog=~tog; a++; if(a>9) { a=0; b++; } if(b>5) { b=0; c++; } if(c>9) { c=0; d++; } if(d>5) { logicbrigade.com/?p=50
8/9
04/06/2012
Propeller Clock using 8051 microcontroller » Logic Brigade
d=0; e++; } if(e>12) { e=0; } if(e>9) { f=1; } else { f=0; } } } Previous Entry: Digital Code Lock Next Entry: Analog line tracking robot
Posted in 8051 Projects , Uncategorized You can follow any responses to this entry through the RSS 2.0 Feed . Both comments and pings are currently closed.
Comments are closed. © 2012 Logic Brigade · Proudly powered by WordPress & Green Park 2 by Cordobo. Valid XHT ML 1.0 T ransitional | Valid CSS 3
logicbrigade.com/?p=50
Back to T op
9/9