[Post] rotation LED electronic clock based on 51 Single-Chip Microcomputer

Source: Internet
Author: User
Tags 0xc0

Http://hi.baidu.com/52_diy/blog/item/d8310dfac0a97716a8d3114b.html

 

POV is persistancd of vision. It uses a single-chip microcomputer to control the flow lamp, and uses the movement of the flow lamp and the temporary effect of human vision to generate various graphics or texts. The effect is as follows:

 

 

 

This figure shows how it works.

 

The principle is relatively simple, it is easy to implement with a single-chip microcomputer, and the detailed process of rotating the LED clock in the post is described.

As for the two difficulties proposed by the author, in my personal opinion, the power supply department uses a motor for separate power supply, and the single chip microcomputer power supply is attached to the rotating circuit board. Improve the circuit, use an electronic clock chip, install a backup battery, and install a backup battery can easily solve the problem of time adjustment. I plan to improve the program on the basis of the next step. The source program provided by the other author does not have any comments, which is inconvenient for new users. Then I will write a program with detailed comments after the circuit is improved, to facilitate production by more people, please stay tuned.

The following content is transferred from "Yixin Studio"

On the Internet, I saw a lot of rotating LED display screens made by foreigners, very cool. I also tried a similar display screen with the cave board, and the result was pretty good. As a result, I continue to work hard to further improve my work and make it look like this. Since I just learned 51 single-chip microcomputer and the software for making circuit boards also started from scratch, I did spend a lot of time and energy. However, in this difficult independent production process, many real things have been learned. The key of this project is how to solve the power supply and adjustment problems of high-speed rotating circuit boards. I use the principle of Electric Brush motor, the rotating shaft is drilled empty, through a plug from the back of the power supply to the front of the circuit board, the Rotary plug is in contact with two pieces of copper fixed on the backboard. It is difficult to adjust the time. First, let the circuit board be connected to the PC before rotation, and the computer transfers the data during the adjustment. This is feasible but not convenient. The remote control method is also used, but this solution has great difficulties in debugging. In terms of display mode, I use a balanced two-row led. In addition to maintaining a good balance during rotation, I can use the alternate display mode on both sides, which is twice faster than the single-row display. This device is not only a clock, but also a dynamic display of Chinese characters and patterns. The specific production process is as follows: 1. From the consideration of production cost and convenience, the production of the rotary motor selects the DC brushless motor on the large soft drive used by the old computer, but only modifies the part.

This kind of antique soft drive

After the DC brushless motor on the soft drive is split, the motor is carefully split into the DC motor, and the aluminum shaft with the disc is opened from the middle so that it can just insert a plug.

Process the rotating shaft like this

  

After assembly

In reverse order, the DC motor is installed on the shaft.

After motor assembly

After the two pieces of copper are installed with a brush, the side of the brush changes the prominent components on the circuit board to the opposite side. The power supply of the motor is connected. From the symbol marked by the circuit board, "+" indicates that the power supply is positive, and "G" indicates that the power supply is negative, the "C" and "m" ends are directly connected to the power supply, so that the motor can run and open an old recording at the position of the motor seat, the lighting board for positioning should be determined based on the position of the photosensitive component on the circuit board. II. The circuit board is controlled by 51 single-chip microcomputer. The electric schematic is as follows:

The circuit board was designed and manufactured with Protel 99. The final work.

The remote control uses the Panasonic model and uses only six of the keys. 3. Software Programming

Because the learning is the C51 (do not understand assembly) here only provides the C language source program.

# Include <reg51.h>

Sbit limit 11 = P3 ^ 0;
Sbit limit 12 = P3 ^ 1;

Unsigned char buffer [] = {0, 0, 0, 1, 1, 7 };
Unsigned char M [] = {, 30 };

Unsigned char maxnum [] = {, 99 };
Unsigned char minnum [] = {0, 1, 1, 0 };

Unsigned char YY [34];

Unsigned char code num1 [] =
{

0x80, 0x7f, 0xc0, 0xff, 0x40, 0x90, 0x40, 0x8c, //-0-
0x40, 0x82, 0xc0, 0xff, 0x80, 0x7f, 0x00,0x00,

0 x, 0 x, 0 x, 0 x, 0 x, 0x81, 0xc0, 0xff, //-1-
0xc0, 0xff, 0 x, 0x80, 0 x, 0x80, 0 x, 0x00,

0x80, 0xe0, 0xc0, 0xf0, 0x40, 0x98,0x40, 0x8c, //-2-
0x40, 0x86, 0xc0, 0xc3, 0x80, 0xc1, 0x00,0x00,

0x80, 0x40, 0xc0, 0xc0, 0x40, 0x84,0x40, 0x84, //-3-
0x40, 0x84, 0xc0, 0xff, 0x80, 0x7b, 0x00,0x00,

0x00, 0x0c, 0x00, 0x0e, 0x00, 0x0b, 0x80, 0x89, //-4-
0xc0, 0xff, 0xc0, 0xff, 0x00,0x88,0x00,0x00,

0xc0, 0x47, 0xc0, 0xc7, 0x40, 0x84,0x40, 0x84, //-5-
0x40, 0x8c, 0x40, 0xfc, 0x40, 0 x, 0 x, 0x00,

0x00, 0x7f, 0x80, 0xff, 0xc0, 0x84,0x40, 0x84, //-6-
0 x, 0 x, 0x00, 0xfc, 0 x, 0 x, 0 x, 0x00,

0xc0, 0x00, 0xc0, 0x00,0x40, 0xf0, 0x40, 0xf8, //-7-
0x40, 0x0c, 0xc0, 0x07, 0xc0, 0x03,0x00,0x00,

0x80, 0x7b, 0xc0, 0xff, 0x40, 0x84,0x40, 0x84, //-8-
0x40, 0x84, 0xc0, 0xff, 0x80, 0x7b, 0x00,0x00,

0x80, 0x03, 0xc0, 0x87,0x40, 0x84,0x40, 0x84, //-9-
0x40, 0xc4, 0xc0, 0x7f, 0x80, 0x3f, 0x00,0x00,

0 x, 0 x, 0 x, 0 x, 0 x, 0 x, 0x63 ,//-:-
0 x, 0 x, 0 x, 0 x, 0 x, 0 x, 0x00,
};

Unsigned char code num2 [] =
{
0 x, 0x00, 0x7f, 0x80, 0xff, 0xc0, 0x40, //-0-
0x8c, 0x40, 0x90, 0x40, 0xff, 0xc0, 0x7f, 0x80,

0 x, 0 x, 0 x, 0x20, 0x40, 0x60, 0x40, //-1-
0xff, 0xc0, 0xff, 0xc0, 0 x, 0x40, 0 x, 0x40,

0 x, 0 x, 0x41, 0xc0, 0xc3, 0xc0, 0 x, 0x40, //-2-
0x8c, 0x40, 0x98,0x40, 0xf0, 0xc0, 0x60, 0xc0,

0 x, 0 x, 0x40, 0x80, 0xc0, 0xc0, 0x88,0x40, //-3-
0x88,0x40,0x88,0x40, 0xff, 0xc0, 0x77,0x80,

0x00,0x00, 0x0c, 0x00, 0x1c, 0x00,0x34,0x00, //-4-
0x64, 0x40, 0xff, 0xc0, 0xff, 0xc0, 0x04,0x40,

0x00,0x00, 0xf8, 0x80, 0xf8, 0xc0, 0x88,0x40, //-5-
0x88,0x40, 0x8c, 0x40, 0x8f, 0xc0, 0x87,0x80,

0x00,0x00, 0x3f, 0x80, 0x7f, 0xc0, 0xc8, 0x40, //-6-
0x88,0x40,0x88,0x40, 0x0f, 0xc0, 0x07,0x80,

0x00,0x00, 0xc0, 0x00, 0xc0, 0x00,0x83, 0xc0, //-7-
0x87, 0xc0, 0x8c, 0x00, 0xf8, 0x00, 0xf0, 0x00,

0 x, 0 x, 0 x, 0x80, 0xff, 0xc0, 0x88,0x40, //-8-
0x88,0x40,0x88,0x40, 0xff, 0xc0, 0x77,0x80,

0 x, 0 x, 0x00, 0xf8, 0x40, 0 x, 0x40, //-9-
0x88,0x40,0x88, 0xc0, 0xff, 0x80, 0x7f, 0x00,

0 x, 0 x, 0x00, 0xc0, 0 x, 0 x, 0 x ,//-/-
0 x, 0x00, 0x0c, 0 x, 0 x, 0 x, 0x30, 0x00,
};

Unsigned char code hz_12 [] =
{

0x80, 0 x, 0x88, 0x1f, 0x30, 0x48, 0 x, 0x24, // "tune"
0xf0, 0x1f, 0x10, 0x01,0x50, 0x1d, 0xf0, 0x15,
0x50, 0x1d, 0x10, 0x41, 0xf8, 0x7f, 0x10, 0x00,

0 x, 0 x, 0 x, 0 x, 0 x, 0 x, 0x60, 0x31, // "min"
0x18, 0x0f, 0 x, 0 x, 0 x, 0 x, 0x41,
0x40, 0x3f, 0x80, 0 x, 0 x, 0 x, 0x01,

0xe0, 0x1f, 0x20, 0x09,0x20,0x09,0x20,0x09, // "hour"
0xe0, 0x1f, 0x40, 0x0x40, 0x40, 0x01,0x40, 0x26,
0x40, 0x40, 0xf8, 0x7f, 0x40, 0 x, 0x40, 0x00,

0 x, 0 x, 0 x, 0 x, 0 x, 0x00, 0xf0, 0x3f, // "day"
0x10, 0x11, 0x10, 0x11, 0x10, 0x11, 0x10, 0x11,
0x11, 0xf8, 0x3f, 0x10, 0 x, 0 x, 0x00,

0 x, 0x40, 0 x, 0x20, 0 x, 0x10, 0xf8, 0x0f, // "month"
0 x,
0 x, 0x42, 0xf8, 0x3f, 0 x, 0 x, 0 x, 0x00,

0 x, 0 x, 0 x, 0 x, 0 x, 0 x, 0 x, 0x07, // "year"
0x90,0x04,0x90,0x04, 0xf0, 0x7f, 0x90,0x04,
0x90,0x04,0x98,0x04,0x90,0x04,0x10 ,0x04
};

Unsigned int disp1, disp2, key1, key2, key;
Unsigned int II, JJ;
Unsigned int I, W, N, xz, CM, tz, BZ;

Void delay (unsigned int MS ){
MS = Ms * 3;
While (-- ms );
}

Void num_led (int aa, int bb)
{
Int KK;
For (KK = 0; KK <8; KK ++ ){
Keys 11 = key1; keys 12 = key2;
P2 = ~ Num1 [AA + KK * 2]; P1 = ~ Num1 [AA + 1 + KK * 2];
Delay (20 );
P1 = 0xff; P2 = 0xff;

Keys 11 = key2; keys 12 = key1;
P2 = ~ Num2 [BB + 15-kk * 2]; P1 = ~ Num2 [BB + 14-kk * 2];
Delay (20 );
P1 = 0xff; P2 = 0xff;
}
}

Void display_clock (void)
{
Key1 = key; key2 =! Key;
Disp1 = buffer [3]/10; disp2 = buffer [4]-(buffer [4]/10) * 10;
II = disp1 * 16; JJ = disp2 * 16;
Num_led (II, JJ );
P2 = 0xff; P1 = 0xff; delay (60 );

Disp1 = buffer [3]-disp1 * 10; disp2 = buffer [4]/10;
II = disp1 * 16; JJ = disp2 * 16;
Num_led (II, JJ );
P2 = 0xff; P1 = 0xff; delay (60 );

II = 160; JJ = 160;
Num_led (II, JJ );
P2 = 0xff; P1 = 0xff; delay (60 );

Disp1 = buffer [2]/10; disp2 = buffer [5]-(buffer [5]/10) * 10;
II = disp1 * 16; JJ = disp2 * 16;
Num_led (II, JJ );
P2 = 0xff; P1 = 0xff; delay (60 );

Disp1 = buffer [2]-disp1 * 10; disp2 = buffer [5]/10;
II = disp1 * 16; JJ = disp2 * 16;
Num_led (II, JJ );
P2 = 0xff; P1 = 0xff; delay (60 );

II = 160; JJ = 160;
Num_led (II, JJ );
P2 = 0xff; P1 = 0xff; delay (60 );

Disp1 = buffer [1]/10; disp2 = buffer [6]-(buffer [6]/10) * 10;
II = disp1 * 16; JJ = disp2 * 16;
Num_led (II, JJ );
P2 = 0xff; P1 = 0xff; delay (60 );

Disp1 = buffer [1]-disp1 * 10; disp2 = buffer [6]/10;
II = disp1 * 16; JJ = disp2 * 16;
Num_led (II, JJ );
P2 = 0xff; P1 = 0xff; delay (60 );
}

Void display_tz (void)
{
Limit 11 = key; Limit 12 =! Key;

For (JJ = 0; JJ <16; JJ ++ ){
P2 = 0xff; P1 = 0xff;
Delay (40 );
}

For (JJ = 0; JJ <12; JJ ++ ){
P2 = ~ Hz_12 [JJ * 2]; P1 = ~ Hz_12 [1 + JJ * 2];
Delay (40 );
P1 = 0xff; P2 = 0xff;
}

For (JJ = 0; JJ <12; JJ ++ ){
P2 = ~ Hz_12 [TZ * 24 + JJ * 2]; P1 = ~ Hz_12 [TZ * 24 + 1 + JJ * 2];
Delay (40 );
P1 = 0xff; P2 = 0xff;
}

For (JJ = 0; JJ <8; JJ ++ ){
P2 = ~ Num1 [160 + JJ * 2]; P1 = ~ Num1 [160 + 1 + JJ * 2];
Delay (40 );
P1 = 0xff; P2 = 0xff;
}
Disp1 = buffer [TZ + 1]/10;
For (JJ = 0; JJ <8; JJ ++ ){
P2 = ~ Num1 [disp1*16 + JJ * 2]; P1 = ~ Num1 [disp1*16 + 1 + JJ * 2];
Delay (40 );
P2 = 0xff; P1 = 0xff;
}
Delay (60 );

Disp1 = buffer [TZ + 1]-disp1 * 10;
For (JJ = 0; JJ <8; JJ ++ ){
P2 = ~ Num1 [disp1*16 + JJ * 2]; P1 = ~ Num1 [disp1*16 + 1 + JJ * 2];
Delay (40 );
P2 = 0xff; P1 = 0xff;
}
Delay (60 );
}

Void intersvr0 (void) interrupt 0
{
Key =! Key;
If (W = 0) W = 1;
}

Void intersvr1 (void) interrupt 2
{

Th1 = 0; TL1 = 0;
}

Void timer1 (void) interrupt 3 using 1
{
}

Void timer0 (void) interrupt 1 using 1
{
Th0 =-(5000/256 );
Tl0 =-(5000% 256 );
Tr0 = 1;
Buffer [0] = buffer [0] + 1;
If (buffer [6] % 4 = 0) m [1] = m [1] + 1;
If (buffer [0]> 201 + xz ){
Buffer [0] = 0;
Buffer [1] = buffer [1] + 1;
If (buffer [1] = 60 ){
Buffer [1] = 0;
Buffer [2] = buffer [2] + 1;
If (buffer [2] = 60 ){
Buffer [2] = 0;
Buffer [3] = buffer [3] + 1;
If (buffer [3] = 24 ){
Buffer [3] = 0;
Buffer [4] = buffer [4] + 1;
If (buffer [4]> M [buffer [5]-1]) {
Buffer [4] = 1;
Buffer [5] = buffer [5] + 1;
If (buffer [5]> 12 ){
Buffer [5] = 1;
Buffer [6] = buffer [6] + 1;
If (buffer [6]> 99 ){
Buffer [6] = 0;
M [1] = m [1]-1;
}
}
}
}
}
}
}
}

 

Void JM (void)
{
Unsigned int KK, mm;
Cm = 0x00;
For (KK = 0; KK <30; KK ++ ){
Mm = 0;
While (P3 & 0x80) = 0x00 ){};
While (P3 & 0x80) = 0x80) {mm ++ ;};
If (MM> 350) & (mm <100) {CM = 0x00; break ;};
YY [Kk] = mm;
}
For (KK = 17; KK <22; KK ++ ){
Cm = cm <1;
If (yy [Kk]> 65) & (yy [Kk + 8] <65) {CM = cm | 0x01 ;}
Else {If (yy [Kk]> 65) | (yy [Kk + 8] <65) {CM = 0x00; break ;}
}
}
}

 

Void main (void)
{
Xz = 8; TZ = 1; Bz = 0;
Key1 = 0; key2 = 1;

Ea = 1;

It0 = 1; ex0 = 1;
Ex1 = 1;

It1 = 1; et0 = 1;
Tmod = 0x11;
Th0 =-5000/256; tl0 =-5000% 256;
Tr0 = 1;

Th1 = 0; TL1 = 0;
Tr1 = 1;

For (;;){
W = 0; CM = 0;
Delay (50 );
If (W = 2) {ex1 = 0; JM (); delay (1200); ex1 = 1; W = 0 ;};
If (Bz = 1) if (W = 1) {display_tz (); n = 1 ;}
If (Bz = 0) if (W = 1) {display_clock (); n = 1 ;}
If (Cm = 9) {buffer [1] = 0; delay( 1200); Bz =! BZ; W = 0; CM = 0 ;}
If (Cm = 11) {delay( 1200); Key =! Key; W = 1; Bz = 0; W = 0; CM = 0 ;}
If (Cm = 23) if (Bz = 1) {If (buffer [TZ + 1] <maxnum [TZ-1]) buffer [TZ + 1] ++; else buffer [TZ + 1] = minnum [TZ-1]; delay (1200); W = 0; CM = 0 ;}
If (Cm = 19) if (Bz = 1) {If (buffer [TZ + 1]> minnum [TZ-1]) buffer [TZ + 1] --; else buffer [TZ + 1] = maxnum [TZ-1]; delay (1200); W = 0; CM = 0 ;}
If (Cm = 31) if (Bz = 1) {If (tz <5) TZ ++; else TZ = 1; delay (1200); W = 0; cm = 0 ;}
If (Cm = 15) if (Bz = 1) {If (tz> 1) TZ --; else TZ = 5; delay (1200); W = 0; cm = 0 ;}

N ++; If (n> 10) W = 1;
}
}

4. The running effect is changed from boot to final completion. Status during startup

Normal running status

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.