Design of high-precision water level monitoring instrument based on single-chip microcomputer

Publisher:Yuexiang888Latest update time:2011-12-24 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
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 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.

Reference address:Design of high-precision water level monitoring instrument based on single-chip microcomputer

Previous article:Practical eight-channel level measuring instrument based on 89C52 single chip microcomputer
Next article:Digital trigger controlled by 51 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号