High integration high-speed PLC slave node communication method and system
By assigning fixed priorities, real-time monitoring, and dynamic scheduling to PLC slave nodes, the problem of processor overload in high-speed PLC slave nodes under power line channel interference is solved, achieving a balance between communication reliability and control real-time performance, and avoiding processor resource contention caused by retransmission and detection.
Patent Information
- Application Number
- CN202611319660.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-28
- Publication Date
- 2026-11-24
AI Technical Summary
In the fields of smart homes and industrial IoT, when the power line channel is interfered with, the high-speed PLC slave node SoC chip experiences frequent retransmission of communication tasks and increased processor load due to route probing, resulting in communication delays and control task time conflicts, forming a vicious cycle.
By using a built-in hardware timer to assign fixed priorities to PLC communication interruptions and user control tasks, the system monitors the communication error rate and retransmission count in real time, dynamically adjusts the task scheduling order, and adjusts the route detection frequency and retransmission waiting time in conjunction with the system, ensuring that critical tasks can maintain network online even under channel interference conditions.
It achieves joint assurance of communication reliability and control real-time performance under channel interference conditions, reduces the risk of vicious competition for processor resources, and ensures both communication stability and control real-time performance.
Smart Images

Figure CN123164073A_ABST
Abstract
Description
Technical Field
[0001] This invention proposes a highly integrated, high-speed PLC slave node communication method and system, which relates to the field of node communication technology, specifically to the field of highly integrated, high-speed PLC slave node communication technology. Background Technology
[0002] In the fields of smart homes and industrial IoT, high-speed PLC slave node SoC chips need to simultaneously handle communication protocol processing and user control tasks on a single processor. When power line channels are interfered with, leading to an increased packet error rate, frequent automatic retransmissions and route probing will significantly increase the processor load. If the scheduling strategy remains unchanged, communication tasks will encroach on control task time, causing PWM jitter or beacon reception timeouts and network disconnection; while user tasks occupying the processor will exacerbate communication latency, creating a vicious cycle. Summary of the Invention
[0003] This invention provides a highly integrated, high-speed PLC slave node communication method and system to solve the above-mentioned problems: This invention proposes a highly integrated, high-speed PLC slave node communication method and system, the method comprising: S1. By using the built-in hardware timer, PLC communication interrupts and user control tasks are divided into fixed priorities to obtain the basic response timing and processor idle window. S2. Real-time threshold monitoring of communication packet error rate and retransmission count is performed using basic response timing to obtain the degree of interference impact. S3. Dynamically adjust the task scheduling order based on the degree of interference to obtain the execution window for critical tasks; S4. Adjust the routing detection frequency and retransmission waiting time in a coordinated manner through the critical task execution window to achieve a balanced working mode.
[0004] Furthermore, the system includes: The interrupt partitioning module is used to partition PLC communication interrupts and user control tasks with fixed priorities through a built-in hardware timer, so as to obtain the basic response timing and processor idle window. The real-time monitoring module is used to perform real-time threshold monitoring of communication packet error rate and retransmission count through basic response timing to obtain the degree of interference impact; The dynamic adjustment module is used to dynamically adjust the task scheduling order based on the degree of interference, thereby obtaining the execution window for critical tasks; The linkage adjustment module is used to adjust the route detection frequency and retransmission waiting time in a coordinated manner through the critical task execution window to obtain a balanced working mode.
[0005] The beneficial effects of this invention are as follows: By sequentially advancing through four stages—priority division, status monitoring, dynamic scheduling, and linkage adjustment—it solves the processor congestion problem caused by communication task overload in single-chip PLC slave nodes under channel interference conditions, achieves joint assurance of communication reliability and control real-time performance, and reduces the risk of vicious competition for processor resources caused by excessive retransmission and frequent probing. Attached Figure Description
[0006] Figure 1 This is a schematic diagram of a highly integrated, high-speed PLC slave node communication method; Figure 2 Flowchart for configuring fixed priority levels for interrupt sources and acquiring free windows; Figure 3 Flowchart for determining the continuity of idle intervals and merging continuous idle periods; Figure 4 A flowchart for the comprehensive determination of dual-index channel interference status and the quantification of interference impact; Figure 5 A flowchart for classifying and quantifying the direction and magnitude of interruption frequency changes; Figure 6 A flowchart for dynamic task scheduling priority adjustment and critical task window assurance based on channel state; Figure 7 Flowchart for progressively assessing and statistically confirming the on-time completion status of key tasks; Figure 8 Flowchart for event-triggered route detection and retransmission timeout linkage adjustment; Figure 9 Flowchart for jointly verifying the balance between communication stability and control real-time performance; Figure 10 This is a schematic diagram of the gateway's uplink connection. Figure 11 This is a schematic diagram of the application from a slave node. Detailed Implementation
[0007] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.
[0008] Example 1 One embodiment of the present invention provides a highly integrated, high-speed PLC slave node communication method, the method comprising: S1. By using the built-in hardware timer, PLC communication interrupts and user control tasks are divided into fixed priorities to obtain the basic response timing of each task and the processor idle window under normal power line conditions. S2. Real-time threshold monitoring of communication packet error rate and retransmission count is performed using basic response timing to determine whether the current channel has entered an interference state and the degree of interference impact on processor load. S3. Dynamically adjust the task scheduling order based on the degree of interference to obtain the critical task execution window that can maintain the network online status even when the channel deteriorates. S4. By adjusting the routing probe frequency and retransmission waiting time in a linked manner through the critical task execution window (actively slowing down the probe and shortening the waiting time when the interference is stronger), a balanced working mode that is acceptable for both communication stability and control real-time performance is achieved, thereby avoiding excessive retransmissions that exacerbate processor congestion. Figure 1 As shown.
[0009] By utilizing the processor's built-in hardware timer resources, PLC communication interrupt tasks and user control tasks are processed in a hierarchical manner according to a fixed priority, thereby determining the response order of each task under normal operating conditions and identifying the time intervals in which the processor can be utilized during idle periods.
[0010] Using the obtained standard response timing as a reference, the error rate of data packets and the number of data retransmissions during the communication process are continuously monitored to determine the degree of channel interference and its impact on processor operation.
[0011] Based on the assessment of the impact of interference, the scheduling priority of each software task is flexibly adjusted to ensure that critical tasks necessary to maintain connectivity when network conditions are poor can receive sufficient processing time.
[0012] Based on the time window in which critical tasks can be executed on time, the frequency of route probing and the timing of retransmission waiting are adjusted in a coordinated manner, so as to achieve a balance between communication reliability and control real-time performance.
[0013] By configuring the interrupt priority control register, the hardware priority of the PLC receive completion interrupt and transmit completion interrupt is set to the highest level, and this configuration is permanently locked to form a fixed hardware priority lookup table.
[0014] Based on the generated hardware priority configuration table, the PWM cycle matching interrupt is assigned the second highest priority, and the ADC sampling completion interrupt is assigned the normal priority, thus obtaining a complete fixed priority sorting table for all interrupt sources.
[0015] After configuring the processor according to the fixed priority sorting table, the module was run for a long time in a standard laboratory environment to record the trigger time and exit time of each interrupt in its entirety, and to obtain the raw data of the execution time of each interrupt service routine and its subsequent idle interval.
[0016] Based on the execution time of each interrupt and the time period information in the original record table, blank time periods in which no interrupts were triggered are filtered out, and these time periods are merged to finally obtain the processor idle window and basic response timing.
[0017] The idle intervals that occur after each interruption are completed are sorted in ascending order of duration to obtain the duration distribution sequence of all idle intervals.
[0018] Based on the duration distribution sequence, check whether there is an interruption trigger point between the start times of two adjacent idle intervals, thereby dividing the continuous idle intervals into the same group.
[0019] All idle intervals within the same group are joined end-to-end and merged, including the execution time of each interval and the brief interruptions between them, and the start and end times and total duration of the merged continuous idle period are calculated.
[0020] From all the merged consecutive idle periods, select the periods whose total duration reaches the preset minimum available threshold, remove fragmented periods that do not meet the threshold, and output them in chronological order to obtain the processor idle window and basic response timing.
[0021] The number of erroneous packets in each batch of received data packets is cumulatively counted, and the error rate of the current batch is continuously statistically analyzed.
[0022] The number of times automatic retransmission is triggered in each batch of transmission attempts is accumulated and counted to continuously calculate the retransmission rate of the current batch.
[0023] The statistically obtained packet error rate and retransmission rate are compared one by one with the preset packet error rate alarm threshold and retransmission rate alarm threshold to determine whether the limits have been exceeded.
[0024] Based on the results of exceeding the limits of packet error rate and retransmission rate, it is comprehensively determined whether the channel is currently in an interference state. When it is determined to be in an interference state, the change of the frequency of interruption within a unit time relative to the reference value is quantitatively compared to obtain the degree of interference impact.
[0025] A logical OR operation is performed on the packet error rate exceeding the limit and the retransmission rate exceeding the limit. If either one exceeds the limit, the result is true, and a comprehensive judgment flag is obtained to determine whether the channel is currently in an interference state.
[0026] Branch processing is performed based on the comprehensive judgment flag. If the flag is in a normal state, the subsequent quantization steps are skipped and the normal flag is output directly. If the flag is in an interference state, the analysis process of interrupting the frequency change amplitude is started to obtain the enable signal for whether to enter the quantization analysis.
[0027] After the enable signal starts the analysis, the total number of interrupts per unit time is read and compared with the baseline value of the number of interrupts under normal conditions to determine the direction of change in the interrupt frequency, and the increase is divided into three levels: slight, moderate and significant.
[0028] The results of the change direction determination and the change magnitude level are combined into a unified state description. The normal state is assigned the value of no burden, and the interference state is assigned the corresponding burden level labels according to slight, moderate and significant, respectively, to obtain the final quantitative classification result of the interference impact degree.
[0029] Determine whether the scheduling adjustment process needs to be initiated based on the current channel state. Adjustment is only initiated under interference conditions, while the original scheduling remains unchanged under normal conditions, and a scheduling adjustment enable flag is obtained.
[0030] After the scheduling adjustment process is started, the priorities of all tasks are re-divided. The PLC beacon frame receiving task is set to the highest software priority, the routing table maintenance task is set to the second highest software priority, and the user PWM, ADC, and serial port tasks retain their original priorities. The adjusted software task priority ranking list is obtained.
[0031] According to the new software task priority list, the scheduling algorithm configuration of the task scheduler is updated so that ready tasks are executed in the new priority order, and high-priority tasks can preempt low-priority tasks, thus obtaining the dynamic scheduling strategy configuration that has taken effect.
[0032] After the dynamic scheduling strategy takes effect, observe the actual execution of the beacon frame reception task and the route maintenance task to confirm that they are always completed before the specified deadline and are not delayed by user tasks, thus obtaining a confirmation result that the execution window of the critical tasks has been guaranteed.
[0033] After the dynamic scheduling strategy is configured and takes effect, the actual completion time of each beacon frame receiving task is read and compared with the preset deadline of the task. The judgment result of whether the beacon frame receiving task is completed on schedule is recorded one by one.
[0034] Referring to the successive determination records of the beacon frame reception task, the start time of the route maintenance task within the same period is determined, its actual completion time is read and matched with the preset end time of the period, and the route maintenance task is determined one by one to determine whether it is completed on schedule.
[0035] By comprehensively statistically analyzing the successive judgment records of the two types of critical tasks, calculating whether the proportion of on-time completion times to the total number of observations meets the preset requirements, and obtaining statistical results on whether the current scheduling strategy effectively guarantees the execution window of critical tasks.
[0036] Based on the statistical results, the protection status of the critical task execution window is finally confirmed. If the preset ratio requirement is met, it is confirmed as protected. If it is not met, it is marked as insufficient protection and an alarm is triggered, thus obtaining the final confirmation result of the protection status of the critical task execution window.
[0037] Based on the guarantee status of the critical task execution window, check the triggering conditions of the current route probe operation, change the triggering method to trigger probe only when the channel state changes, cancel the periodic timed probe, and obtain the adjusted route probe triggering rules.
[0038] The routing table update process is controlled according to the adjusted route probe triggering rules. When a probe is triggered, the update is performed. When no probe is triggered, the existing routing table is used, resulting in an adaptive control mechanism in which the route probe frequency is automatically adjusted according to the channel state.
[0039] According to the adaptive control mechanism, the timeout duration of the retransmission waiting timer is actively shortened under interference conditions to avoid the processor being blocked in the waiting for acknowledgment state for a long time, thus obtaining a retransmission timeout configuration that is linked to the channel state.
[0040] The overall effect of the route detection adaptive control mechanism and retransmission timeout configuration was jointly verified. It was confirmed that the number of detections was reduced and the waiting time was shortened under interference conditions. At the same time, the network remained connected and the PWM output waveform was free of jitter, resulting in a balanced working mode in which both communication stability and control real-time performance were acceptable.
[0041] After the adaptive control mechanism and retransmission timeout configuration take effect, the actual number of route probes initiated in the current unit time is read and compared with the baseline number of probes in the normal environment. If the actual number is not greater than the baseline number, a verification flag is obtained to determine whether the route probe frequency meets the slowdown requirement.
[0042] Provided that the verification flag meets the requirements, the current network connectivity is detected by checking whether the most recent beacon frame reception timed out and whether there are valid neighbor entries in the routing table, and thus obtaining the connectivity flag to determine whether the network remains connected.
[0043] Provided that the connectivity flag is connected, the waveform of the PWM output pin is sampled, and the consistency of the current waveform's period and duty cycle with the expected set value is checked to confirm that there are no sudden changes or periodic jitters, thereby obtaining a real-time control flag indicating whether the PWM waveform is stable.
[0044] The verification flag, connectivity flag, and control real-time flag are combined and calculated. If all three flags are satisfied, connected, and stable, the joint verification is considered successful. If any one of them is not satisfied, the verification is considered unsuccessful, thus obtaining the final confirmation result of the balanced working mode.
[0045] PLC physical layer communication is based on advanced OFDM orthogonal multicarrier technology and supports the IEEE 1901.1 PLC standard, enabling stable and reliable communication and data transmission over wires. Typical point-to-point communication distances can reach 100-300 meters. Supported frequency range: 2-12MHz, default operating frequency: 2.4-5.7MHz, typical communication rate >120kbps – 1.2Mbps, embedded PLC Mesh network technology, supports dynamic, adaptive multi-node MESH networking and real-time communication. Supports more than 512 slave nodes. This high-performance PLC receiver exhibits attenuation resistance exceeding 95dB under standard testing conditions. It integrates a high-speed M4 MCU, supporting secondary software development by the user. Lihe Micro provides relevant SDKs and APIs to facilitate application software development for users.
[0046] Using a gateway uplink connection, such as Figure 10 As shown.
[0047] The node application diagram is as follows: Figure 11 As shown.
[0048] The working principle and technical effects of the above solution are as follows: When the PLC slave node is running normally, its processor needs to handle two types of tasks simultaneously: one is PLC communication-related tasks, including physical layer interrupt response, data frame reception, beacon frame synchronization, routing table maintenance, etc.; the other is user control tasks, including PWM dimming output, ADC analog signal acquisition, serial port data transmission and reception, etc. These two types of tasks share the same processor core. When the communication task is busy, it will encroach on the processing time of the control task. Conversely, if the control task occupies the processor for a long time, it will lead to communication interruption response delays or even packet loss.
[0049] This method uses a built-in hardware timer to assign fixed priorities to PLC communication interrupts and user control tasks, ensuring that PLC communication interrupts always have the highest priority. This allows the basic response timing of each task and the processor idle window to be obtained under normal power line conditions. The basic response timing refers to the inherent response time sequence and duration of each interrupt task when there is no external interference. The processor idle window refers to the period during which all interrupts are not triggered and the processor can execute background tasks or enter a low-power state.
[0050] This method uses the obtained basic response timing as a benchmark reference value to monitor the packet error rate and retransmission count in real time during the communication process, and compares them with preset thresholds. The packet error rate reflects the signal quality of the receiving link, and the retransmission count reflects the acknowledgment success rate of the sending link. When either exceeds the threshold, the channel is determined to be in an interference state. At the same time, by comparing the difference between the current interruption frequency and the benchmark frequency, the degree of additional load caused by the interference to the processor is quantified.
[0051] This method dynamically adjusts the task scheduling order based on the degree of interference. Under interference conditions, critical tasks that maintain network online status (such as beacon frame reception and route maintenance) are elevated to the highest software priority, ensuring that these tasks are always completed before the specified deadline, thereby obtaining a critical task execution window that can still guarantee network connectivity when the channel deteriorates.
[0052] This method, based on the obtained critical task execution window, adjusts the route probing frequency and retransmission waiting time in a coordinated manner: when interference is stronger, the route probing frequency is actively slowed down to prevent probe frames from further aggravating channel congestion, while the waiting time for a single retransmission is shortened to prevent the processor from being blocked in the waiting-for-acknowledgment state for a long time. Through the above coordinated adjustment, a balanced operating mode that is acceptable in both communication stability and control real-time performance is finally achieved.
[0053] By implementing a sequential approach involving four stages—priority allocation, status monitoring, dynamic scheduling, and coordinated adjustment—the problem of processor congestion caused by communication task overload in single-chip PLC slave nodes under channel interference conditions is solved. This achieves joint assurance of communication reliability and control real-time performance, and reduces the risk of vicious competition for processor resources caused by excessive retransmissions and frequent probes.
[0054] In one embodiment of the present invention, S1 includes: By configuring the interrupt priority registers of PLC receive completion interrupt and PLC send completion interrupt, the highest priority of the two types of PLC communication interrupts is fixed and locked, so as to obtain a hardware priority configuration table in which communication interrupts always take precedence over all user interrupts. The PWM cycle matching interrupt and ADC sampling completion interrupt are assigned second-highest and normal priorities by using the hardware priority configuration table, thus obtaining a fixed priority level list of all interrupt sources. By using a fixed priority ranking list, the entire process of continuous operation of the module in a standard laboratory environment is recorded at each interrupt triggering time and exit time, and the original record table of the execution time of each interrupt service routine and its subsequent idle interval is obtained. By filtering and merging the time periods during which no interrupts were triggered using each execution time and the original record table, the start and end times of the processor's idle window and basic response timing under normal power line conditions are obtained, such as... Figure 2 As shown.
[0055] The working principle and technical effect of the above technical solution are as follows: The PLC slave node processor contains multiple interrupt sources, including PLC receive completion interrupt, PLC transmit completion interrupt, PWM cycle matching interrupt, and ADC sampling completion interrupt. These interrupt sources compete for processor resources simultaneously. If the priority configuration is improper, interrupts of user control tasks may disrupt communication interrupt processing during PLC communication, leading to the loss of communication data frames. This method addresses the PLC receive completion interrupt and PLC transmit completion interrupt by configuring the interrupt priority configuration register to solidify the hardware priority of these two PLC communication interrupts to the highest level and lock this configuration to prevent modification by subsequent operations. "Solidification" means that the priority setting remains effective once written and does not change with the software's running state; "locking" means that other software processes are prohibited from temporarily modifying this priority value. After this operation, whether it's PLC receive completion or transmit completion, the interrupt response will take priority over all user interrupts. Based on the PLC communication interrupt occupying the highest priority, this method, through the obtained hardware priority configuration table, assigns the remaining PWM cycle matching interrupt and ADC sampling completion interrupt the second highest priority and normal priority, respectively. The PWM period matching interrupt is used to generate a precise dimming period signal, and its timing accuracy directly affects the dimming quality, so it is given the second highest priority. The ADC sampling completion interrupt is used to acquire analog signals, and its requirements for response timeliness are relatively relaxed, so it is given a normal priority. This yields a complete fixed priority list of all interrupt sources from high to low.
[0056] This method writes the aforementioned priority ranking list into the processor and makes it effective. Then, it continuously runs the module in a standard laboratory environment, which refers to test conditions with no additional electromagnetic interference, stable power supply, and controllable power line background noise. Under these conditions, the trigger and exit times of each interrupt are recorded throughout the process, obtaining a raw record table of the execution time of all interrupt service routines and their subsequent idle intervals. Execution time refers to the length of time from the start of an interrupt trigger to the completion and exit of the interrupt service routine; subsequent idle intervals refer to the length of time from the completion of this interrupt execution to the next interrupt trigger.
[0057] This method filters out time periods when no interrupts are triggered by using the execution time of each interrupt and the original record table. In other words, it divides all blank time periods without interruption activity from the complete timeline, and arranges and merges these blank time periods in chronological order to obtain the start and end times of the processor idle window and the basic response timing under normal power line conditions.
[0058] By using a fixed priority configuration at the hardware level, the technical problem of packet loss caused by user interrupts potentially preempting communication interrupts is solved. This achieves absolute priority response of PLC communication interrupts among all interrupt sources, reduces communication timing uncertainty caused by interrupt nesting or preemption, and provides a stable and reliable benchmark reference for identifying idle windows and monitoring channel interference in subsequent steps.
[0059] In one embodiment of the present invention, the step of filtering and merging time periods during which no interrupts are triggered by each execution time and the original record table to obtain the start and end times of the processor idle window and the basic response timing under normal power line conditions includes: The idle intervals after each interrupt are sorted by duration (from shortest to longest) by the execution time and the original record table to obtain the duration distribution sequence of all idle intervals; By analyzing the duration distribution sequence, the continuity between adjacent intervals is checked at the start time of each idle interval (to determine whether there is an interruption trigger point between two adjacent idle intervals), thus obtaining idle time period groups with continuity. By grouping idle periods into groups, a merging operation is performed on all intervals within each group, connecting the beginning and end (including the execution time of each idle interval within the same group and the time spent on brief interruptions between them). This yields the start and end times and the total duration of each merged consecutive idle period. By filtering and retaining time periods whose duration reaches a preset minimum available threshold within each consecutive idle period (time periods below the threshold are considered unusable fragmented time and are discarded), and arranging the retained time periods in chronological order, the start and end times of the processor idle window and basic response timing under normal power line conditions are obtained. Figure 3 As shown.
[0060] Specifically, by using the duration distribution sequence to check the continuity between adjacent idle intervals at their start times (determining whether there is an interruption trigger point between two adjacent idle intervals), continuous idle time period groups are obtained, including: The end time of the current idle interval to be checked is read by the duration distribution sequence, and the start time of the next adjacent idle interval is read to obtain the time interval endpoint pair between the current interval and the next interval. The time difference between two adjacent intervals is calculated by subtracting the end time of the current interval from the start time of the next interval, and the interval gap duration of the adjacent interval pair is obtained. The continuity determination result of whether the adjacent interval pairs belong to the same continuous idle group is obtained by comparing the interval gap duration with the preset maximum allowable gap threshold (if the gap duration is not greater than the threshold, it is determined to be continuous; if it is greater than the threshold, it is determined to be discontinuous). By traversing all adjacent interval pairs one by one and marking them into groups based on the continuity determination results (adjacent intervals determined to be continuous are grouped into the same group, and those determined to be discontinuous are broken as group boundaries), idle time period groups with continuity are obtained.
[0061] The working principle and technical effect of the above technical solution are as follows: After obtaining a large number of discrete idle intervals from the original record table, these discrete intervals need to be merged into a meaningful continuous idle period. However, not all adjacent idle intervals on the time axis can be merged. If two idle intervals are separated by an interrupt trigger point, they are essentially two fragmented times interrupted by an interrupt and cannot be regarded as the same continuous idle time.
[0062] This method reads the end time of the currently inspected free interval and the start time of the next adjacent free interval from the duration distribution sequence, and pairs these two times. An adjacent free interval refers to two free intervals arranged sequentially on the time axis, with the previous interval ending immediately followed by the next interval, and no other free intervals in between.
[0063] This method calculates the time difference between the start time of the next interval and the end time of the current interval to obtain the interval length between two adjacent intervals. This interval length reflects the time interval between two idle intervals. If the interval is zero or very small, it means that the two idle intervals are almost consecutive; if the interval is large, it means that there is an interruption in activity between them.
[0064] This method compares the calculated interval duration with a preset maximum allowable gap threshold for continuous judgment. This threshold is a pre-set tolerance value used to determine whether a small gap between two idle intervals can be ignored. If the gap duration is not greater than the threshold, the two adjacent idle intervals are determined to belong to the same continuous idle group, even if there is a very brief interruption in execution time between them, it will be regarded as part of the continuous idle; if the gap duration is greater than the threshold, the two adjacent idle intervals are determined not to belong to the same group, and the gap position is marked as the group boundary.
[0065] This method applies the aforementioned continuity determination process to all adjacent interval pairs, iterating through them one by one and assigning each adjacent interval pair to a group. Continuous intervals are grouped into the same group, while discontinuous intervals are separated by a boundary. After the iteration is complete, all idle intervals are divided into several groups. The idle intervals within each group are either continuous or have only negligible minor discontinuities on the time axis, forming idle time period groups with continuity.
[0066] By defining and applying a continuity threshold, the problem of how to merge discrete idle intervals into effective continuous idle windows is solved, achieving accurate clustering of processor idle time, avoiding misjudging fragmented idle time as available idle windows, and improving the accuracy of idle window identification.
[0067] In one embodiment of the present invention, S2 includes: By accumulating the number of erroneous packets in each batch of received data packets, the current packet error rate is continuously statistically analyzed to obtain the degree of packet error rate of the current batch. By accumulating the number of times automatic retransmission is triggered in each batch of sending attempts, the current retransmission rate is continuously statistically analyzed to obtain the degree of retransmission rate of the current batch. By comparing the preset packet error rate alarm threshold and retransmission rate alarm threshold one by one according to the degree of packet error rate and retransmission rate, the judgment results of packet error rate exceeding the limit and retransmission rate exceeding the limit are obtained. The channel state is comprehensively determined by the results of packet error rate exceeding the limit and retransmission rate exceeding the limit (if either exceeds the limit, it is determined to be an interference state; otherwise, it is a normal state). The change in the frequency of interruptions per unit time when the state is determined to be interference is quantitatively compared to obtain the degree of interference impact. Figure 4 As shown.
[0068] The working principle and technical effect of the above technical solution are as follows: After obtaining the basic response timing and processor idle window under normal power line environment, it is necessary to monitor in real time whether the current channel has entered the interference state and assess the additional burden caused by the interference to the processor.
[0069] This method cumulatively counts the number of erroneous packets in each batch of received data packets, thereby continuously calculating the packet error rate of the current batch. Each batch refers to a statistical unit of data packets divided according to a preset number. The packet error rate reflects the severity of interference in the current receiving link; a higher packet error rate indicates poorer signal quality.
[0070] This method cumulatively counts the number of transmission attempts in each batch, tracking the number of times automatic retransmission is triggered, thereby continuously calculating the retransmission rate of the current batch. Automatic retransmission refers to the automatic retransmission of data triggered when the sending end does not receive an acknowledgment response from the receiving end within a specified acknowledgment time after sending data. The retransmission rate reflects the reliability of the transmission link and the responsiveness of the receiving node.
[0071] This method compares the current packet error rate with a preset packet error rate alarm threshold, and simultaneously compares the current retransmission rate with a preset retransmission rate alarm threshold, obtaining results indicating whether the packet error rate and retransmission rate have exceeded the limits, respectively. These two alarm thresholds are preset based on communication quality statistics under normal conditions and are used to distinguish between normal fluctuations and abnormal interference.
[0072] This method integrates the results of packet error rate exceeding the limit and retransmission rate exceeding the limit. If either result is exceeded, the current channel is determined to be in an interference state; only when both results are normal is the channel determined to be in a normal state. For cases determined to be in an interference state, this method further compares the interruption frequency per unit time with a normal baseline value to quantify the magnitude of the interruption frequency change, thus obtaining the degree of interference impact.
[0073] By combining dual indicators (packet error rate and retransmission rate) and using a two-stage processing approach (first determining the state and then quantifying the degree), the technical problems of misjudging channel state and interference level by single indicators are solved, thus achieving accurate identification of channel interference state and graded quantification of additional processor load.
[0074] In one embodiment of the present invention, the method of comprehensively determining the channel state based on the packet error rate exceeding the limit and the retransmission rate exceeding the limit (if either limit is exceeded, it is determined to be an interference state; otherwise, it is a normal state), and quantitatively comparing the change amplitude of the interruption frequency per unit time when the state is determined to be interference, to obtain the degree of interference impact, includes: By performing a logical OR operation on the packet error rate exceeding the limit and the retransmission rate exceeding the limit (if either exceeds the limit, the result is true), a comprehensive judgment flag is obtained to determine whether the channel is currently in an interference state. The branch selection of the current operating state is performed by comprehensively judging the flag (if the flag is in the normal state, the subsequent quantization steps are skipped and the normal flag is output directly; if the flag is in the interference state, the interrupt frequency change amplitude analysis process is started) to obtain the enable signal for whether to enter the quantization analysis process. The total number of interrupts per unit time is read by the enable signal (when analysis is started), and the difference is compared with the baseline value of the number of interrupts under normal conditions to obtain the current direction and magnitude of the change in interrupt frequency (the increase is divided into three levels: slight, moderate and significant). The additional burden on the processor caused by the current channel interference is comprehensively assigned a value based on the current direction and magnitude of the change (no burden is assigned in the normal state, and corresponding burden levels are assigned for slight / moderate / significant under interference conditions), thus obtaining the final quantitative classification result of the interference impact. Figure 5 As shown.
[0075] Specifically, the total number of interrupts per unit time is read using the enable signal (when analysis is started), and the difference is compared with the baseline value of the number of interrupts under normal conditions to obtain the current direction and magnitude of change in the interrupt frequency (the increase is divided into three levels: slight, moderate, and significant), including: The total number of interrupts per unit time is read by the enable signal (when analysis has started), and the baseline value of the number of interrupts per unit time is extracted from the normal environment baseline response timing table in S1 to obtain the measured value pair of the current number of interrupts and the baseline number of interrupts. The current change in interrupt frequency is obtained by performing a difference operation on the measured values (subtracting the baseline interrupt count from the current interrupt count), and the direction of change (increase, decrease, or no change) is determined by judging whether the difference is positive, negative, or zero. The current change value is compared with the preset first change threshold and second change threshold (the second threshold is higher than the first threshold) in two levels: if the change does not exceed the first threshold, it is classified as slight; if it exceeds the first threshold but does not exceed the second threshold, it is classified as moderate; if it exceeds the second threshold, it is classified as significant, thus obtaining the result of the change magnitude level of the interruption frequency. By combining the results of the change direction determination and the change magnitude level determination (merging the direction and magnitude into a single state description), a complete classification result of the current change direction and change magnitude level of the interruption frequency is obtained.
[0076] The working principle and technical effect of the above technical solution are as follows: After determining that the channel is in an interference state and starting the quantization analysis process, it is necessary to accurately assess the direction and magnitude of the frequency change caused by the interference, so as to provide a hierarchical basis for subsequent scheduling strategies.
[0077] After the quantitative analysis process is started, this method reads the total number of interruptions within the current unit time and extracts the baseline value of the number of interruptions within the corresponding unit time from the normal environment baseline response time sequence table obtained in S1 of Example 1, and then pairs the two. The so-called corresponding unit time means that the current statistical period and the baseline statistical period have the same time length to ensure the fairness of the comparison.
[0078] This method subtracts the baseline number of interrupts from the current number of interrupts to obtain the change in interrupt frequency. The direction of the frequency change is determined by whether the difference is positive, negative, or zero: a positive value indicates an increase in interrupt frequency, a negative value indicates a decrease, and zero indicates no change. Since channel interference typically increases communication errors and triggers more interrupts, the interference state normally corresponds to an increase.
[0079] This method compares the change value with a preset first change threshold and a second change threshold in two levels, with the second threshold being higher than the first threshold. If the change value does not exceed the first threshold, it indicates that the additional interrupt burden caused by the interference is relatively light, and is classified as a minor level; if the change value exceeds the first threshold but does not exceed the second threshold, it indicates that the interference has significantly increased the processor interrupt burden, and is classified as a moderate level; if the change value exceeds the second threshold, it indicates that the interference is severe and the processor interrupt burden has increased significantly, and is classified as a significant level.
[0080] This method combines the result of the change direction determination and the result of the change magnitude determination into a complete state description, such as "frequency increases and amplitude is significant", thereby obtaining a complete classification result of the change direction and change magnitude of the interruption frequency.
[0081] By using difference comparison and two-level threshold classification, the technical problem of the inability to qualitatively distinguish the degree of channel interference into multiple levels is solved, realizing a fine classification of the degree of interference impact. This provides differentiated input parameters for subsequent dynamic scheduling strategies, allowing for mild adjustments under slight interference and aggressive scheduling only under severe interference.
[0082] In one embodiment of the present invention, S3 includes: The scheduling adjustment process is determined based on the current channel state (it is only initiated in the interference state, and the original scheduling is maintained in the normal state), and the scheduling adjustment enable flag is obtained. By adjusting the scheduling enable flag (when enabled), the priority of the current task list is re-divided (the PLC beacon frame receiving task is set to the highest software priority, the routing table maintenance task is set to the second highest software priority, and the user PWM / ADC / serial port task retains its original priority), and the adjusted software task priority list is obtained. The scheduling algorithm in the task scheduler is configured and updated by using a software task priority ranking list (ready tasks are executed in the new priority order, and high-priority tasks can preempt low-priority tasks), thus obtaining the effective dynamic scheduling strategy configuration. By configuring dynamic scheduling strategies to observe the actual execution of beacon frame reception and route maintenance tasks (confirming that they are always completed before the specified deadline and are not delayed by user tasks), we can obtain confirmation that the execution window for critical tasks that can maintain network online status even when the channel deteriorates is guaranteed. Figure 6 As shown.
[0083] The working principle and technical effect of the above technical solution are as follows: After obtaining whether the current channel is in a state of interference and the degree of its impact, it is necessary to dynamically adjust the task scheduling order based on this information to ensure that critical communication tasks can still be completed on time when the channel deteriorates.
[0084] This method determines whether to initiate the scheduling adjustment process based on the current channel state: if the channel state is normal, it means that the current communication environment is good and the existing scheduling strategy is sufficient to meet the requirements, so the original scheduling remains unchanged; if the channel state is interfering, it means that the communication environment has deteriorated and processor resources need to be reallocated, so the scheduling adjustment process is initiated and a scheduling adjustment enable flag is obtained to control the execution of subsequent sub-steps.
[0085] Once the scheduling adjustment process is initiated, this method re-prioritizes all current tasks. Specifically, the PLC beacon frame reception task is set to the highest software priority. Beacon frames are crucial signals for network synchronization and node keep-alive; if the beacon frame reception task is delayed, slave nodes may lose network access due to delayed responses. The routing table maintenance task is set to the second highest software priority. Routing table maintenance ensures that data packets can find the correct path, which is especially important when the network topology may change dynamically due to interference. User PWM output, ADC sampling, and serial communication tasks retain their original priorities. After this operation, an adjusted software task priority ranking list is obtained.
[0086] This method updates the scheduling algorithm in the task scheduler based on the adjusted priority ranking list. The core of the configuration update is to ensure that the task scheduler executes ready tasks according to the new priority order, and that high-priority tasks can preempt low-priority tasks. That is, when a high-priority task is ready, even if a low-priority task is being executed, the processor will immediately switch to the high-priority task.
[0087] This method continuously monitors the actual execution of beacon frame reception and route maintenance tasks after the dynamic scheduling strategy takes effect, confirming that these two types of critical tasks are always completed before their respective deadlines and are not delayed by user tasks. Once the above conditions are confirmed to be met, it indicates that the critical task execution window required to maintain network online status under channel degradation conditions has been effectively guaranteed.
[0088] By adopting a differentiated scheduling strategy based on channel state (adjustment is only initiated in the interference state) and a critical task priority guarantee mechanism, the problem of beacon frame reception timeout caused by communication tasks and control tasks competing for processor resources under channel degradation conditions is solved. This achieves the technical goal of prioritizing network connection stability under interference conditions and reduces the risk of slave nodes being kicked out of the network due to scheduling delays.
[0089] In one embodiment of the present invention, the observation of the actual execution of the beacon frame reception task and the route maintenance task through dynamic scheduling strategy configuration (confirming that they are always completed before the specified deadline and are not delayed by user tasks) to obtain a confirmation result that the execution window of the key tasks that can still maintain the network online status when the channel deteriorates is guaranteed includes: By configuring a dynamic scheduling strategy, the actual completion time of each beacon frame receiving task is read and compared sequentially with the preset deadline time of the beacon frame receiving task to obtain a record of whether the beacon frame receiving task is completed on schedule. The actual completion time of each route maintenance task is read by successive judgment records and compared with the preset deadline of the route maintenance task in chronological order to obtain successive judgment records of whether the route maintenance task is completed on schedule. By analyzing the successive judgment records of the two types of tasks, a comprehensive statistical analysis of the completion status of multiple consecutive tasks is conducted (to determine whether the proportion of on-time completions to the total number of observations meets the preset proportion requirement), and statistical results are obtained on whether the current scheduling strategy effectively guarantees the execution window of critical tasks. The statistical results are used to finally confirm the guarantee status of the critical task execution window (if the statistical results reach the preset ratio requirement, it is confirmed as guaranteed; if not, it is marked as insufficient guarantee and an alarm is triggered for upper-layer processing). This obtains confirmation that the critical task execution window, which can maintain network online status even when the channel deteriorates, has been guaranteed. Figure 7 As shown.
[0090] Specifically, a dynamic scheduling strategy is used to read the actual completion time of each beacon frame reception task and compare it sequentially with the preset deadline time of that beacon frame reception task to obtain a successive record of whether the beacon frame reception task was completed on schedule, including: The trigger time of the route maintenance task is located by successively determining the record of the beacon frame receiving task (reading the actual start time of the route maintenance task scheduled for execution within the same period as the beacon frame receiving task), and the start time of the current execution of the route maintenance task is obtained. The actual completion time of the route maintenance task is read by the start time (the task exit timestamp is obtained from the task end flag), and then paired with the preset route maintenance deadline time within the beacon frame reception period corresponding to this route maintenance task to obtain a comparison data pair of the completion time and deadline time of this route maintenance task. By comparing the data pairs sequentially (determining whether the completion time is no later than the deadline), a single judgment result is obtained as to whether the route maintenance task was completed on schedule (completed on schedule or completed beyond the deadline). By summarizing and recording all single judgment results within multiple consecutive observation periods using the single judgment result (marking each judgment result in chronological order), a record of each judgment is obtained to determine whether the route maintenance task was completed on schedule.
[0091] The working principle and technical effect of the above technical solution are as follows: After the dynamic scheduling strategy takes effect, it is necessary to accurately determine the execution status of two key tasks, namely the beacon frame reception task and the route maintenance task, to ensure that they can both be completed before the specified deadline. Among them, the route maintenance task and the beacon frame reception task are time-dependent. The route maintenance task is usually triggered and executed within the same beacon period, so its deadline is related to the period of the beacon frame reception task.
[0092] This method uses the obtained beacon frame reception task records to locate the actual start time of the scheduled execution of the route maintenance task within the same period as the beacon frame reception task. Since the route maintenance task is usually triggered immediately after the beacon frame reception is completed, it is necessary to use the beacon frame reception period as a reference to determine the execution start point of the route maintenance task within the same period.
[0093] This method reads the actual exit timestamp of the route maintenance task from the end flag bit to obtain the actual completion time of the route maintenance task; at the same time, it extracts the preset route maintenance deadline from the beacon frame reception period corresponding to the task and pairs the actual completion time with the deadline.
[0094] This method compares the completion time and deadline time after pairing in chronological order: if the completion time is not later than the deadline time, the route maintenance task is considered completed on schedule; if the completion time is later than the deadline time, it is considered completed late. The determination result is recorded sequentially.
[0095] This method summarizes the above single judgment results one by one over multiple consecutive observation periods. The judgment results of each observation period are marked sequentially in chronological order to form a complete sequential judgment record of whether the route maintenance task is completed on schedule.
[0096] In one embodiment of the present invention, S4 includes: The triggering conditions for the current route probe operation are checked through the critical task execution window (probes are only triggered when the channel state changes from normal to interference or from interference to normal, and periodic timed probes are canceled) to obtain the adjusted route probe triggering rules. By controlling the current routing table update process through routing probe trigger rules (updating the routing table when a probe is triggered, and using the existing routing table when there is no trigger), an adaptive control mechanism is obtained to automatically increase or decrease the router probe frequency as the channel state changes. The timeout duration of the current retransmission waiting timer is configured through an adaptive control mechanism (the timeout waiting time is shortened under interference conditions to avoid occupying the processor for a long time while waiting for confirmation), and the effective retransmission timeout configuration linked to the channel state is obtained. The overall operating status of the module was jointly verified through a route detection frequency adaptive control mechanism and retransmission timeout configuration (confirming that the number of detections is reduced and the retransmission wait time is shortened under interference conditions, while the network remains connected and the PWM output waveform is jitter-free), thus obtaining a balanced operating mode that is acceptable in terms of both communication stability and control real-time performance. Figure 8 As shown.
[0097] The working principle and technical effect of the above technical solution are as follows: After the critical task execution window is guaranteed, it is necessary to adjust the routing detection frequency and retransmission waiting time in a coordinated manner to avoid the vicious cycle between communication degradation and processor overload from the root.
[0098] This method checks the triggering conditions of the current route probe operation based on the assurance status of the critical task execution window. The conventional approach is to trigger route probes periodically, but under interference conditions, timed probes only increase unnecessary communication traffic, further exacerbating channel congestion. This method changes the triggering condition to event-triggered, triggering probes only when the channel state transitions from normal to interference or from interference to normal; periodic timed probes are canceled at other times. After this check, the adjusted route probe triggering rules are obtained.
[0099] This method controls the routing table update process based on adjusted triggering rules: when the triggering condition is met (state transition), route probing is performed and the routing table is updated; when the triggering condition is not met, no probing is initiated, and the existing routing table is used directly. This control mechanism makes the route probing frequency no longer fixed, but automatically increases or decreases with changes in channel state, with fewer probes when the channel is stable and more probes during state transitions.
[0100] This method configures the timeout duration of the retransmission waiting timer based on an established adaptive control mechanism. In interference-prone conditions, due to poor channel quality, transmitted data packets may require multiple retransmissions to succeed. If the waiting time for each retransmission is too long, the processor will be occupied for an extended period while waiting for acknowledgments, preventing it from handling other tasks. Therefore, this method proactively shortens the timeout duration under interference conditions, allowing retransmission attempts to conclude more quickly and freeing up processor resources.
[0101] This method jointly verifies the overall effectiveness of the adaptive control mechanism for route probing frequency and the retransmission timeout configuration: it confirms that the actual number of probes is indeed reduced and the retransmission waiting time is indeed shortened under interference conditions, while the network still maintains connectivity (beacon frames can be received normally and valid neighbors exist in the routing table), and the PWM output waveform is jitter-free. After the joint verification is passed, a balanced operating mode in which both communication stability and control real-time performance are acceptable is obtained.
[0102] By changing route probing from timed triggering to event triggering and adjusting retransmission waiting time in conjunction with channel status, the problems of increased channel congestion and ineffective processor waiting caused by fixed-period probing and fixed retransmission waiting under channel interference conditions are solved. This achieves the technical goal of proactively reducing processor communication load while ensuring network connectivity, fundamentally breaking the positive feedback vicious cycle of communication degradation leading to excessive retransmission, which in turn exacerbates processor congestion.
[0103] In one embodiment of the present invention, the overall operating state of the module is jointly verified through a route detection frequency adaptive control mechanism and a retransmission timeout configuration (confirming that the number of detections is reduced and the retransmission wait time is shortened under interference conditions, while the network remains connected and the PWM output waveform is jitter-free), to obtain a balanced operating mode in which both communication stability and control real-time performance are acceptable, including: The actual number of route probes initiated per unit time under the current operating state is read through the adaptive control mechanism and retransmission timeout configuration, and compared with the baseline number of probes under normal conditions (to confirm that the actual number of probes is not greater than the baseline number), so as to obtain a verification flag for whether the route probe frequency meets the slowdown requirement. The network connectivity under the current operating state is detected by verifying the flag (if the requirements are met, verification continues; if not, verification is directly marked as failed). This is done by checking whether the most recent beacon frame reception timed out and whether there are valid neighbor entries in the routing table. The network connectivity flag is then used to determine whether the network is still connected. The waveform of the current PWM output pin is sampled and compared using a connectivity flag (continuing verification when connected, marking verification failure when disconnected). This involves checking the consistency of the current PWM waveform's period and duty cycle with the expected set value to confirm the absence of sudden changes or periodic jitter, thus obtaining a real-time control flag indicating whether the PWM output waveform is stable. The verification flag, connectivity flag, and control real-time flag are combined and calculated (the joint verification is considered successful if all three flags are satisfied / connectivity / stability is met; otherwise, the verification is considered unsuccessful). This yields the final confirmation result of a balanced operating mode that satisfies both communication stability and control real-time performance. Figure 9 As shown.
[0104] Specifically, the waveform of the current PWM output pin is sampled and compared using a connectivity flag (continuing verification when connected, marking verification failure when disconnected). This involves checking the consistency of the current PWM waveform's period and duty cycle with the expected setpoint to confirm the absence of sudden changes or periodic jitter, thus obtaining a real-time control flag indicating whether the PWM output waveform is stable. This flag includes: The waveform sampling is triggered by the connectivity flag (verification continues when connected) to obtain the original level sampling sequence of the current PWM waveform by acquiring the logic level state sequence of the PWM pin at fixed intervals within a preset continuous observation window. The level change edges between adjacent sampling points are detected by the original level sampling sequence (the time of each rising edge and falling edge is recorded), and the time interval between adjacent same-direction edges is calculated to obtain the measured period value and measured high-level duration value of the current PWM waveform. The deviations between the measured period value and the measured high-level duration value and the preset expected period value and expected high-level duration value are calculated (the period deviation amplitude and duty cycle deviation amplitude are calculated separately), and compared with the preset allowable deviation threshold to obtain two independent check results for PWM waveform period consistency and duty cycle consistency. The stability of the PWM output waveform is determined by a comprehensive assessment of the results of two independent checks (the waveform is considered stable only when both the cycle consistency and duty cycle consistency checks are qualified; if either check is unqualified, the waveform is considered unstable).
[0105] The working principle and technical effect of the above technical solution are as follows: During the joint verification process, it is necessary to confirm that the dynamic scheduling and linkage adjustment measures do not impair the real-time performance of the user's control task. The PWM output waveform is the most direct physical indicator for measuring the real-time performance of the control. If the period or duty cycle of the PWM waveform changes abruptly or fluctuates periodically, it indicates that the processor has failed to respond to the PWM period matching interrupt in a timely manner, and the real-time performance of the control task has been compromised.
[0106] This method, assuming the connectivity flag is connected, samples the waveform of the current PWM output pin and collects the logic level state sequence of the PWM pin at fixed time intervals within a preset continuous observation window. The continuous observation window refers to a continuous time range; fixed-interval sampling means recording the level value of each sampling point with a uniform time step, thereby obtaining a digital representation of the PWM waveform.
[0107] This method processes the acquired raw level sampling sequence, detecting level change edges between adjacent sampling points, specifically the rising edge (level change from low to high) and the falling edge (level change from high to low). After recording the time of each change edge, the time interval between two adjacent edges in the same direction (between two rising edges or two falling edges) is calculated; this time interval is the measured period value of the PWM waveform. Simultaneously, the time interval between the rising edge and the falling edge within the same period is calculated; this interval is the measured high-level duration value.
[0108] This method calculates the deviation between the measured period value and the preset expected period value to obtain the period deviation amplitude; it also calculates the deviation between the measured high-level duration value and the preset expected high-level duration value to obtain the duty cycle deviation amplitude. These two deviation amplitudes are then compared with a preset allowable deviation threshold, which defines the engineering-acceptable error range for the PWM waveform, thus obtaining two independent check results: period consistency and duty cycle consistency.
[0109] This method comprehensively judges the results of two checks: the PWM waveform is considered stable only when both period consistency and duty cycle consistency are deemed satisfactory; if either fails, the waveform is considered unstable. This comprehensive judgment result serves as a real-time indicator of whether the PWM output waveform is stable.
[0110] By using the quality of the PWM output waveform as an observable verification indicator of control real-time performance, the problem of the lack of hardware-level verification methods for the impact of communication optimization measures on control real-time performance is solved. This enables physical-layer confirmation of the real-time performance of control tasks, allowing joint verification to go beyond software statistics and be implemented in the actual output signal quality, thereby improving the reliability of verification.
[0111] According to one embodiment of the present invention, the system includes: The interrupt partitioning module is used to partition PLC communication interrupts and user control tasks with fixed priorities through a built-in hardware timer, and to obtain the basic response timing of each task and the processor idle window under normal power line conditions. The real-time monitoring module is used to perform real-time threshold monitoring of the communication packet error rate and retransmission count through basic response timing, and to obtain whether the current channel has entered an interference state and the degree of interference impact on the processor load. The dynamic adjustment module is used to dynamically adjust the task scheduling order based on the degree of interference, so as to obtain the critical task execution window that can still maintain the network online status when the channel deteriorates. The linkage adjustment module is used to adjust the routing detection frequency and retransmission waiting time in a linked manner through the critical task execution window (the stronger the interference, the slower the detection and the shorter the waiting time will be), so as to obtain a balanced working mode that is acceptable to both communication stability and control real-time performance, thereby avoiding processor congestion caused by excessive retransmission.
[0112] The working principle and technical effect of the above technical solution are as follows: This system uses a built-in hardware timer to divide PLC communication interrupts and user control tasks into fixed priorities, so that PLC communication interrupts are always at the highest priority, thereby obtaining the basic response timing of each task and the processor idle window under normal power line conditions.
[0113] This system uses the obtained basic response timing as a benchmark reference value to monitor the packet error rate and retransmission count in real time during the communication process, and compares them with preset thresholds. The packet error rate reflects the signal quality of the receiving link, and the retransmission count reflects the acknowledgment success rate of the sending link. When either exceeds the threshold, the channel is determined to be in an interference state. At the same time, by comparing the difference between the current interruption frequency and the benchmark frequency, the additional load caused by the interference to the processor is quantified.
[0114] This system dynamically adjusts the task scheduling order based on the degree of interference. Under interference conditions, critical tasks that maintain network online status (such as beacon frame reception and route maintenance) are elevated to the highest software priority to ensure that these tasks are always completed before the specified deadline, thereby obtaining a critical task execution window that can still guarantee network connectivity when the channel deteriorates.
[0115] Based on the obtained critical task execution window, this system adjusts the route probing frequency and retransmission waiting time in a coordinated manner: when interference is stronger, the route probing frequency is actively slowed down to prevent probe frames from further aggravating channel congestion, while the waiting time for a single retransmission is shortened to prevent the processor from being blocked in the waiting-for-acknowledgment state for a long time. Through the above coordinated adjustment, a balanced operating mode that is acceptable in both communication stability and control real-time performance is finally achieved.
[0116] By implementing a sequential approach involving four stages—priority allocation, status monitoring, dynamic scheduling, and coordinated adjustment—the problem of processor congestion caused by communication task overload in single-chip PLC slave nodes under channel interference conditions is solved. This achieves joint assurance of communication reliability and control real-time performance, and reduces the risk of vicious competition for processor resources caused by excessive retransmissions and frequent probes.
[0117] Example 2 This embodiment further modifies the timing of preemption of the software priority of critical communication tasks, so that critical communication tasks that need to be executed immediately continue to be preempted according to the software priority determined in Embodiment 1, and critical communication tasks that still have sufficient deadline margin and can be fully accommodated by the subsequent processor idle window are postponed to the corresponding processor idle window for execution.
[0118] Specifically, this embodiment includes steps S1-S5.
[0119] S1. Following the method described in Example 1, PLC communication interrupts and user control tasks are divided into fixed priorities, and the execution timing of each interrupt is recorded and merged to obtain the basic response timing and processor idle window.
[0120] S2. Following the method described in Example 1, monitor and compare the communication packet error rate, retransmission rate, and number of interruptions per unit time to obtain the current channel status and the degree of interference.
[0121] S3. Following the method described in Example 1, when the channel is in an interference state, increase the software priority of the PLC beacon frame reception task and the route maintenance task, and obtain the critical task execution window guarantee status based on the actual completion time and preset deadline of the corresponding task.
[0122] S4. Following the method described in Example 1, the routing detection and retransmission waiting time are adjusted in conjunction with the critical task execution window guarantee status, and the network connectivity and PWM output waveform are verified to obtain a balanced working mode.
[0123] S5. Under the condition that the software task priority determined in Example 1 remains unchanged, based on the deadline margin of the current critical communication task to be executed and the capacity of the subsequent processor idle window for the critical communication task, a second determination is made as to whether the critical communication task will be preempted immediately, so as to obtain the corrected actual execution time of the critical communication task.
[0124] S5 includes S51-S53.
[0125] S51. Determine the urgency of the current critical communication task by the preset deadline, the current scheduling time, and the estimated remaining execution time of the current critical communication task to be executed; the urgency is used to characterize the risk that the current critical communication task will be completed before the preset deadline if it continues to be delayed.
[0126] S52. Based on the preset deadline of the current critical communication task to be executed, the estimated remaining execution time, and the duration and end time of the processor idle window obtained in Example 1, determine whether the subsequent processor idle windows can fully accommodate the current critical communication task before the preset deadline, and obtain the idle window matching degree; the idle window matching degree is used to characterize the feasibility of postponing the current critical communication task to the corresponding processor idle window for execution.
[0127] S53. By jointly determining the urgency of the task and the matching degree of the idle window, the scheduling decision result of the current critical communication task to be executed is obtained, and the scheduling decision result is used to determine whether the current critical communication task should be preemptively executed according to the software priority determined in Embodiment 1, or postponed to the matching processor idle window.
[0128] Further, S51 includes: After the PLC beacon frame receiving task or route maintenance task enters the ready state, the preset deadline time corresponding to the current key communication task to be executed is read, and the current scheduling time is read through the built-in hardware timer.
[0129] Extract the historical execution time corresponding to the current critical communication task type from the original execution time record obtained in Example 1, and combine it with the processing progress of the current critical communication task to determine the estimated remaining execution time of the processor required to complete the current critical communication task.
[0130] Based on the remaining time between the current scheduling time and the preset deadline, and the extent to which the expected remaining execution time accounts for within the remaining time, the urgency of the current critical communication task is evaluated to obtain the task urgency level.
[0131] When the estimated remaining execution time is close to the remaining time between the current scheduling time and the preset deadline, it indicates that the available execution margin after the current critical communication task is further delayed is small, and the corresponding task urgency increases; when the estimated remaining execution time is significantly less than the remaining time, it indicates that the current critical communication task still has a large deadline margin, and the corresponding task urgency decreases.
[0132] Therefore, whether a critical communication task needs to be executed immediately is no longer determined solely by its software priority, but is further linked to the actual remaining execution time and deadline requirements.
[0133] Further, S52 includes: Starting from the current scheduling time, read the processor idle windows located after the current scheduling time from the processor idle windows obtained in Example 1 in chronological order, and determine the duration and end time of each processor idle window.
[0134] The estimated remaining execution time of the current critical communication task is compared with the duration of the idle window of each processor to determine whether the idle window of the corresponding processor has the time capacity required to fully execute the current critical communication task.
[0135] For a processor idle window whose duration is sufficient to accommodate the current critical communication task, its end time is further compared with the preset deadline of the current critical communication task to determine whether the current critical communication task can still be completed before the preset deadline after being scheduled to be executed in the corresponding processor idle window.
[0136] Based on the remaining time capacity of the processor's idle window after accommodating the current critical communication task, and the time slack remaining between the completion of the critical communication task in the processor's idle window and the preset deadline, the idle windows of each processor are matched and evaluated to obtain the corresponding idle window matching degree.
[0137] The longer the duration of the processor idle window is relative to the expected remaining execution time, and the further away the end time of the processor idle window is from the preset deadline, the higher the matching degree of the corresponding processor idle window. Conversely, when the processor idle window can barely accommodate the current critical communication task, or when the execution is completed close to the preset deadline, the matching degree of the corresponding processor idle window decreases.
[0138] Multiple processor idle windows that meet the deadline requirements are compared, and the processor idle window with the highest matching degree is determined as the preferred processor idle window for the current critical communication task, and its matching degree is used as the preferred idle window matching degree for the current critical communication task.
[0139] Therefore, the preset deadline and the estimated remaining execution time in S51 are simultaneously involved in the processor idle window matching process in S52, so that the urgency of the task itself and the availability of subsequent processor resources are associated around the same critical communication task.
[0140] Furthermore, S53 includes: The scheduling decision is obtained by reading the task urgency obtained in S51 and the optimal idle window matching degree obtained in S52, and by jointly comparing the deadline risk of the current critical communication task with the carrying capacity of the subsequent processor idle resources for the critical communication task.
[0141] When the urgency of the current critical communication task is high, indicating a significant risk of deadline if its execution is delayed further, the established software task priority is maintained, and the current critical communication task is allowed to be preemptively executed immediately according to the software task priority.
[0142] When the current critical communication task still has a large deadline margin and there is a preferred processor idle window that can fully accommodate the critical communication task before the preset deadline, the critical communication task will not preempt the current user task. Instead, the critical communication task will be registered in the list of tasks to be executed in the corresponding preferred processor idle window. The critical communication task will be called and executed after the processor enters the preferred processor idle window.
[0143] When the urgency of the current critical communication task is low, but there is no processor free window that can fully accommodate the critical communication task before its preset deadline, delayed scheduling is not performed. Instead, the software task priority determined in Example 1 is still executed to avoid the actual overdue time of the critical communication task due to waiting for subsequent free windows.
[0144] After the current critical communication task is completed according to the scheduling decision, its actual completion time is read and compared with the preset deadline time as described in Example 1, and the PWM output waveform is detected at the same time. When the critical communication task meets the deadline requirement and the PWM output remains stable, the current scheduling decision is confirmed to be valid; when the critical communication task has an insufficient deadline or the PWM output stability decreases, S51-S53 is re-executed in the next scheduling cycle.
[0145] In this embodiment, S51 uses the preset deadline, the current scheduling time, and the estimated remaining execution time to determine the urgency of the task. S52 continues to use the preset deadline and the estimated remaining execution time, and combines them with the duration and end time of the processor idle window to determine the degree of matching of the idle window. S53 then uses the urgency of the task and the degree of matching of the idle window to determine the actual preemption opportunity of the critical communication task, thereby forming a progressive relationship between the task deadline risk, the processor idle resources, and the actual execution time of the task.
[0146] This embodiment further defines when the critical communication task, after being given a higher software priority, will actually be preempted.
[0147] For critical communication tasks whose deadlines are approaching or for which there is no suitable processor free window, they can still be executed in a timely manner according to the determined software priority. For critical communication tasks that still have a large deadline margin and can be fully carried out by subsequent processor free windows, they can be executed by using the identified processor free windows. This reduces unnecessary preemption of user tasks such as PWM by critical communication tasks, and improves the continuous processor execution time that user control tasks can obtain while ensuring the online status of the PLC slave node network.
[0148] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A highly integrated, high-speed PLC slave node communication method, characterized in that, The method includes: S1. By using the built-in hardware timer, PLC communication interrupts and user control tasks are divided into fixed priorities to obtain the basic response timing and processor idle window. S2. Real-time threshold monitoring of communication packet error rate and retransmission count is performed using basic response timing to obtain the degree of interference impact. S3. Dynamically adjust the task scheduling order based on the degree of interference to obtain the execution window for critical tasks; S4. Adjust the routing detection frequency and retransmission waiting time in a coordinated manner through the critical task execution window to achieve a balanced working mode.
2. The highly integrated, high-speed PLC slave node communication method according to claim 1, characterized in that, S1 includes: The hardware priority configuration table is obtained by fixing and locking the highest priority of the two types of PLC communication interrupts through the interrupt priority configuration registers of PLC receive completion interrupt and PLC send completion interrupt; The PWM cycle matching interrupt and ADC sampling completion interrupt are assigned second-highest and normal priorities by using a hardware priority configuration table to obtain a fixed priority level ranking list. By using a fixed priority ranking list, the entire process of continuous operation of the module in a standard laboratory environment is recorded at each interruption trigger moment and exit moment, and the execution time and its original record table are obtained. By filtering and merging the time periods during which no interrupts were triggered by each execution time and the original record table, the processor idle window and basic response timing can be obtained.
3. The highly integrated, high-speed PLC slave node communication method according to claim 2, characterized in that, The process involves filtering and merging time periods during which no interrupts were triggered by each execution time and the original record table to obtain the processor idle window and basic response timing, including: By sorting the idle intervals after each interruption by the execution time and the original record table, a duration distribution sequence is obtained. By checking the continuity between adjacent intervals at the start time of each idle interval using the duration distribution sequence, idle time periods are grouped. By grouping idle time periods, all intervals within each group are merged end-to-end to obtain the start and end times and the total duration. By filtering and retaining the time periods whose duration reaches the preset minimum available threshold from each continuous idle time period, and arranging the retained time periods in chronological order, the start and end times of the processor idle window and the basic response timing are obtained.
4. The highly integrated, high-speed PLC slave node communication method according to claim 1, characterized in that, S2 includes: By accumulating the number of erroneous packets in each batch of received data packets, the current packet error rate is continuously statistically analyzed to obtain the degree of packet error rate. By accumulating the number of times automatic retransmission is triggered in each batch of sending attempts, the current retransmission rate is continuously statistically analyzed to obtain the degree of retransmission rate. By comparing the preset packet error rate alarm threshold and retransmission rate alarm threshold one by one according to the degree of packet error rate and retransmission rate, the judgment results of packet error rate exceeding the limit and retransmission rate exceeding the limit are obtained. The channel status is comprehensively determined by the results of packet error rate exceeding the limit and retransmission rate exceeding the limit. The change in the frequency of interruption occurring per unit time when the state is determined to be interference is quantitatively compared to obtain the degree of interference impact.
5. The highly integrated, high-speed PLC slave node communication method according to claim 4, characterized in that, The process involves comprehensively determining the channel state based on the packet error rate exceeding the limit and the retransmission rate exceeding the limit, and quantifying and comparing the change in the frequency of interruptions per unit time when the state is determined to be interference, to obtain the degree of interference impact, including: By performing a logical OR operation on the packet error rate exceeding the limit judgment result and the retransmission rate exceeding the limit judgment result, a comprehensive judgment flag is obtained; The branch selection is performed based on the comprehensive judgment flags to obtain the enable signal; The total number of interrupts per unit time is read by the enable signal and compared with the interrupt frequency baseline value to obtain the current direction and magnitude of the interrupt frequency change. By comprehensively assigning values to the additional burden on the processor caused by the current channel interference based on the current direction and magnitude of the change, the final quantitative classification result of the interference impact is obtained.
6. The highly integrated, high-speed PLC slave node communication method according to claim 1, characterized in that, S3 includes: The scheduling adjustment process is determined based on the current channel state to obtain the scheduling adjustment enable flag; By adjusting the scheduling enable flags, the priority of the current task list is re-divided to obtain a software task priority ranking list. The scheduling algorithm in the task scheduler is configured and updated by using a software task priority ranking list to obtain a dynamic scheduling strategy configuration. By configuring dynamic scheduling strategies, the actual execution status of beacon frame reception and route maintenance tasks can be observed to obtain the execution window of critical tasks.
7. The highly integrated, high-speed PLC slave node communication method according to claim 6, characterized in that, The process of observing the actual execution of beacon frame reception and route maintenance tasks through dynamic scheduling strategy configuration to obtain the critical task execution window includes: The actual completion time of each beacon frame receiving task is read by configuring a dynamic scheduling strategy, and compared with the preset deadline time of the beacon frame receiving task in sequence to obtain a successive judgment record. The actual completion time of each route maintenance task is read by successive judgment records and compared with the preset deadline time of the route maintenance task in chronological order to obtain successive judgment records. By analyzing the successive judgment records of the two types of tasks, the completion status of multiple consecutive tasks is comprehensively statistically analyzed to obtain statistical results. The statistical results are used to make a final confirmation of the guarantee status of the critical task execution window, and the critical task execution window is obtained.
8. The highly integrated, high-speed PLC slave node communication method according to claim 1, characterized in that, S4 includes: The triggering conditions of the current route probing operation are checked through the critical task execution window to obtain the route probing triggering rules; An adaptive control mechanism is obtained by controlling the current routing table update process through route detection trigger rules; The retransmission timeout configuration is obtained by configuring the timeout duration of the current retransmission waiting timer through an adaptive control mechanism. By jointly verifying the overall operating status of the module through adaptive control mechanisms and retransmission timeout configuration, a balanced operating mode is obtained.
9. The highly integrated, high-speed PLC slave node communication method according to claim 8, characterized in that, The method of jointly verifying the overall operating status of the module through adaptive control mechanism and retransmission timeout configuration to obtain a balanced working mode includes: The number of actual route probes initiated per unit time under the current operating state is read through adaptive control mechanism and retransmission timeout configuration, and compared with the baseline number of probes under normal environment to obtain verification flags; The network connectivity in the current operating state is detected by verifying the flags to obtain the connectivity flags; The waveform of the current PWM output pin is sampled and compared using the connectivity flag to obtain the control real-time flag; By combining and calculating the three flags—verification flag, connectivity flag, and control real-time flag—a balanced operating mode is obtained.
10. A highly integrated, high-speed PLC slave node communication system, characterized in that, The system includes: The interrupt partitioning module is used to partition PLC communication interrupts and user control tasks with fixed priorities through a built-in hardware timer, so as to obtain the basic response timing and processor idle window. The real-time monitoring module is used to perform real-time threshold monitoring of communication packet error rate and retransmission count through basic response timing to obtain the degree of interference impact; The dynamic adjustment module is used to dynamically adjust the task scheduling order based on the degree of interference, thereby obtaining the execution window for critical tasks; The linkage adjustment module is used to adjust the route detection frequency and retransmission waiting time in a coordinated manner through the critical task execution window to obtain a balanced working mode.
