Design and implementation of liquid level monitoring instrument using multiple single chip microcomputers

Publisher:shmilydeLatest update time:2016-09-07 Source: ofweek Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
It is a common practice to design a liquid level monitor   using a single-chip microcomputer . If there are many channels (more than 16 channels) for the liquid level to be measured, each channel is required to be able to scroll and display the total input and output of each shift, day, and month within one year (3 shifts per day), the data will not be lost in normal or accidental power outages, the human-computer interaction ability must be strong (an appropriate number of buttons and LCD display must be set), and each channel of liquid level requires corresponding 2 channels of control output signals (liquid tank liquid input control and output control), configure a micro printer port, and set a sound alarm. All of these undoubtedly require a lot of I/O ports to support, which cannot be done by a single-chip microcomputer alone, and an expanded I/O port is required. In this design, the author believes that the use of a dedicated I/O expansion chip has many disadvantages. After weighing the pros and cons, the method of using a single-chip microcomputer to replace the dedicated I/O interface chip was chosen.

 

  1 Comparison between dedicated I/O chips and MCUs used as I/O chips

 

  ① The number of I/O ports of the dedicated I/O interface chip is not more than that of the single-chip microcomputer (the single-chip microcomputer model used by the author is 89C52);

  ② The dedicated I/O interface chip is not flexible to use. Several usage modes have been set by the chip designer and cannot be changed beyond this range. However, the single-chip microcomputer is less restricted and more flexible to use.

  ③ The dedicated I/O interface chip has poor independence and intelligence. Whether it is receiving input signals or outputting control signals, the I/O dedicated chip cannot make decisions on the input and output of signals. The decision must be made by the single-chip microcomputer. It only plays the role of relay or transition signal, has no monitoring ability, and cannot handle problems independently. However, the single-chip microcomputer is different and can flexibly handle problems in a variety of ways.

  ④ To use the I/O expansion chip, you must be familiar with it. Engineering technicians are generally much more familiar with the MCU than with it. In comparison, using it will waste time. In addition, the price of the I/O expansion chip is higher than that of the MCU, which is not economical from the cost accounting point of view;

  ⑤ The dedicated I/O chip has poor real-time performance. Since the dedicated I/O expansion chip only plays the role of sending and receiving signals and has no ability to process signals, the transmission of signals back and forth through it is bound to cause delays, resulting in poor real-time performance;

  ⑥Using single-chip microcomputer as I/O interface facilitates modularization of software and hardware design, with clear division of labor, which greatly facilitates design, debugging and maintenance;

  ⑦ Using a single-chip microcomputer as an I/O interface strengthens the supervision of the interface and reduces the burden on the main single-chip microcomputer.

 

  2 Hardware structure and division of labor

 

  The hardware design is divided into the following parts: single chip microcomputer; A/D conversion part; control signal output part; non-volatile memory (for RAM expansion); key part; display part; print I/O port part; analog switch part. The hardware structure diagram is shown in Figure 1.

 

  Multi-MCU Liquid Level Monitor Hardware Block Diagram

 

  Hardware design:

  ① The single-chip microcomputer uses 89C52, which has the characteristics of 8KB ROM inside the chip and does not require external ROM expansion;

  ②The A/D converter uses MC14433, which has the characteristics of high conversion accuracy and strong anti-interference ability. It can convert about 20 times per second. Because the liquid level changes not very quickly, it can meet the needs of monitoring liquid level changes;

  ③ The control signal output adopts the method of controlling 74LS373 latch by single chip microcomputer, so the number of control output ports can be increased or decreased by increasing or decreasing the number of latches;

  ④ Because each channel is required to be able to scroll and display the total input and output volume of each shift, day, and month within one year (3 shifts per day), and the data will not be lost in normal or unexpected power outages, the AT29LV040A (512KB) flash memory (FRAM can also be used) is used. Because the 89C52 can expand up to 64KB of RAM, in order to ensure sufficient storage space, the A16, A17, and A18 address lines of the AT29LV040A can be connected to a port of the 1# microcontroller. In this way, the purpose of using the 512KB space of the AT29LV040A can be achieved by controlling the changes of these three address lines.

  ⑤ The key part can use the conventional non-encoded keyboard method;

  ⑥ In order to improve the human-computer interaction ability, the display part adopts the GXM12864SL large-screen LCD, so that the screen can display self-edited Chinese characters, numbers, equations and simple patterns;

  ⑦ Print I/O port, you can make corresponding connection configuration according to requirements;

  ⑧The analog switches use multiple CD4051s, which work with the microcontroller to select the analog value of one of the multiple liquid level analog values, and then perform A/D conversion.

  The selection of three single-chip microcomputers effectively solves the problem of insufficient I/O ports, and simplifies the design a lot. It only needs to follow the conventional chip connection method, eliminating many transition chips, such as 74LS244, 74LS245, 74LS73, etc., and also makes software design simple and easy. Because the hardware connection is simple and all are conventional connections, this article does not provide a detailed circuit connection diagram. The data exchange between the three single-chip microcomputers uses serial port communication, as shown in Figure 1. In this design, the three single-chip microcomputers are reset at the same time. Of course, they can also be reset separately, but the buttons need to be increased. This situation depends on the requirements.

 

  3 Software Structure Design

 

  Since the three MCUs are reset at the same time, they are in parallel working state after reset. The main work of 1# MCU is to convert all liquid level analog quantities into digital quantities and save them. It can transmit the collected and processed results to 2# MCU for display and 3# MCU for output control according to keyboard commands or system default format, or it can monitor only the liquid level changes of a specified one or several channels according to commands. The main work of 2# MCU is to read keyboard commands, issue commands to 1# and 3# after processing, and then display them on LCD according to feedback results. It can also continuously update its display content according to the data collected by 1# MCU. LCD display mode can be varied, it can cyclically display the specified liquid level of several channels, or fixedly display the liquid level of a channel, or cyclically display the input and output volume of each day or each shift of a certain day of a month, etc. The specific gravity of each liquid, calculation correction value, upper and lower limit height setting of liquid level, etc. can be input and saved through the keyboard. Passwords can also be set through the keyboard to prevent others or misoperation from destroying the set content. The input method should be designed so that there is no need to read the instructions, just follow the prompts on the LCD display to make the selection. The main work of the 3# microcontroller is to send control signals or print out results according to keyboard commands or data collected by the 1# microcontroller in a timely manner. The printout format can be selected according to the keyboard commands. The flowcharts of the three microcontrollers are shown in Figures 2, 3 and 4 respectively.

 

  1# MCU program flow chart

 

  2#, 3# MCU program flow chart

 

  In addition to transmitting normal data and commands through the serial port, the three microcontrollers also need to monitor each other (this is difficult for I/O expansion chips to do).

  ① After the information is transmitted between each other, it must be verified, that is, the sender must receive the receiver's receipt in time;

  ② The three parties visit each other regularly to ensure that everything is going well;

  ③ In addition to self-checking, mutual checking is also required during each power-on reset.

  The purpose of mutual supervision is to improve the performance of the entire system and facilitate system maintenance. 1# and 3# MCUs are equipped with two transmitting diodes to monitor whether the other two MCUs are working properly. 2# MCU itself has an LCD display and does not need a light-emitting diode. The serial communication interrupt service program, the sending program flow chart, and the timed mutual visit program flow chart are not given because they are relatively simple.

 

  4 Debugging

 

  In a system, using multiple MCUs to debug the entire system does bring some inconvenience. It is best to have as many MCU development devices as there are MCUs in the system, which is very helpful for debugging, because the status of each MCU can be checked at any time during debugging, but in reality there are usually only one MCU instead of multiple MCUs.

  The program of each single-chip microcomputer is basically composed of two parts, one is an independent part that has no connection with other single-chip microcomputers, and the other is the part that communicates with each other between single-chip microcomputers (this part of the program is relatively small). When debugging, first debug the independent parts of each single-chip microcomputer, which will not be a problem for single-chip microcomputer application personnel. Then debug the serial communication program between single-chip microcomputers, first establish simple communication between each other, and after they can recognize and transmit data to each other, gradually add the complete program step by step. When designing and compiling a program, you should think about how to debug, so that when compiling a program, you will consciously divide the program into valid blocks, and you can debug it piece by piece when debugging. There are many debugging methods for multiple single-chip microcomputers, and this is just a one-sided view.

 

  Conclusion

 

  Using multiple microcontrollers in a liquid level monitoring system is an attempt, but it does simplify the system design, facilitates division of labor and collaboration among multiple people, and facilitates product improvement and updating. Its most significant effect is that it shortens the design, debugging and production cycle of the product.

 

Reference address:Design and implementation of liquid level monitoring instrument using multiple single chip microcomputers

Previous article:Design of intelligent window control system based on single chip microcomputer
Next article:51 MCU long key test program

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号