1. System Introduction
The time controller is a small system composed of a P87LPC761 microcontroller and a 74HCl64 expansion chip. It controls a relay and can set the time of the day, the relay opening time and closing time. A total of 6 timing groups can be set, which can eliminate unnecessary timings and enable emergency start. All settings are realized through the keyboard, and the buttons have a combo function. Each state has an indicator light. The time controller uses an external 100kHz crystal oscillator and is powered by AC power and equipped with a rechargeable battery. After the AC power is removed, it enters the leisure mode and the clock continues to run.
2 Hardware Circuit Design and Analysis
The system functional block diagram is shown in Figure 1. The difficulty of this system design is not in the hardware but in the software design under the low-frequency crystal oscillator.
The entire hardware circuit can be divided into three parts: power supply, keyboard display and CPU, which are analyzed as follows.
2.1 Power supply
Convert AC power into DC power required by the microcontroller. This is a very common power supply circuit. In order to ensure that the clock can continue to run after the AC power is removed, a charging circuit is added to the power supply part with a rechargeable battery. When there is AC power, the external power supply is directly used to charge the rechargeable battery at the same time. After the AC power is removed, the rechargeable battery is used as the power supply to enter the leisure mode.
2.2 Keyboard and display circuit
In order to save components, a dynamic scanning method is used to display the clock, and a 74HCl64 is added to this part. The microcontroller sends data to the 74HCl64 through the serial port, and the data is displayed on the seven-segment digital tube. A triode is added to the common end of each digital tube to amplify the current of the scanning signal to drive each digital tube.
2.3 CPU part
The CPU part is the core of the time relay. It is mainly controlled by P87LPC761. As a member of the Philips small package series, P87LPC761 is a 20-pin packaged single-chip microcomputer, suitable for many occasions requiring high integration and low cost, and can meet many performance requirements. P87LPC761 provides high-speed and low-speed crystal oscillators and RC oscillation modes, programmable selection, with a wide operating voltage range, programmable I/O port line output mode selection, selectable Schmitt trigger input, LED drive output, and internal watchdog timer. P87LPC761 uses 80C51 accelerated processor, and the structural instruction execution speed is twice that of the standard 80C51 MCU. The schematic diagram of the CPU part circuit is shown in Figure 3.
3 Software Design
Each machine cycle of the P87LPC761 microcontroller is 6 clock cycles, using a 100kHz crystal oscillator, and each machine cycle is 60/1s. According to experiments, in order to ensure that the LED does not appear to flicker, the time interval between lighting up the digital tubes cannot be greater than 24ms. There are 4 digital tubes in total, so the time interval between lighting up every two digital tubes cannot be greater than 6ms. This should be noted in programming. There are a total of 100 machine cycles between each two interrupts, which is very limited. Therefore, the following principles should be followed when programming:
(1) The program should be as simple as possible. The main program should be as short as possible.
(2) Make the interrupt program as short as possible to give as much time as possible to other programs.
(3) The branch program should be as numerous and short as possible to avoid unnecessary work. [page]
Due to the length of this article, only the overall flow chart of the program is introduced here, as shown in Figure 4.
4.1 Timing compensation
Timer. Works in mode 1, and the count of mode 1 is affected by software. In order to reduce the timing error, when restoring the initial value of timer 1 (3CBOH), the time occupied by the software should be made up. Re-assigning the initial value in the interruption is done as follows:
After software compensation, if the crystal oscillator is accurate, the only error that can cause timing error is the interrupt response time.
4.2 Low power consumption processing
Low power consumption is an issue that must be addressed in this design. The presence of AC power is detected through the AC detection circuit. In the program, it is handled as follows: query the level of P1.3 port. When P1.3 port is high, it enters the normal state, that is, the display, keyboard, all interrupts, and serial port are working normally. Once P1.3 port is low, the display, keyboard, serial port and T1 interrupt are turned off, that is, only the TO interrupt of the refresh clock is opened (this is to ensure that the clock can still run and data is not lost in the idle mode) to enter the idle mode. In order to reduce system power consumption, it is also necessary to turn off power-off detection, comparators, etc. This part of the work is completed in the initialization part.
4.3 Status indicator
In order to make full use of the system hardware resources, the decimal point of the seven-segment digital tube is used as the status indicator. Because there is no decimal in the clock display. In the program, we control the decimal point in this way. In the seven-segment code table, the code with a decimal point is placed after the code without a decimal point. The code positions with and without a decimal point for the same number are 10 apart. When a decimal point is needed, just add 10 to the pointer of the code. Two indicator lights are arranged, D10 (green) is the on time indicator, and D11 (yellow) is the off time indicator. If both green and yellow lights are on, it means that the current timing group has been disabled.
Previous article:Development of Chinese version of LCD display based on BP elevator control system
Next article:Discussion on MSP430 Program Upgrade Method
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- 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
- Analog Electronics Tong Shibai 223 pages Frequency Response
- EEWORLD University Hall----Live Replay: Infineon BMS solutions protect electric vehicles and energy storage systems!
- Explore TE's PCB Subsystem Solutions
- Application of operational amplifier in active filtering
- Solution to EK200-6Q7C stuck during operation
- Goodbye February, hello March
- Embedded protocol selection issues
- [ST NUCLEO-H743ZI Review] (5) ADC conversion speed and accuracy test
- uPySteppers, a wirelessly controlled rotating platform using the ESP32
- [Anxinke UWB indoor positioning module NodeMCU-BU01] 03: Power consumption measurement and onboard resource testing