Design of infrared microcomputer automatic liquid pump based on single chip microcomputer

Publisher:leader5Latest update time:2013-01-22 Source: dzsc Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  1 System overall design

  The system can automatically detect whether there is an object close to the liquid outlet, with a detection distance of 15 to 20 cm. The LED display roughly shows the remaining amount of detergent in the container, which is divided into 3 situations:

  (1) The lowest LED is on, indicating that the remaining amount of detergent is low and needs to be refilled as soon as possible;

  (2) If the lowest and middle segments light up at the same time, it means there is enough detergent;

  (3) If the three segments light up at the same time, it means that the detergent in the container has exceeded the safety warning line and no more detergent can be added. The error between the segments is ±5mm.

  In addition, the system is equipped with an operation button for selecting the flow rate. The default value when the machine is turned on is low flow rate. Press the button once to select medium flow rate, press it twice to select high flow rate, press it three times to enter the cleaning mode, and press it again to exit the cleaning mode and select low flow rate.

  The block diagram of the automatic liquid feeding system is shown in Figure 1.

Automatic liquid feeding system block diagram

  The LED display is used to display the rough remaining amount of liquid in the container. The display is a three-segment bar LED display, which is vertically installed on the liquid dispenser housing.

  The two devices, infrared transmitter and receiver, cooperate with each other to form an active infrared detection radar, which is used to detect whether there is an object approaching the liquid outlet. The detection distance is 15-20cm. The infrared transmission carrier frequency is 38.4kHz, which is obtained by dividing the main clock by the timer inside the microcontroller (MCU); the center frequency of the receiving head is 39.7kHz; the detection distance is adjusted by adjusting the transmission current. [page]

  The liquid level sensor is a resistive sensor. A float with a rotating shaft drives the potentiometer to rotate, thereby converting the change in liquid level into a change in resistance. Then a certain current passes through the resistor, which indirectly converts the liquid level change into a voltage change. The microcontroller (MCU) can obtain the liquid level value by reading the resistance value through analog-to-digital conversion (ADC). The ADC conversion accuracy is 8 bits.

  Serial interface This interface is a spare interface for future system expansion. In addition, the MCU also sends the liquid level value to other systems through this interface. The transmission rate is 1200b/s. The data can be received by a PC or other system with a UART unit.

  2 System Hardware Structure

  The MCU pin definition is shown in Table 1:

MCU pin definition

  3. System software structure

  3.1 Main program flow chart

  The main program flow chart is shown in Figure 2. It mainly completes the initialization work, performs target detection, controls the liquid discharge, and displays the liquid level. A large number of other subroutines are called in the entire program. For the sake of convenience, other subroutine charts are not listed one by one. The main program adopts the query method and is in a waiting state for response after the initialization is completed.

Main program flow chart

  Timer interrupt subroutine, this subroutine is responsible for the setting of infrared detection in the whole system. In the design of single-chip microcomputer, timer is an important link. This design adopts the working mode of timer 0 interrupt. The interrupt program flow chart is shown in Figure 3.

  The liquid discharge control subroutine is an important part of this design. It controls the operation of the stepper motor according to the result of target detection. The program flow chart is roughly shown in Figure 4.

  3.2 MCU internal RAM allocation

  The AT89C2051 has a total of 128B of RAM, which is allocated as follows:

  00H~07H: Working register group (R0~R7), used as general registers.

  10H~14H: Liquid level sampling data buffer (ADCBuff).

  16H: Software timer (SoftTimel).

  17H: Liquid level value (OldADCOut).

  1FH: Key value (KeyValue).

  20H: Working flag group 0 (WF0).

  5FH: Flow control value (FluxValue).

  60H~7H: 32B system stack (STACK).

[page]

  3.3 Flag bit allocation

  F_Xms: WF0.0, timer 0 interrupt service flag, set at the end of the timer 0 interrupt service routine, reset after querying the flag in the software timer operation program. This flag is mainly used to notify the system program that "a timer interrupt has been processed."

  SendEN: WF0.1, active infrared detector transmission switch, when this flag is set, the infrared detector is allowed to transmit 38.4kHz infrared detection signals, and when reset, it is not allowed to transmit. This flag is set when the infrared detector is started and reset when the detector is turned off.

  DetEN: WF0.2, infrared detection switch, when this flag is set, the system starts the infrared detector to detect the target, and when reset, the system does not start the detector. This flag is set when the system exits the standby mode and reset after detecting the target.

  MTCEN: WF0.3, motor running, when the flag is set, it indicates that the motor is in operation, and the system checks whether the operation time has ended. If both MTCEN and DetEN are reset, the system will enter standby mode: neither detecting the target nor starting the motor, and automatically exit the standby mode after 3 seconds. This flag is set after the infrared detector detects the target and starts the motor, and resets after the motor operation time has ended.

  WashMode: WF0.4, washing flag, when the flag is set, it indicates that the system is in washing mode, other functions of the system will be turned off, and the washing function will be turned off when reset. This flag is set when the user starts the washing function and reset when the washing function is turned off.

  KeyST: WF0.5, key status flag. When the flag is set, it indicates that the key is in the released state, and the system detects whether the key is pressed. When reset, it indicates that the key has been pressed and the system waits for the key to be released. This flag is set when the key is released and reset when the key is pressed.

  KeyLPF: WF0.6, key detection jitter elimination control bit.

  4 Conclusion

  The design is highly versatile and cost-effective, and can be applied to many non-contact liquid supply systems, such as: faucet automatic water supply sensor; induction hand washer; automatic control induction faucet; automatic shower; automatic soap dispenser; induction hand dryer, etc. The design idea introduced in this article can be extended to other similar liquid level and liquid output control systems.

Reference address:Design of infrared microcomputer automatic liquid pump based on single chip microcomputer

Previous article:Design of three-phase bridge controllable trigger circuit based on ATMEL89S52 single chip microcomputer
Next article:The software and hardware design of digital voltmeter realized by single chip microcomputer

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号