Environmental monitoring method and system based on single chip microcomputer
By building an abnormal model, real-time monitoring of the operating status of the microcontroller is solved, and the inaccurate environmental monitoring data caused by microcontroller failure in traditional systems is achieved, and high-precision environmental parameter monitoring is achieved.
Patent Information
- Application Number
- CN202411427630.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-14
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2044-10-14
AI Technical Summary
The traditional environmental monitoring system based on microcontrollers lacks real-time monitoring of the operating status of microcontrollers, resulting in insufficient accuracy and accuracy of environmental monitoring data, affecting subsequent management.
By constructing an abnormal model, using the timer to reset the time index, communication incomplete communication index and current instability index, the operating status of the microcontroller is monitored in real time, determine whether the microcontroller is faulty, and issue an alarm when problems occur.
The accuracy of environmental parameter monitoring data in the environmental monitoring system is improved, ensuring the reliability and integrity of the data, and avoiding misleading decisions caused by microcontroller failure.
Smart Images

Figure CN119356171B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of environmental monitoring systems, and in particular to an environmental monitoring method and system based on a single chip microcomputer. Background Art
[0002] An environmental monitoring system based on a single-chip microcomputer is an electronic system used to monitor environmental parameters in real time. It utilizes the high-performance processing capabilities and rich peripheral interfaces of the single-chip microcomputer, combined with various sensor modules, to achieve high-precision monitoring of environmental parameters such as temperature, humidity, air quality, air pressure, and light. Due to its high performance, low power consumption, flexibility, and easy scalability, the environmental monitoring system based on a single-chip microcomputer is widely used in many fields, providing reliable technical support for modern environmental monitoring (for example, smart greenhouses).
[0003] When using a single-chip microcomputer-based environmental monitoring system to monitor the environment with high precision, it relies on the single-chip microcomputer for operation. The single-chip microcomputer is responsible for controlling the data collection, processing, communication and other functions of various sensors to achieve accurate monitoring and management of the monitoring data of environmental parameters. When monitoring the environment, traditional single-chip microcomputer-based environmental monitoring systems often assume that the core of the entire system, that is, the single-chip microcomputer, is actually operating normally. There is a lack of real-time monitoring of the operating status of the single-chip microcomputer. Once the single-chip microcomputer fails and is not detected in time, although the environmental monitoring system can still monitor the environment, the monitoring data of the environmental parameters monitored is incorrect. Or, even if no error occurs, the accuracy of the detected environmental data is low, which has an adverse impact on subsequent management.
[0004] In view of this, it is necessary to improve the environmental monitoring method and environmental monitoring system based on the single chip microcomputer in the existing technology to solve the above problems. Summary of the Invention
[0005] The purpose of the present invention is to disclose an environmental monitoring method and system based on a single-chip microcomputer to solve the aforementioned technical problems, and in particular to monitor whether the single-chip microcomputer included in the environmental monitoring system has a fault, so as to ensure the accuracy and reliability of the environmental monitoring system in monitoring environmental data, thereby improving the detection accuracy of environmental data.
[0006] To achieve one of the above objectives, the present invention first provides an environmental monitoring method based on a single chip microcomputer, comprising the following steps:
[0007] S1. Get the actual reset time of the timer contained in the MCU within the set time period, and get the timer reset time index WDRI based on the actual reset time and the preset reset time. index,i ;
[0008] S2. Acquire the actual communication data of the single chip microcomputer within the set time period, and calculate the communication incompleteness index DL based on the actual communication data;
[0009] S3, obtaining the actual current data of the single chip microcomputer within the set time period, and obtaining the current instability index Ed based on the actual current data;
[0010] S4, resetting the time index WDRI based on the timer index,i , the communication incomplete index DL and the current instability index Ed construct an abnormal model, to determine the abnormal coefficient Lgt through the abnormal model, and compare the abnormal coefficient Lgt with the abnormal coefficient threshold to determine whether the microcontroller fails according to the comparison result.
[0011] As a further improvement of the present invention, the step S1 is specifically as follows:
[0012] Divide the set time period into N sub-intervals of equal length;
[0013] Obtain the difference between a plurality of actual reset times formed by the timer of the single chip microcomputer in each subinterval and the corresponding preset reset time;
[0014] Based on time alignment, obtaining a reset time difference sequence of the subintervals;
[0015] The average value of the reset time difference sequence of each sub-interval is calculated by the following formula (1): i ):
[0016]
[0017] In formula (1), Mean(W i ) is the average reset time difference of the i-th subinterval, WDRI j is the jth reset time difference in the reset time difference sequence;
[0018] For each subinterval, the standard deviation Std(W) of the reset time difference sequence is calculated by the following formula (2): i ):
[0019]
[0020] In formula (2), Std(W i ) is the standard deviation of the reset time difference of the i-th subinterval;
[0021] The timer reset time index WDRI of the sub-interval is calculated by the following formula (3): index,i :
[0022] WDRI index,i=Mean(W i )+k×Std(W i ) formula (3);
[0023] The timer reset index Fh is obtained by adding the timer reset time indices of all subintervals.
[0024] As a further improvement of the present invention, step S2 is specifically as follows:
[0025] Obtain the number of data actually uploaded by the MCU within the set time period and the corresponding preset number of data uploaded, and calculate the data transmission incompleteness index YJ using the following formula (4):
[0026]
[0027] In formula (4), W 实 y W is the number of data actually uploaded by the MCU within the set time period. 预 y is the number of data preset to be uploaded by the microcontroller within the set time period, y represents the number of data actually uploaded by the microcontroller within the set time period and the corresponding preset number of data to be uploaded, y = [1, m], and m is a positive integer.
[0028] As a further improvement of the present invention, step S2 further includes:
[0029] Obtain the actual upload time and the corresponding preset upload time of each data actually uploaded by the MCU within the set time period, and calculate the data transmission delay index Hy using the following formula (5):
[0030]
[0031] In formula (5), K 实 d K is the actual upload time of each data uploaded by the MCU within the set time period. 预 d The preset upload time for uploading each data by the single chip computer within the set time period, d is the actual upload time of uploading each data and the number of the preset upload time for uploading each data, and d is a positive integer;
[0032] Substitute the data transmission incompleteness index YJ and the data transmission delay index Hy into formula (6), and calculate the communication incompleteness index DL through formula (6):
[0033] DL=f1×YJ+f2×Hy Formula (6);
[0034] In formula (6), f1 is the preset proportional coefficient of the data transmission incompleteness index YJ, f2 is the preset proportional coefficient of the data transmission delay index Hy, and both f1 and f2 are greater than 0.
[0035] As a further improvement of the present invention, step S3 is specifically as follows:
[0036] Get the actual current value I of the microcontroller at different times within the set time period 实 x , x represents the number of the actual current value of the microcontroller at different times within the set time period, x = [1, c], and c is a positive integer;
[0037] Calculate the actual current value I of the microcontroller at different times within the set time period 实 x The standard deviation Q of the actual current value I is calculated by the following formula (7): 实 x The standard deviation Q is:
[0038]
[0039] In formula (7), The actual current value I of the microcontroller at different times within the set time period 实 x The average value of the actual current value It is calculated by the following formula (8):
[0040]
[0041] By setting the time period, according to the actual current value I of the microcontroller at different times 实 x The standard deviation Q of is used to obtain the current instability index Ed, wherein the current instability index Ed is equal to the standard deviation Q.
[0042] As a further improvement of the present invention, the abnormal coefficient Lgt in step S4 is determined by an abnormal model.
[0043] The abnormal model is
[0044] b1 is the proportional coefficient of the timer reset index Fh, b2 is the proportional coefficient of the communication incompleteness index DL, and b3 is the proportional coefficient of the current instability index Ed. b1, b2, and b3 are all greater than 0.
[0045] As a further improvement of the present invention, step S4 further includes:
[0046] Compare the abnormal coefficient Lgt with the abnormal coefficient threshold, and determine whether the single chip microcomputer has a problem in the environmental monitoring system based on the comparison result;
[0047] When the abnormal coefficient Lgt is greater than or equal to the abnormal coefficient threshold, it is determined that the microcontroller has a fault and an alarm is issued; when the abnormal coefficient Lgt is less than the abnormal coefficient threshold, it is determined that the microcontroller has no fault and no alarm is issued.
[0048] As a further improvement of the present invention, the single-chip microcomputer is an STM32 single-chip microcomputer; the actual communication data is monitoring data formed by physical quantities collected within a set time period, and the physical quantities include temperature, humidity, air quality, air pressure and light, and each physical quantity forms a four-byte data volume.
[0049] Based on the same inventive concept, this application also discloses an environmental monitoring system based on a single-chip microcomputer, comprising:
[0050] The timer reset module is used to obtain the actual reset time of the timer contained in the MCU within the set time period, and obtain the timer reset time index WDRI based on the actual reset time and the preset reset time index,i ;
[0051] The communication incomplete module is used to obtain the actual communication data of the microcontroller within a set time period and calculate the communication incomplete index DL based on the actual communication data;
[0052] The current instability module is used to obtain the actual current data of the microcontroller within a set time period and obtain the current instability index Ed based on the actual current data;
[0053] An evaluation and judgment module is used to reset the time index WDRI based on the timer index,i , the communication incomplete index DL and the current instability index ED construct an abnormal model, to determine the abnormal coefficient Lgt through the abnormal model, and compare the abnormal coefficient Lgt with the abnormal coefficient threshold to determine whether the microcontroller fails according to the comparison result.
[0054] As a further improvement of the present invention, the single-chip microcomputer is an STM32 single-chip microcomputer; the actual communication data is monitoring data formed by physical quantities collected within a set time period, and the physical quantities include temperature, humidity, air quality, air pressure and light, and each physical quantity forms a four-byte data volume.
[0055] Compared with the prior art, the present invention has the following beneficial effects:
[0056] In the present application, by judging whether there is a problem with the single-chip microcomputer in the environmental monitoring system based on the single-chip microcomputer, the present application realizes real-time monitoring of the operating status of the single-chip microcomputer in the environmental monitoring system based on the single-chip microcomputer, so that the monitoring data of the environmental parameters monitored by the environmental monitoring system is more accurate and will not affect subsequent management. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 This is a flow chart of the single chip microcomputer-based environmental monitoring system of the present invention;
[0058] Figure 2 This is a specific structural diagram of the single chip microcomputer-based environmental monitoring system of the present invention;
[0059] Figure 3 The topological diagram of the environmental monitoring device including the single chip microcomputer-based environmental monitoring system of the present invention. DETAILED DESCRIPTION
[0060] The present invention is described in detail below with reference to the various embodiments shown in the accompanying drawings, but it should be noted that these embodiments are not limitations of the present invention, and any equivalent transformations or substitutions in functions, methods, or structures made by ordinary technicians in this field based on these embodiments are all within the scope of protection of the present invention.
[0061] Ginseng Figure 1 As shown, the present invention first provides a specific implementation of an environmental monitoring method based on a single chip microcomputer (hereinafter referred to as the "method"). The execution logic and technical solution contained in the method are as follows Figure 2 The disclosed single chip microcomputer based environmental monitoring system 100 is implemented. Figure 3 The microcontroller 1 in the system monitors the ability and function of collecting environmental data through several sensors to ensure Figure 3 The environmental monitoring device 1000 shown has the monitoring capability and accuracy of environmental data.
[0062] The single chip microcomputer-based environmental monitoring method in this embodiment includes the following steps S1 to S4.
[0063] Step S1: Obtain the actual reset time of the timer contained in the single chip microcomputer within the set time period, and obtain the timer reset time index WDRI according to the actual reset time and the preset reset time index,i .
[0064] Step S1 is specifically as follows:
[0065] The set time period is divided into N sub-intervals of equal length. The set time period is any operating cycle of the single chip microcomputer 1 and is preferably a cycle defined by multiple sub-intervals, for example, the set time period is one hour or half an hour.
[0066] Obtain the difference between several actual reset times and corresponding preset reset times formed by the timer of the single-chip microcomputer 1 in each subinterval. The actual reset time is the time from when the single-chip microcomputer 1 fails or is considered to have failed to when the failure is resolved or repaired. The preset reset time is the simulation time of the single-chip microcomputer 1. Usually, the preset reset time can be set to 10ms. If the actual reset time is less than the preset reset time, the monitored environmental data is considered to be true and accurate; if the actual reset time is or is equal to the preset reset time, the monitored environmental data is considered to be untrue and inaccurate.
[0067] Based on time alignment, a reset time difference sequence of the sub-intervals is obtained.
[0068] The average value of the reset time difference sequence of each sub-interval is calculated by the following formula (1): i ):
[0069]
[0070] In formula (1), Mean(W i ) is the average reset time difference of the i-th subinterval, WDRI j is the jth reset time difference in the reset time difference sequence.
[0071] For each subinterval, the standard deviation Std(W) of the reset time difference sequence is calculated by the following formula (2): i ):
[0072]
[0073] In formula (2), Std(W i ) is the standard deviation of the reset time difference of the i-th subinterval.
[0074] The timer reset time index WDRI of the sub-interval is calculated by the following formula (3): index,i :
[0075] WDRI index,i =Mean(W i )+k×Std(W i ) formula (3);
[0076] The timer reset index Fh is obtained by adding the timer reset time indices of all subintervals.
[0077] Step S2: Acquire actual communication data of the single chip microcomputer within a set time period, and calculate a communication incompleteness index DL based on the actual communication data.
[0078] Step S2 is specifically as follows:
[0079] Obtain the number of data actually uploaded by the MCU within the set time period and the corresponding preset number of data uploaded, and calculate the data transmission incompleteness index YJ using the following formula (4):
[0080]
[0081] In formula (4), W 实 y W is the number of data actually uploaded by the MCU within the set time period. 预 y is the number of data preset to be uploaded by the microcontroller within the set time period, y represents the number of data actually uploaded by the microcontroller within the set time period and the corresponding preset number of data to be uploaded, y = [1, m], and m is a positive integer.
[0082] Step S2 further includes:
[0083] Obtain the actual upload time and the corresponding preset upload time of each data actually uploaded by the MCU within the set time period, and calculate the data transmission delay index Hy using the following formula (5):
[0084]
[0085] In formula (5), K 实 d K is the actual upload time of each data uploaded by the MCU within the set time period. 预 d The preset upload time for uploading each data by the single chip computer within the set time period, d is the actual upload time of uploading each data and the number of the preset upload time for uploading each data, and d is a positive integer;
[0086] Substitute the data transmission incompleteness index YJ and the data transmission delay index Hy into formula (6), and calculate the communication incompleteness index DL through formula (6):
[0087] DL=f1×YJ+f2×Hy Formula (6);
[0088] In formula (6), f1 is the preset proportional coefficient of the data transmission incompleteness index YJ, f2 is the preset proportional coefficient of the data transmission delay index Hy, and both f1 and f2 are greater than 0.
[0089] Step S3: Acquire actual current data of the single chip microcomputer within a set time period, and obtain a current instability index Ed based on the actual current data.
[0090] Step S3 is specifically as follows:
[0091] Get the actual current value I of the microcontroller 1 at different times within the set time period 实 x , x represents the number of the actual current value of the single chip computer 1 at different times within the set time period, x = [1, c], and c is a positive integer;
[0092] Calculate the actual current value I of the microcontroller 1 at different times within the set time period 实 x The standard deviation Q of the actual current value I is calculated by the following formula (7): 实 x The standard deviation Q is:
[0093]
[0094] In formula (7), is the actual current value I of the microcontroller 1 at different times within the set time period 实 x The average value of the actual current value It is calculated by the following formula (8):
[0095]
[0096] By setting the time period, according to the actual current value I of the microcontroller 1 at different times 实 x The standard deviation Q of is used to obtain the current instability index Ed, where the current instability index Ed is equal to the standard deviation Q.
[0097] Step S4: Reset the time index WDRI based on the timer index,i , communication incomplete index b and current instability index Ed to build an abnormal model, to determine the abnormal coefficient Lgt through the abnormal model, to compare the abnormal coefficient Lgt with the abnormal coefficient threshold, to determine whether the single chip computer has a fault based on the above comparison results. Specifically, the abnormal coefficient threshold is pre-set and saved in Figure 3 The abnormal coefficient threshold is assigned to the memory 11 of the single-chip microcomputer 1 through the serial communication method and saved in the memory 11. It should be noted that the aforementioned memory 11 is understood to be a memory defined physically and logically inside the single-chip microcomputer 1, and ROM, RAM, Flash memory, etc. can be selected.
[0098] The abnormality coefficient Lgt in step S4 is determined by the following abnormality model.
[0099] The abnormal model is
[0100] Among them, b1 is the proportional coefficient of the timer reset index Fh, b2 is the proportional coefficient of the communication incomplete index DL, and b3 is the proportional coefficient of the current instability index Ed. b1, b2 and b3 are all greater than 0. The abnormal coefficient Lgt in this application comprehensively considers the timer reset time index WDRI index,i The combined influence of b1, b2, and b3 on the final determination of whether microcontroller 1 is faulty is avoided. Therefore, preferably, b1, b2, and b3 are all greater than 0.5, but less than 1 and not equal to 1.
[0101] Step S4 also includes: comparing the abnormal coefficient Lgt with the abnormal coefficient threshold, and determining whether there is a problem with the single-chip microcomputer 1 in the single-chip microcomputer-based environmental monitoring system 100 based on the comparison result; when the abnormal coefficient Lgt is greater than or equal to the abnormal coefficient threshold, it is determined that the single-chip microcomputer 1 has a fault and an alarm is issued; when the abnormal coefficient Lgt is less than the abnormal coefficient threshold, it is determined that the single-chip microcomputer 1 has no fault and no alarm is issued.
[0102] Microcontroller 1 is an STM32 microcontroller. The actual communication data is the monitoring data generated by the physical quantities collected during a set time period. Physical quantities include temperature, humidity, air quality, air pressure, and light intensity, with each physical quantity generating four bytes of data.
[0103] Combine Figure 2 and Figure 3 As shown, a single-chip microcomputer-based environmental monitoring system 100 provided in an embodiment of the present invention comprehensively judges whether there is a problem with the single-chip microcomputer 1 in the single-chip microcomputer-based environmental monitoring system 100 by setting a timer reset module 10, an incomplete communication module 20, an unstable current module 30 and an evaluation and judgment module 40, thereby realizing real-time monitoring of the operating status of the single-chip microcomputer 1 in the single-chip microcomputer-based environmental monitoring system 100, so that the monitoring data (i.e., environmental data) on environmental parameters monitored by the single-chip microcomputer-based environmental monitoring system 100 has high accuracy and will not affect subsequent management.
[0104] It should be noted that the single-chip microcomputer 1 has a built-in timer (i.e., Timer, and not specifically shown), and the several actual reset times contained in the timer can be obtained through the monitoring system inside the environmental monitoring system 100. The corresponding preset reset time is obtained based on the fixed timer reset time initially set, and the details will not be repeated here. The aforementioned monitoring system can be regarded as a watchdog timer independent of the internal integration of the single-chip microcomputer 1, and specifically a timer that is independent of the internal part of the single-chip microcomputer 1 but physically belongs to the environmental monitoring system 100, and can use a DS1302 chip. The monitoring system is used to collect and record the actual upload time of environmental data and can be used as a counter to count the number of environmental data actually uploaded by the single-chip microcomputer 1 within a set time period.
[0105] The timer can be a watchdog timer (WDT). By periodically resetting the watchdog timer and constantly resetting and resetting, the normal operation of the single-chip microcomputer 1 can be ensured. It should be noted that the watchdog timer is logically formed inside the single-chip microcomputer 1 and is used to determine whether the program running by the single-chip microcomputer autonomously decides to restart the program when an exception occurs. If the single-chip microcomputer 1 fails to reset the WDT in time due to a program dead loop or other reasons, the WDT will trigger the single-chip microcomputer 1 to reset, indicating that the single-chip microcomputer 1 is operating abnormally. Therefore, the larger the timer reset index Fh, the greater the degree of abnormality of the operating state of the single-chip microcomputer 1, and the smaller the timer reset index Fh, the smaller the degree of abnormality of the operating state of the single-chip microcomputer 1. When the timer reset index Fh is larger, it represents that an accident has occurred in the single-chip microcomputer 1. Although the environmental monitoring system 100 can still monitor the environment, the accuracy of the monitoring data (i.e., environmental data) monitored about the environmental parameters is low, which has an adverse impact on subsequent management. In this application, monitoring data and environmental data have the same meaning.
[0106] The number of environmental data items actually uploaded by the microcontroller 1 during the set time period and the actual upload time of each item can be obtained through the monitoring system within the environmental monitoring system 100. The corresponding preset number of environmental data items to be uploaded and the preset upload time are set by the user based on actual circumstances and will not be further described. The aforementioned monitoring system can also use the DS1302 chip.
[0107] It should be noted that if the single-chip microcomputer 1 is operating normally, the number of environmental data actually uploaded by the single-chip microcomputer 1 within the set time period should match the number of environmental data uploaded by the preset time period, and the actual upload time of each data actually uploaded should be close to or equal to the preset upload time. The environmental data obtained by the monitoring system (i.e., DS1302 chip) carried by the environment monitoring system 100 will show this consistency, thereby confirming the normal operating state during the communication process. Once the number of data actually uploaded by the single-chip microcomputer 1 within the set time period should be inconsistent with the number of environmental data uploaded by the preset time period and the actual upload time of each environmental data actually uploaded should be delayed with the preset upload time, it represents that the single-chip microcomputer 1 has an accident or fault. Although, at this time, the environmental monitoring system 100 can still monitor the environment, the accuracy of the monitored environmental data is low, which has an adverse effect on subsequent management, and the reasons are as follows.
[0108] The preset number and time of environmental data upload are one of the basic assumptions for the design and operation of the environmental monitoring system 100. If the actual situation does not meet expectations, this may mean that the environmental monitoring system has a problem during the environmental data collection, processing or transmission process, such as communication failure, data loss or processing error, or even a failure or power outage of the single-chip microcomputer 1 itself. The reliability and accuracy of the environmental monitoring system 100 require the integrity of the environmental data, that is, all data in each time period should be correctly collected and uploaded. Therefore, it is necessary to ensure the integrity and accuracy of the environmental data. If the number of environmental data does not meet expectations, it may result in incomplete or erroneous monitoring data of environmental parameters. The monitoring data obtained by the environmental monitoring system 100 directly affects subsequent management decisions. If the environmental data is inaccurate or incomplete, managers will not be able to make accurate analysis and decisions based on these environmental data, thereby affecting the real-time and effectiveness of environmental monitoring. Any unexpected or abnormal situation may affect the stability and reliability of the environmental monitoring system 100. The aforementioned environmental data is data formed by the physical quantities referred to in this application.
[0109] As the core control unit of environmental monitoring system 100, the operating status of microcontroller 1 directly impacts the functionality and efficiency of the entire system. Therefore, if the number and timing of environmental data uploaded by microcontroller 1 within a set time period differ from expectations, this is generally considered a significant indicator of a possible anomaly or unexpected situation within environmental monitoring system 100. Therefore, a larger value for the communication incompleteness index DL indicates a greater degree of abnormality in the operating status of microcontroller 1, while a smaller value for the communication incompleteness index DL indicates a lesser degree of abnormality in the operating status of microcontroller 1.
[0110] The actual current value of the single-chip microcomputer 1 at different times can be obtained by the monitoring system inside the environmental monitoring system 100. The monitoring system collects the actual current value flowing through the single-chip microcomputer 1 at different times in real time, and obtains the actual current value of the single-chip microcomputer 1 at different times within the set time period. The specific method of obtaining it will not be repeated. The aforementioned monitoring system is different from the environmental monitoring system 100 in each embodiment of the present application. The aforementioned monitoring system can be regarded as a sampling circuit included in the environmental monitoring system 100. The sampling circuit can be a sampling resistor connected in series with the power supply end (i.e., the VCC end) of the single-chip microcomputer 1. The sampling resistor is connected across the VCC end and the GND end, so that the voltage formed at its two ends is collected by the sampling resistor, and the voltage is connected to the AD acquisition pin of the single-chip microcomputer 1. The AD acquisition pin varies according to the type and model of the single-chip microcomputer 1, and is well known to those skilled in the art of the present application. Therefore, it is not described in detail in this application. The voltage across the sampling resistor can be used to calculate the current value flowing through the microcontroller 1 based on Ohm's law, so as to accurately calculate and collect the actual current value flowing through the microcontroller 1 at different times.
[0111] The current instability index Ed describes the degree of instability of the current of the microcontroller 1 when the entire microcontroller-based environmental monitoring system 100 is running. If the degree of instability of the current of the microcontroller 1 is greater when the entire microcontroller-based environmental monitoring system 100 is running, it means that the microcontroller 1 has an accident or failure. Although the environmental monitoring system 100 here can still monitor the environment, the accuracy and reliability of the monitoring data on environmental parameters (that is, environmental data) are low, and will have an adverse impact on subsequent management. The reasons are as follows.
[0112] The instability of the current may reflect that there is a problem with some components or power supply in the environmental monitoring system 100. When the single-chip microcomputer 1 is running, the fluctuation of its current may be a manifestation of unstable hardware or power supply. In this case, the circuit operation of the environmental monitoring system 100 may be affected, which may cause some functions of the environmental monitoring system 100 to fail to operate normally or to operate abnormally. Reduced data acquisition accuracy: Current fluctuations will directly affect the collection and processing of sensor data: The single-chip microcomputer 1 is usually used to connect various sensors to collect monitoring data of environmental parameters such as temperature, humidity, etc. If the current is unstable, it may cause the electrical signal received by the sensor to change, thereby affecting the working stability of the sensor and the accuracy of the data. Reduced stability of data processing: Unstable current may cause errors in the internal data processing of the single-chip microcomputer 1: In the case of unstable current, the single-chip microcomputer 1 may have data processing errors or calculation errors, thereby affecting the accuracy and stability of the environmental data finally generated.
[0113] Environmental monitoring system 100 is used, for example, in smart greenhouses, weather stations, industrial control systems, or medical equipment. Accurate monitoring of environmental parameters is key to ensuring the proper operation and data reliability of environmental monitoring system 100. If the monitoring data is inaccurate due to unstable current in microcontroller 1, it may mislead decision-making or cause the environmental monitoring system 100 to respond untimely or inappropriately to environmental changes. In the field of environmental monitoring and control, high-precision and high-stability monitoring data is the basis for making decisions and taking action. Unstable current can lead to increased errors in monitoring data, thereby affecting the effectiveness and accuracy of subsequent management and decision-making.
[0114] In summary, the current instability of the single-chip microcomputer 1 during operation may not only indicate that there are potential hardware problems in the environmental monitoring system 100, but may also directly affect the collection, processing and transmission of data, which may lead to problems such as reducing the stability of the environmental monitoring system and the accuracy of the monitoring data of environmental parameters. Therefore, the larger the current instability index Ed, the greater the degree of abnormality of the operating state of the single-chip microcomputer 1, and the smaller the current instability index Ed, the smaller the degree of abnormality of the operating state of the single-chip microcomputer 1. In the present application, the abnormal coefficient Lgt and the abnormal coefficient threshold are compared, and based on the comparison results, it is determined whether the single-chip microcomputer 1 in the environmental monitoring system 100 based on the single-chip microcomputer has a fault, or whether there is a technical problem of low monitoring progress although there is no fault.
[0115] When the abnormality coefficient Lgt is greater than or equal to the abnormality coefficient threshold, it indicates that there is a problem with the single-chip microcomputer 1 in the single-chip microcomputer-based environmental monitoring system 100. Although the environmental monitoring system 100 can still monitor the environment, the accuracy of the monitoring data on the environmental parameters is low, which has an adverse impact on subsequent management. At this time, the single-chip microcomputer-based environmental monitoring system 100 immediately issues an alarm to remind the staff that there is a problem with the single-chip microcomputer 1 and that corresponding measures need to be taken in a timely manner. In addition, the current monitoring data on the environmental parameters monitored is of low accuracy and cannot be used, and subsequent analysis and management cannot be carried out based on the monitoring data on the environmental parameters monitored.
[0116] When the abnormality coefficient Lgt is less than the abnormality coefficient threshold, it means that the single-chip microcomputer 1 in the single-chip microcomputer-based environmental monitoring system 100 is operating normally and there is no fault. At this time, the single-chip microcomputer-based environmental monitoring system 100 does not issue an alarm, and the current monitoring data on the environmental parameters monitored has a high accuracy, and subsequent analysis and management can be carried out based on the monitoring data on the environmental parameters monitored.
[0117] The above formulas are all dimensionless and numerical calculations. The formulas are obtained by collecting a large amount of data and performing software simulation to obtain the most recent real situation. The preset parameters in the formulas are set by technicians in this field according to actual conditions.
[0118] The technical solutions and computer logic included in the single-chip microcomputer-based environmental monitoring method disclosed in this embodiment are implemented by the timer reset module 10, the communication incomplete module 20, the current unstable module 30, and the evaluation and judgment module 40 in the single-chip microcomputer-based environmental monitoring system 100 described in the second specific embodiment below. The technical solutions and computer logic included in the single-chip microcomputer-based environmental monitoring method are encapsulated in the timer reset module 10, the communication incomplete module 20, the current unstable module 30, and the evaluation and judgment module 40. For details, refer to the specific embodiment below.
[0119] Based on the technical solutions of the single chip microcomputer-based environmental monitoring method disclosed in the above embodiments, and referring to Figure 2 and Figure 3 As shown, the present invention also provides a specific implementation of an environment monitoring system 100 based on a single chip microcomputer (hereinafter referred to as "environmental monitoring system 100" or "system 100").
[0120] The environmental monitoring system 100 includes: a timer reset module 10, an incomplete communication module 20, an unstable current module 30 and an evaluation and judgment module 40, and each module is interconnected. It should be noted that in actual manufacturing and use scenarios, the environmental monitoring system 100 and the single-chip microcomputer 1 can be integrated into a circuit board or electronic device (not shown). The circuit board or electronic device connects the single-chip microcomputer 1 to multiple sensors through a wired (for example, RS-485 bus form) or wireless (for example, Zigbee protocol) connection method, that is, Figure 3 Sensors 21, 22 to 2i in the embodiment, wherein i is a positive integer greater than or equal to 1, are used to detect the physical quantity collected from the environmental data individually or collectively through one or more sensors.
[0121] The environmental monitoring system 100 based on the single chip microcomputer includes: a timer reset module 10 for obtaining the actual reset time of the timer contained in the single chip microcomputer 1 within a set time period, and obtaining the timer reset time index WDRI based on the actual reset time and the preset reset time index,i The communication incomplete module 20 is used to obtain the actual communication data of the single chip computer 1 within the set time period, and calculate the communication incomplete index DL based on the actual communication data. The current unstable module 30 is used to obtain the actual current data of the single chip computer 1 within the set time period, and calculate the current instability index Ed based on the actual current data. The evaluation and judgment module 40 is used to reset the time index WDRI based on the timer.index,i , communication incomplete index DL and current instability index Ed to construct an abnormal model, to determine the abnormal coefficient Lgt through the abnormal model, to compare the abnormal coefficient Lgt with the abnormal coefficient threshold, to determine whether the single chip 1 has a fault according to the comparison result. The environmental monitoring system 100 is included in Figure 3 In the illustrated environment monitoring device 1000 , the environment monitoring system 100 is connected to one or more sensors (ie, sensor 21 to sensor 2i ), and together with the one or more sensors constitutes the environment monitoring device 1000 ; or, together with the GUI 3 , constitutes the environment monitoring device 1000 .
[0122] Microcontroller 1 is an STM32 microcontroller. The actual communication data is the monitoring data generated by the physical quantities collected within the set time period. The physical quantities include temperature, humidity, air quality, air pressure and light, and each physical quantity forms a four-byte data volume (Note: Based on the request message format of the MODBUS-RTU protocol). The preset reset time is greater than the actual reset time. In addition, the reference Figure 3 As shown, the environmental monitoring system 100 can be connected to a graphical user interface (i.e., GUI 3) via a bus connection method well-established in the prior art. The user can use GUI 3 to access and modify pre-configured parameters or variables in the environmental monitoring system 100, such as a preset reset time. The microcontroller-based environmental monitoring system 100 disclosed in this embodiment incorporates the same technical solutions as the microcontroller-based environmental monitoring method in the aforementioned embodiment, as described in the first embodiment, and will not be further elaborated here.
[0123] The series of detailed descriptions listed above are only specific descriptions of feasible implementation methods of the present invention. They are not intended to limit the scope of protection of the present invention. Any equivalent implementation methods or changes that do not deviate from the technical spirit of the present invention should be included in the scope of protection of the present invention.
[0124] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above and that the invention can be embodied in other specific forms without departing from the spirit or essential characteristics of the invention. Therefore, the embodiments should be considered in all respects as illustrative and non-restrictive, and the scope of the invention is defined by the appended claims, not the foregoing description, and all variations within the meaning and range of equivalents of the claims are intended to be included therein. Any reference sign in a claim should not be construed as limiting the claim to which it relates.
Claims
1. The environmental monitoring method based on single chip microcomputer is characterized in that: The following steps are involved: S1. Get the actual reset time of the timer contained in the MCU within the set time period, and get the timer reset time index WDRI based on the actual reset time and the preset reset time. index,i ; S2. Acquire the actual communication data of the single chip microcomputer within the set time period, and calculate the communication incompleteness index DL based on the actual communication data; S3, obtaining the actual current data of the single chip microcomputer within the set time period, and obtaining the current instability index Ed based on the actual current data; S4, resetting the time index WDRI based on the timer index,i , constructing an abnormality model with the communication incomplete index DL and the current instability index Ed, determining an abnormality coefficient Lgt through the abnormality model, and comparing the abnormality coefficient Lgt with an abnormality coefficient threshold to determine whether the single chip microcomputer has a fault according to the comparison result; The step S2 is specifically as follows: Obtain the number of data actually uploaded by the MCU within the set time period and the corresponding preset number of data uploaded, and calculate the data transmission incompleteness index YJ using the following formula (4): In formula (4), W 实 y W is the number of data actually uploaded by the MCU within the set time period. 预 y is the number of data preset to be uploaded by the microcontroller within the set time period, y represents the number of data actually uploaded by the microcontroller within the set time period and the corresponding preset number of data to be uploaded, y = [1, m], and m is a positive integer.
2. The environmental monitoring method according to claim 1, characterized in that: The step S1 is specifically as follows: Divide the set time period into N sub-intervals of equal length; Obtain the difference between a plurality of actual reset times formed by the timer of the single chip microcomputer in each subinterval and the corresponding preset reset time; Based on time alignment, obtaining a reset time difference sequence of the subintervals; The average value of the reset time difference sequence of each sub-interval is calculated by the following formula (1): i ): In formula (1), Mean(W i ) is the average reset time difference of the i-th subinterval, WDRI j is the jth reset time difference in the reset time difference sequence; For each subinterval, the standard deviation Std(W) of the reset time difference sequence is calculated by the following formula (2): i ): In formula (2), Std(W i ) is the standard deviation of the reset time difference of the i-th subinterval; The timer reset time index WDRI of the sub-interval is calculated by the following formula (3): index,i : WDRI index,i =Mean(W i )+k×Std(W i ) Formula (3), In formula (3), k is the weight coefficient of the standard deviation of the reset time difference of the i-th subinterval; The timer reset time index Fh is obtained by adding the timer reset time indexes of all subintervals.
3. The environmental monitoring method according to claim 1, characterized in that: The step S2 further includes: Obtain the actual upload time and the corresponding preset upload time of each data actually uploaded by the MCU within the set time period, and calculate the data transmission delay index Hy using the following formula (5): In formula (5), K 实 d K is the actual upload time of each data uploaded by the MCU within the set time period. 预 d The preset upload time for uploading each data by the single chip computer within the set time period, d is the actual upload time of uploading each data and the number of the preset upload time for uploading each data, and d is a positive integer; Substitute the data transmission incompleteness index YJ and the data transmission delay index Hy into formula (6), and calculate the communication incompleteness index DL through formula (6): DL=f1×YJ+f2×Hy Formula (6); In formula (6), f1 is the preset proportional coefficient of the data transmission incompleteness index YJ, f2 is the preset proportional coefficient of the data transmission delay index Hy, and both f1 and f2 are greater than 0.
4. The environmental monitoring method according to claim 1, characterized in that: The step S3 is specifically as follows: Get the actual current value I of the microcontroller at different times within the set time period 实 x , x represents the number of the actual current value of the microcontroller at different times within the set time period, x = [1, c], and c is a positive integer; Calculate the actual current value I of the microcontroller at different times within the set time period 实 x The standard deviation Q of the actual current value I is calculated by the following formula (7): 实 x The standard deviation Q is: In formula (7), The actual current value I of the microcontroller at different times within the set time period 实 x The average value of the actual current value It is calculated by the following formula (8): By setting the time period, according to the actual current value I of the microcontroller at different times 实 x The standard deviation Q of is used to obtain the current instability index Ed, wherein the current instability index Ed is equal to the standard deviation Q.
5. The environmental monitoring method according to claim 2, characterized in that: The abnormal coefficient Lgt in step S4 is determined by the abnormal model. The abnormal model is b1 is the proportional coefficient of the timer reset index Fh, b2 is the proportional coefficient of the communication incompleteness index DL, and b3 is the proportional coefficient of the current instability index Ed. b1, b2, and b3 are all greater than 0.
6. The environmental monitoring method according to claim 5, characterized in that: The step S4 further includes: Compare the abnormal coefficient Lgt with the abnormal coefficient threshold, and determine whether the single chip microcomputer has a problem in the environmental monitoring system based on the comparison result; When the abnormal coefficient Lgt is greater than or equal to the abnormal coefficient threshold, it is determined that the microcontroller has a fault and an alarm is issued; when the abnormal coefficient Lgt is less than the abnormal coefficient threshold, it is determined that the microcontroller has no fault and no alarm is issued.
7. The environmental monitoring method according to claim 1, characterized in that: The single-chip microcomputer is an STM32 single-chip microcomputer; the actual communication data is monitoring data formed by physical quantities collected within a set time period, and the physical quantities include temperature, humidity, air quality, air pressure and light, and each physical quantity forms a four-byte data volume.
8. The environmental monitoring system based on single chip microcomputer is characterized by: include: The timer reset module is used to obtain the actual reset time of the timer contained in the MCU within the set time period, and obtain the timer reset time index WDRI based on the actual reset time and the preset reset time index,i ; The communication incomplete module is used to obtain the actual communication data of the microcontroller within a set time period and calculate the communication incomplete index DL based on the actual communication data; The current instability module is used to obtain the actual current data of the microcontroller within a set time period and obtain the current instability index Ed based on the actual current data; An evaluation and judgment module is used to reset the time index WDRI based on the timer index,i , constructing an abnormality model with the communication incomplete index DL and the current instability index Ed, determining an abnormality coefficient Lgt through the abnormality model, and comparing the abnormality coefficient Lgt with an abnormality coefficient threshold to determine whether the single chip microcomputer has a fault according to the comparison result; The method for obtaining the actual communication data of the single chip microcomputer within a set time period and calculating the communication incompleteness index DL based on the actual communication data is specifically: Obtain the number of data actually uploaded by the MCU within the set time period and the corresponding preset number of data uploaded, and calculate the data transmission incompleteness index YJ using the following formula (4): In formula (4), W 实 y W is the number of data actually uploaded by the MCU within the set time period. 预 y is the number of data preset to be uploaded by the microcontroller within the set time period, y represents the number of data actually uploaded by the microcontroller within the set time period and the corresponding preset number of data to be uploaded, y = [1, m], and m is a positive integer.
9. The environmental monitoring system according to claim 8, characterized in that: The single-chip microcomputer is an STM32 single-chip microcomputer; the actual communication data is monitoring data formed by physical quantities collected within a set time period, and the physical quantities include temperature, humidity, air quality, air pressure and light, and each physical quantity forms a four-byte data volume.
Citation Information
Patent Citations
Reset control device and method
CN102508533A
A Single Chip Microcomputer System and a Reset Method for Single Chip Microcomputer System
CN106489109A