Brief Introduction of Time Controller System Based on P87LPC761 Single Chip Microcomputer

Publisher:幸福时光Latest update time:2013-11-09 Source: dzscKeywords:P87LPC761 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

Keywords:P87LPC761 Reference address:Brief Introduction of Time Controller System Based on P87LPC761 Single Chip Microcomputer

Previous article:Design of remote thermometer based on quartz crystal
Next article:Embedded MIPS32 M4K processor core SRAM interface application

Latest Microcontroller Articles
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号