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 precision, 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. It adopts industrial control single-chip microcomputers, 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 acquisition; application of high-precision 16-bit analog-to-digital converter AD7705 in the system; application of precise 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 signals; interface implementation for communication with the upper microcomputer. The system block diagram is shown in Figure 1.
In this system, the main control chip we selected 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, and non-intrusive, full-speed online system debugging can be performed through the 4-pin JTAG interface.
2.1 SPI communication interface design
In the system design, two external chips use the SPI interface: AD7705 and AD421. The microcontroller and these two peripheral chips form an SPI bus system. The NSS terminal of the microcontroller is left floating and is set to a high level by the pull-up resistor inside 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:
It can be calculated that when the measurement 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 requirement is to be accurate to 2mm, so if a 16-bit ADC is used, it can fully meet our design requirements. In the design, the variable resistor method has low measurement accuracy, so the 12-bit ADC in the microcontroller is used. 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. 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. The channels are switched in the software.
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 the output is connected 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. It 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 conduction. The specific alarm method can be flexibly selected. The alarm light or alarm bell can be connected in series in the external circuit. When the relay is activated, the corresponding alarm starts (the light is on or the bell rings).
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, and then transmit it over long distances after transformation, and then transform it into a voltage signal for measurement near the measuring equipment. The signals suitable for long-distance transmission of industrial measurement and control systems are generally current sources or frequency signals. In order to transform 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 of DALLAS. The main control chip C8051F021 used in the water level monitor has two serial ports. In our design, one is used for communication with the upper microcomputer and the other is used for communication 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 sequence. The clock chip has very strict timing requirements. The timing determination is closely related to the hardware. The registers and latches inside the chip have strict timing requirements, 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 uses RS-232 communication method; the second one uses 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 needs 4 0.1μF capacitors, which further reduces the cost and space occupied. [page]
在我们的设计中,采用了SN65LBC184电平转换芯片,SN65LBC184是SN5176行业标准范围内的差分数据线收发器,它带有内置高能量瞬变噪声保护装置,这种设计特点显著提高了抵抗数据同步传输电缆上的瞬变噪声的可靠性。差分驱动器设计集成了由转换率控制(slew-rate- controlled)的输出端,足可以250kbps的速率传送数据,转换率控制比之不受控制可允许更长的无终止电缆运转和来自主干线的更长的短截线长度以及更快的电压转变速度。独有的接收器设计可在输入端处于漂浮(开路)时提供高电平输出失效保护,SN65LBC184接收器包括一个高输入电阻,该电阻等效于1/4单位的负载,允许在总线上挂接最多128个类似器件。SN65LBC184的工作温度为-40℃至+85℃,因此足可以满足工作温度环境要求。
为了防止上位机和下位机的之间互相的干扰,采用光电隔离器件是一种简单而有效的方法。在RS-485的接口电路中我们选用的也是高速光电耦合器6N136。连接电路如图4所示,其中图中电源标号+5(2)表示从DC-DC模块输出的+5V电源。
3 Software Design of Water Level Monitor System
In our design of water level monitor, the software debugging environment selected is Cygnal IDE, which is an integrated development environment tailored for C8051 series microcontrollers. We integrated the tools of 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 single-chip microcomputer 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, which are called in the main program. System initialization subroutine? Interrupt system has done the initialization work. The loop subroutine is an infinite loop, which includes the initialization of the display part and the loop body content. 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 key and channel, and the control processing of the relay output signal. The water level monitor can meet the design requirement 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 multifunctional design and conforms to a variety of usage methods, and the function can be selected according to specific requirements; it can easily realize human-machine operation, set and modify various parameters, and to a certain extent meet the requirements of intelligence.
Previous article:Practical eight-channel level measuring instrument based on 89C52 single chip microcomputer
Next article:Digital trigger controlled by 51 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
- 【Chuanglong TL570x-EVM】HELLO_WORLD of python!
- Help!!! Insufficient stall current!
- Operational amplifier stability analysis problem
- 【NXP Rapid IoT Review】+ My Review Summary
- VHDL Introduction. Questions and Answers. Classic Examples. Experience Summary
- ROM and RAM How does the microcontroller execute step by step after power is turned on?
- How does the program execute from the reset sequence to the main function?
- [AutoChips AC7801x motor demo board review] + Motor drive - BLDC sensorless method
- EEWORLD University ---- Practical Projects for IoT Embedded Engineers
- AC 220v to DC 24v (LM7824CT)