Design of digital calendar system based on single chip microcomputer

Publisher:tyloo820Latest update time:2022-04-20 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

This design consists of four modules: data display module, temperature acquisition module, time processing module and adjustment setting module.


The core of the system uses the STC89C52 single-chip microcomputer; the data display module uses an LCD liquid crystal display; the temperature acquisition module uses the DS18B20 temperature sensor, which uses a single bus transmission and has an internal A/D conversion, making it very convenient to use; the time processing module uses the DS1302 clock chip, which can time the year, month, day, weekday, hour, minute, and second, and also has multiple functions such as leap year compensation; the adjustment setting module includes four buttons: mode selection button, function selection button, adjustment plus button, and adjustment minus button.

The electronic perpetual calendar of this project is a specific application of single-chip microcomputer control technology. The main research contents include the following aspects:


1) When selecting an electronic perpetual calendar chip, focus on devices that are easy to use, have single-chip storage, low power consumption, and are resistant to power outages.


2) Design peripheral circuits and microcontroller interface circuits based on the selected electronic perpetual calendar chip.


3) When designing the hardware, the structure should be as simple, practical and easy to implement as possible, making the system circuit as simple as possible.


4) Complete the soldering of components on the development board according to the circuit diagram.


5) Based on the designed hardware circuit, write the microcontroller program to control the STC89C52 chip.


6) Through programming, compiling and debugging, download the program to the microcontroller to run it and realize the functions of this design.


7) When designing hardware circuits and software programs, the main considerations are to improve the friendliness of the human-computer interface and facilitate user operation.

There are many ways to make a single-chip electronic calendar, and there are also many devices and technologies to choose from. Therefore, the overall design of the system should fully consider the environment in which the system is used, while meeting the system's functions. The selected structure should be simple to use and easy to implement, and the selection of devices should focus on appropriate parameters, stable performance, low power consumption and low cost.


According to the requirements of system design, it is preliminarily determined that the system consists of six modules: power module, clock module, display module, keyboard interface module, temperature measurement module and alarm module. The circuit system block diagram is shown in Figure 1. 


1 DS1302 interface circuit design


The interface circuit and working principle of the clock chip DS1302: Vcc1 is the backup power supply and Vcc2 is the main power supply.


VCC1 provides low power and low power battery backup in single power and battery powered systems. VCC2 provides main power in dual power systems. In this application, VCC1 is connected to the backup power supply to save time information and data in the absence of main power.

2 DS18B20 interface circuit design

 

The digital temperature sensor DS18B20 is used in this system, which has the characteristics of high measurement accuracy and simple circuit connection. This type of sensor only needs one data line for data transmission, which is connected to the DQ port of DS18B20 with P3.7, Vcc connected to the power supply, and GND connected to the ground.


The operating current of DS18B20 is about 1mA, VCC is generally 5V, then the resistance R=5V/1mA=5KΩ. The resistors currently used are generally not adjustable resistors, but fixed resistance values, and there are only a few models on the market.


If the DS18B20 is connected to a power supply, it needs a pull-up resistor to work stably. This resistor is usually large, so we choose a 10K resistor to pull it up to a high level to protect the subsequent circuit.

3 LCD1602 and MCU interface circuit design

 

D0~D7 of LCD are respectively connected to P0 port of microcontroller as data line. Because there is no pull-up resistor inside P0 port, a 4.7K pull-up resistor is added externally; P2.5-P2.7 are respectively connected to RS, RW and E control pins of LCD; RV1 is used to adjust the gray scale of LCD display; BLK and BLA are cathode and anode of backlight, and the backlight will be turned on when connected to corresponding electrical levels.

The third pin of 1602 is connected to a series resistor of 10K and 1.5K to play a voltage divider role, which can adjust the brightness contrast between the first and second rows. The 16th pin is connected to a transistor to amplify the function, so that the backlight of the LCD can be turned on, so that the perpetual calendar can be viewed at night.


4. Key module circuit design

 

This system uses 4 buttons, one of which is used for manual reset of the system, and the other 4 are independent buttons. This connection method is simple to query and program, and can save CPU resources. The button circuit is shown in Figure 19. The 4 independent buttons are respectively connected to the P3.0, P3.1, P3.2, and P3.3 interfaces of STC89C52.

A brief description of the above 4 buttons is as follows: K1 - SET button, K2 - UP button, K3 - DOWN button, K4 - OUT/STOP button.


SET button: Press the SET button to enter the time calibration state. Press once to adjust the seconds, twice to adjust the minutes, and so on to calibrate the year, month, day, hour, minute, second and week.


UP key: When the SET key is pressed, UP performs the addition operation of the SET selected item (such as hours);


DOWN key: When the SET key is pressed, DOWN performs a subtraction operation on the SET selected item (such as hours);


OUT key: When the OUT key is pressed, this key function is to exit the calibration function and enter the next mode to display the temperature value and the upper and lower temperature limits.



5 Design of main program flow chart

 

6 DS1302 Read and Write Program Design

 

The time reading of this system mainly comes from the operation of the microcontroller on DS1302. In terms of hardware, the connection between the clock chip DS1302 and the microcontroller requires three lines, namely SCLK (7), I/O (6), and RST (5). For the specific connection diagram, see the system hardware design schematic diagram.


When DS1302 exchanges data with the microprocessor, the microprocessor first sends a command byte to the circuit. The highest bit MSB (D7) of the command byte must be logic 1. If D7=0, writing to DS1302 is prohibited, that is, write protection; D6=0 specifies clock data, D6=1 specifies RAM data; D5~D1 specify specific registers for input or output; the lowest bit LSB (D0) is logic 0, specifying a write operation (input), and D0=1 specifies a read operation (output).


Reference address:Design of digital calendar system based on single chip microcomputer

Previous article:Design of temperature monitoring and alarm system based on single chip microcomputer
Next article:Design of Traffic Light Control System Based on Single Chip Microcomputer

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号