This paper describes the hardware and software design method of a timing charging controller based on single chip computer, and describes the working principle of the controller. It focuses on the operation mode of reading and writing of LCD module and clock chip, and the principle of on-off control of relay. Some circuit schematic diagrams and C language program codes are given. With the sustained and rapid development of China’s economy and society, the shortage of energy supply is becoming increasingly apparent. The concept of green, low-carbon and energy-saving has gradually become popular. Charging electric bicycles have entered a large number of ordinary families. The research and application of electric vehicles are also gradually advancing.
The safe charging of batteries and batteries has attracted people’s attention. Overcharging is an important factor affecting the service life of batteries and batteries.
The controller designed in this paper can accurately control the charging time and effectively prevent overcharging. [1].
The microcontroller obtains time information by reading the clock chip. The user sets the reserved charging time and the charging time by pressing the button. The set time value is displayed by the LCD module. After setting, press the start button to charge. When the charging time is up, the MCU sends instructions to the relay to control the relay to disconnect the charging circuit and stop charging. The hardware block diagram of the system is shown in Figure 1. It mainly includes STC89C52 single chip computer, clock chip (DS12C887), 12864 LCD module, keys, relays, buzzers and power supply of the main control board. The SCM model is STC89C52, which has 8K in-chip program memory and 256 bytes in-chip data memory. The clock chip DS12C887 can automatically generate time information such as century, year, month, day, hour, minute and second. It also has lithium batteries. When the external power is off, the internal time information can be maintained for 10 years.
The LCD module is 12864, which contains the simplified Chinese Library of the national standard. It has 128 16*8 ASCII character sets and 829 16*16 Chinese characters, thermostatic element which constitute the human-computer interaction interface of the system. The relay adopts DC-controlled AC solid-state relay. The output terminal is connected to 220V AC circuit. The control terminal and the output terminal have optocoupler isolation protection, and the switching noise is very small. The schematic diagram of the clock chip interface circuit is shown in Figure 2. DS12C887 has its own crystal oscillator, so it does not need external crystal oscillator. AD0-AD7 is a signal line, which is connected to the port of P.0-P.7 of MCU through 10K pull-up resistance. The suspension of the MOT pin determines that the clock chip of the system adopts Intel mode of operation.
At this time, DS pin is used as the input for reading.
The R/W pin is used as a write allowable input in Intel mode. AS is the address gated input foot. When reading and writing, the rising edge of AS latches the address information appearing on AD0-AD7 to DS12C887, while the next falling edge clears the address information on AD0-AD7.
CS is a chip selection input, the pin is low level, DS12C887 works.
Fig. 3 is the schematic diagram of the interface circuit between MCU and 12864 LCD module. The “D0-D7” in the diagram is the data port of LCD module. It connects with the MCU’s P 0.0-P 0.7 through 10K pull-up resistance respectively to transmit the signal data and command data of LCD module. RS is the “data/command” selector, D0-D7 transmits signal data at high level, D0-D7 transmits command data at low level.
RW is the “read/write” selector. At high level, MCU reads LCD data; at low level, MCU writes data into LCD. In order to enable EN, LCD module interacts with MCU at high level. PSB is a serial/parallel mode selector. The system adopts parallel data transmission mode, so the PSB is fixed to high level. The pin 2 and pin 3 are connected by a precise adjustable resistance of 10K ohm, and the display brightness of the LCD module is adjusted by changing its resistance value. The program of timing charge controller mainly includes three parts: read and write program of DS12C887 clock chip, on-off program of relay and man-machine interaction program. When the system is powered on, the MCU resets the initialization register and peripheral devices, reads the clock chip, and displays the time information on the LCD screen. At this time, the system waits for the user’s button operation. The user can set the reserved charging time and the charging time by the button calibration time. After pressing the confirmation key, the system starts countdown. When the appointment time arrives, the MCU sends a high-level signal to the relay control terminal. The relay closes the charging circuit and starts charging. When the charging time is up, the MCU sends a low-level signal to the relay control terminal. The relay disconnects the charging circuit and the charging ends [3]. Relay control terminal achieves high level, the output terminal is closed, otherwise the output terminal is disconnected. In this paper, the design of hardware and software of timing charging controller is studied. The hardware circuit of the controller is designed completely. The key program codes are elaborated in detail.
At the same time, the hardware system is built by using universal circuit board. Experiments show that the expected results are achieved.