Switching value and analog quantity acquisition system
By combining polling and interrupt, photoelectric isolation and filtering technologies, as well as multi-channel parallel acquisition and adaptive algorithms, the problem of low performance of switching and analog acquisition systems in the existing technology is solved, and fast response, high precision and resistance are achieved Interference collection effect.
Patent Information
- Application Number
- CN202411591646.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-08
- Publication Date
- 2025-02-18
AI Technical Summary
The existing switching and analog acquisition systems have low performance in response time, anti-interference, signal integrity, accuracy and real-time, and are difficult to meet the needs of rapidly changing environments and complex systems.
Signal acquisition is performed using a combination of polling and interruption, and interference sources are monitored through photoelectric isolation and filtering technology; analog quantity acquisition is performed using multi-channel parallel acquisition mode and digital filtering technology, and dynamically adjust the acquisition range using adaptive algorithms; real-time The operating system optimizes response time; designs storage policies in the data storage module to realize data inspection, error handling and secure storage.
The response speed, anti-interference, signal integrity and data accuracy of the switching quantity and analog quantity acquisition system are improved, ensuring the high performance and reliability of the system.
Smart Images

Figure CN119472424A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of data acquisition, in particular to a switch quantity analog quantity acquisition system. Background Art
[0002] Switching quantity and analog quantity are two different types of signals, and they play different roles in digital circuits and automated control systems. Switching quantity refers to the acquisition and output of discontinuous signals, including remote signal acquisition and remote control output. The purpose of switching quantity control is to make the PLC generate corresponding switching quantity outputs based on the current input combination and historical input sequence, so that the system can work in a certain order. Analog quantity refers to the amount of a variable that changes continuously within a certain range, and can take any value within a certain range. Analog quantity usually refers to continuously changing physical quantities such as voltage, current, pressure, speed, and flow. In automated control systems, analog quantity control usually involves converting analog signals into digital signals for processing.
[0003] In practical applications, the acquisition of switching quantities and analog quantities can realize comprehensive monitoring and control of equipment. However, the existing switching quantity and analog quantity acquisition systems have some defects and challenges in practical applications, including: 1) Switching quantity acquisition system: slow response time, unable to meet the needs of rapidly changing environments; susceptible to electromagnetic interference, resulting in erroneous signal acquisition; in complex system environments, signal loss or delay may occur, affecting the stability of the system. 2) Analog quantity acquisition system: the acquisition of analog signals may be affected by noise, resulting in low data accuracy; the range of some sensors is limited and cannot meet various measurement requirements; the analog-to-digital converter (ADC) may introduce delays during the conversion process, affecting real-time performance. In short, the existing switching quantity and analog quantity system performance is low, affecting the intelligence and automation process of the equipment. Therefore, the present invention proposes a switching quantity analog quantity acquisition system to solve the above problems. Summary of the invention
[0004] In order to overcome the shortcomings of the prior art, the purpose of the present invention is to provide a switch quantity analog quantity acquisition system, which not only ensures the response speed, anti-interference and signal integrity during switch quantity acquisition, but also ensures high precision and real-time performance during analog quantity acquisition, thereby greatly improving the performance of the acquisition system.
[0005] To achieve the above object, the present invention provides the following solution: a switching analog quantity acquisition system, comprising:
[0006] The switch quantity acquisition module is used to collect signals by combining polling and interruption, and monitor the interference source in real time during the signal acquisition process through photoelectric isolation and filtering technology;
[0007] Analog quantity acquisition module, used to collect data in multi-channel parallel acquisition mode, eliminate high-frequency noise and low-frequency interference using digital filtering technology, and dynamically adjust the acquisition range using adaptive algorithms;
[0008] The fast response module is used to use the real-time operating system to perform task processing and performance optimization, making the system response time in milliseconds;
[0009] The data storage module is used to design storage strategies in the main program to implement data checking, error handling, and security storage.
[0010] Optionally, the switch quantity acquisition module includes:
[0011] The signal acquisition unit is used to collect signals, and during the acquisition process, the GPIO pins of the microcontroller are used to configure external interrupts to implement interrupt service routines, and then polling is implemented through the main loop to process corresponding state changes;
[0012] The interference suppression unit is used to use the optoelectronic isolator to transmit information between the input and output of the switch signal and block high voltage and noise, use hardware filtering to smooth the signal in the switch signal line and remove high-frequency noise, and use software filtering to eliminate occasional noise and pulse interference from the data obtained by polling.
[0013] Optionally, the signal acquisition unit includes:
[0014] An interrupt subunit, used to trigger the interrupt service program according to the change of the switch signal, and perform timestamp recording and current signal saving operations during the interrupt process; wherein the interrupt service program includes rising edge interrupt, falling edge interrupt or bidirectional trigger;
[0015] The polling subunit is used to set a polling mechanism in the interrupt service program to perform periodic checks and obtain new open quantity states. When an interrupt is detected, the saved state is set as the data structure required by the main program so that the main program processes the corresponding state changes.
[0016] Optionally, the analog quantity acquisition module includes:
[0017] Multi-channel parallel acquisition unit, used to connect various analog signal sources to different input channels of ADC, and then configure the sampling rate and resolution of ADC according to application requirements to achieve parallel signal acquisition;
[0018] A digital filtering unit, used for transmitting the collected parallel signals to an adaptive filter for real-time filtering processing; wherein a dynamic adjustment mechanism is provided inside the adaptive filter;
[0019] The adaptive unit is used to use an adaptive filter to monitor the strength of the analog signal in real time by adopting global monitoring or local monitoring based on a sliding window, and compare the monitored signal strength with a preset threshold to obtain an adjustment range, and then dynamically adjust the sampling range and gain of the ADC based on the adjustment range and signal strength.
[0020] Optionally, the dynamic adjustment mechanism includes:
[0021] A noise measurement subunit, used to monitor and evaluate the environmental noise in real time using the signal-to-noise ratio, and dynamically adjust the step size factor according to the noise level;
[0022] A signal feature analysis subunit, used to evaluate the signal change trend by using a moving window average or RSS and to adjust the order of the adaptive filter in real time based on the change trend;
[0023] The error feedback mechanism subunit is used to preset a trigger parameter and recalculate the initial coefficient of the adaptive filter when the error is greater than or equal to the trigger parameter to eliminate error accumulation.
[0024] Optionally, the rapid response module includes:
[0025] The task processing unit is used to divide tasks based on the independence principle and the priority principle, so as to obtain high-priority tasks for collecting switch quantities and key analog quantities and low-priority tasks for data storage and non-real-time communication;
[0026] An interrupt priority unit, used for setting an interrupt priority based on the interrupt service program, wherein the interrupt of the critical signal of the high priority task takes precedence over the execution of the low priority task;
[0027] The time scheduling unit is used to use the timer to collect data regularly for tasks that need to be executed regularly, and to use the time slice scheduling strategy to allocate the time that tasks occupy the CPU;
[0028] The optimization unit is used to implement memory management using static memory allocation, monitor task response time and execution cycle using performance analysis tools, and then optimize the code based on the performance analysis results to reduce the calculation process.
[0029] Optionally, the data storage module includes:
[0030] Storage structure unit, used to define data categories and data storage methods;
[0031] A data verification unit, used to perform data integrity checks and save integrity marks for each piece of data;
[0032] The data correction unit is used to capture exceptions and record error information in the log, and then correct the error through retry operations or through active user intervention;
[0033] The data security unit is used to encrypt and store sensitive data user information and system configuration using symmetric or asymmetric encryption algorithms, and set encryption protocols during collection and transmission.
[0034] Optionally, the data categories in the storage structure unit include switch quantities and analog quantities, the switch quantities and the analog quantities both include timestamps, data values and data integrity identifiers, and the data storage methods include queues and time series databases.
[0035] The present invention discloses the following technical effects by providing a switch quantity analog quantity acquisition system:
[0036] 1. Fast response and accuracy: Using polling combined with interruption to collect signals is an effective method that can reduce the probability of signal loss while responding quickly. At the same time, combined with photoelectric isolation and filtering technology, the accuracy and stability of the collected signals can be ensured. The systematic implementation process of this method can effectively improve the performance of the acquisition system.
[0037] 2. High-precision acquisition and anti-interference: The use of multi-channel parallel acquisition mode can effectively improve the acquisition speed and reduce conversion delay; at the same time, the combination of digital filtering technology and adaptive algorithm can ensure the accuracy of the collected data and adapt to different signal strengths, and cope with various signal strengths and interference in practical applications. This comprehensive method ensures the accuracy of the data and the reliability of the system.
[0038] 3. System reliability: The use of real-time operating system can ensure the response time of switch quantity and analog quantity acquisition system to millisecond level. Reasonable task division, priority setting, interrupt service, task interval and resource optimization can improve the reliability of the system and make it perform well in complex applications.
[0039] 4. Storage security: An efficient and reliable data storage and processing mechanism is implemented in the main program of the switch quantity and analog quantity acquisition system. From data integrity check, error handling, error correction to data security assurance, it provides strong support for the stability and reliability of the system; this can not only improve the performance of the system in practical applications, but also lay a good foundation for subsequent data decision support.
[0040] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0042] Figure 1 A schematic diagram of a system architecture provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0043] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0044] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0045] like Figure 1 As shown, the present invention provides a switch quantity analog quantity acquisition system, comprising:
[0046] 1. Switch quantity acquisition module. It is used to collect signals by combining polling and interruption, and monitor interference sources in real time during the signal acquisition process through photoelectric isolation and filtering technology; the switch quantity acquisition module includes:
[0047] 1.1 Signal Acquisition Unit
[0048] 1.11 is used for signal acquisition, and during the acquisition process, the GPIO pin of the microcontroller is used to configure external interrupts to implement the interrupt service routine (ISR). When the switch signal changes (such as switching from high level to low level or vice versa), the interrupt service routine (ISR) is triggered. It can be set to rising edge interrupt, falling edge interrupt, or bidirectional trigger to capture all changes in the signal.
[0049] ISR implementation: In the interrupt service routine, quickly process signal changes: record timestamps for subsequent analysis of signal change time. Save the current signal status (high or low) to a temporary variable or buffer, and notify the main program for further processing. ISR should be as short as possible to avoid long delays that affect the real-time performance of the system.
[0050] 1.12 Polling is then implemented through the main loop to process the corresponding state changes; the signal acquisition unit includes:
[0051] Interrupt subunit: used to trigger the interrupt service program according to the change of the switch signal, and perform timestamp recording and current signal saving operations during the interrupt process; wherein, the interrupt service program includes rising edge interrupt, falling edge interrupt or bidirectional trigger;
[0052] Polling subunit: used to set up a polling mechanism in the interrupt service program to perform periodic checks and obtain new open quantity states. When an interrupt is detected, the saved state is set to the data structure required by the main program (such as a FIFO queue, a ring buffer, etc.), so that the main program can process the corresponding state changes in each polling and store data for subsequent analysis.
[0053] The polling subunit is set with an appropriate polling interval, and a reasonable polling interval is set according to the application and performance to avoid wasting CPU resources due to frequent polling while ensuring the system.
[0054] 1.2 Interference suppression unit
[0055] Isolation technology: used to use optoelectronic isolators to transmit information between the input and output of switching signals and block high voltage and noise to ensure accurate signal acquisition.
[0056] Filtering technology: Use hardware filtering to smooth signals in switch signal lines, remove high-frequency noise, and effectively reduce false positives caused by jitter; use software filtering (such as using a moving average filter or a median filter) to eliminate occasional noise and pulse interference in the data obtained through polling.
[0057] 2. Analog quantity acquisition module. It is used to collect data in multi-channel parallel acquisition mode, eliminate high-frequency noise and low-frequency interference using digital filtering technology, and dynamically adjust the acquisition range using adaptive algorithms; the analog quantity acquisition module includes:
[0058] 2.1 Multi-channel parallel acquisition unit
[0059] It is used to connect various analog signal sources to different input channels of the ADC, and then configure the sampling rate and resolution of the ADC according to application requirements to achieve parallel signal acquisition; the acquisition process is:
[0060] Initialize the ADC through the controller and enable sampling of all channels;
[0061] Define the sampling interval to ensure that enough data points are obtained to adapt to signal changes;
[0062] A synchronous start signal is used to ensure that all input channels are sampled at the same timestamp to facilitate subsequent data analysis and processing.
[0063] 2.2 Digital Filter Unit
[0064] Used to transmit the collected parallel signals to an adaptive filter (the cutoff frequency needs to be determined in the filter design to ensure that unnecessary noise in the signal can be effectively filtered) for real-time filtering. Adaptive filter types, commonly used are FIR (finite impulse response) filters: simple and easy to implement, suitable for most applications. IIR (infinite impulse response) filters: can use the same number of coefficients more effectively, suitable for applications that require fast response. Adaptive filters are usually based on FIR or IIR type designs, combined with adaptive algorithms to adjust the filter coefficients.
[0065] The adaptive filter is internally provided with a dynamic adjustment mechanism; the dynamic adjustment mechanism includes:
[0066] Noise measurement subunit: used to monitor environmental noise in real time. The signal-to-noise ratio can be used to monitor and evaluate environmental noise in real time, and the step factor can be dynamically adjusted according to the noise level. When the noise level is high, the step factor is appropriately increased to speed up convergence, and when the noise level decreases, the step factor is reduced to maintain stability.
[0067] Signal feature analysis subunit: used to evaluate the signal change trend using moving window average or RSS and adjust the order of the adaptive filter in real time based on the change trend; when the signal feature changes significantly, the filter order can be increased to better adapt to the change.
[0068] Error feedback mechanism subunit: used to preset trigger parameters, and recalculate the initial coefficients of the adaptive filter when the error is greater than or equal to the trigger parameters to avoid long-term error accumulation.
[0069] 2.3 Adaptive Unit
[0070] It is used to monitor the strength of analog signals in real time by using adaptive filters, global monitoring or local monitoring based on sliding windows, and compare the monitored signal strength with the preset threshold to obtain the adjustment range, and then dynamically adjust the sampling range and gain of the ADC based on the adjustment range and signal strength. For example, when the signal strength is low, the gain is automatically increased to improve the signal resolution; when the signal strength is too high, the gain is reduced to avoid saturation.
[0071] 3. Rapid response module. It is used to use the real-time operating system to process tasks and optimize performance, so that the system response time is in the millisecond level; the rapid response module includes:
[0072] 3.1 Task Processing Unit
[0073] It is used to divide tasks based on the principles of independence and priority. Each task is responsible for a specific task, such as switch quantity acquisition, analog quantity acquisition, data and communication tasks; high priority tasks and low priority tasks are obtained.
[0074] High priority tasks: Set switch quantity acquisition and key analog quantity acquisition tasks as high priority tasks to ensure rapid response when the signal changes.
[0075] Low-priority tasks: Set tasks such as data storage and non-real-time communication as low-priority tasks to reduce the impact on high-priority tasks.
[0076] 3.2 Interrupt Priority Unit
[0077] The interrupt service routine is used to set the interrupt priority, and the interrupt of the critical signal of the high priority task takes precedence over the execution of the low priority task.
[0078] Among them, the interrupt service program should be as short as possible to quickly complete the signal collection and pass the data to the task for processing.
[0079] 3.3 Time Scheduling Unit
[0080] It is used to use timers to collect data regularly for tasks that need to be executed regularly, and use time slice scheduling strategies to allocate the time that tasks occupy the CPU.
[0081] 3.4 Optimization Unit
[0082] Resource management and optimization: Use static memory allocation to implement memory management and avoid delays caused by dynamic allocation; monitor the execution time of each task, adjust task priority reasonably, and ensure that the system remains responsive under high load.
[0083] Performance monitoring and optimization: Use performance analysis tools to monitor task response time and execution cycle, and then optimize the code based on the performance analysis results to reduce unnecessary calculations and delays.
[0084] 4. Data storage module, used to design storage strategies in the main program to implement data checking, error handling, and security storage. The data storage module includes:
[0085] 4.1 Storage Structure Unit
[0086] It is used to define data categories and data storage methods; the data categories include switch quantities and analog quantities, both of which include timestamps, data values, and data integrity identifiers, and the data storage methods include queues and time series databases. Data is first stored in the queue, and when the queue reaches the number, it is stored using the time series database.
[0087] 4.2 Data Verification Unit
[0088] Used to perform data integrity checks and save integrity marks for each piece of data (such as CRC value, hash value, etc.).
[0089] 4.3 Data Correction Unit
[0090] It is used to capture exceptions and record error information in the log, and then correct the error by retrying the operation or through active user intervention.
[0091] 4.4 Data Security Unit
[0092] It is used to encrypt and store sensitive data, user information, and system configuration using symmetric or asymmetric encryption algorithms, and set encryption protocols during collection and transmission to ensure the security of data during network transmission.
[0093] Therefore, the present invention provides a switch quantity analog quantity acquisition system, which not only ensures the response speed, anti-interference and signal integrity during switch quantity acquisition, but also ensures high precision and real-time performance during analog quantity acquisition, thereby greatly improving the performance of the acquisition system.
[0094] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0095] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of the present invention. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A switch quantity analog quantity acquisition system, characterized in that: include: The switch quantity acquisition module is used to collect signals by combining polling and interruption, and monitor the interference source in real time during the signal acquisition process through photoelectric isolation and filtering technology; Analog quantity acquisition module, used to collect data in multi-channel parallel acquisition mode, eliminate high-frequency noise and low-frequency interference using digital filtering technology, and dynamically adjust the acquisition range using adaptive algorithms; The fast response module is used to use the real-time operating system to perform task processing and performance optimization, making the system response time in milliseconds; The data storage module is used to design storage strategies in the main program to implement data checking, error handling, and security storage.
2. A switch quantity analog quantity acquisition system according to claim 1, characterized in that: The switch quantity acquisition module comprises: The signal acquisition unit is used to collect signals, and during the acquisition process, the GPIO pins of the microcontroller are used to configure external interrupts to implement interrupt service routines, and then polling is implemented through the main loop to process corresponding state changes; The interference suppression unit is used to use the optoelectronic isolator to transmit information between the input and output of the switch signal and block high voltage and noise, use hardware filtering to smooth the signal in the switch signal line and remove high-frequency noise, and use software filtering to eliminate occasional noise and pulse interference from the data obtained by polling.
3. A switch quantity analog quantity acquisition system according to claim 2, characterized in that: The signal acquisition unit comprises: An interrupt subunit, used to trigger the interrupt service program according to the change of the switch signal, and perform timestamp recording and current signal saving operations during the interrupt process; wherein the interrupt service program includes rising edge interrupt, falling edge interrupt or bidirectional trigger; The polling subunit is used to set a polling mechanism in the interrupt service program to perform periodic checks and obtain new open quantity states. When an interrupt is detected, the saved state is set as the data structure required by the main program so that the main program processes the corresponding state changes.
4. A switch quantity analog quantity acquisition system according to claim 3, characterized in that: The analog quantity acquisition module comprises: Multi-channel parallel acquisition unit, used to connect various analog signal sources to different input channels of ADC, and then configure the sampling rate and resolution of ADC according to application requirements to achieve parallel signal acquisition; A digital filtering unit, used for transmitting the collected parallel signals to an adaptive filter for real-time filtering processing; wherein a dynamic adjustment mechanism is provided inside the adaptive filter; The adaptive unit is used to use an adaptive filter to monitor the strength of the analog signal in real time by adopting global monitoring or local monitoring based on a sliding window, and compare the monitored signal strength with a preset threshold to obtain an adjustment range, and then dynamically adjust the sampling range and gain of the ADC based on the adjustment range and signal strength.
5. A switch quantity analog quantity acquisition system according to claim 4, characterized in that: The dynamic adjustment mechanism includes: A noise measurement subunit, used to monitor and evaluate the environmental noise in real time using the signal-to-noise ratio, and dynamically adjust the step size factor according to the noise level; A signal feature analysis subunit, used to evaluate the signal change trend by using a moving window average or RSS and to adjust the order of the adaptive filter in real time based on the change trend; The error feedback mechanism subunit is used to preset a trigger parameter and recalculate the initial coefficient of the adaptive filter when the error is greater than or equal to the trigger parameter to eliminate error accumulation.
6. A switch quantity analog quantity acquisition system according to claim 5, characterized in that: The rapid response module comprises: The task processing unit is used to divide tasks based on the independence principle and the priority principle, so as to obtain high-priority tasks for collecting switch quantities and key analog quantities and low-priority tasks for data storage and non-real-time communication; An interrupt priority unit, used for setting an interrupt priority based on the interrupt service program, wherein the interrupt of the critical signal of the high priority task takes precedence over the execution of the low priority task; The time scheduling unit is used to use the timer to collect data regularly for tasks that need to be executed regularly, and to use the time slice scheduling strategy to allocate the time that tasks occupy the CPU; The optimization unit is used to implement memory management using static memory allocation, monitor task response time and execution cycle using performance analysis tools, and then optimize the code based on the performance analysis results to reduce the calculation process.
7. A switch quantity analog quantity acquisition system according to claim 6, characterized in that: The data storage module comprises: Storage structure unit, used to define data categories and data storage methods; A data verification unit, used to perform data integrity checks and save integrity marks for each piece of data; The data correction unit is used to capture exceptions and record error information in the log, and then correct the error through retry operations or through active user intervention; The data security unit is used to encrypt and store sensitive data user information and system configuration using symmetric or asymmetric encryption algorithms, and set encryption protocols during collection and transmission.
8. A switch quantity analog quantity acquisition system according to claim 7, characterized in that: The data categories in the storage structure unit include switch quantities and analog quantities, both of which include timestamps, data values and data integrity identifiers, and the data storage methods include queues and time series databases.
Citation Information
Patent Citations
General multi-channel data collection system
CN103336667A
Intelligent power distribution monitoring management device
CN107807576A
Marine automation system and cloud server communication method
CN116938982A
Low-pass filtering method and system for quick response of analog quantity signal
CN117833914A
Embedded software interface asynchronous application execution system and method
CN118132271A
Cited By
Multi-channel analog quantity switching value acquisition system
CN120979443A
A multi-channel analog and digital signal acquisition system
CN120979443B
Production equipment yield evaluation method, system, equipment and storage medium
CN121188550A