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.
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:
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.
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 allocationF_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.
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
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- TI DBV package silkscreen details
- MSP430F6638 baud rate setting
- KiCAD released a new version - 5.1.10
- 2020 National College Student Electronics Contest Test Questions
- High voltage and small size: the latest technology trends of Nichicon's drive film capacitors
- [Chip] Interesting chips, interesting engineer souls
- Serial communication
- TMS320C6678DSP SRIO channel and frequency settings
- Development troubles, what to do when you encounter bad teammates
- Should 5G be blamed for cheating in the college entrance examination?