introduction
Timed on/off is a common problem in daily, weekly, monthly, etc. timed on/off. For example, in the booster pump room of a residential area, when the water consumption is low (such as late at night to early morning), the booster system is turned off on time, and water is only supplied by the pipe network; when the water consumption is high, the booster system is turned on on time to supply water at a constant pressure. In order to realize timed on/off, the system needs to be connected to a real-time clock chip (such as DSl302) to obtain real-time time.
For scheduled power on and off within a certain period (such as every day), it is necessary to solve the carry problem in real time. Taking hours and minutes as an example, tomorrow's 1:00 is farther away from the current time than today's 23:59, because the former is actually equivalent to 25:00. Therefore, if you want to judge the size of hours and minutes, you need to compare the date at the same time, which increases the difficulty of judgment. This article mainly takes the scheduled power on and off within 24 hours as an example to explain the method of solving the problem of scheduled power on and off judgment by looking up the table. This method only needs to compare hours and minutes.
1 Scheduled power on and off once within 24 hours
There are two cases for analysis. One case is that the power-on time (i.e., the time when the power-on starts) is greater than the power-off time (i.e., the time when the power-off starts). For example, the power-on time is 05:00 and the power-off time is 02:00, as shown in Figure 1(a). The other case is that the power-on time is less than the power-off time. For example, the power-on time is 04:00 and the power-off time is 23:00, as shown in Figure 1(b). The shaded parts in the figure are all the power-off time periods.
As can be seen from Figure 1(a), if the real-time time is greater than or less than both the power-on time and the power-off time, the system is powered on; if the real-time time is greater than the power-off time and less than the power-on time, the system is powered off.
As can be seen from Figure 1(b), if the real-time time is greater than or less than both the startup time and shutdown time, the system will be shut down; if the real-time time is greater than the shutdown time and less than the startup time, the system will be turned on. The result is exactly the opposite of Figure 1(a).
In fact, whether the system needs to be powered on is determined by the comparison results of the following three times: real time and power-on time, real time and power-off time, power-on time and power-off time. There are 8 possible combinations of these three comparison results. Based on the above analysis, Table 1 can be obtained, and 0 and 1 are used to represent the logical relationship between them.
After analysis, Table 1 has irrelevant items (x), and the comparison results corresponding to serial numbers 2 and 5 will not appear. According to Table 1, a program table suitable for different single-chip microcomputers can be compiled (such as MCS51, Table 1: db O, 1, 55h, O, 1, 55h, 0, 1). The results corresponding to the irrelevant items can be represented by specific values (such as 55h) to indicate errors, which are handled by the upper-level application. When compiling a program, you only need to combine the results of comparing the three times to get the results by looking up the table. The comparison results of the power-on time and the power-off time can be determined and saved in advance when setting. In actual operation, you only need to compare the real-time time with the power-on time, and the real-time time with the power-off time.
2 Multiple scheduled power on/off and other situations within 24 hours
As shown in Figure 2, 4 groups of power on and off times are set within 24 hours. The shaded part in the figure is the shutdown time period. According to different power on and off time groups, the table is looked up according to Table 1 according to the above method, and all the results are ANDed to determine whether to start or shut down. The system can only be turned on when the real time meets all the power on time conditions.
When the computer is turned on within a non-cyclic fixed time period (such as 2009-10-1 06:00 to 2009-10-8 23:00), it is actually only necessary to determine whether the real time is within the time period. In this case, the shutdown time is assumed to be greater than the startup time. The application in the reference is of this kind.
When a fixed period is used as a cycle (such as weekly, monthly, etc.), it is only necessary to change the algorithm when the three times are compared with each other. The system output can still be obtained by looking up the table based on the comparison results of the three.
Conclusion
This paper proposes a method to solve the problem of timing on/off judgment within a certain cycle in a single-chip microcomputer application system by using a table lookup method. The real-time, on-time, and off-time are compared with each other, and the table is looked up based on the comparison results to determine the control result. This method is simple and practical, and can also be used in other embedded systems or control systems.
Previous article:Function of the output transformer of the full-bridge inverter UPS
Next article:Design and implementation of a simple infrared remote control password lock
Recommended ReadingLatest update time:2024-11-16 16:33
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- CGD and Qorvo to jointly revolutionize motor control solutions
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Nidec Intelligent Motion is the first to launch an electric clutch ECU for two-wheeled vehicles
- Bosch and Tsinghua University renew cooperation agreement on artificial intelligence research to jointly promote the development of artificial intelligence in the industrial field
- GigaDevice unveils new MCU products, deeply unlocking industrial application scenarios with diversified products and solutions
- Advantech: Investing in Edge AI Innovation to Drive an Intelligent Future
- CGD and QORVO will revolutionize motor control solutions
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Mini OLED Game Console
- How does a trace moisture meter perform for factory equipment testing?
- Does anyone have the IPM driver board?
- Oximeter Principle
- Those sneaky tech giants
- Playing with Zynq Serial 26 - Functional Simulation of PL in Vivado
- EMC testing of Bluetooth electronic products powered by lithium batteries
- Playing with Zynq serial 8 - Installing Linux cross compiler under Ubuntu
- About the disassembly and welding of this type of module
- [Repost] Introduction to the application of hard-flex PCB