1. System Introduction
This time controller is a small system composed of a P87LPC761 microcontroller and an extended 74HCl64. It controls a relay and can set the time of the day, the on and off time of the relay. A total of 6 timing groups can be set, which can eliminate unnecessary timings and enable emergency start. All settings are implemented through the keyboard, and the buttons have a combo function. Each state has an indicator light. This 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 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 The power supply part
converts 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 rechargeable battery is used and a charging circuit is added to the power supply part. 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 expanded in this part. The single-chip microcomputer 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. This 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, which can be programmably selected, 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.
3 Software Design
Each machine cycle of the P87LPC761 microcontroller is 6 clock cycles. It uses a 100kHz crystal oscillator and each machine cycle is 60/1s. According to experiments, in order to ensure that the LED does not flicker, the time interval between lighting up the digital tube cannot be greater than 24ms. There are 4 digital tubes in total, so the time interval between lighting up each two digital tubes cannot be greater than 6ms. This should be noted in programming. There are 100 machine cycles between each interrupt, which is very limited. Therefore, the following principles should be followed when programming:
(1) The program should be as simple as possible and the main program should be as short
as possible. (2) The interrupt program should be as short as possible, giving as much time as possible to other programs.
(3) The branch program should be as many and as short as possible to avoid wasted work.
4.1 Timing compensation
timer. Working in mode 1, the count of mode 1 is affected by software. In order to reduce the timing error, when restoring the initial value (3CBOH) of timer 1, the time occupied by the software should be made up. The following method is used to re-initialize the interrupt:
After software compensation, if the crystal oscillator is accurate, the only error that can cause timing errors is the response time of the interrupt.
4.2 Low power consumption processing
Low power consumption is a problem that must be handled in this design. The presence of AC power is detected by 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 the 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, comparator, etc. This part of the work is completed in the initialization part.
4.3 Status indicator
In order to make full use of 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. We control the decimal point in the program 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 indicator light for the on time, and D11 (yellow) is the indicator light for the off time. If both the green and yellow lights are on, it means that the current timing group has been disabled.
References:
[1]. P87LPC761 datasheet http://www.dzsc.com/datasheet/P87LPC761.html.
[2]. 80C51 datasheet http://www.dzsc.com/datasheet/80C51_103447.html.
Previous article:Design of remote thermometer based on quartz crystal
Next article:Embedded MIPS32 M4K processor core SRAM interface application
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- 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
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- The maximum compensation is more than 200,000 yuan, and Toshiba’s Dalian factory is closed!
- Could you please help me analyze what the Darlington tube does in this circuit? Thank you.
- 550 Cases of Electrical Engineering Design and Calculation
- About BMS secondary protection chip
- [Perf-V Evaluation] Clock generation based on Perf-V development board
- Correctly understand the phase difference caused by capacitance and inductance
- 【SoC】Realize Ethernet interaction function
- Can anyone provide a download link for the AD package library (with 3D effects)? It's quite complete. Thank you.
- [ESP32-Korvo Review] (1) Development Board Circuit Connection
- What to do if ESP32-WROOM-32 has high power consumption when connected to the Internet