Design of Rotary Clock Based on Single Chip Microcomputer

Publisher:SparklingMoonLatest update time:2016-04-13 Source: 21icKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1 Introduction

At present, the types of clocks are becoming more and more diverse, and the functions are becoming more and more abundant, but most clocks are still traditional clocks, that is, fixed dials and pointers, and their forms and functions are relatively simple, so they are difficult to attract people. A rotating clock not only breaks away from the design of traditional clocks in terms of creativity, but also caters to people's curiosity, and the functions can also be diversified, not only can it display time and date, but even text. Based on the single-chip microcomputer, this article designs a rotating clock with the same second hand, minute hand, hour hand and dial scale as the traditional mechanical clock, and has the functions of accurately displaying the instant time and calibrating the time, and both can be easily completed by the infrared remote control.

2 Overall design ideas and solutions

The article intends to use the on and off of 16 light-emitting diodes to simulate the clock dial, and its rotation is achieved by the rotation of a DC motor; the 1s source signal of the clock is generated by the DS1302 clock chip; in order to ensure the stability of the clock dial display, an infrared pair of tubes is used to achieve it; in order to facilitate the power supply of the rotating circuit board, wireless power supply is used; in order to be able to conveniently adjust the time of the rotating clock, an infrared remote control is proposed. Therefore, the hardware modules of the system are mainly composed of the following parts: display module, wireless power supply module, single-chip minimum system module, infrared remote control module, clock module, calibration module, and motor drive module. The system principle block diagram is shown in Figure 2.1. Among them, the wireless power supply module uses coil coupling to transmit energy to the single-chip microcomputer system, and the single-chip microcomputer system can work normally. The motor drives the single-chip microcomputer system to rotate rapidly; then the single-chip microcomputer quickly reads the time of the clock module and sends this time information to the display module; the display module can control the corresponding light-emitting diodes to turn on and off according to this time information, and then cooperate with the rotation of the motor to realize the display of the clock. Since the entire clock rotates at high speed, it is more convenient to use an infrared remote control module to set parameters such as time and position. The clock module provides accurate time for the entire system, while the calibration module is used to detect the starting point of the clock display.

3 Unit Module Circuit Analysis and Design

3.1 Analysis and design of the minimum system module of the single-chip microcomputer

The minimum system module of the single-chip microcomputer is composed of a single-chip microcomputer chip (STC12C5A60S2), a clock crystal circuit and a reset circuit. The reset circuit can realize the two functions of key reset and power-on reset. The clock crystal circuit uses a 12MHz crystal oscillator to provide a clock signal to the single-chip microcomputer. The 31st pin (/EA terminal) of the STC12C5A60S2 chip is connected to a high level to enable it to read instructions from the internal program memory. In order to prevent the 31st pin from accidentally outputting a low level and burning the single-chip microcomputer, a 10K resistor needs to be connected to the 31st pin.

3.2 Analysis and design of wireless power supply module

The wireless power supply module consists of a transmitting module and a receiving module. The wireless transmitting module is mainly composed of transistors B772 and 9013 and a primary coil. B772 generates a lot of heat when working, so a heat sink is required. The main working principle of the circuit is to convert direct current into alternating current according to Faraday's law of electromagnetic induction, and then send the energy out through the primary coil. The secondary coil finally induces electricity and then passes through the corresponding circuit to complete the power supply to the microcontroller. Among them, the direct current to alternating current part uses a self-excited oscillation circuit.

The main principle of the wireless receiving module is as follows: First, the secondary coil is used to receive the energy sent by the primary coil of the sending module. Because the sending module uses DC to AC to transmit energy, the secondary coil always senses AC power, and the power supply requirement of the microcontroller is DC power, so it must be rectified to become DC power, and finally passed through the 7805 voltage regulator chip to output a stable 5V power supply to power the microcontroller.

3.3 Analysis and design of motor drive module

The motor used in the motor drive module is the RF370 motor. When its operating voltage is 5V, its speed is between 2500 and 3100 rpm, and the current is only 20mA, which is very energy-saving. The speed can meet the design requirements, and the noise is small when rotating, so it is very suitable for completing the design. The motor is connected to the wireless power supply module through a 2-pin pin, and the 5V power supply is used to power the motor. Since the motor stores energy when it is working and releases it when it stops working, in order to prevent the current released by the motor from burning other circuits, a current limiting diode 1N4148 is connected in parallel at both ends of the motor to protect the circuit.

3.4 Clock module analysis and design

The clock module consists of the clock chip DS1302 and its peripheral hardware circuits. A 32.768KHz crystal oscillator is connected between pins 2 and 3 of the DS1302 chip. After frequency division inside the DS1302 chip, a standard signal of 1Hz can be obtained, providing an accurate time signal for the clock. The Vcc1 of pin 8 is connected to an external 3V button battery. When the module is powered off, it allows the DS1302 to continue working to save time data; the VCC2 of pin 1 also needs an external power supply of 5V. When dual power is used, VCC2 is used as the main power supply to power the module; pin 5 (/RST) is the reset/chip select terminal, which is used to control DS1302 to communicate with the outside world and is connected to the P3.5 pin of the microcontroller; pin 7 (SCLK) is the serial clock input terminal, which provides a clock for data transmission and is connected to the P3.7 pin of the microcontroller; pin 6 (I/O) is the serial data input/output terminal (bidirectional), which is the data transmission pin during communication and is connected to the P3.6 pin of the microcontroller.

3.5 Calibration module analysis and design

Since the rotating clock needs the LED to rotate to have a circular effect, it is necessary to use sensors or infrared tubes to help determine the starting point position, and also to make the clock dial display fixed. This design uses infrared tubes, in which the infrared transmitting tube is welded in the wireless power transmission module, and the infrared receiving tube is connected to the P3.3 pin of the microcontroller. When the receiving tube receives the transmitting tube signal, the resistance value will become very small, and P3.3 will output a low level at this time; when no signal is received, the resistance value of the receiving tube becomes very large, and P3.3 will output a high level at this time, that is, a falling edge is generated. The P3.3 pin is the input pin of the microcontroller external interrupt 1. If the interrupt is set to a falling edge trigger, the falling edge will immediately trigger the interrupt, allowing the microcontroller to execute the starting point detection program to achieve normal and accurate display of the clock.

3.6 Display Module Analysis and Design

The display module uses a row of LED lights to achieve the clock display effect. In this design, 16 LED lights are connected to the P1 and P0 pins of the microcontroller, of which D1~D4 are green LED lights and D5~D16 are red LED lights. D1 is used to display the clock disk frame, and D2~D4 are used to display the dial scale. If the time is 12 o'clock, 3 o'clock, 6 o'clock, and 9 o'clock, 3 lights will be on, and if it is at other times, two lights will be on. D5~D16 is used to display the dial pointer, so that the display effect is the same as the actual clock pointer. Since the second hand is the longest in the clock, D5~D16 must be all lit when displaying the second hand; the length of the minute hand is in the middle, so when displaying, D8~D16 must all be lit; the length of the hour hand is the shortest, so when displaying, only D11~D16 will be lit.

3.7 Analysis and Design of Infrared Remote Control Module

The infrared remote control module consists of a remote control and a receiving module. The remote control uses the NEC protocol, which is also used by many home appliances. The receiving module uses the infrared integrated receiving head VS1838B, where its 3-pin is connected to the power supply 5V, 2-pin is grounded, and 1-pin transmits the demodulated signal of the receiving head to the external interrupt 0 pin (i.e. P3.2) of the microcontroller, and the interrupt is used to enable the microcontroller to realize infrared decoding.

4 Software Program Analysis and Design

The main idea of ​​the program design is: first use a timer to generate a fixed time interrupt, and the main task of the interrupt execution is to let a variable (named Count) add 1. This variable Count is very important because it is based on its value to determine the display. For example, every time the motor rotates one circle, Count increases from 0 to 180. A dial has 60 scales (because seconds and minutes are both 60). Then every time Count increases by 15, the microcontroller will drive the LED to display the corresponding time point, and it will continue to increase to 180, and then 12 time scale points will be displayed. Therefore, the maximum value of Count should be a multiple of 60.

To solve the display of the clock hands, you only need to read the time of DS1302 and then determine whether the Count reaches the corresponding Count values ​​of seconds, minutes, and hours. If it reaches the corresponding Count values, the second hand, minute hand, and hour hand will be displayed respectively. For example, if the second value of DS1302 is equal to 20, since the maximum Count is 180 for one rotation, and one rotation is 60 seconds, since 180/60=3, when the Count is added from 0 to 180, when it is added to 20*3=60, the microcontroller will light up the LED corresponding to the second hand. The display principle of the minute hand is similar to this, because there are also 60 scales for minutes on a dial. The algorithm for the hour hand is different, because there are only 12 scales for hours on a dial. The algorithm for hours is as follows: (Hour*15)+(Minu/4). Because the count value is added to 180 for one circle of the dial, and there are only 12 points on the dial, so 180/12=15, plus the movement of the minute will affect the movement of the hour hand, the conversion relationship is: (Minu*3)/12, Minu*3 is the count value corresponding to the minute at this time, and the minute only moves 30 degrees when it moves 360 degrees, so 360/30=12. The corresponding count value for the comprehensive display is (Hour*15)+(Minu/4). The requirement for this is that the interruption time of the timer must be closely matched with the rotation cycle of the motor, and the motor speed must be stable.

5 System Function Test Analysis

The actual welding circuit is shown in Figures 5.1 and 5.2. Figure 5.1 is the front of the circuit board. The modules that can be seen on it are the single-chip minimum system module, display module, clock module, infrared remote control receiving module and wireless power receiving module. Figure 5.2 is the back of the circuit board. There are infrared pair tube receiving module and wireless power receiving coil on it. The two screws are used for counterweight.

b.jpg

The functional test results are shown in Figures 5.3, 5.4, 5.5 and 5.6. Figure 5.3 shows the instant time 10:43:12 after the system is powered on; Figure 5.4 shows the time 10:43:21 after the clock moves normally for 9 seconds; Figure 5.5 shows the effect of adjusting the hour hand, which is adjusted from 10 o'clock to 1 o'clock; Figure 5.6 shows the effect of adjusting the minute hand, which is adjusted from 39 minutes to 50 minutes. It can be seen from the test results that the electronic rotary clock operates normally, the time display is accurate, the dial display is stable, and the time adjustment function can also be realized, so the design function meets the expected requirements.

6 Conclusion

The test results show that the rotating clock designed in this paper has the following advantages compared with other solutions on the market: ① The dial (including scale and pointer) displays stably without vibration; ② The time can always move accurately and normally without running errors after a period of time, pointer pointing randomly, etc.; ③ The display brightness is consistent without uneven display brightness. Of course, there are also areas where the design needs to be further improved, such as adding the display of date and text, so that the content displayed on the dial can be increased, and the display mode can be switched by pressing buttons.

Keywords:MCU Reference address:Design of Rotary Clock Based on Single Chip Microcomputer

Previous article:CAN bus communication program based on single chip microcomputer
Next article:Master the essence of single chip microcomputer - timer

Recommended ReadingLatest update time:2024-11-15 15:55

The difference between STM32 MCU and 51 MCU
Introduction to MCU A single-chip microcomputer is abbreviated as an MCU. In simple terms, it is a device that integrates CPU (calculation, control), RAM (data storage-memory), ROM (program storage), input and output devices (serial port, parallel port, etc.) and interrupt system on the same chip. In our own personal
[Microcontroller]
Design of electronic password lock based on 51 single chip microcomputer -- 1602 display
1. Hardware Solution This system consists of STC89C52 single-chip microcomputer, 44 matrix keyboard, buzzer, reset circuit and crystal oscillator circuit, relay, etc. The 44 keyboard is mainly used for password input and modification, the buzzer alarm, reset circuit and crystal oscillator circuit and STC89C52 single-c
[Microcontroller]
Design of electronic password lock based on 51 single chip microcomputer -- 1602 display
Sharing of assembly program of DC voltmeter based on PIC microcontroller
Define user registers WEI1EQUH'0C';BIT0=MODS: Select mode bit 0: Mode 11: Mode 2 ;BIT1=BREK: Break detection bit 0: No break 1: Break ;BIT2= ;BIT3= ;BIT4= ;BIT5=slow ring ;BIT6=Quick ring ;BIT7=Long beep WEI2EQUH'0D'; Starting value of "hundreds value operation"   WEI3EQUH'0E'; Starting value of "ten-digit operation
[Microcontroller]
Sharing of assembly program of DC voltmeter based on PIC microcontroller
Programming of LED digital tube seconds display based on PIC16F84A microcontroller
  The source program pIC07.c is a 2-digit LED digital tube second display based on the PIC16F84A microcontroller. Its display mode is 0 to 99 seconds repeated display. If readers need to conduct experiments, real-time display can be performed on the hardware circuit (of course, the prerequisite is to first burn the ta
[Microcontroller]
Programming of LED digital tube seconds display based on PIC16F84A microcontroller
MCU LED light flashing program
We have completed the program for lighting up the LED light in the second lesson, which is to set LED = 0. The program for turning off the light is also very simple, which is LED = 1. Now that we know how to turn on and off, if we add a delay between turning on and off, and repeatedly turn the light on and off, it wil
[Microcontroller]
51 single chip microcomputer multi-point 18b20 temperature measurement system
Share my final homework, multi-point temperature measurement based on 51 single-chip microcomputer. The multi-point temperature measurement is to mount multiple 18b20 temperature sensors on a single bus. The single-chip source program is as follows: #include reg51.h         #include intrins.h    #define uchar unsign
[Microcontroller]
How to select memory bank 0 or 1 in PIC16C6X microcontroller
The data memory of the intermediate product PIC16C6X of PIC microcontroller is usually divided into two banks, namely, bank 0 (Bank0) and bank 1 (Bank1). Each bank is composed of two parts: dedicated registers and general registers. Some register units in the two banks are actually the same register units, but have dif
[Microcontroller]
On the Proportional Electromagnet Control Technology of C8051F005 Single Chip Microcomputer
  introduction   As an actuator, the proportional solenoid is one of the key products of mechatronics and is widely used in various automatic control systems. The proportional solenoid has a large thrust, simple structure, convenient maintenance, and low cost. It is a widely used electro-mechanical converter . The ch
[Microcontroller]
On the Proportional Electromagnet Control Technology of C8051F005 Single Chip Microcomputer
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号