1 Introduction
Water level monitors are widely used in automatic detection and control systems in the fields of water conservancy, petroleum, chemical industry, metallurgy, and electric power. At present, some water level monitors have some problems in operation, such as: system instability, poor anti-interference ability, low accuracy, output control or display signal does not meet the requirements, on-site program changes or program upgrades are troublesome, and communication capabilities are poor. The intelligent water level monitor designed in this paper absorbs the latest design experience of intelligent instruments at home and abroad, adopts industrial control single-chip microcomputer, integrates water level acquisition, storage, display and remote networking, and is suitable for various liquid level measurements and gate opening measurements.
2 Overall design of system hardware
The main functions considered in the hardware part of this system are: analog quantity conversion; analog quantity collection; application of high-precision 16-bit analog-to-digital converter AD7705 in the system; application of accurate clock chip DS1302; four-way relay alarm, relay driver chip uses ULN2003; application of 4~20mA current loop output digital-to-analog converter AD421 to provide system detection signal; interface for communication with upper microcomputer. The system block diagram is shown in Figure 1.
In this system, the main control chip we chose is the highly integrated MCU chip C8051F021. The C8051F microcontroller is a fully integrated mixed-signal system-on-chip (SOC). It has a high-speed CIP-51 core compatible with 8051 and an instruction set fully compatible with MCS-51; the chip integrates analog, digital peripherals and other functional components commonly used in data acquisition and control systems; built-in FLASH program memory and internal RAM; most devices also have RAM located in the external data memory space, namely XRAM; the C8051F microcontroller has an on-chip debugging circuit, which can perform non-intrusive, full-speed online system debugging through the 4-pin JTAG interface.
2.1 SPI communication interface design
In the system design, there are two external chips that use the SPI interface: AD7705 and AD421. The microcontroller and these two peripheral chips form an SPI bus system. The NSS end of the microcontroller is left floating and is set to a high level by the pull-up resistor on the chip. Because AD421 is a 4~20mA output digital-to-analog converter chip, the data line connected to the microcontroller only has the master device output and the slave device input, that is, MOSI. The connection of the SPT system in the water level monitor is shown in Figure 2.
2.2 Analog-to-digital conversion design
In this design, we selected two analog-to-digital conversion circuits. The first one is to use the 12-bit ADC inside the microcontroller. This circuit is used in the variable resistor channel. The other is the high-precision analog-to-digital conversion chip AD7705 outside the chip. The accuracy of this chip is 16 bits. It is used in the data acquisition of the pressure sensor channel. The following calculation shows the accuracy that can be achieved in specific applications. In the design of the water level monitor, we ignore the front-end error of the analog circuit, so the number of millimeters that can be accurately calculated can be calculated by formula 1:
Calculation shows that when the measuring range a=10m, if a 12-bit ADC is used, the measurement accuracy is 2.44mm; if a 16-bit ADC is used, the measurement accuracy can reach 0.153mm.
Our design requires an accuracy of 2mm, so a 16-bit ADC can fully meet our design requirements. In the design, the variable resistor method itself has a low measurement accuracy, so it uses the 12-bit ADC inside the microcontroller. In order to maximize the measurement accuracy and reduce the measurement error, we also use another channel of the microcontroller to collect the power supply voltage of the variable resistor. The two are properly integrated in the software, which will not be described in detail here. For the pressure sensor channel, we chose the off-chip ADC conversion chip AD7705. The AD7705 chip has two analog channels for our two pressure sensor channels. Channel switching is performed in the software. [page]
2.3 Alarm circuit design
The design of the four-way alarm circuit in this system is realized by using the I/O port of the microcontroller plus the Darlington driver chip ULN2003, and then connecting the output to the control end of the relay. ULN2003 consists of 7 groups of Darlington transistor arrays and corresponding resistor networks and clamping diode networks. It has the ability to drive 7 groups of loads at the same time and is a monolithic bipolar high-power high-speed integrated circuit. The relay uses the G6B-1174P model product with a 24V power supply voltage. The electrical internal structure connection diagram is shown in Figure 3.
This system design uses four relay signal output alarms, including high water level 1, high water level 2, low water level 1, and low water level 2. These four alarm water level heights can be manually set and modified through the lower computer buttons or the upper computer interface. Take high water level 1 as an example. When the water level value is between high water level 1 and high water level 2, the single-chip microcomputer sends a switch control signal to make the corresponding relay normally open contact contact and conduct. The specific alarm method can be flexibly selected, and an alarm light or alarm bell can be connected in series in the external circuit. When the relay is activated, the corresponding alarm starts (manifested as a light on or a bell ringing).
2.4 Design of 4-20mA current loop output digital-to-analog conversion circuit and clock circuit
In the microcomputer industrial measurement and control site, there is often a long distance between the analog voltage signal to be measured and the measuring equipment. It is obviously unreasonable to send the analog voltage signal to be measured directly to the measuring equipment through a long line. The commonly used method is: amplify and filter the analog signal to be measured at the measurement site, then transmit it over a long distance after transformation, and then transform it into a voltage signal near the measuring equipment for measurement. Signals suitable for long-distance transmission of industrial measurement and control systems generally include current sources or frequency signals. In order to convert the analog voltage signal to be measured into a current source signal for transmission, a voltage/current conversion circuit is often used. This system uses a high-performance digital analog converter AD421, and the converter output signal is a 4~20mA current loop.
In the single-chip microcomputer application system, in order to make the system real-time, a clock circuit is required to provide the system with a clock signal (year, month, day, hour, minute, second). We chose the DS1302 chip from DALLAS. The main control chip C8051F021 used in the water level monitor has two serial ports. In our design, one is used to communicate with the upper microcomputer and the other is used to communicate with the encoder. Therefore, in the interface design between the clock module and the single-chip microcomputer, only the second interface method can be used, that is, using the ordinary I/O port to simulate the working timing. The clock chip has very strict requirements on the timing. The determination of the timing is closely related to the hardware. The registers and latches inside the chip have strict requirements on the timing, so it fully reflects the importance of combining software and hardware in the development process. In the process of program design, data transmission errors caused by timing problems were also encountered, but they were finally solved smoothly.
2.5 Design of serial communication circuit
In this design, we used two communication methods for the serial port part of the communication between the lower computer and the upper microcomputer: the first one used the RS-232 communication method; the second one used the RS-485 communication method.
In this design, the RS-232 communication level is realized by the conversion chip MAX202. MAX202 is suitable for RS-232 communication in a noisy environment. Each transmitter output and receiver input can resist ±15kV electrostatic discharge (ESD) impact without being closed. MAX202 has two drivers and two receivers. The MAX202 chip is a bidirectional conversion chip designed for RS-232C and TTL/COMS level conversion in the absence of ±12V power supply. The power supply of MAX202 is +5V, and the maximum level conversion speed is not less than 120kbps. The MAX202 chip has very few peripheral devices, and only 4 0.1μF capacitors are needed, which further reduces the cost and space occupied.
In our design, the SN65LBC184 level conversion chip is used. The SN65LBC184 is a differential data line transceiver within the SN5176 industry standard range. It has a built-in high-energy transient noise protection device. This design feature significantly improves the reliability of resisting transient noise on the data synchronization transmission cable. The differential driver design integrates a slew-rate-controlled output, which is sufficient to transmit data at a rate of 250kbps. The slew-rate control allows longer unterminated cable runs and longer stub lengths from the main line and faster voltage transition speeds than uncontrolled. The unique receiver design provides high-level output failure protection when the input is floating (open circuit). The SN65LBC184 receiver includes a high input resistance, which is equivalent to a 1/4 unit load, allowing up to 128 similar devices to be connected on the bus. The operating temperature of the SN65LBC184 is -40℃ to +85℃, so it is sufficient to meet the operating temperature environment requirements.
In order to prevent mutual interference between the upper and lower computers, the use of optoelectronic isolation devices is a simple and effective method. In the RS-485 interface circuit, we also use the high-speed optocoupler 6N136. The connection circuit is shown in Figure 4, where the power supply label +5 (2) represents the +5V power supply output from the DC-DC module.
[page]
3. Software Design of Water Level Monitoring System
In our water level monitor design, the software debugging environment selected is Cygnal IDE, which is an integrated development environment tailored for the C8051 series microcontrollers. We integrated the tools of the Kei18051 compilation environment into Cygnal IDE, thus forming a development environment that integrates a series of functions such as editing, compiling, downloading code, and online debugging, which is very convenient for the development of microcontroller programs.
In our system, the overall program design is divided into two large modules: initialization module and loop execution module. The corresponding subroutines are: system initialization subroutine and loop subroutine, and these two subroutines are called in the main program. System initialization subroutine? The interrupt system has done the initialization work. The loop subroutine is an infinite loop, which includes the initialization of the display part and the content of the loop body. In the loop body, we not only complete the function of the display part, but also do some signal quantities that the system should always query, such as the interrupt enable switching corresponding to the button and channel, and the control processing of the relay output signal. This water level monitor can meet the design requirements of 1mm in terms of accuracy; in terms of reliability, it can basically overcome external interference and achieve stable operation; in terms of function, it has a multi-functional design, meets a variety of usage methods, and can select functions according to specific requirements; it can easily realize human-machine operation, set and modify various parameters, and meet the requirements of intelligence to a certain extent.
Previous article:Analysis of the design scheme of switching control microcontroller circuit
Next article:Simulating PLC Control Using Atmel89S51 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
- BMS solutions for electric bicycles and electric motorcycles under the new national standard for electric vehicles
- Bluetooth spoofing vulnerability affects billions of IoT devices
- About Sensorless Brushless DC Motor (BLDCM) High Torque/Heavy Load Starting
- Electromagnetic compatibility of independent power systems and their power electronic devices
- Conversion between CC2640R2F projects
- Bluetooth RF Conformance Test
- Next-Generation C2000 Microcontrollers and CapTIvate Technology Live Broadcast Registration Open!
- Regarding impedance matching, is the characteristic impedance setting of the board trace the same as the series resistor impedance matching?
- EEWORLD University Hall----Live Replay: TI chip technology helps motor development
- ADC Test Voltage vs. Temperature