Design of High-Precision Water Level Monitor Based on Single Chip Microcomputer

Source: Internet
Author: User

Design of High-Precision Water Level Monitor Based on Single Chip Microcomputer
[Date: 2008-9-3] Source: carefree electronic development network Author: Zhang Yixiang [Font:Large Medium Small]

 

 

1Introduction

The water level monitor is widely used in automatic detection and control systems in water conservancy, petroleum, chemical, metallurgy, electric power and other fields. At present, some water level monitors have some problems during operation, such: unstable System, poor anti-interference capability, low precision, output control or insufficient display signal, trouble in updating the program or program on site, and poor communication capability. The Intelligent Water Level Monitoring Instrument designed in this paper is a collection of the latest design experience of smart meters at home and abroad, using industrial control single-chip microcomputer, water level collection, storage, display and remote networking in one, it is applicable to various liquid level measurement and gate opening measurement.

2Overall system hardware design

The main functions of the system hardware are: analog conversion, analog acquisition, application of high-precision 16-bit Analog Converter AD7705 in the system, application of precise clock chip DS1302, and alarm of four relays, the relay driver chip uses ULN2003; 4 ~ The 20mA current loop outputs the application of the digital-to-analog converter AD421 to provide the system detection signal. It is used to implement the interface for communication with the upper computer. System diagram 1.

Figure 1 system hardware schematic

In this system, the main control chip we choose is the high-integration MCU chip C8051F021. C8051F single-chip microcomputer is a fully integrated hybrid signal system-level chip (SOC ). high-speed CIP-51 kernel with 8051 compatibility and fully compatible Instruction Set with MCS-51; chip integrated with common analog, digital peripherals and other functional components in data acquisition and control systems; built-in FLASH program memory and internal RAM. Most devices also have RAM (XRAM) located in the external data storage space. C8051F Microcontroller has an in-chip debugging circuit, the 4-foot JTAG interface can be used for non-intrusive online system debugging at full speed.

2.1 SPICommunication Interface Design

In the system design, two external chips apply the SPI interface methods: AD7705 and AD421. The single chip microcomputer and the two peripheral chips constitute an SPI bus system. The NSS end of the single chip microcomputer is suspended and the on-Chip pull resistance is set to a high level connection, because AD421 is a 4 ~ 20mA output of the digital-to-analog converter chip, so it is connected to the single-chip microcomputer data line only the main device output from the device input, that is, MOSI. The SPT system connection 2 in the Water Level Monitoring Instrument is shown in.

Figure 2 SPI interface system schematic

2.2Modulus conversion design

In this design, we have selected two analog-to-digital conversion circuits. The first one is to use the 12-bit ADC in the single-chip microcomputer, which is used in the variable resistor channel: the other is the out-of-chip high-precision analog-to-digital conversion chip AD7705, which has a precision of 16 bits. It is applied to the data collection of the pressure sensor channel. The following calculations show 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 accurate can be calculated by Formula 1:

(1)

The calculation result is as follows: when the measurement range is a = 10 m, the measurement accuracy is 2.44 if the 12-bit ADC is used. If the 16-bit ADC is used, the measurement accuracy can reach 0.153.

Our design requirements are accurate to 2mm, so 16-bit ADC can fully meet our design requirements. In the design, the variable resistor method has low measurement accuracy, so it uses 12-bit ADC in the single chip microcomputer. In order to improve the measurement accuracy and reduce the measurement error, we also use another single-chip microcomputer channel to collect the power supply voltage of the variable resistor, and integrate the two in the software. For the pressure sensor channel, we have selected an external ADC conversion chip AD7705. The AD7705 chip has exactly two analog channels for our two-way pressure sensor channels to switch between channels in the software.

2.3Alarm Circuit Design

In this system, the four-way alarm circuit is designed to use the I/O port of the single-chip microcomputer and the uln2003 driver chip, and then the output is connected to the control end of the relay. Uln2003 consists of seven dington transistor arrays and corresponding resistance networks and clamp diode networks. It has the ability to simultaneously drive seven groups of loads and is a single-chip dual-pole High-Power High-Speed Integrated Circuit. Relays are selected G6B-1174P model products, 24 V power supply voltage. Electrical internal structure connection diagram 3.

In this system design, four relays are used to output alarms, including high water level 1, high water level 2, low water level 1, and low water level 2, the four alarm levels can be set and modified by pressing the lower computer or using the upper computer interface. A high water level example shows that when the water level is between high water level and high water level, the microcontroller sends a switch control signal so that the corresponding relays normally open contact conduction, the specific alarm method can be flexibly selected. An alarm lamp or an alarm bell can be connected in a series in an external circuit. When the relay acts, the corresponding alarm starts (represented by a light or a bell ).

Figure 3 alarm circuit principle diagram

2.4 4-20mACurrent loop output digital-analog conversion circuit and Clock Circuit Design

The distance between the analog voltage signal to be tested and the measuring equipment is often seen in the microcomputer industrial measurement and control field, it is unreasonable to directly send the analog voltage signal to the measurement device through a long line. Generally, the following methods are used: At the measurement site, the simulated testing signal is amplified, filtered, and pre-processed, and then transcoded for long-distance transmission. The voltage signal is then reversed near the measurement device for measurement. Signals suitable for remote transmission of industrial measurement and control systems generally include current sources or frequency signals. The voltage/current conversion circuit is often used to convert the analog voltage signal to the current source signal for transmission. The system adopts a high-performance digital analog converter AD421, and the output signal of the converter is 4 ~ 20mA current ring.

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. In our design, one of the main control chips used in the water level monitor is used to communicate with the upper microcomputer, and the other is used to communicate with the encoder, in the interface design between the clock module and the single-chip microcomputer, only the second interface method can be used, that is, the Work sequence can be simulated with a common I/O port. The clock chip has strict timing requirements. Timing Sequence determination must be closely connected with hardware. The registers and latches inside the chip all have strict timing requirements, therefore, it fully reflects the importance of combining software and hardware in the development process. Data transmission errors caused by timing problems were also encountered during the program design process, but they were finally solved smoothly.

2.5Design of serial communication circuit

In this design, the lower computer and the upper computer communication serial port part we adopt two kinds of communication mode: The first adopts the RS-232 communication mode; the second adopts the RS-485 communication mode.

In this design, the RS-232 communication level is achieved by using the conversion chip MAX202. MAX202 is suitable for RS-232 communication in scenarios with severe noise. Each transmitter output and receiver input must not be closed and can withstand the impact of ± 15kV electrostatic Discharge (ESD, Electro-Static Discharge, MAX202 has two drives and two receivers. The MAX202 chip is a bidirectional conversion chip designed for RS-232C and TTL/COMS level conversion in the absence of ± 12 V power supply, the power supply of MAX202 is + 5 V, and the maximum level conversion speed is not less than 120 kbps. There are few peripheral devices on the MAX202 chip. Only four 0.1 μF capacitors are needed, which further reduces costs and space occupied.

In our design, the SN65LBC184 level conversion chip is adopted. SN65LBC184 is a differential data cable transceiver within the SN5176 industry standard range, which has a built-in High Energy Transient noise protection device, this design feature significantly improves the reliability against transient noise on the Data Synchronization transmission cable. The differential drive design integrates the output end of slew-rate-controlled to deliver data at a speed of kbps, higher Conversion Rate Control allows longer non-terminated cables, longer transient line lengths from the main trunk, and faster voltage conversion speeds. The unique receiver design provides high-level output failure protection when the input end is floating (open circuit). The SN65LBC184 Receiver includes a high-input resistor, equivalent to a load of 1/4 units, A maximum of 128 similar devices can be mounted on the bus. The operating temperature of SN65LBC184 is-40 ℃ to + 85 ℃, so it can meet the requirements of the operating temperature environment.

To prevent interference between the host computer and the lower computer, it is a simple and effective method to adopt a photoelectric isolation device. In the interface circuit of the RS-485, we also choose high-speed Photoelectric Coupler 6N136. Connection Circuit 4, in which the power label + 5 (2) represents the + 5 V power output from the DC-DC module.

Figure 4 RS-485 interface circuit diagram

3Software Design of the Water Level Monitor System

In our water level monitor design, the software debugging environment we selected is Cygnal IDE, which is an integrated development environment tailored for the C8051 series microcontroller, we integrated the Kei18051 compilation environment tool into Cygnal IDE to form a Development Environment Integrating a series of functions such as editing, compiling, downloading code, and online debugging, it facilitates the development of single-chip microcomputer programs.

In our system, the overall program design is divided into two major modules: initialization module and cyclic execution module. The corresponding subprograms are system initialization subprograms and cyclic subprograms. These subprograms are called in the main program. The system initialization subroutine initializes the I/O, external oscillator, AD/DA, timer, dart, SPI, and interrupt system. The loop subroutine is an endless loop, which includes initialization of the display part and the content of the loop body. In the loop body, we not only complete the function of displaying the part, we also made some semaphores that should be constantly queried by the system, such as buttons, interrupt enable switching corresponding to the channel, and control and processing of the output signal of the relay.

Author's Innovation: The Water Level Monitoring Instrument can meet the design requirements of 1mm in terms of accuracy. It can basically overcome external interference in terms of reliability and achieve stable operation. It has multiple functions in design, in compliance with multiple usage methods, functions can be selected according to specific requirements. It can easily implement human-machine operations and set and modify various parameters, meeting the intelligent requirements to a certain extent.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.