Automatic Pet Feeder based on Single Chip Microcomputer

This paper has designed an automatic pet feeder based on single chip microcomputer, in order to solve the problem that pets from eating normally on time because of people often work overtime or go on business trips. The system uses STC89C52 microcontroller as the core to control each module to work. First, the single-chip microcomputer STC89C52 determines the real-time time by reading the DS1302 real-time clock chip, and displays the current real-time time through the LCD1602 liquid crystal, and then through the control buttons you can modify the real-time time and set the feeding time. After setting the time, the program will constantly compare the feeding time with the real-time time. When the feeding time is reached, the buzzer will play a specific signal to attract pets to eat, and at the same time, the motor module drives the stepper motor to rotate the food. The system can replace the owner to realize the function of feeding pets regularly.


Introduction
With the increasing wealth of material life, people began to pay attention to the enjoyment of spiritual life, and keeping pets is a more prominent representative. More often, pets are not only partners, but also people's emotional sustenance. But nowadays, people often face long-term absence from home such as overtime or business trips, resulting in pets unable to feed on time [1], irregular diet [2], frequent or hungry or fullness, etc. [3], which makes many pet owners a headache. As more and more people keep pets, the problem of pet feeding has become more and more prominent. In order to solve this problem, some organizations specializing in raising pets have appeared on the market, which can help pet lovers take care of their foster pets. However, due to the chaotic management of the pet surrogacy market and the mixed organization of surrogacy, it is difficult to meet the requirements of pet owners for the physical and mental health of pets [4,5], In addition, the cost of surrogacy is relatively high, so out of concerns about pets and cost considerations, very few pet owners choose surrogacy agencies [6].
The automatic pet feeder came into being, which can automatically feed pets in the absence of the owner, solving the urgent needs of pet lovers [7][8][9]. This paper designs an automatic pet feeder controlled by a single-chip microcomputer. The owner puts the pet's feed in a simple and convenient container in advance, and then sets multiple fixed times. When each time point is reached, the system will drive the stepper motor to rotate to control the quantitative outflow of feed, and trigger the voice system to send a specific signal to achieve the purpose of attracting pets to eat. It can feed pets

System Architecture
The main function to be realized in this design is: when the owner is not at home, the automatic feeding device is activated. When the specified feeding time is reached, the single-chip microcomputer sends a command to rotate the stepper motor to finally realize the function of automatic pet feeding.
The structural block diagram of the automatic feeding system determined according to the system functional requirements is shown in Figure 1. The whole system is mainly composed of a single chip microcomputer module, a clock module, a button module, a motor drive module, a voice module, and a liquid crystal display module.
The STC89C52 single-chip microcomputer is used as the main control chip to control each module. The real-time time and feeding time are set through the operation of the buttons, and the LCD liquid crystal display screen displays them for easy viewing. When the real time reaches the feeding time, the voice chip of the voice module will control the buzzer to send out a set signal, so that the pet can react quickly after hearing it and get close to the signal source, and then the motor drive module will control the stepping motor to start Rotate, and finally make the mouth of the container with food large enough, so that the food flows out slowly, so that the function of automatic feeding can be realized.

Fig1.
Block diagram of automatic feeding system Main control module: STC89C52 single-chip microcomputer is used as the main control chip, which is the core of the control system, which is used to control the coordinated work of the various modules of the entire system. Clock module: use the clock chip DS1302 to control the real-time time, and protect it from power failure through an external power supply to ensure the accuracy of the real-time time. Button module: realize the control of time, including real-time time and feeding time.
Motor drive module: Use the ULN2003 drive board to drive the stepper motor, and use the motor drive principle to pull the bottom cover of the food container for food delivery. Liquid crystal display module: Using LCD1602, the main function is to display real-time time, feeding time and feeding status. Voice module: The voice chip WT588D collects and saves the sound, connects the buzzer to the outside, and plays the sound at a specific time to attract pets to come and eat.

Hardware Design
The hardware part of this system is mainly composed of a single chip microcomputer module, a clock module, a button module, a motor drive module, a voice module and a display module.

STC89C52 SCM
Nowadays, single-chip microcomputers have been widely used in various fields of life and production. The STC89C52 single-chip microcomputer is a prominent and popular one in the entire industry market. It has the characteristics of small size, low cost, and easy productization. The STC89C52 type single-chip microcomputer can constitute a variety of intelligent control equipment and various types of intelligent instruments. In terms of control, it can solve various types of control from simple to complex in a targeted manner. It has very high performance, so it is widely used in electronic equipment and electromechanical control systems.

Clock Module
The clock module uses a high-performance and familiar clock chip DS1302 chip, which can not only run at very low power consumption, but also a real-time clock chip with random access memory.

Button Module
The main function of the button module is time adjustment and mode conversion. It adopts 6 touch key switches, and 6 key switches respectively correspond to different functions: 2 real-time time adjustment buttons, which are used to adjust the real-time time. 2 feeding time setting buttons, which are used to set the feeding time.1 mode switch button and 1 reset button. When the mode switch button is pressed, it represents the real-time time start the timer. When the system is stuck, you only need to press the reset button, and the time will return to the initial time.

Motor Drive Module
The motor drive module mainly receives the feeding command sent by the single-chip microcomputer, processes the signal to drive the stepper motor to rotate and turn on the feeding device. The circuit connection diagram of this module is shown in Fig 3. The motor drive module uses the ULN2003 chip, which is mostly used in control circuits such as single-chip microcomputers, smart meters, and PLCs. It can directly drive loads such as relays and stepping motors to drive the stepping motor to rotate, thereby turning on the feeding device. The whole motor drive circuit has a simple structure, stable performance and easy operation.

Voice Module
The voice module uses the voice chip WT588D, which is chosen because of its outstanding function, not only can be programmed, but also can be erased repeatedly. In terms of software operation, WT588D is simple and easy to operate. In addition, a triode and a buzzer are selected when the voice is externally broadcast, which can achieve the effect of amplification. When the buzzer sounds, it can ensure that pets can be attracted to eat.

Display Module
The display module is mainly used to display the current time, feeding time and feeding status. For performance, durability and cost considerations, this design selects LCD1602 chip that can display letters, numbers, symbols, etc. and the display part of the circuit is shown in

Software Design
After the hardware part of the system is designed, software support is needed to drive the coordinated work of each part to complete the set function. The software design in this paper uses C language for programming to improve the readability and portability of the program.

Main Program
In order to facilitate later maintenance and debugging, the software part of this design adopts modular programming. The main program flowchart is shown in Fig 5, which mainly includes the initialization of the entire system, the display of each time on the LCD liquid crystal display, and the judgment of each button function. After powering on the entire circuit, the entire program starts to run. The first is to initialize. The current time is displayed on the LCD. The user can set the real-time time and feeding time, and then it will enter the interrupt response (feeding). When the reset button is pressed, the program will return to initialization, otherwise the program will continue until the end.

Interrupt Program
In the interrupt program, the commonly used timer interrupt is used. The function of the entire interrupt program is to allow the microcontroller to continuously detect the set feeding time and compare it with the current time at the same time. If the current time does not reach the feeding time, the system continues to judge. And if the current time reaches the set feeding time, the system will automatically proceed to the next operation, that is, the voice chip controls the buzzer to make a sound and the stepper motor will rotate under the control of the drive chip to finally achieve the feeding goal. The program flow chart is shown in

System Test
The performance of the designed automatic feeding system was tested, and the real-time time and feeding time were set by pressing the button. When the real-time time reaches the set feeding time, a word "Eat" ("eat", that is to start feeding) will appear on the right side of the real-time time part of the LCD display. At the same time, the buzzer will emit a sound, and A red LED indicator light will light up to indicate that it is feeding, and then the motor will rotate and the food will flow out from the gap, so that achieve the automatic feeding. When the real time exceeds the feeding time, the word "eat" will change to the first few bars again, the buzzer will stop beeping, the LED indicator will stop flashing, and the stepper motor will rotate in the opposite direction and return to the initial position. The feeding process is over.
The system test shows that the designed automatic feeding system can realize the function of automatic timing feeding.

Conclusion
This article designs an automatic pet feeder based on STC89C52 single chip microcomputer. People can set the feeding time in advance by pressing the button. When the automatic feeder starts to work, the single-chip microcomputer continuously detects the current time and compares it with the feeding time. When the current time reaches the feeding time, the single-chip microcomputer controls the motor to rotate and put the real object, and at the same time controls the voice module to play music, attracting pets to come and eat. The current time, feeding time and feeding status can be viewed through the LCD display. The system realizes the purpose of feeding pets automatically and quantitatively, and solves the problem of people being away from home for a long time due to overtime or going on business trips, causing pets to fail to eat normally and affecting their health. The automatic feeding system is simple and practical in structure and cost-effective. It is a must-have for every pet lover.