Environmental monitoring method and system based on single-chip microcomputer
By constructing an abnormality model and using the timer reset time, communication data and current data of the microcontroller to determine whether the microcontroller has failed, the problem of lack of real-time fault monitoring in traditional environmental monitoring systems is solved, and the accuracy of environmental data and the reliability of the system are improved. sex.
Patent Information
- Application Number
- CN202411427630.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-14
- Publication Date
- 2025-01-24
- 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, which leads to the inability to detect in time when microcontrollers fail, affecting the accuracy and reliability of environmental data.
By obtaining the timer reset time, communication data and current data of the microcontroller, the corresponding index (WDRIindex, DL, Ed) is calculated, an abnormality model is constructed to determine the abnormality coefficient Lgt, and compared with the threshold to determine whether the microcontroller is faulty.
It realizes real-time monitoring of the operating status of the microcontroller, improves the detection accuracy of environmental data and the reliability of the system, and promptly detects microcontroller faults and issues alarms.
Smart Images

Figure CN119356171A_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] The environmental monitoring system based on the single-chip microcomputer is an electronic system used to monitor the monitoring data of 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 parameters such as temperature, humidity, air quality, air pressure, and light in the environment. The environmental monitoring system based on the single-chip microcomputer is widely used in many fields due to its high performance, low power consumption, flexibility and easy expansion, providing reliable technical support for modern environmental monitoring (for example, smart greenhouses).
[0003] When using a microcontroller-based environmental monitoring system to monitor the environment with high precision, it relies on the microcontroller to run. The microcontroller is responsible for controlling the data collection, processing, communication and other functions of various sensors to achieve accurate monitoring and management of environmental parameter monitoring data. When monitoring the environment, the traditional microcontroller-based environmental monitoring system often assumes that the core of the entire system, that is, the microcontroller, is actually running normally, and lacks real-time monitoring of the microcontroller's running status. Once the microcontroller fails and is not detected in time, although the environmental monitoring system can still monitor the environment, the monitoring data on environmental parameters is wrong, 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 single chip microcomputer in the prior art 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, so as to improve the detection accuracy of environmental data.
[0006] To achieve one of the above purposes, the present invention first provides an environmental monitoring method based on a single chip microcomputer, comprising the following steps:
[0007] S1. 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 ;
[0008] S2, obtaining the actual communication data of the single chip microcomputer within a set time period, and calculating the communication incompleteness index DL according to 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 according to the actual current data;
[0010] S4, based on the timer reset time index WDRI 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 to compare the abnormal coefficient Lgt with the abnormal coefficient threshold to determine whether the single chip microcomputer 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 sub-interval and the corresponding preset reset time;
[0014] Based on time alignment, obtaining a reset time difference sequence of the sub-intervals;
[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 sub-interval, 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 sub-interval;
[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 time index Fh is obtained by adding the timer reset time indexes of all subintervals.
[0024] As a further improvement of the present invention, the step S2 is specifically as follows:
[0025] The number of data actually uploaded by the MCU within the set time period and the corresponding number of data preset for upload are obtained, and the data transmission incompleteness index YJ is calculated by the following formula (4):
[0026]
[0027] In formula (4), W 实 y W is the number of data actually uploaded by the microcontroller within the set time period. 预 y is the number of data preset for uploading by the MCU within the set time period, y represents the number of data actually uploaded by the MCU within the set time period and the corresponding number of data preset for uploading, y=[1,m], and m is a positive integer.
[0028] As a further improvement of the present invention, the step S2 further includes:
[0029] The actual upload time and the corresponding preset upload time of each data actually uploaded by the single-chip microcomputer within the set time period are obtained, and the data transmission delay index Hy is calculated by the following formula (5):
[0030]
[0031] In formula (5), K 实 d K is the actual upload time of each data uploaded by the microcontroller 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 number of the actual upload time for uploading each data and 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 a preset proportional coefficient of the data transmission incompleteness index YJ, f2 is a 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, the 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 single-chip microcomputer 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), is 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] 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.
[0045] As a further improvement of the present invention, the step S4 further includes:
[0046] The abnormal coefficient Lgt is compared with the abnormal coefficient threshold, and according to the comparison result, it is determined in the environmental monitoring system based on the single chip microcomputer whether there is a problem with the single chip microcomputer;
[0047] When the abnormal coefficient Lgt is greater than or equal to the abnormal coefficient threshold, it is determined that the single-chip microcomputer 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 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 data volume of four bytes.
[0049] Based on the same inventive concept, the present 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 microcontroller 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 single chip microcomputer 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 single chip microcomputer within a set time period, and obtain the current instability index Ed according to 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 to compare the abnormal coefficient Lgt with the abnormal coefficient threshold to determine whether the single chip microcomputer 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 data volume of four bytes.
[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 the subsequent management. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 It is a flow chart of the environmental monitoring system based on single chip microcomputer of the present invention;
[0058] Figure 2 It is a specific structural diagram of the environmental monitoring system based on a single chip microcomputer of the present invention;
[0059] Figure 3 It is a topological diagram of an 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 in conjunction with 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 the 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 method 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 environment 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 environment monitoring method in this embodiment includes the following steps S1 to S4.
[0063] Step S1, obtaining the actual reset time of the timer contained in the single-chip microcomputer within the set time period, and obtaining 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 operation cycle of the single chip computer 1, and preferably includes a cycle defined by multiple sub-intervals, for example, the set time period is one hour or half an hour.
[0066] Get the difference between several actual reset times and corresponding preset reset times formed by the timer of the single-chip microcomputer 1 in each sub-interval. 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 the 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 sub-interval, 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 time index Fh is obtained by adding the timer reset time indexes 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] The number of data actually uploaded by the MCU within the set time period and the corresponding number of data preset for upload are obtained, and the data transmission incompleteness index YJ is calculated by the following formula (4):
[0080]
[0081] In formula (4), W 实 y W is the number of data actually uploaded by the microcontroller within the set time period. 预 y is the number of data preset for uploading by the MCU within the set time period, y represents the number of data actually uploaded by the MCU within the set time period and the corresponding number of data preset for uploading, y=[1,m], and m is a positive integer.
[0082] Step S2 also includes:
[0083] The actual upload time and the corresponding preset upload time of each data actually uploaded by the single-chip microcomputer within the set time period are obtained, and the data transmission delay index Hy is calculated by the following formula (5):
[0084]
[0085] In formula (5), K 实 d K is the actual upload time of each data uploaded by the microcontroller 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 number of the actual upload time for uploading each data and 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 a preset proportional coefficient of the data transmission incompleteness index YJ, f2 is a preset proportional coefficient of the data transmission delay index Hy, and both f1 and f2 are greater than 0.
[0089] Step S3, obtaining actual current data of the single chip microcomputer within a set time period, and obtaining a current instability index Ed according to the actual current data.
[0090] Step S3 is specifically as follows:
[0091] Get the actual current value I of MCU 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 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 microcomputer fails according to the above comparison results. Specifically, the abnormal coefficient threshold is pre-set and stored in Figure 3 The abnormal coefficient threshold is assigned and saved in the memory 11 of the single-chip microcomputer 1 through the serial communication mode. It should be noted that the aforementioned memory 11 is understood as a memory defined internally in the single-chip microcomputer 1 in physical logic, and ROM, RAM and Flash memory 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 composite influence of the communication incompleteness index DL and the current instability index Ed on the final result of determining whether the single chip computer 1 is faulty is avoided. The inaccuracy of the conclusion drawn by using a single evaluation index 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 according to 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 formed 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.
[0103] Combination 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 determines 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 achieving 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) about environmental parameters monitored by the single-chip microcomputer-based environmental monitoring system 100 has a higher 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 actual reset times contained in the timer can be obtained through the monitoring system built into the environmental monitoring system 100. The corresponding preset reset time is obtained according to the fixed timer reset time set initially, and the details are not repeated here. The aforementioned monitoring system can be regarded as a watchdog timer independent of the integrated single-chip microcomputer 1, and specifically a timer independent of the single-chip microcomputer 1, but physically belonging to the environmental monitoring system 100, and a DS1302 chip can be used. 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, Watch Dog Timer). By resetting the watchdog timer regularly 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 run 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 dead loop of the program or other reasons, the WDT will trigger the single-chip microcomputer 1 to reset, indicating that the single-chip microcomputer 1 is running abnormally. Therefore, the larger the timer reset index Fh, the greater the abnormality of the running state of the single-chip microcomputer 1, and the smaller the timer reset index Fh, the smaller the abnormality of the running state of the single-chip microcomputer 1. When the timer reset index Fh is larger, it represents that the single-chip microcomputer 1 has an accident. Although the environmental monitoring system 100 can still monitor the environment, the accuracy of the monitored monitoring data (i.e., environmental data) about environmental parameters is low, which has an adverse effect on subsequent management. In this application, monitoring data and environmental data have the same meaning.
[0106] The number of environmental data actually uploaded by the single-chip microcomputer 1 within the set time period and the actual upload time of each environmental data actually uploaded can be obtained through the monitoring system inside the environmental monitoring system 100. The corresponding preset number of environmental data uploaded and the preset upload time are set by the user according to the actual situation, and the details are not repeated here. The aforementioned monitoring system can also use the DS1302 chip.
[0107] It should be noted that if the single-chip microcomputer 1 operates 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) inside the environmental monitoring system 100 will show this consistency, thereby confirming the normal operation 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 failure. 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 uploaded 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 problems in the process of environmental data collection, processing or transmission, such as communication failure, data loss or processing error, or even failure of the single-chip microcomputer 1 itself or power failure and unavailability. The reliability and accuracy of the environmental monitoring system 100 require the integrity of the environmental data, that is, all data should be correctly collected and uploaded in each time period. 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 lead to incomplete or erroneous monitoring of the 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 quantity referred to in this application.
[0109] The single-chip microcomputer 1 is the core control unit of the environmental monitoring system 100, and its operating state directly affects the normal function and operating efficiency of the entire system. Therefore, when it is found that the number and time of environmental data uploaded by the single-chip microcomputer 1 within the set time period are inconsistent with expectations, it is usually regarded as an important indicator that the environmental monitoring system 100 may have an abnormal or unexpected situation. Therefore, the larger the communication incompleteness index DL is, the greater the degree of abnormality of the operating state of the single-chip microcomputer 1 is, and the smaller the communication incompleteness index DL is, the smaller the degree of abnormality of the operating state of the single-chip microcomputer 1 is.
[0110] The actual current value of the single-chip microcomputer 1 at different times can be obtained by the monitoring system provided 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, and the sampling circuit can be a sampling resistor connected in series with the power supply end (i.e., 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 both 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 technicians in the technical field to which the present application belongs, so it is not described in detail in the present application. The voltage across the sampling resistor can be used to calculate the current value flowing through the single chip computer 1 based on Ohm's law, so as to accurately calculate and collect the actual current value flowing through the single chip computer 1 at different times.
[0111] The current instability index Ed describes the instability of the current of the single-chip microcomputer 1 when the entire single-chip microcomputer-based environmental monitoring system 100 is running. If the current instability of the single-chip microcomputer 1 is greater when the entire single-chip microcomputer-based environmental monitoring system 100 is running, it means that the single-chip microcomputer 1 has an accident or failure. Although the environmental monitoring system 100 here can still monitor the environment, the monitoring data on environmental parameters (that is, environmental data) is less accurate and reliable, and will have an adverse impact on subsequent management for the following reasons.
[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 data processing within 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] The environmental monitoring system 100 is used, for example, in smart greenhouses, weather stations, industrial control systems or medical equipment. Accurate monitoring of environmental parameter data is the key to ensuring the normal operation of the environmental monitoring system 100 and data reliability. If the monitoring data is inaccurate due to unstable current in the single-chip microcomputer 1, it may mislead the decision or cause the environmental monitoring system 100 to respond to environmental changes untimely or inappropriately. In the field of environmental monitoring and control, high-precision and high-stability monitoring data is the basis for making decisions and taking actions. Unstable current may cause an increase in the error of the 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 abnormality of the operating state of the single-chip microcomputer 1, and the smaller the current instability index Ed, the smaller the 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 judged whether the single-chip microcomputer 1 in the environmental monitoring system 100 based on the single-chip microcomputer is faulty, or 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 monitored 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 relevant environmental parameters monitored has a low accuracy and cannot be used, and subsequent analysis and management cannot be performed based on the monitoring data on the relevant 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 degree of 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 formula is a formula for the most recent real situation obtained by collecting a large amount of data and performing software simulation. The preset parameters in the formula are set by technicians in this field according to actual conditions.
[0118] The technical solutions and computer logic contained 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 in the second specific implementation manner described below. The technical solutions and computer logic contained in the single-chip microcomputer-based environmental monitoring method are encapsulated in the aforementioned 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 following specific implementation manner.
[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 "environment 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 The sensors 21, 22 to 2i in the embodiment are as follows, wherein i is a positive integer greater than or equal to 1. Thus, the physical quantity collected from the environmental data is detected individually or jointly by one or more sensors.
[0121] The single chip microcomputer-based environmental monitoring system 100 comprises: 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 according to 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 microcomputer 1 within a 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 microcomputer 1 within a set time period, and calculate the current unstable 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 timerindex,i , the communication incomplete index DL and the 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 computer 1 fails according to the comparison result. The environmental monitoring system 100 includes Figure 3 In the environment monitoring device 1000 shown, 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 formed 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, Figure 3 As shown, the environment monitoring system 100 can be connected to the graphical user interface (i.e., GUI3) through a mature bus connection method in the prior art, and the user can access and modify the pre-configured parameters or variables in the environment monitoring system 100 with the help of the graphical user interface 3, such as the preset reset time, etc. The single-chip microcomputer-based environment monitoring system 100 disclosed in this specific embodiment has the same technical solution as the single-chip microcomputer-based environment monitoring method in the aforementioned embodiment, which is described in the first specific embodiment and will not be repeated 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 invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description, and it is intended that all variations falling within the meaning and scope of the equivalent elements of the claims be included in the invention. Any reference numeral in a claim should not be considered 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. 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 ; S2, obtaining the actual communication data of the single chip microcomputer within a set time period, and calculating the communication incompleteness index DL according to the actual communication data; S3, obtaining the actual current data of the single chip microcomputer within a set time period, and obtaining the current instability index Ed according to the actual current data; S4, based on the timer reset time index WDRI 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 to compare the abnormal coefficient Lgt with the abnormal coefficient threshold to determine whether the single chip microcomputer fails according to the comparison result.
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 sub-interval and the corresponding preset reset time; Based on time alignment, obtaining a reset time difference sequence of the sub-intervals; 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 sub-interval, 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 sub-interval; 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); 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 is specifically as follows: The number of data actually uploaded by the MCU within the set time period and the corresponding number of data preset for upload are obtained, and the data transmission incompleteness index YJ is calculated by the following formula (4): In formula (4), W 实 y W is the number of data actually uploaded by the microcontroller within the set time period. 预 y is the number of data preset for uploading by the single-chip microcomputer within the set time period, y represents the number of data actually uploaded by the single-chip microcomputer within the set time period and the corresponding number of preset uploaded data, y=[1, m], and m is a positive integer.
4. The environmental monitoring method according to claim 3, characterized in that: The step S2 further comprises: The actual upload time and the corresponding preset upload time of each data actually uploaded by the single-chip microcomputer within the set time period are obtained, and the data transmission delay index Hy is calculated by the following formula (5): In formula (5), K 实 d K is the actual upload time of each data uploaded by the microcontroller 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 number of the actual upload time for uploading each data and 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 a preset proportional coefficient of the data transmission incompleteness index YJ, f2 is a preset proportional coefficient of the data transmission delay index Hy, and both f1 and f2 are greater than 0.
5. 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 single chip microcomputer 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), is 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.
6. The environmental monitoring method according to claim 1, characterized in that: The abnormal coefficient Lgt in step S4 is determined by the abnormal model. The abnormal model is 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.
7. The environmental monitoring method according to claim 6, characterized in that: The step S4 further comprises: The abnormal coefficient Lgt is compared with the abnormal coefficient threshold, and according to the comparison result, it is determined in the environmental monitoring system based on the single chip microcomputer whether there is a problem with the single chip microcomputer; When the abnormal coefficient Lgt is greater than or equal to the abnormal coefficient threshold, it is determined that the single chip microcomputer 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 has no fault and no alarm is issued.
8. 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, the physical quantities include temperature, humidity, air quality, air pressure and light, and each physical quantity forms a data volume of four bytes.
9. 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 microcontroller 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 single chip microcomputer 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 single chip microcomputer within a set time period, and obtain the current instability index Ed according to the actual current data; 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 to compare the abnormal coefficient Lgt with the abnormal coefficient threshold to determine whether the single chip microcomputer fails according to the comparison result.
10. The environmental monitoring system according to claim 9, 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, the physical quantities include temperature, humidity, air quality, air pressure and light, and each physical quantity forms a data volume of four bytes.
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
Integrated single-chip microcomputer chip anomaly analysis system
CN111123786A
Self-checking reset method and device applied to switch
CN112506722A
Single-chip microcomputer power-on processing method and device
CN112783070A