Design and production of calendar clock based on 12864 LCD module without font library

Publisher:qq8174350Latest update time:2010-10-22 Keywords:LCD Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

In this article, we will use the font-free 12864 LCD module to make a small calendar clock. The final effect is shown in Figure 1.

Make a small calendar clock by using the 12864 LCD module without font library www.elecfans.com

What are the features of this small calendar clock?

1. The circuit is simple, uses few components, and is easy to make. The core is the microcontroller ATMega8L and the calendar clock 1302.

2. All low-voltage components are used and can work with a voltage of 3V.

3. The use of self-edited small fonts and graphic interface makes the display unique: the current date and time can be clearly read on the text interface, and a small animation is added to make the display more vivid. The analog scale and pointer are used in the graphic interface to dynamically indicate the current time, and the two interfaces can be switched by buttons.

Circuit Principle www.elecfans.com

Figure 2 Circuit Principle

4. The power supply is made on an independent small circuit board. When debugging the program, insert a 3.3V regulated power supply powered by USB. After completion, you can remove it, plug in the switch, and use battery power.

5. When the backlight is not in use, the power consumption is very small (about 3mA for the whole machine), and it can be powered by a CR2O32 wafer lithium battery.

The calendar clock is installed on a small 50mm x 50mm multi-purpose board. See Figure 1 for the appearance.

Circuit Principle

The electrical schematic is shown in Figure 2. The LCD model is as mentioned above. The microcontroller is AVR's ATMega8L-8PU (hereinafter referred to as M8), which can work at low voltage. The PD port of M8 controls the LCD, mainly controlling the serial writing of display data. DS13O2 (hereinafter referred to as 1302) is a commonly used calendar clock chip, and the 32768Hz crystal B is its oscillation source. There are 10 command registers inside it to store the values ​​of date and time and control the chip operation. M8 controls 1302's RST, SCLK, and I/O through PB0PB1 and PB2: 1302 can only be read and written when RST is high. Both reading and writing allow data to be transmitted serially on I/O. When SCLK rises, 1 bit of address or data is written, and 1 bit of address or data is written. After writing the address, the data is read out every time SCLK falls. Reading and writing start from the lowest bit and are synchronized by the SCLK clock. After the power is turned on, it must start the timing through the MCU program. As long as there is power or power supply, it can keep working, regardless of whether the MCU is working. The 4 touch buttons connected to the PC port of M8, S1, S2, S3 are used to adjust the time: confirm the modification, move the cursor, and modify the value; S4 is used for interface switching. The power pack is inserted into two parts: the disc battery CR2O32 is connected to the VCC1 of 1302 through the diode VD1 as the back power supply, so that 1302 can continue to work when it is turned off. The other way can be used to power the LCD, MB, and VCC2 of 1302 through the switch S5. In order to avoid consuming the battery during debugging, another 5V to 3.3V small voltage regulator board is connected, and the 5V power supply is obtained from the outside using the micro SB interface. After debugging, remove the voltage regulator board, plug the small toggle switch S5 into the jack, and you can use the lithium battery. Note that diode VD1 cannot be omitted, because according to the 1302 manual, when VCC2 is higher than VCC1, it is powered by VCC2, and when VCC2 is lower than VCC1, it is powered by VCC1. When using batteries, due to the two straws, VCC2 is higher than VCC1, and the battery is powered normally. When the battery is turned off, VCC2 is 0, and the battery is used as the subsequent power supply through the diode, which meets the requirements and ensures the normal operation of the circuit.

Hardware Production

This calendar clock circuit is simple and requires few components. The integrated circuit uses a dual in-line socket, and the 90-degree pin row soldered on the LCD is connected to the 90-degree pin header socket soldered on the multi-purpose board. The 6-wire programming port and the power supply part socket use a round hole 2.54mm spacing socket strip. The battery uses a round lithium battery CR2O32. A 5cm square multi-purpose board is used to install all components. First, a section of 90° pin header is cut and soldered to the center of the upper back of the circuit board as an LCD socket. The M8 IC socket should also be installed on the back of the circuit board. For this purpose, its pins are bent outwards and the IC socket is positioned according to the corresponding position of the LCD socket pins. First, the RC reset component and some related wires are soldered, and then the MB socket is positioned and soldered to the circuit board pad. The 1302 socket is positioned according to the M8 socket and is also soldered on the back of the circuit board together with the 32768HZ crystal. Although this unconventional installation is not entirely reasonable, it effectively utilizes the installation area of ​​the multi-purpose board (otherwise the area occupied by the LCD is inconvenient to use), and it can make the connection between the LCD and the MB and 1302 very simple, and can be directly connected with solder. On the front of the circuit board, it is also necessary to install a touch button, a battery nest, a programming jack row, and a power block jack. The layout of components on both sides is shown in Figures 3 and 4. Another small multi-purpose board is used to solder the micro USB socket, filter capacitor, low-voltage regulator LM1117-3.3, and the IC pins corresponding to the power jack of the clock board.

When soldering the 90° pin header of the LCD, you can first insert it into the pin header that has been soldered on the circuit board, and then solder the gold-plated pads on the LCD. Be careful to keep the LCD and the circuit board parallel, so the pins cannot be inserted to the bottom of the LCD.

Because the LCD backlight consumes too much power for a small lithium battery with a capacity of only 2OOmAh, a current of 50mA is not installed. If you need to install it, it is best to connect it to an external power source instead of using a small battery.

programming

Although the circuit is simple, in order to make the LCD and 1302 without fonts work in an orderly manner under the unified leadership of M8, the specific programming must solve the following problems.

Figure 7 Program flow

1. Make the clock move, and you can set or modify the current data by pressing buttons.

2. Let the LCD display the information currently provided by the clock chip: year, month, day, hour, minute, and second, and refresh the two display interfaces on time.

3. Make fonts and graphical interface programming.

The first point above is to use M8 to control 1302. We can compile some functions according to its timing requirements. In addition, we can create an array DateTime[7] in the program to store the year, month, day, hour, minute, and second read from 1302 as the basis for data refresh. The second point is mainly to display the current data of this array on the LED (note that the format of 1302 to store date and time is BCD code, so the number system must be converted before access). Data refresh is actually to query whether the current "second" of 1302 is equal to the last query result. If not, 1 second has passed, record the new second in the array, and refresh the displayed "second" - of course, it is refreshed once every 1 second; and when the second is updated to 0, the "minute" must be updated... and so on. The third point has been described last time, using the Panpan font method, which has compiled 8 x 8 small numbers, 12×16 numbers, and 16×16 Chinese characters for different display positions. In addition, there is an animation of a chicken pecking at rice. You can click with the mouse in the 16-dot font tool to draw two patterns of a chicken lowering its head and a chicken raising its head, and display them alternately when the second refreshes. After using the font software to make the required fonts, put all the constant font array definitions in the header file miniClock, and all these arrays are placed in the FLASH area.

It is not difficult to make analog indicator needles and scales in the graphical interface. You just need to plan the length of the horizontal scale in advance, draw horizontal lines with the starting and ending coordinates, and draw short vertical lines for the vertical scale according to the scale position. The indicator ground is a vertical straight line above or below the scale. Its position must be calculated and changed according to the refresh of time data.

The title "Little Calendar Clock" is a Chinese character string, and a Chinese character string display function is used, Vold show-string1616(ucharx,uchary,uchar * string,uchar string_length); the parameters are the display starting column, page, string pointer, and string length. At the same time, one or more string arrays pointed to by pointers must be defined in advance. The elements of this array are the positions of the fonts to be displayed in the font array.

The entire program flow is shown in Figure 7. The left is the main process, and the right is the year, day, month, hour, minute, and second update process.

debug

After the hardware is soldered, check repeatedly without inserting M8, 1302 and LCD lithium battery, plug in the voltage regulator board, connect USB power supply, test M8 socket, 1302 socket, programming port and LCD VCC power supply should be normal 3.3V, remove the voltage regulator and turn off the power, plug in the lithium battery, 1302 socket 8 pin should be 2.4V, plug in S5 and turn it on, VCC should be 3∨, so the battery is fine. Unplug S5, plug in M8, LCD and 1302, plug in the voltage regulator board and USB power supply. If you have never used this kind of LCD, you might as well compile some small programs yourself (for example, after starting and initializing M8 and LCD, run the clear screen function with different parameters) to observe whether the LCD display is as expected. If there is no response, check again whether the definition of M8 pin in the program is consistent with your actual hardware wiring. This small LCD is different from some other LCDs. It does not require hardware to adjust the contrast summer, and will not not display due to improper contrast adjustment (unless you modify the default value). This level must be passed before going down. Download the program to M8. If everything is normal, the screen will appear immediately. However, the current date and time are wrong. Press S2 and a vertical cursor will appear on the separator of the date and time in the bottom row. Press S2 continuously and the cursor will move right in a loop. Press S1 at the position where the cursor stops, and the set value will appear on it. Press repeatedly to increase the value in a loop. In this way, the date and time are adjusted one by one, as shown in Figure 5. Finally, press S3, and the new time will be stored in 1302 and can be refreshed by seconds. Now plug in the battery and everything will be fine. As shown in Figure 6, it can be seen that the hours and minutes have been changed to the new set values. The voltage regulator can be removed. Although the LCD is off, 1302 is still running silently. If you plug in the switch S5 and turn it on again, the LCD will light up again. In order to save battery consumption, don't always turn it on. Just like an old pocket watch, open the cover before looking at the watch.

Keywords:LCD Reference address:Design and production of calendar clock based on 12864 LCD module without font library

Previous article:Power saving methods for NUC1xx microcontrollers (MCUs)
Next article:Brushless ESC solution for model aircraft based on Sinowin SH79F168 MCU

Recommended ReadingLatest update time:2024-11-17 15:43

STM32 SPI drives TFT LCD
Using STM32F030's SPI to drive TFT LCD, the LCD I use is a 2.4-inch color screen with 240*320 pixels, and the driver IC is ili9341. Only four wires are needed to light up the LCD. Here is the SPI configuration. I'd like to state that the SPI configuration of F030 is somewhat different from that of F103, etc. /*LCD SPI
[Microcontroller]
Design of LCD touch screen system based on ARM
  introduction   With the rapid development of embedded system technology, industrial equipment products are becoming more and more modernized, and generally require visual operation. LCD touch screens have low energy consumption, low heat dissipation, low cost, thin and light, small size, and easy installation. Using
[Microcontroller]
Design of LCD touch screen system based on ARM
STM8 SPI drives LCD12864
System functions The SPI communication bus inside STM8 is used to drive LCD12864.    hardware design   LCD12864 circuit schematic diagram  software design /************************************************************************ Target system: Based on STM8 microcontroller  Application software: Cosmic CxSTM8  *
[Microcontroller]
STM8 SPI drives LCD12864
LG has stopped producing LCD screens for Apple's iPhone
      According to 9To5Mac, citing supply chain reports, LG Display has stopped producing LCD iPhone screens and has given up hope of future production. In addition, LG Display said it may stop producing its own smartphones.   9To5Mac notes that LG continues to produce LCD screens for Apple's older iPhones, but a re
[Mobile phone portable]
6. 2440 bare metal development LCD operation
LCD (Liquid Crystal Display) is a liquid crystal display. The structure of LCD is to place a liquid crystal box between two parallel glass substrates, set TFT (thin film transistor) on the lower substrate glass, and set color filter on the upper substrate glass. The signal and voltage on the TFT are changed to control
[Microcontroller]
6. 2440 bare metal development LCD operation
LCD 12232F serial port C51 program
Since the 12232F display is quite commonly used, but what we usually see are some parallel port assembly programs, and there is no parallel port program corresponding to 12232F, and the serial port C51 program is extremely rare. In order to facilitate everyone's use, this site has debugged it. Please give your advice!
[Microcontroller]
Differences and advantages between LED display and LCD
LED applications can be divided into two categories: one is LED single tube application, including backlight LED, infrared LED, etc.; the other is LED display screen. At present, China still has a certain gap with the international level in the manufacturing of LED basic materials, but as far as LED display screens
[Power Management]
s3c2440 bare metal-LCD programming (6. Display characters on LCD)
1. Transplantation of font library Characters are also made up of dots, a dot matrix composed of dots. In fact, to display text is to transplant the font library to the board that matches the corresponding model. Each character in the font library is a combination of dots according to the corresponding format. into a
[Microcontroller]
s3c2440 bare metal-LCD programming (6. Display characters on LCD)
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号