Application of single chip microcomputer in intelligent water level monitoring instrument

Publisher:清新心情Latest update time:2012-06-25 Source: 21ic 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 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.

Reference address:Application of single chip microcomputer in intelligent water level monitoring instrument

Previous article:Analysis of the design scheme of switching control microcontroller circuit
Next article:Simulating PLC Control Using Atmel89S51 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号