Design of a Lower-Level Machine for a Remote Environmental Monitoring Information System Using ADuC812
2026-04-06 06:00:49··#1
Abstract: This paper presents a design method for a lower-level machine of a remote environmental monitoring information system based on ADuC812. It introduces the advantages of ADuC812 and the hardware circuit design and software implementation of the lower-level machine data acquisition system. Utilizing the 24-bit addressing capability of ADuC812, a large-capacity data storage is achieved using a 28F640 flash memory. Keywords: ADuC812, environmental monitoring, data acquisition, flash memory 1 Introduction The ADuC812 is a truly complete data acquisition system chip first developed by Analog Devices (ADI) and was the first micro-converter product to enter the market. It boasts excellent performance, low price, and complete development methods, representing a new type of highly integrated, high-precision 12-bit data acquisition system. Its internal 12-bit A/D conversion cycle is only 4µs, several times faster than the commonly used AD574. Replacing a data acquisition system composed of conventional chips with the ADuC812 will significantly reduce product costs, shrink equipment size, and improve system reliability and electrical performance. The ADuC812 chip integrates a high-performance 8-bit (8051 compatible) MCU with reprogrammable non-volatile flash/electrically erased program memory, a high-performance self-calibrating multi-channel (8 input channels) ADC, two 12-bit DACs, and 32 programmable I/O interfaces. The ADuC812 microcontroller core is instruction-compatible with the 8051, allowing for direct porting of existing user software, thus facilitating application development. It features 9 interrupt sources (2 priorities) and integrates 8KB of flash/electrically erased program memory, 640 bytes of flash/electrically erased data memory, and 256 bytes of RAM. Additionally, it includes a watchdog timer and power monitor, DMA between the ADC and data memory, memory protection, a general-purpose asynchronous serial transceiver, and SPI and I²C bus interfaces. The ADuC812 has 24-bit external data addressing capability, addressing up to 16MB of external data memory. 2. Overview of the Remote Environmental Monitoring Information System This remote environmental monitoring information system is designed to meet the requirements of automation, networking, and informatization in today's remote environmental monitoring. It consists of multiple lower-level machines distributed across various monitoring stations at different distances and an upper-level machine located at a central station, as shown in Figure 1. The upper and lower-level machines communicate remotely via modem and telephone lines. The upper-level machine stores the data transmitted from each lower-level machine in a database and performs data analysis on the environmental data. The lower-level machines are distributed across a wide range of environmental monitoring stations, collecting various environmental data in real time from various monitoring instruments, such as those for air, water quality, and acid rain. Slow-changing parameters such as SO2, NO2, and NO output from environmental monitoring instruments are sampled every 2 minutes, and acid rain parameters output from acid rain meters are sampled every 0.5 mm of rainfall. Sampled data is required to be continuously stored for 7 days, with daily averages stored for one month. The sampled data stored in the lower-level machines is ready to be queried by the upper-level machine and transmitted to it at any time. 3. Lower-level Hardware Circuit Design The design of the lower-level hardware circuit mainly considers the rate of change and number of channels of the measured signal, as well as the requirements for measurement accuracy, resolution, and speed. The data acquisition system circuit includes: an ADuC812, an analog amplifier/conversion circuit, an external data memory 28F128, serial communication, a keyboard, and an LCD display, as shown in Figure 2. 3.1 Analog Signal Input of the Acquisition Circuit In the ADuC812, P1.0-P1.7 are initialized to 8 channels of analog input. If used for digital input, the ports should be written to "0" first during programming. This circuit sets port P1 as an 8-channel analog input for each environmental monitoring instrument. Since the ADC's reference voltage is 2.5 volts, while the analog output of each monitoring instrument is generally 0-1 volt or 4-20 mA, an analog amplifier/conversion circuit is needed to convert the input signal into a standard input of 0-2.5 volts. The conversion circuit is shown in Figure 3. Figure 3. Analog Amplifier/Conversion Circuit 3.2 Interface Circuit between ADuC812 and External Data Memory To meet the large data storage requirements of this design system, a system using conventional chips would require ten 128K HM628128 data memories (RAMs). This would not only result in high cost and complex circuit design, but also low system reliability and electrical performance. Since the ADuC812 has a 24-bit external data addressing capability, this solution uses one 28F640. The 28F640 is a high-capacity flash memory with a single chip capacity of 8MB, which not only better meets the design requirements of this system, but also meets the requirements when the acquisition parameters increase or the sampling time changes, thus improving system compatibility. To access the 28F640, the ADuC812 is connected to the 28F640 using two 8-bit latches 74HC573. Port P0 outputs the lower 8 bits of address (A0-A7) and 8 bits of data in a time-division multiplexing manner. The lower 8 bits of address can be latched into an 8-bit latch U2 using the address latch signal ALE. Port P2 outputs the higher 8 bits of address and the middle 8 bits of address in a time-division multiplexing manner. The higher 8 bits of address can be latched into an 8-bit latch U4 using the address latch signal ALE. This achieves a 24-bit addressing space. Since the 28F640 only has 23 address lines (A0-A22), the A23 address line output by the latch is left floating. 3.3 Keyboard and Display Interface Circuit The purpose of connecting an external keyboard and LCD display is to allow users to select the desired parameter via the keyboard and display it on the screen when data transmission errors occur or when data is manually queried, making the lower-level machine's operation more flexible and convenient. To connect the keyboard and display, an 8155 I/O port expansion chip is needed, using a 4x4 touch keyboard and a dot-matrix LCD display. The key values on the keyboard correspond to various environmental parameters. If a "0" key is pressed, the display subroutine is invoked. Afterward, each key press displays the corresponding environmental parameter on the screen. If a key other than "0" is pressed, the key value is sent to accumulator A. When an "F" key is pressed, the display subroutine is exited. 3.4 Serial Communication Interface Circuit Since communication with the host PC is required via a modem and telephone line, the MAX232 chip is used for RS-232 port level matching and driving. The MAX232 is an IC chip containing two receivers and drivers. It has an internal power supply voltage converter that can convert the input +5V power supply voltage to the ±10V voltage required for the RS-232C output level. 4 Lower-Level Software Design 4.1 Overall Software Design The lower-level software design mainly consists of three parts: a data acquisition and storage subroutine, a keyboard scanning and LCD display program, and a communication subroutine with the host computer. The flowchart is shown in Figure 4. In the main program, the keyboard, display, AD module, and communication port are initialized first. The data acquisition and storage subroutine is written as a timed interrupt subroutine, using Timer 2 to call the data acquisition and storage subroutine every 2 minutes to acquire data once. Acid rain data acquisition is achieved through external interrupt INT1. Whenever the acid rain concentration reaches 0.5mm, an interrupt request is sent to the ADuC812, and the ADuC812 acquires acid rain data once. The main program continuously scans the keyboard; when a key is pressed, it jumps to the keyboard scanning subroutine. The communication program with the host computer is set as an external interrupt subroutine in the main program, with the interrupt signal input via INT0. When the host computer requests data transmission, it selects a lower-level device via dialing, and the lower-level device's program jumps to the communication subroutine to complete communication with the host computer. Figure 4 shows the software flowchart. 4.2 Software Design Features The ADuC812 microcontroller core is compatible with the 8051 instruction set, allowing direct porting of existing user software. However, the programming differs from the 8051 in terms of the ADC conversion module and data storage. In the data acquisition and storage subroutine, the ADC must first be initialized. The operation of the ADuC812's AD conversion module is controlled by three special function registers (SFRs): ADCON1, ADCON2, and ADCON3. ADCON1 controls the conversion and acquisition time, hardware conversion mode, and power-down mode. In the ADCON1 settings, the ADC operates normally with a clock division ratio of 2. Since the output impedance of the input signal analog amplification and conversion circuits is less than 8KΩ, the ADC acquisition clock is selected as 1. The timer 2 conversion bit T2C is set, resulting in ADCON1 = 52H. ADCON2 controls the ADC channel selection and conversion mode. Because this data acquisition system uses 8-channel sequential acquisition, the ADC needs to convert the analog input values of all 8 channels sequentially. Therefore, the channel number CHAG value must be sent to ADCON2. ADCON3 is unused. Once the special function registers ADCON1-3 are set, the ADC will convert the analog input and provide the 12-bit ADC result word in the special function register ADCDADAH/L. The CPU manages the A/D converter using interrupts. When the A/D conversion is complete, a request signal is sent to the CPU. The CPU responds with an interrupt, and the interrupt handler is responsible for reading the converted data and storing it in the external data memory 28F128. Then, the channel number is incremented by 1, and the corresponding flash memory address is also incremented by 1. When the user accesses the 16MB external data space of the micro-converter ADuC812, a data page pointer DPP must be added. Similar to a regular MCS-51, a MOV instruction that sends data to DPTR still only sends 16 bits of data to DPH and DPL. However, an INC DPTR instruction that causes DPH to overflow will increment the address by one page instead of incrementing by 1. The page size is related to DPP. Therefore, the 16MB external data space can be accessed using the data page pointer DPP. Reading and writing to the 28F640 is based on page programming operations. The 28F640 is a high-capacity flash memory. To ensure reliable operation of various operations, control logic is added internally, such as the User Command Unit Interface (CUI) and the Write Eraser State Machine (WSM) for accepting various operation commands. During data exchange, the chip select pin is first enabled to put the memory into operation, and then the corresponding command word is sent to the CUI. The CUI, based on the command requirements and the address latch addressing, controls the WSM to automatically execute programming algorithms and apply necessary delays to the corresponding memory cells or memory block areas, thereby completing operations such as erasing, writing, and latching data blocks. 5. Conclusion Applying the ADuC812 chip to the design of the lower-level machine in a remote environmental monitoring information system significantly improves the performance of the data acquisition system and greatly reduces development time and cost, meeting the requirements of modern environmental monitoring. With slight modifications according to specific requirements, this system can also be applied to various departments requiring real-time monitoring, such as meteorology, power, and hydrology.