Home > Microcontroller >Microcontroller Production > Temperature and clock display

Temperature and clock display

Source: InternetPublisher:消失的歌 Keywords: Display single chip microcomputer Updated: 2024/09/30

This article introduces a "temperature and clock display" composed of AT89S52 single-chip microcomputer. The circuit has simple hardware structure, concise program, low cost, flexible use, and is very suitable for adding auxiliary functions to products.

  1. Main functions and features of the circuit

  (1) Test the indoor temperature and display the current time.

  (2) Both the clock chip and the analog-to-digital conversion chip use serial interfaces, occupy MCL, and have fewer ports.

  (3) As an industrial auxiliary function, the program occupies less internal resources of the microcontroller.

  (4) The use of a dedicated clock chip and reasonable power supply design make the circuit have strong anti-interference ability.

  (5) All programs are written in a modular way to facilitate future maintenance and updates.

2. Circuit hardware

(1) Power supply circuit (see Figure 1). Interference in industrial control is inevitable. This power supply circuit uses the common 7805 as a voltage regulator. The author made a simple improvement by adding a common-mode choke to the circuit. The leakage inductance of the common-mode choke is used to generate an appropriate amount of differential-mode inductance to suppress the differential-mode current. Readers should pay attention to controlling the parasitic capacitance of the common-mode choke when designing, otherwise the isolation effect against high-frequency interference will be very poor. The more turns the common-mode choke has, the larger the parasitic capacitance is, and the worse the high-frequency isolation effect is.
  (2) Functional circuit (see Figure 2)

  AT89S52 single-chip microcomputer chip U1 is used as the MCU of this circuit, and the power-on automatic reset and clock circuits all adopt simple devices.

  ① LCD display 12232: It means displaying 122 columns and 32 rows. Two 0713 chips are used as dot matrix drivers (one 0713 chip drives 61 columns and 32 rows). Therefore, there are chip select signals CS1 and CS2 at the pin end. The 8th pin (A0) is the data/command selection terminal. When the level is high, the data DO~D7 (pins 9~16) is sent to the display RAM. When the level is low, the data DO~D7 is sent to the command executor.

  ② Clock chip BL5372: Some mobile phone circuits use BL5372 as a clock module. The chip uses the I2C interface protocol, and the maximum transmission rate is 400kbit/s. After successfully completing the read and write signal, the embedded word address register address will automatically increase. It should be noted that the SCL and SDA pins of the FC interface are often open-drain circuits, so a 10k pull-up resistor must be connected when the function is implemented. The clock chip has an automatic leap year adjustment function, and the power consumption current is 400NA/3.6V. It has a wide range of applications. Quite a number of battery-powered devices use this circuit. The clock chip BL5372 and PCF8563 have similar functions (only the device address and time register address need to be changed).

  ③AD conversion chip ADC0832: When industrial control equipment measures indoor temperature, the conversion rate and conversion accuracy of A/D are not high. At the same time, the use of MCU ports should be minimized. Therefore, ADC0832 with serial output and reasonable cost performance is selected as the conversion module. The hardware circuit adopts the typical connection method of A/D conversion, and uses the resistance change of thermistor to obtain different analog quantities after voltage division. Pin D1 is the selection pin of input analog channels IN0 and IN1 (D1 is 0 to select IN01 channel, D1 is 1 to select IN1 channel). The converted digital quantity is accompanied by the falling edge of 8 CLK pulses, and 8-bit data is serially output on the DO pin.

  ④Temperature sensor: Use MF series PTC thermistor.

    (3) Program Introduction

    This program is written in C language. The overall idea is to display specific text at a fixed position on the LCD, and display the converted clock and temperature data at the corresponding position through table lookup. In this way, the program can be divided into three modules: LCD display, clock display, and temperature display. It has the characteristics of flexible calling and convenient later modification. The flow of the main program is shown in Figure 3. After power-on reset, the program initializes 89S52 (MCU) and 12232 (LCD). During this period, it is a process of continuously reading BL5372 (clock chip) and ADC0832 (analog-to-digital conversion). The programming adopts modular calling mode. The author has marked detailed comments on each modular program in the program. The function of the subroutine LCD_Show_tAB is to predefine the content table of the displayed text to facilitate the later modification of the displayed text.

  When writing the clock program, the I2C interface of BL5 372 has three ways to read data. The data reading mode adopted by the author is as follows
 
  :

  The purpose of the write driver mode is to make the microcontroller select the clock chip. The device address of BL5372 is 0l10010+R/W (R is 1, W is 0). Since we are currently writing instructions, we send the driver address 0x64.

  The purpose of the read driver mode is to read the contents of the clock chip, process it through the microcontroller, and send it to the LCD. The I2C protocol of BL5372 stipulates that the upper four bits are the internal register address, and the lower four bits are the transmission mode (when reading the status, the transmission mode is defined as "0100"). Since the internal address of the second is (OH), 0x04H should be written when reading the second address.

  Acknowledgement signal: The I2C interface protocol stipulates that the master device generates a clock acknowledgement pulse after sending and receiving each byte. Since the I2C interface circuit is embedded in BL5372, when the clock chip receives a byte signal sent from the microcontroller, it automatically generates an ACK acknowledgement signal. However, since the 80C51MCU does not have an I2C interface, when a byte in the clock chip is read, BL5372 will keep the SDA state at a high level. At this time, we need to provide an ACK acknowledgement signal. The specific method is to manually generate a low level of SDA after receiving a byte.

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号