System Function Overview and Block Diagram
This design uses the MCS-51 single-chip microcomputer combined with digital chips and analog circuits to complete the detection and automatic control of the water level.
The basic workflow is: the host sets its own and the slave's liquid level through the keyboard, the ultrasonic sensor measures the voltage value corresponding to the current water level, and then sends it to the controller through ICL7135 analog-to-digital conversion to compare with the set value. The single-chip microcomputer adjusts the host liquid level by controlling the solenoid valve, and displays the set value and current value on the LCD; the host controller transmits the set value to the slave controller through 485 communication, and the slave controller can also control the liquid level like the host controller, and display the host given value and current liquid level value through LCD; and use 485 communication to transmit the current liquid level of the slave to the host for display.
The system consists of a single-chip system data processing module, an A/D data input module, a 485 communication module, a liquid level control and alarm module, and a keyboard and display module. The overall system block diagram is shown in Figure 1.
Scheme demonstration and comparison
Considering the requirements of the system, in the process of selecting devices, the focus is on the selection of sensors and analog-to-digital conversion chips.
Sensor
During the system design process, the following three sensors were mainly selected and compared.
Scheme 1: Pressure sensor
Figure 1: System Block Diagram
Most of the current liquid level pressure sensors are submersible static pressure level transmitters, and submersible static pressure level sensors can only measure accurately with reference to atmospheric pressure. However, the ventilation in the connecting cable will be affected by the environment, causing condensation and condensation on the inner wall of the air pipe. Dew drops on electronic devices and sensors, which will affect the accuracy or output drift. At the same time, if the condensation is too fast, the service life of the transmitter will be greatly shortened. This pressure sensor is easily affected by the environment, resulting in inaccurate measurement, and it is inconvenient to install.Solution 2: Piezoresistive pressure sensor
Piezoresistive sensors use integrated circuit technology to directly make diffused varistors on silicon flat diaphragms according to a certain crystal orientation; silicon flat diaphragms have good elastic properties when slightly deformed. When the silicon wafer is compressed, the deformation of the diaphragm causes the resistance value of the diffused resistor to change; this variable resistor is easily affected by the external environment, such as temperature, resulting in inaccurate measurement, and the volume is generally large, not easy to install and carry; generally its accuracy is also relatively low. It cannot meet the design needs, so it is not selected.
Solution 3: Ultrasonic sensor
The ultrasonic sensor is the first small sensor in the industrial field with key setting function and self-diagnosis function. Although it is small in size, it has the functions of other large sensors. It is easy to install and use and is not affected by the color of the object being measured. It has many special functions, such as: self-diagnosis LED display and key setting function, temperature compensation function, selectable analog or switch output, etc.; its power supply voltage is 10~30V, the measurement range is 30mm~300mm, the output voltage is 0V~10V, the output current is 4mA~20mA, the minimum load impedance is 2.5 ohms, the accuracy can reach 0.5mm, and the shape is divided into linear and right-angle types. The sensing diameter is 18mm.
The conditions of the ultrasonic sensor meet the design requirements of 0~25cm liquid level control and the requirements of liquid level error not exceeding ±0.3cm, and solve the problem of inconvenient installation. Therefore, this design chooses an ultrasonic sensor with high accuracy and small size.
A/D Converter
The accuracy and performance of the A/D converter used directly affect the accuracy of the data received by the back-end microcontroller. Here we compare and analyze the following two AD converters.
Solution 1: Use 8-bit ADC0809 A/D converter
ADC0809 is a commonly used 8-bit A/D converter, which is a successive approximation type. ADC0809 is powered by a single +5V. The chip contains 8 analog electronic switches with latching functions, which can convert 8 analog voltage signals of 0~+5V in time-sharing. It takes about 100us to complete a conversion, so the speed is fast, but the ADC0809 chip has low resolution and insufficient accuracy. It cannot meet the requirements of this system and is not adopted.
Solution 2: Use 4-bit half-double integral A/D converter ICL7135
ICL7135 is a widely used A/D converter, an integral A/D converter with dynamic BCD code output. Its characteristics are: high precision, automatic polarity conversion output, automatic zero calibration, single power supply operation, dynamic BCD code output. Since the secondary integration time of the double integration method is relatively long, the A/D conversion speed is slow, usually (3~10) times/s. In addition, the integration of the periodic interference signal is zero, and the anti-interference performance is also relatively good. Under the same accuracy, the price is lower than the successive approximation A/D converter, so this type of A/D converter is more suitable for occasions where the speed requirement is not high.
Considering the requirements of the system, this design uses the ICL7135 A/D converter with higher control accuracy.
Hardware circuit and software design
The hardware circuit of this design includes the minimum system circuit, liquid level control and alarm circuit, signal acquisition and transmission circuit, keyboard and display module, etc.
Minimum system (power supply circuit and I/O expansion and selection circuit)
The minimum system board used in this design is based on the 80C52 microcontroller as the core and has good scalability. The CPU is connected to an external 11.0592MHz crystal oscillator, and is mainly composed of 74LS373 latch circuit, 74LS138 decoding circuit, buttons, display devices, ICL7135 and its peripheral typical circuits, and the I/O interface is expanded by 8255. The minimum system circuit is shown in Figure 2.
Figure 2: Minimum system circuit diagram
This circuit needs an external AC220/9V transformer. The secondary side of the transformer is rectified and filtered, and then input into CW7805 to obtain +5V voltage, which is used as the power supply of the minimum system.In the system, 24 I/O ports, including PA, PB, and PC, are expanded through 8255 to serve as the input and output channels of the system. The output of 74LS138 is used as the decoding selection terminal of each chip. In addition to Y0~Y3 used in the minimum system, Y4~Y7 are available for other expansions. [page]
Liquid level control and alarm circuit
The liquid level control circuit designed in this design is a closed-loop circuit. The sensor transmits the liquid level to the microcontroller for comparison with the set value. The microcontroller controls the liquid level by controlling the solenoid valve. The relay is powered by a 9V power supply, the sensor is powered by a 24V power supply, and the solenoid valve is powered by a 220V AC power supply; in the alarm circuit, the buzzer is powered by a 9V power supply, and an alarm is issued when the liquid level exceeds 25cm or is lower than 2cm. In the water supply loop, a motor is used to circulate water to ensure the continuous operation of the program.
ICL7135 signal acquisition and transmission circuit
This circuit is implemented by a small integrated circuit. The sampled signal is sent to ICL7135 for processing through a potentiometer, and the processed signal is directly sent to the single-chip minimum system. The ICL7135 range is 0~2V, and the reference voltage is divided by the MC1403 output (2.5V) to obtain a 1V voltage.
HC240 is an eight-bit buffered line/line driver, which contains eight inverting buffers with three-state outputs. The inverting buffer with three-state output has an output enable control terminal (ENA, ENB). Each EN controls four buffers, 1A and 2A data input, and 1Y and 2Y output. The output sends out the ones, tens, hundreds, thousands, and ten thousand bits respectively.
HC157 is a four-way two-to-one switch, 1 is the selection input terminal, when S is low level, select A output; when S is high level, select B output. The bit selection output terminals D1-D5 of the BCD code of ICL7135 are respectively connected to PA0~PA3 and PB0~PB4 of the 8-bit programmable logic interface circuit 8255. The CPU can read the status of each bit and judge, and read the BCD data at the B1~B8 output terminals of ICL7135. The ICL7135 signal acquisition and transmission circuit is shown in Figure 3.
Figure 3: ICL7135 signal acquisition and transmission circuit
Software DesignThe software part mainly uses the 51 series single-chip microcomputer as the controller, samples the output voltage of the sensor, compares the sampled value with the set value, and the single-chip microcomputer controls the solenoid valve to adjust the liquid level. The host sets the value to the extension through 485 communication, and the extension controller controls the extension liquid level. The software part includes ICL7135 sampling part, 485 communication part, digital processing part, display part, keyboard part, etc. In order to avoid inaccurate measurement data caused by sensor movement, a zero adjustment function is specially added to further improve the accuracy of the system. The main program flow chart is shown in Figure 4.
Figure 4: Main program flow chart
Experimental results and analysis
The test equipment required includes a 4-digit 1/2 high-precision digital multimeter, a scale, and a 100M dual-trace digital oscilloscope. The test results are shown in Table 4-1.
From the above data, we can see that the test data accuracy of each detection unit of the system is very high, the LCD display value and the measured value are very close to the set value, which is linearly related to the sensor output voltage and proportional to the weight. This is inseparable from the selection of hardware and its parameter matching as well as the selection of software control algorithm.
Design Summary
In terms of hardware, this design uses S18UUA ultrasonic sensor, ICL7135 and other high-precision chips and instruments for liquid level measurement, so that the measured liquid level accuracy is much higher than the requirement that the liquid level error does not exceed ±0.3cm. This design also uses MAX485 communication, OCM4X8C liquid crystal display LCD and other chips and components to make the design more in line with the requirements of practical applications and correspondingly reduce the difficulty of software design. In terms of software, a standardized programming method is adopted to effectively reduce the storage space required for the program.
Previous article:Implementation of 3V photoelectric smoke sensor based on RE46C190
Next article:Design of a high performance 32-bit shift register unit
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
- Oscilloscope test of auto repair model CAN line test
- How to Accurately Test Phase Noise
- [XMC4800 Relax EtherCAT Kit Review] + Getting Started with DAVE, XMC4800 EtherCAT Slave Module Example Analysis
- Apply for the USB PD power receiving protocol chip CH224 and CH224EVT for free, show your DIY creativity and win Qinheng gifts!
- Industrial control personnel must learn Kingview and Siemens PLC wireless PPI classic communication solution
- Happy National Day to all forum friends!
- 555 classic circuit diagram: dual tone generator circuit diagram
- The two outputs of the voltage comparator LM393 are abnormal
- Just because I rotated a high-speed PCB, the result was completely different...
- BTT6030-2EKA