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.
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.
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
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- TLC7524 interface circuit program.pdf
- Here is the motor drive information on the national competition list
- RC snubber circuit design principles
- A Brief Analysis of Object-Oriented Thinking in RT-Thread System
- EEWORLD University ---- Linux driver tutorial (by itop4412)
- DSP 28335 program automatic upgrade solution
- What is the IoT edge? Where is the IoT edge?
- ISO13400 Ethernet Diagnostic Protocol
- The 4th volume of Mr. Yang's new book "New Concept Analog Circuits" is online! Hurry up if you need it~
- Can UC28025 be frequency modulated?