A current control method of a current control board card and the current control board card
Patent Information
- Application Number
- CN202611406763.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-11
- Publication Date
- 2026-10-13
AI Technical Summary
[0003]然而,在负载特性或者电流输出回路的工作状态发生变化时,预先设定的PID参数难以适应不同的电流偏差状态,导致实际输出电流对目标电流的跟踪精度不足
本申请中,电流控制板卡基于目标电流参数和实际输出电流形成当前电流偏差及偏差变化参数,并采用模糊推理得到比例参数调整量、积分参数调整量和微分参数调整量,以动态更新PID参数和修正模拟量输出控制量,最主要能够提高负载电流的控制精度;同时,周期性反馈采集与同步状态发送能够提高电流输出变化的响应能力以及上位主站获取电流控制信息的及时性。
Smart Images

Figure CN122902197A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of current control board technology, and in particular to a current control method and a current control board for a current control board. Background Technology
[0002] In industrial automation control systems, current control boards are typically used to receive target current parameters from a host computer and control the current output circuit to output the corresponding current to the load based on these parameters. To reduce the deviation between the actual output current and the target current, existing current control boards usually acquire the actual output current and use pre-set PID parameters to perform closed-loop regulation of the analog output.
[0003] However, when the load characteristics or the operating state of the current output circuit change, the preset PID parameters are difficult to adapt to different current deviation states, resulting in insufficient tracking accuracy of the actual output current to the target current. Summary of the Invention
[0004] This application provides a current control method and a current control board for a current control board, which can improve the control accuracy of the load current.
[0005] The first aspect of this application provides a current control method for a current control board, the current control board including a slave controller, a digital-to-analog converter, an analog-to-digital converter, and a current output circuit, the current control method including: In response to the synchronization interrupt signal generated by the slave controller, the target current parameters sent by the master station are received. An analog output control quantity is generated based on the target current parameter, and a control voltage is output through the digital-to-analog converter to control the current output circuit to output the load current. The feedback voltage signal corresponding to the load current is periodically acquired and converted into the actual output current by the analog-to-digital converter; The current current deviation is determined based on the target current parameter and the actual output current, and the deviation change parameter is determined based on the current current deviation and the historical current deviation. Based on the current current deviation and the deviation change parameters, fuzzy reasoning is performed to obtain the proportional parameter adjustment, integral parameter adjustment, and derivative parameter adjustment. The PID parameters are updated based on the proportional parameter adjustment, the integral parameter adjustment, and the derivative parameter adjustment to obtain the updated PID parameters, and the current control correction is calculated based on the updated PID parameters. The analog output control quantity is updated according to the current control correction quantity, and the actual output current is sent to the master station through the slave station controller.
[0006] Optionally, the step of performing fuzzy inference based on the current current deviation and the deviation change parameter to obtain the proportional parameter adjustment, integral parameter adjustment, and derivative parameter adjustment includes: The deviation fuzziness level is determined based on the correspondence between the current current deviation and the preset deviation range; The fuzziness level of the deviation change is determined based on the correspondence between the deviation change parameters and the preset change range; Based on the combination of the deviation fuzziness level and the deviation change fuzziness level, the proportional parameter fuzzy rule table, the integral parameter fuzzy rule table, and the differential parameter fuzzy rule table are queried respectively to obtain the proportional parameter fuzzy output value, the integral parameter fuzzy output value, and the differential parameter fuzzy output value. The fuzzy output values of the proportional parameter, the integral parameter, and the derivative parameter are numerically processed to obtain the adjustment amounts of the proportional parameter, the integral parameter, and the derivative parameter, respectively.
[0007] Optionally, the step of querying the proportional parameter fuzzy rule table, the integral parameter fuzzy rule table, and the differential parameter fuzzy rule table respectively based on the combination of the deviation fuzziness level and the deviation change fuzziness level to obtain the proportional parameter fuzzy output value, the integral parameter fuzzy output value, and the differential parameter fuzzy output value includes: The first index positions in the proportional parameter fuzzy rule table, the integral parameter fuzzy rule table, and the differential parameter fuzzy rule table are determined respectively based on the deviation fuzziness level; The second index positions in the proportional parameter fuzzy rule table, the integral parameter fuzzy rule table, and the differential parameter fuzzy rule table are determined respectively based on the fuzzy level of the deviation change; The rule units determined by the first index position and the second index position are read respectively to obtain the fuzzy output values of the proportional parameter, the integral parameter, and the derivative parameter.
[0008] Optionally, the PID parameters include proportional parameters, integral parameters, and derivative parameters. The step of updating the PID parameters based on the adjustment amounts of the proportional, integral, and derivative parameters to obtain updated PID parameters, and calculating the current control correction based on the updated PID parameters, includes: Add the current proportional parameter to the adjusted proportional parameter to obtain the updated proportional parameter; Add the current integral parameter to the integral parameter adjustment amount to obtain the updated integral parameter; Add the current differential parameter to the differential parameter adjustment amount to obtain the updated differential parameter; Calculate the proportional control component based on the current current deviation and the updated proportional parameter; The integral control component is calculated based on the cumulative current deviation and the updated integral parameters. The differential control component is calculated based on the deviation change parameter and the updated differential parameter, wherein the cumulative current deviation is obtained based on the current current deviation and the current deviations corresponding to each control cycle before the current control cycle. The proportional control component, the integral control component, and the derivative control component are superimposed to obtain the current control correction.
[0009] Optionally, after determining the current current deviation based on the target current parameter and the actual output current, and determining the deviation change parameter based on the current current deviation and the historical current deviation, and before performing fuzzy inference based on the current current deviation and the deviation change parameter to obtain the proportional parameter adjustment, integral parameter adjustment, and derivative parameter adjustment, the current control method further includes: The absolute value of the current current deviation is compared with a preset current deviation threshold. When the absolute value of the current current deviation is greater than the preset current deviation threshold, the cumulative deviation duration is defined as the duration during which the absolute value of the current current deviation is continuously greater than the preset current deviation threshold. When the duration of the deviation reaches the preset duration, the current output of the current output circuit is paused, and current output abnormality information is generated; The abnormal current output information is written into the communication interaction data and sent to the master station via the slave station controller.
[0010] Optionally, the periodic acquisition of the feedback voltage signal corresponding to the load current, and the conversion of the signal by the analog-to-digital converter to obtain the actual output current, includes: Configure a hardware timer to periodically generate a sampling trigger signal; Based on the sampling trigger signal, the analog-to-digital converter is controlled to sample and convert the feedback voltage signal; In response to the conversion completion interrupt signal generated by the analog-to-digital converter, the sampled conversion value is read; Based on the preset mapping relationship between the sampled conversion value and the output current, the sampled conversion value is converted into the actual output current.
[0011] Optionally, before receiving the target current parameters sent by the master station in response to the synchronization interrupt signal generated by the slave controller, the current control method further includes: Initialize the EtherCAT protocol stack, write detection data to the target register of the slave controller, and read feedback data; The access status of the target register is determined by comparing the detection data with the feedback data. When the access status is abnormal, a hardware reset is performed on the slave controller, and the target register is accessed again after the hardware reset; When re-accessing the target register fails, the initialization process of the EtherCAT protocol stack ends, and the error indicator light switches to the exception indication state.
[0012] Optionally, comparing the detection data with the feedback data to determine the access status of the target register includes: When the detection data matches the feedback data, the access status of the target register is determined to be normal. When the detection data is inconsistent with the feedback data, the number of register accesses is accumulated, and the operation of writing the detection data to the target register and reading the feedback data is re-executed. When the number of register accesses reaches the preset number of accesses, and the detection data and the feedback data are still inconsistent, the access status is determined to be an abnormal status.
[0013] A second aspect of this application provides a current control board for implementing the method of the first aspect and any possible embodiment of the first aspect. The current control board includes a slave controller, a digital-to-analog converter, an analog-to-digital converter, and a current output circuit. The current control board includes: The receiving unit is used to receive the target current parameters sent by the master station in response to the synchronization interrupt signal generated by the slave station controller. The output unit is used to generate an analog output control quantity based on the target current parameter, output a control voltage through the digital-to-analog converter, and control the current output circuit to output the load current. The acquisition unit is used to periodically acquire the feedback voltage signal corresponding to the load current, and convert it into the actual output current through the analog-to-digital converter; The determining unit is used to determine the current deviation based on the target current parameter and the actual output current, and to determine the deviation change parameter based on the current current deviation and the historical current deviation. The inference unit is used to perform fuzzy inference based on the current current deviation and the deviation change parameters to obtain the proportional parameter adjustment amount, integral parameter adjustment amount and differential parameter adjustment amount; The updating unit is used to update the PID parameters according to the proportional parameter adjustment amount, the integral parameter adjustment amount and the derivative parameter adjustment amount to obtain the updated PID parameters, and to calculate the current control correction amount based on the updated PID parameters. The transmitting unit is used to update the analog output control quantity according to the current control correction quantity, and send the actual output current to the master station through the slave controller.
[0014] A third aspect of this application provides an electronic device, comprising: Processor, memory, input / output units, and bus; The processor is connected to the memory, the input / output unit, and the bus; The memory stores a program, and the processor calls the program to execute the method of the first aspect and any possible implementation of the first aspect.
[0015] The fourth aspect of this application provides a computer-readable storage medium storing a program that, when executed on a computer, causes the computer to perform the methods of the first aspect and any possible implementation thereof.
[0016] As can be seen from the above technical solutions, this application has the following advantages: In this application, the current control board generates current deviation and deviation change parameters based on the target current parameters and the actual output current, and uses fuzzy inference to obtain proportional parameter adjustment, integral parameter adjustment, and derivative parameter adjustment to dynamically update PID parameters and correct analog output control quantities. Most importantly, it can improve the control accuracy of load current. At the same time, periodic feedback acquisition and synchronous status transmission can improve the response capability to current output changes and the timeliness of the upper master station to obtain current control information. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a flowchart illustrating one embodiment of the current control method for the current control board in this application; Figure 2 This is a flowchart illustrating the first sub-implementation of the current control method for the current control board in this application; Figure 3This is a flowchart illustrating the second sub-implementation of the current control method for the current control board in this application; Figure 4 This is a flowchart illustrating the third sub-implementation of the current control method for the current control board in this application; Figure 5 This is a flowchart illustrating the fourth sub-implementation of the current control method for the current control board in this application; Figure 6 This is a flowchart illustrating the fifth sub-implementation of the current control method for the current control board in this application; Figure 7 This is a flowchart illustrating the sixth sub-implementation of the current control method for the current control board in this application; Figure 8 This is a flowchart illustrating the seventh sub-implementation of the current control method for the current control board in this application; Figure 9 This is a schematic diagram of the structure of one embodiment of the current control board in this application; Figure 10 This is a schematic diagram of the structure of one embodiment of the electronic device in this application. Detailed Implementation
[0019] This application provides a current control method and a current control board for improving the control accuracy of load current.
[0020] The method described in this application can be applied to servers, terminals, or other devices with logical processing capabilities; therefore, this application does not limit its application. For ease of description, the following description uses a server as the executing entity.
[0021] The embodiments of this application will now be described with reference to the accompanying drawings.
[0022] Please see Figure 1 , Figure 1 One embodiment of the current control method for the current control board provided in this application includes a slave controller, a digital-to-analog converter, an analog-to-digital converter, and a current output circuit. This embodiment includes: 101. In response to the synchronization interrupt signal generated by the slave controller, receive the target current parameters sent by the master station.
[0023] The slave controller interacts with the master station according to a preset communication cycle and generates a synchronization interrupt signal when the synchronization time is reached. The synchronization interrupt signal is a hardware interrupt signal used to instruct the current control board to perform periodic communication operations. After detecting the synchronization interrupt signal, the current control board enters the corresponding interrupt handling process and reads the data sent by the master station from the communication data area provided by the slave controller.
[0024] The read data includes the target current parameter. This target current parameter represents the magnitude of the current that the host computer requires the current control board to output to the load. It can be a numerical value, a corresponding digital code, or a data format that can be converted into a numerical value. The current control board parses the target current parameter according to a preset data format and saves the parsing result to the parameter storage area corresponding to the current control cycle.
[0025] By using a synchronous interrupt signal to trigger the reception of the target current parameters, the parameter reading time can be correlated with the communication cycle of the upper master station, thus preventing the current control board from reading data that has not yet been updated while the upper master station is updating data.
[0026] 102. Generate analog output control quantity based on target current parameters, output control voltage through digital-to-analog converter, and control the current output circuit to output load current.
[0027] After obtaining the target current parameters, the current control board converts the target current parameters into analog output control quantities according to the pre-established correspondence between the target current and the control voltage. The analog output control quantities are digital control data used to configure the output amplitude of the digital-to-analog converter, and their values correspond to the control voltage to be output.
[0028] For example, when the current output circuit adopts a driving method in which the control voltage corresponds to the load current, the target current parameter can be proportionally converted according to the voltage input range and current output range of the current output circuit to obtain the target control voltage. Then, according to the resolution and output range of the digital-to-analog converter, the target control voltage can be converted into the corresponding digital control data.
[0029] The current control board writes the analog output control signal into the corresponding conversion channel of the digital-to-analog converter (DAC). The DAC converts the digital analog output control signal into a control voltage and provides this control voltage to the current output circuit. The current output circuit generates a load current corresponding to the target current parameter based on the control voltage and outputs this load current to the connected load.
[0030] 103. Periodically collect the feedback voltage signal corresponding to the load current, and convert it into the actual output current through an analog-to-digital converter.
[0031] During load current output, the current control board initiates a current acquisition operation according to a preset sampling period. The sampling period can be determined by a timing signal generated by a hardware timer, ensuring that each acquisition operation is performed at a set time interval. The load current is converted into a feedback voltage signal by the current detection circuit, and the amplitude of the feedback voltage signal has a preset correspondence with the current load current.
[0032] The analog-to-digital converter (ADC) receives the feedback voltage signal and performs analog-to-digital conversion on it when the sampling operation is triggered, obtaining the corresponding digital sample value. After the analog-to-digital conversion is completed, the current control board reads the digital sample value and converts it into a current value according to the ADC's input range, conversion resolution, and the correspondence between the feedback voltage and the load current.
[0033] The calculated current value is used as the actual output current, representing the magnitude of the current supplied to the load by the current output circuit at the current sampling moment. Periodically acquiring the feedback voltage signal generates actual output current data arranged in chronological order.
[0034] 104. Determine the current current deviation based on the target current parameter and the actual output current, and determine the deviation change parameter based on the current current deviation and the historical current deviation.
[0035] The current control board calculates the difference between the target current value corresponding to the target current parameter and the currently sampled actual output current to obtain the current deviation. The magnitude of the current current deviation indicates the degree of difference between the actual output current and the target current value, and the positive or negative direction of the current current deviation indicates the direction of deviation of the actual output current relative to the target current value.
[0036] Historical current deviation is the current deviation formed and saved before the current control cycle. It can be the current deviation of the previous control cycle or the current deviation processing results corresponding to multiple historical control cycles. After completing the calculation of the current current deviation, the current control board reads the historical current deviation from the deviation storage area and calculates the difference between the current current deviation and the historical current deviation to obtain the deviation change parameter.
[0037] The deviation variation parameter is used to characterize the direction and degree of change of the current deviation between adjacent control cycles. For example, a positive deviation variation parameter indicates that the current current deviation changes in the positive direction relative to the historical current deviation; a negative deviation variation parameter indicates that the current current deviation changes in the negative direction; and a deviation variation parameter close to zero indicates that the current deviation changes little between adjacent control cycles.
[0038] 105. Based on the current current deviation and deviation change parameters, perform fuzzy reasoning to obtain the proportional parameter adjustment, integral parameter adjustment, and derivative parameter adjustment.
[0039] The current control board performs fuzzification processing on the current current deviation and deviation change parameters, converting continuously changing values into corresponding fuzzy levels. Fuzzy levels are discrete states divided according to numerical magnitude and positive / negative direction, and can include negative large, negative medium, negative small, zero, positive small, positive medium, and positive large. Negative large to negative small represent different degrees of negative values, positive small to positive large represent different degrees of positive values, and zero indicates that the value is in a preset zero-value neighborhood.
[0040] After determining the deviation fuzziness level corresponding to the current deviation and the deviation change fuzziness level corresponding to the deviation change parameter, the current control board uses the two fuzziness levels as input combinations for fuzzy inference. Using the deviation fuzziness level as one index dimension and the deviation change fuzziness level as another index dimension, it queries the proportional parameter fuzzy rule table, the integral parameter fuzzy rule table, and the derivative parameter fuzzy rule table, respectively.
[0041] Each fuzzy rule table records the parameter adjustment level under the corresponding fuzzy level combination. The current control board reads the corresponding parameter adjustment levels from the three fuzzy rule tables and converts them into numerical forms according to a preset quantization relationship, obtaining the proportional parameter adjustment, integral parameter adjustment, and derivative parameter adjustment. The proportional parameter adjustment, integral parameter adjustment, and derivative parameter adjustment represent the changes in the three PID parameters within the current control cycle.
[0042] 106. Update the PID parameters based on the proportional parameter adjustment, integral parameter adjustment, and derivative parameter adjustment to obtain the updated PID parameters, and calculate the current control correction based on the updated PID parameters.
[0043] The current control board reads the currently used proportional, integral, and derivative parameters, and combines the adjustment values of each parameter with the corresponding current parameters to obtain updated proportional, integral, and derivative parameters. When the parameter adjustment value is positive, the corresponding PID parameter increases by the corresponding amount; when the parameter adjustment value is negative, the corresponding PID parameter decreases by the corresponding amount; when the parameter adjustment value is zero, the corresponding PID parameter remains unchanged.
[0044] Subsequently, the proportional control component is calculated based on the updated proportional parameters and the current current deviation; the integral control component is calculated based on the updated integral parameters and the cumulative current deviation; and the differential control component is calculated based on the updated derivative parameters and the deviation change parameters. The cumulative current deviation can be obtained by accumulating the current deviations generated in the current control cycle and previous control cycles.
[0045] After the proportional control component, integral control component, and derivative control component are calculated, the current control board synthesizes the three control components according to a preset PID calculation method to obtain the current control correction. The current control correction is the control output data generated by the PID calculation, used to represent the comprehensive adjustment amplitude and direction corresponding to the current control cycle.
[0046] 107. Update the analog output control quantity according to the current control correction quantity, and send the actual output current to the upper master station through the slave controller.
[0047] The current control board combines the current control correction value with the current analog output control value. It increases or decreases the current analog output control value based on the positive or negative direction of the current control correction value to obtain the updated analog output control value. During the update process, the calculation result can also be limited according to the control data range allowed by the digital-to-analog converter (DAC) to prevent the updated result from exceeding the DAC's effective output range.
[0048] The updated analog output control signal is written to the corresponding output channel of the digital-to-analog converter (DAC) to adjust the control voltage output by the DAC. The current control board repeatedly executes current acquisition, deviation determination, fuzzy inference, PID parameter update, and control signal correction according to the control cycle, forming a closed-loop control process between the target current parameter, the actual output current, and the analog output control signal.
[0049] After completing data processing for the current control cycle, the current control board writes the actual output current into the communication data area corresponding to the slave controller. Furthermore, the current control board can also write the current control status into the corresponding communication data area of the slave controller. The current control status is information characterizing the current operating status of the current control process, and can include the control cycle execution status, output channel operating status, and control data update status. Upon reaching the communication synchronization time, the slave controller sends the actual output current to the master station.
[0050] The current control board generates current deviation and deviation change parameters based on the target current parameters and the actual output current. It then uses fuzzy inference to obtain proportional, integral, and derivative parameter adjustment values to dynamically update PID parameters and correct analog output control values. This primarily improves the control accuracy of the load current. At the same time, periodic feedback acquisition and synchronous status transmission enhance the responsiveness to changes in current output and the timeliness of current control information acquisition by the host computer.
[0051] Please see Figure 2In some embodiments of this application, step 105 in the above embodiments, based on the current current deviation and deviation change parameters, performs fuzzy inference to obtain the proportional parameter adjustment amount, integral parameter adjustment amount, and derivative parameter adjustment amount, and may include the following steps: 201. Determine the fuzzy level of the deviation based on the correspondence between the current current deviation and the preset deviation range.
[0052] After acquiring the current current deviation, the current control board identifies the magnitude and direction of the deviation, and matches it with multiple pre-defined deviation intervals. These pre-defined deviation intervals are multiple continuous numerical ranges divided according to the range of current deviation variation, with each interval corresponding to a specific deviation state.
[0053] When the current current deviation falls within one of the deviation intervals, the current control board determines the level corresponding to that deviation interval as the deviation fuzzy level. The deviation fuzzy level is used to convert the continuously changing current deviation into a discrete state, and can include negative large, negative medium, negative small, zero, positive small, positive medium, and positive large, where different levels represent the direction and degree of deviation of the current deviation, respectively. For the current current deviation located at the boundary of adjacent deviation intervals, the corresponding deviation fuzzy level can be determined according to a preset boundary assignment rule.
[0054] 202. Determine the fuzziness level of the deviation change based on the correspondence between the deviation change parameters and the preset change range.
[0055] After obtaining the deviation change parameters, the current control board compares the deviation change parameters with multiple pre-defined change ranges. The deviation change parameters reflect the direction and degree of change of the current deviation relative to the historical current deviation, while the preset change ranges are used to distinguish different states of change such as rapid increase, slow increase, basically stable, slow decrease, or rapid decrease of the current deviation.
[0056] Based on the comparison results, the current control board determines the target variation range into which the deviation change parameter falls, and defines the level corresponding to the target variation range as the deviation change fuzzy level. The deviation change fuzzy level can also be divided into negative large, negative medium, negative small, zero, positive small, positive medium, and positive large, representing the changing trend of current deviation between adjacent control cycles in a discrete form.
[0057] 203. Based on the combination of deviation fuzziness level and deviation change fuzziness level, query the proportional parameter fuzzy rule table, integral parameter fuzzy rule table and differential parameter fuzzy rule table respectively to obtain the proportional parameter fuzzy output value, integral parameter fuzzy output value and differential parameter fuzzy output value.
[0058] The current control board combines the deviation fuzzy level and the deviation change fuzzy level into fuzzy state combinations, using one fuzzy level as the row index and the other as the column index of the rule table. Each fuzzy state combination corresponds to a rule unit in the rule table, thus enabling the determination of the corresponding output under the common constraints of the two input states.
[0059] Using the same row and column indices, the current control board accesses the proportional parameter fuzzy rule table, the integral parameter fuzzy rule table, and the derivative parameter fuzzy rule table, respectively, and reads the output levels recorded in the three rule units. The proportional parameter fuzzy rule table is used to provide the proportional parameter fuzzy output value, the integral parameter fuzzy rule table is used to provide the integral parameter fuzzy output value, and the derivative parameter fuzzy rule table is used to provide the derivative parameter fuzzy output value.
[0060] Each fuzzy output value represents the adjustment direction and degree of the corresponding parameter, and can be recorded using discrete levels such as negative large, negative medium, negative small, zero, positive small, positive medium, and positive large. Among them, a negative level indicates that the corresponding parameter decreases to a corresponding degree, a positive level indicates that the corresponding parameter increases to a corresponding degree, and a zero level indicates that the corresponding parameter is not adjusted.
[0061] 204. Numericalize the fuzzy output values of the proportional parameter, integral parameter, and derivative parameter respectively to obtain the adjustment amounts of the proportional parameter, integral parameter, and derivative parameter.
[0062] The current control board acquires the discrete levels corresponding to the three fuzzy output values, and converts each discrete level into a numerical value that can participate in the control calculation based on the preset mapping relationship between the level and the value. This mapping relationship allows for the configuration of corresponding adjustment values for each positive level, negative level, and zero level, so that the adjustment direction and degree contained in the fuzzy output value can be represented in numerical form.
[0063] After numerical processing, the fuzzy output values of the proportional parameter are converted into proportional parameter adjustment values, the fuzzy output values of the integral parameter are converted into integral parameter adjustment values, and the fuzzy output values of the derivative parameter are converted into derivative parameter adjustment values. Each of the three parameter adjustment values has a corresponding positive or negative direction and a numerical magnitude, and they are combined with the current fuzzy state.
[0064] The current control board determines the corresponding fuzzy level based on the current current deviation and deviation change parameters. It then queries the proportional parameter fuzzy rule table, integral parameter fuzzy rule table, and derivative parameter fuzzy rule table in combination with the two types of fuzzy levels, and converts the fuzzy output value into parameter adjustment amount. This enables the adjustment direction and adjustment magnitude of the proportional parameter, integral parameter, and derivative parameter to correspond to the current current deviation state.
[0065] Please see Figure 3In some embodiments of this application, step 203 in the above embodiments, based on the combination of the deviation fuzziness level and the deviation change fuzziness level, queries the proportional parameter fuzzy rule table, the integral parameter fuzzy rule table, and the differential parameter fuzzy rule table respectively to obtain the proportional parameter fuzzy output value, the integral parameter fuzzy output value, and the differential parameter fuzzy output value, may include the following steps: 301. Determine the first index position in the proportional parameter fuzzy rule table, integral parameter fuzzy rule table, and differential parameter fuzzy rule table respectively based on the deviation fuzziness level.
[0066] After the current control board obtains the deviation fuzziness level, it converts the deviation fuzziness level into a corresponding index identifier according to the pre-established mapping relationship between fuzziness levels and index positions. The deviation fuzziness level can be arranged into states such as negative large, negative medium, negative small, zero, positive small, positive medium, and positive large, with different states corresponding to different index identifiers.
[0067] The first index position is the position corresponding to the deviation fuzziness level on the specified index dimension of the fuzzy rule table. It can be represented as a row position or a position arranged according to a preset storage order. The current control board determines the first index position corresponding to the deviation fuzziness level in the proportional parameter fuzzy rule table, integral parameter fuzzy rule table, and derivative parameter fuzzy rule table respectively, and records each first index position to distinguish the query range in the three fuzzy rule tables.
[0068] The three fuzzy rule tables can use the same order of deviation fuzziness levels, or they can be configured with different mapping relationships between fuzziness levels and the first index position. When the three fuzzy rule tables use different orderings, the current control board queries their respective mapping relationships to avoid directly using the same index identifier for different fuzzy rule tables.
[0069] 302. Determine the second index position in the proportional parameter fuzzy rule table, integral parameter fuzzy rule table, and differential parameter fuzzy rule table respectively based on the fuzziness level of the deviation change.
[0070] After the first index position is determined, the current control board acquires the fuzzy level of the deviation change and converts it into a corresponding index identifier according to the preset mapping relationship between the fuzzy level and the index position. The fuzzy level of the deviation change is used to represent the direction and degree of change of the current deviation between adjacent control cycles, and different levels are associated with different second index positions.
[0071] The second index position is the position corresponding to the fuzzy level of deviation change on another specified index dimension of the fuzzy rule table. It can be represented as a column position or as another storage dimension position that intersects with the first index position. The current control board determines the second index position of the fuzzy level of deviation change in the proportional parameter fuzzy rule table, the integral parameter fuzzy rule table, and the derivative parameter fuzzy rule table, respectively, and associates and saves each second index position with the corresponding first index position.
[0072] If the three fuzzy rule tables use the same fuzzy level arrangement for deviation changes, the second index position can be determined based on the same mapping relationship; if the arrangement is different, the position is determined based on the mapping relationship corresponding to each fuzzy rule table, thereby maintaining the correspondence between the fuzzy level of deviation change and each second index position.
[0073] 303. Read the rule units determined by the first index position and the second index position respectively to obtain the fuzzy output values of the proportional parameter, the integral parameter, and the derivative parameter.
[0074] The current control board combines the first and second index positions in the proportional parameter fuzzy rule table to locate the rule cell that both index positions point to, and reads the proportional parameter fuzzy output value stored in that rule cell. A rule cell is a data location in the fuzzy rule table used to record the output result corresponding to a combination of a deviation fuzziness level and a deviation change fuzziness level.
[0075] Following the same positioning method, the current control board reads the rule unit pointed to by both the first and second index positions in the integral parameter fuzzy rule table to obtain the fuzzy output value of the integral parameter; and reads the corresponding rule unit in the differential parameter fuzzy rule table to obtain the fuzzy output value of the differential parameter. The three fuzzy output values can be represented by discrete levels such as negative large, negative medium, negative small, zero, positive small, positive medium, and positive large.
[0076] During the reading process, it is possible to check whether each index position is within the valid index range of the corresponding fuzzy rule table, and save the reading results according to the correspondence between the proportional parameter, integral parameter and differential parameter to avoid confusion between the output values of different fuzzy rule tables.
[0077] The current control board determines the first and second index positions in the three types of fuzzy rule tables based on the deviation fuzziness level and the deviation change fuzziness level, and reads the rule unit jointly determined by the two index positions. This enables it to accurately match the proportional parameter fuzzy output value, integral parameter fuzzy output value, and derivative parameter fuzzy output value corresponding to the current fuzzy state combination, thereby reducing the correspondence error between different parameter output results.
[0078] Please see Figure 4In some embodiments of this application, the PID parameters may include proportional parameters, integral parameters, and derivative parameters. Step 106 in the above embodiments updates the PID parameters according to the proportional parameter adjustment, integral parameter adjustment, and derivative parameter adjustment to obtain updated PID parameters, and calculates the current control correction based on the updated PID parameters, which may include the following steps: 401. Add the current proportional parameter to the proportional parameter adjustment amount to obtain the updated proportional parameter.
[0079] The current control board reads the current proportional parameter from the PID parameter storage area. The current proportional parameter can be the proportional parameter saved after parameter adjustment in the previous control cycle, or it can be the initial proportional parameter configured during the initialization of the current control process, used to indicate the strength of the proportional control action in the current control state.
[0080] Subsequently, the adjustment amount of the proportional parameter is added to the current proportional parameter, and the result is determined as the updated proportional parameter. When the adjustment amount of the proportional parameter is positive, the updated proportional parameter is greater than the current proportional parameter; when the adjustment amount of the proportional parameter is negative, the updated proportional parameter is less than the current proportional parameter; when the adjustment amount of the proportional parameter is zero, the updated proportional parameter remains unchanged.
[0081] 402. Add the current integral parameter to the integral parameter adjustment amount to obtain the updated integral parameter.
[0082] After updating the proportional parameters, the current control board reads the current integral parameters. The current integral parameters are used to limit the participation of the cumulative current deviation in the control calculation. They can be the integral parameters saved in the previous control cycle or the initial integral parameters configured during initialization.
[0083] The current control board adds the integral parameter adjustment amount to the current integral parameter and uses the result as the updated integral parameter. The sign of the integral parameter adjustment amount determines the direction of increase or decrease of the integral parameter, and its magnitude determines the magnitude of change of the integral parameter, thus forming the integral parameter corresponding to the current control cycle.
[0084] 403. Add the current differential parameter to the differential parameter adjustment amount to obtain the updated differential parameter.
[0085] The current control board reads the current derivative parameters from the PID parameter storage area. The current derivative parameters are used to limit the degree to which the current deviation trend participates in the control operation. Their initial values can be pre-configured when the control program starts and saved after adjustment in each control cycle.
[0086] After adding the differential parameter adjustment amount to the current differential parameter, the current control board obtains the updated differential parameter. When the differential parameter adjustment amount is positive, the current differential parameter is increased; when the differential parameter adjustment amount is negative, the current differential parameter is decreased; when the differential parameter adjustment amount is zero, the current differential parameter continues to be used.
[0087] 404. Calculate the proportional control component based on the current current deviation and the updated proportional parameters.
[0088] After obtaining the updated proportional parameters, the current control board multiplies the current current deviation by the updated proportional parameters to obtain the proportional control component. The magnitude of the proportional control component depends on both the degree of deviation of the current current deviation and the updated proportional parameters.
[0089] The direction of the current current deviation determines the direction of the proportional control component, and the updated proportional parameter determines the amplification of the current current deviation in the proportional control component. Therefore, when the current current deviation increases or the updated proportional parameter increases, the absolute value of the proportional control component increases accordingly.
[0090] 405. Calculate the integral control component based on the cumulative current deviation and the updated integral parameters.
[0091] The cumulative current deviation is a parameter obtained by accumulating the current deviation and the current deviations corresponding to each control cycle before the current control cycle. It is used to reflect the overall accumulation of current deviation during a continuous control process. The current control board can read the accumulated current deviation results corresponding to each control cycle before the current control cycle from the deviation accumulation area, and add the current current deviation to the accumulated result to form the cumulative current deviation corresponding to the current control cycle.
[0092] Subsequently, the cumulative current deviation is multiplied by the updated integral parameters to obtain the integral control component. The updated integral parameters are used to limit the influence of the cumulative current deviation on the integral control component, and the positive or negative direction of the cumulative current deviation determines the direction of action of the integral control component.
[0093] 406. Calculate the differential control component based on the deviation change parameters and the updated differential parameters.
[0094] The current control board acquires the deviation change parameters previously determined based on the current current deviation and historical current deviation. These deviation change parameters represent the direction and magnitude of current deviation change between adjacent control cycles, reflecting the current current deviation's trend.
[0095] The current control board obtains the differential control component by multiplying the deviation change parameter with the updated differential parameter. The updated differential parameter determines the degree of participation of the deviation change parameter in the differential control component, and the positive or negative direction of the deviation change parameter determines the direction of action of the differential control component.
[0096] 407. The proportional control component, integral control component and derivative control component are superimposed to obtain the current control correction.
[0097] After calculating the three control components, the current control board reads the proportional control component, integral control component, and derivative control component respectively, and performs addition operations on the three control components according to the preset data precision and symbol representation. During the superposition process, each control component retains its positive and negative directions; control components with the same direction are added together, while control components with opposite directions cancel each other out.
[0098] The superposition of the three control components is determined as the current control correction. The current control correction comprehensively includes the control data corresponding to the current current deviation, cumulative current deviation, and deviation change parameters. Its positive and negative directions indicate the correction direction of the current control cycle, and its numerical value indicates the corresponding correction magnitude.
[0099] The current control board updates the corresponding PID parameters using proportional, integral, and derivative parameter adjustments, respectively. It also calculates and superimposes three control components based on the current current deviation, cumulative current deviation, and deviation change parameters, thus forming a current control correction quantity that takes into account the current deviation, the cumulative deviation, and the deviation change trend.
[0100] Please see Figure 5 In some embodiments of this application, after determining the current current deviation based on the target current parameter and the actual output current, and determining the deviation change parameter based on the current current deviation and the historical current deviation, step 104 in the above embodiments may include the following steps before performing fuzzy inference based on the current current deviation and the deviation change parameter to obtain the proportional parameter adjustment amount, integral parameter adjustment amount, and derivative parameter adjustment amount: 501. Compare the absolute value of the current current deviation with the preset current deviation threshold.
[0101] After acquiring the current current deviation, the current control board performs an absolute value calculation on the deviation to eliminate the influence of the deviation direction on the amplitude judgment. A positive current deviation indicates that the actual output current deviates from the target current in one direction; a negative current deviation indicates that the actual output current deviates in the opposite direction. The deviation amplitude obtained after taking the absolute value uniformly represents the degree of difference between the two.
[0102] The preset current deviation threshold is a comparison benchmark used to divide the allowable deviation range from the abnormal deviation range. It can be configured according to the control accuracy of the current output circuit, load characteristics, and actual application requirements. The current control board compares the deviation amplitude with the preset current deviation threshold and generates a comparison result that is greater than, equal to, or less than the preset current deviation threshold. For example, the preset current deviation threshold can be configured to 0.3mA.
[0103] 502. When the absolute value of the current current deviation is greater than the preset current deviation threshold, the cumulative deviation duration.
[0104] The deviation duration characterizes the length of time during which the absolute value of the current current deviation is continuously greater than a preset current deviation threshold. When the absolute value of the current current deviation is continuously greater than the preset current deviation threshold, the corresponding continuous over-limit period forms the deviation duration; when the absolute value of the current current deviation is no longer greater than the preset current deviation threshold, the current continuous over-limit period ends. If the absolute value of the current current deviation subsequently exceeds the preset current deviation threshold again, a new continuous over-limit period is formed, and the durations of the two consecutive non-continuous over-limit periods are not merged.
[0105] When the comparison result indicates that the absolute value of the current current deviation is greater than the preset current deviation threshold, the current control board starts or continues to execute a timing operation to record the duration for which the current current deviation remains within the abnormal deviation range. The deviation duration is the cumulative duration for which the absolute value of the current current deviation is continuously greater than the preset current deviation threshold. It can be calculated from the control cycle count value and the duration of a single control cycle, or it can be directly recorded by a hardware timer or a software timer.
[0106] Within adjacent control cycles, if the absolute value of the current current deviation remains greater than the preset current deviation threshold, the time corresponding to one control cycle is added to the existing timing result; if the absolute value of the current current deviation is detected to be greater than the preset current deviation threshold for the first time, the deviation duration is accumulated from the initial value. Using a continuous time accumulation method can distinguish between instantaneous current fluctuations and persistent current deviations.
[0107] When the absolute value of the current deviation recovers to no greater than the preset current deviation threshold in subsequent control cycles, the existing deviation duration can be cleared so that the timing can be reset the next time a continuous deviation is detected. For example, the duration can be set to 60ms.
[0108] 503. When the deviation duration reaches the preset duration, the current output of the current output circuit is paused, and an abnormal current output information is generated.
[0109] The current control board compares the accumulated deviation duration with the preset duration. When the deviation duration reaches the preset duration, it indicates that the deviation between the actual output current and the target current has existed continuously for a corresponding period of time, and the current control board switches the current current control state to an abnormal state accordingly.
[0110] In abnormal conditions, the current control board stops providing control signals to the current output circuit to maintain the load current. Specifically, it can stop updating the analog output control quantity, configure the corresponding output channel of the digital-to-analog converter to a preset safe output value, or control the current output circuit to enter a shutdown state, thereby pausing the load current output.
[0111] After completing the output pause process, the current control board generates current output anomaly information. This information identifies the anomaly type corresponding to the continuous current deviation and may include at least one of the following: anomaly code, the output channel where the anomaly occurred, the current current deviation, the actual output current, and the time the anomaly occurred. For example, the error code corresponding to the continuous current deviation can be configured as 0x11.
[0112] 504. Write the abnormal current output information into the communication interaction data and send it to the master station through the slave station controller.
[0113] After generating abnormal current output information, the current control board writes the abnormal current output information into the fault information field of the communication interaction data according to the data format agreed upon with the upper master station. The communication interaction data is a collection of data periodically exchanged between the current control board and the upper master station, which can be divided into data areas such as current sampling field, operating status field, control parameter field, and fault information field.
[0114] During the writing process, the current control board can configure the exception code and exception channel identifier into the corresponding fields, and update the data validity flag of the communication interaction data. For multi-channel current output scenarios, the channel identifier can also be used to establish a correspondence between current output exception information and exception output channels.
[0115] When the slave controller generates a communication interruption signal or a synchronization interruption signal, the current control board provides communication interaction data containing current output abnormality information to the slave controller, which then sends it to the master station so that the master station can read the current abnormal status and execute the corresponding upper-level control operation.
[0116] The current control board compares the absolute value of the current deviation with the preset current deviation threshold and determines whether to pause the current output based on the duration of the deviation. This can distinguish between instantaneous current fluctuations and continuous current deviations, reducing the operational risks caused by continuing to output current under continuous deviation conditions. Abnormal current output information is written into the communication interaction data and sent to the upper master station, which helps the upper master station to obtain abnormal status in a timely manner.
[0117] Please see Figure 6 In some embodiments of this application, step 103 in the above embodiments, which involves periodically acquiring the feedback voltage signal corresponding to the load current and converting it into the actual output current using an analog-to-digital converter, may include the following steps: 601. Configure the hardware timer to periodically generate sampling trigger signals.
[0118] The current control board determines the counting parameters of the hardware timer based on a preset sampling period. These parameters can include clock division parameters, counting period parameters, and counting mode. The preset sampling period is used to limit the time interval between two adjacent feedback voltage acquisition operations. It can be pre-configured during the current control board initialization process or determined based on the current acquisition frequency set in the control program.
[0119] After configuring the counting parameters, the current control board starts the hardware timer. The hardware timer continuously counts according to the input clock, and generates a sampling trigger signal when the count value reaches the counting end point corresponding to the counting cycle parameter, and then restarts the next counting cycle. The sampling trigger signal can take the form of a timer update event, a timer trigger output event, or a timer compare event.
[0120] The hardware timer operates with the same counting parameters in each counting cycle, thus forming a sampling trigger signal sequence with relatively fixed time intervals. The sampling trigger signal serves as the timing reference for the feedback voltage acquisition operation, identifying the start time of each sampling conversion.
[0121] 602. The analog-to-digital converter is controlled to sample and convert the feedback voltage signal based on the sampling trigger signal.
[0122] The current control board configures the sampling trigger signal as the conversion trigger source for the analog-to-digital converter, and configures the sampling channel, sampling time, conversion resolution, and data alignment method corresponding to the feedback voltage signal. The feedback voltage signal is obtained by converting the load current through the current detection circuit, and its voltage amplitude corresponds to the magnitude of the load current.
[0123] When the analog-to-digital converter receives a sampling trigger signal, it initiates the sample-and-hold operation for the corresponding sampling channel, and converts the feedback voltage signal into a digital sampled value after the sample-and-hold operation is completed. Each sampling trigger signal corresponds to one sampling conversion operation, so that the feedback voltage signal is continuously sampled according to the period determined by the hardware timer.
[0124] When using multi-channel feedback voltage acquisition, the channel conversion sequence of the analog-to-digital converter can be pre-configured so that different feedback channels respond to the sampling trigger signal in a set order; when using single-channel feedback voltage acquisition, the corresponding sampling channel can be configured as a fixed conversion channel.
[0125] 603. In response to the conversion completion interrupt signal generated by the analog-to-digital converter, read the sampled conversion value.
[0126] After the analog-to-digital converter completes the sampling and conversion of the current feedback voltage signal, it sets the conversion completion status and generates a conversion completion interrupt signal. The conversion completion interrupt signal is used to notify the current control board that the current sampling and conversion result has been generated and data reading operations can be performed.
[0127] After the current control board detects the conversion completion interrupt signal, it enters the corresponding interrupt handler and determines the analog-to-digital converter channel that generated the interrupt based on the interrupt status. Subsequently, it reads the current conversion result from the analog-to-digital converter's data register or the data interface connected to the analog-to-digital converter, and determines the read digital data as the sampled conversion value.
[0128] After the read operation is complete, the current control board can clear the conversion completion status and write the sampled conversion value to the data storage area corresponding to the sampling channel. Using a conversion completion interrupt signal to trigger the read operation ensures that the read time of the sampled conversion value corresponds to the conversion completion time of the analog-to-digital converter.
[0129] 604. Based on the preset mapping relationship between the sampled conversion value and the output current, convert the sampled conversion value into the actual output current.
[0130] After acquiring the sampled conversion value, the current control board converts it into a feedback voltage value based on the conversion resolution of the analog-to-digital converter and the input voltage range. For example, the voltage position corresponding to the feedback voltage value within the input voltage range can be determined based on the proportion of the sampled conversion value within the full-scale digital range of the analog-to-digital converter.
[0131] Subsequently, based on the preset mapping relationship between the feedback voltage value and the output current, the feedback voltage value is converted into the actual output current. The preset mapping relationship can be established in advance based on the sampling resistor of the current detection circuit, the signal amplification factor, the zero-point offset, and the proportional relationship between voltage and current, and is stored in the current control board in the form of conversion parameters, mapping functions, or mapping tables.
[0132] If different current output channels have different feedback conversion characteristics, the current control board can read the corresponding mapping parameters based on the current sampling channel and use the corresponding mapping relationship to complete the current conversion. The converted actual output current is used to represent the magnitude of the current supplied to the load by the current output circuit at the current sampling moment.
[0133] The current control board uses a hardware timer to periodically generate sampling trigger signals and reads the sampled conversion values after the analog-to-digital converter completes the conversion, which can maintain the stability of the sampling timing of the feedback voltage signal. According to the preset mapping relationship, the sampled conversion values are converted into actual output current, which can maintain the consistency of current feedback data conversion in each control cycle.
[0134] Please see Figure 7 In some embodiments of this application, before receiving the target current parameters sent by the master station in step 101 of the above embodiments in response to the synchronization interrupt signal generated by the slave station controller, the following steps may be included: 701. Initialize the EtherCAT protocol stack, write detection data to the target register of the slave controller, and read feedback data.
[0135] After the current control board is powered on, it sequentially initializes the microcontroller interface, communication bus, and related hardware resources of the slave controller, and loads the configuration parameters required for the EtherCAT protocol stack to run. The initialization content may include the communication interface working mode, interrupt interface, synchronization signal interface, and slave controller access timing, enabling the microcontroller to perform read and write operations on the internal registers of the slave controller.
[0136] After completing the basic configuration, the current control board selects the target register in the slave controller used for communication access detection and generates detection data according to the data width of the target register. For example, the 204h register of the slave controller can be used as the target register, and the detection data can be a pre-set register test value that is easy to compare.
[0137] Subsequently, the current control board writes detection data to the target register, and after the write operation is complete, reads the data currently stored in the target register, using the read result as feedback data. The detection data and feedback data are saved separately to the initialization detection area for subsequent determination of whether the slave controller's register access is normal.
[0138] 702. Compare the detection data with the feedback data to determine the access status of the target register.
[0139] After obtaining the detection data and feedback data, the current control board compares the two data with the same data width and format. Before the comparison, a masking process can be performed on the read results, retaining only the valid bits that are allowed to be written and read in the target register, to avoid read-only bits, reserved bits, or automatically changing bits affecting the comparison results.
[0140] When the detected data matches the feedback data, it indicates that the data written to the target register can be correctly saved and read. The current control board then determines the access status of the target register as normal. A normal status means that the register access link between the current microcontroller and the slave controller meets the subsequent EtherCAT protocol stack initialization requirements.
[0141] When the detected data and the feedback data are inconsistent, it indicates that the write or read result of the target register has not met expectations, and the current control board will determine the access status as abnormal. The abnormal status is used to identify data inconsistencies in the current register access process, serving as the basis for subsequent recovery processing.
[0142] 703. When the access status is abnormal, perform a hardware reset on the slave controller and re-access the target register after the hardware reset.
[0143] Once the access status is determined to be abnormal, the current control board switches the hardware reset pin connected to the slave controller to the reset level and maintains it for a preset reset duration, restoring the slave controller's internal communication logic, register state, and interface state to their initial power-on state. After the preset reset duration is reached, the hardware reset pin is released, and the system waits for the slave controller to complete its internal startup.
[0144] After the slave controller restarts, the current control board restores the communication interface configuration between itself and the slave controller and re-establishes the register access conditions. The re-established settings may include interface timing, chip select signal, read / write control signals, and access wait time, avoiding the reuse of potentially abnormal interface states from before the reset.
[0145] After completing the configuration recovery, the current control board writes the detection data to the target register again and rereads the feedback data from the target register to re-execute the target register access. The result of the re-access is used to characterize whether the slave controller's register read / write function has been restored after the hardware reset.
[0146] 704. When re-accessing the target register fails, the initialization process of the EtherCAT protocol stack ends, and the error indicator light is switched to the exception indication state.
[0147] The current control board determines whether the target register can complete data interaction normally based on the write and read results generated during the re-access process. If the corresponding feedback data cannot be read after rewriting the detection data, or if the register access operation is not completed within the allowed time, the result of re-accessing the target register is determined to be a failure.
[0148] Upon failure of a re-access, the current control board stops executing subsequent initialization operations of the EtherCAT protocol stack, no longer enters the synchronous communication configuration and periodic data exchange process, and records the communication initialization status as a failure. It can also clear the running flags related to protocol stack startup to prevent the control program from executing communication tasks before the slave controller is functioning correctly.
[0149] Simultaneously, the current control board writes an abnormal control level to the output port corresponding to the error indicator light, causing the error indicator light to switch from a normal indication state to an abnormal indication state. For example, the error indicator light can be ERR_LED, and the abnormal indication state can be constant, flashing, or other preset display methods to indicate that the EtherCAT protocol stack initialization is incomplete.
[0150] During the EtherCAT protocol stack initialization phase, the current control board performs detection data writing, feedback data reading, and access status judgment on the target register. In case of access abnormality, it performs hardware reset and re-access, which can improve the reliability of the slave controller initialization result. After the re-access fails, the initialization process ends and the error indicator light status is switched, which can prevent abnormal communication links from entering the subsequent operation process and provide initialization fault indication.
[0151] Please see Figure 8 In some embodiments of this application, step 702 in the above embodiments, which compares the detection data with the feedback data to determine the access status of the target register, may include the following steps: 801. When the detection data is consistent with the feedback data, the access status of the target register is determined to be normal.
[0152] The current control board compares the detection data and feedback data bit by bit, using the same data length and format. The detection data is the data written to the target register, and the feedback data is the data read from the target register after the write operation is complete. Before the comparison, the two types of data can be masked according to the effective bit range of the target register to eliminate the influence of reserved bits, read-only bits, or automatically changing bits on the comparison result.
[0153] When each valid data bit in the detection data matches the corresponding data bit in the feedback data, the current control board determines the access status as normal and records the successful register access. A normal status indicates that the detection data has been written to the target register and can be read from the target register according to the corresponding content.
[0154] 802. When the detection data and feedback data are inconsistent, accumulate the number of register accesses and re-execute the operations of writing detection data to the target register and reading feedback data.
[0155] If there are inconsistent valid data bits between the detected data and the feedback data, the current control board determines that the register access did not achieve the expected result and accumulates the register access count. The register access count is used to record the number of times the target register read and write operations are performed consecutively for the same initialization detection. Its initial value can be set to zero when the target register detection begins.
[0156] After the count is completed, the current control board writes the detection data to the target register again, and then reads the data currently stored in the target register to obtain new feedback data. The new feedback data is then compared with the detection data again. Each time a data inconsistency occurs, the count accumulation, detection data writing, and feedback data reading are repeated to form a continuous register access detection process.
[0157] When re-executing a read / write operation, a preset waiting interval can be set between two adjacent accesses to meet the register access timing requirements of the slave controller. For example, the allowed number of register accesses can be configured to ten.
[0158] 803. When the number of register accesses reaches the preset number of accesses, and the detection data and feedback data are still inconsistent, the access status will be determined as an abnormal status.
[0159] After each re-access to the target register, the current control board compares the current register access count with the preset access count and simultaneously checks whether the detected data matches the feedback data read this time. Only when the register access count reaches the preset access count and the data inconsistency persists, is the condition for determining an abnormal state met.
[0160] Once the abnormal state determination conditions are met, the current control board stops increasing the current register access count and sets the access status to abnormal. The abnormal state indicates that consistent read / write of detection data could not be completed within the limited number of accesses, and serves as a status indicator that the slave controller's current register access has not met the initialization requirements.
[0161] The current control board determines the access status of the target register based on the consistency between the detection data and the feedback data, as well as the number of register accesses. This reduces the impact of occasional read / write anomalies on the access status judgment results and uses a preset number of accesses to limit the re-access process, thus avoiding continuous looping of register read / write operations.
[0162] In the foregoing embodiments, the specific implementation process of the method provided in this application has been described in detail. It should be understood that, to implement the above method, this application also provides corresponding devices and computer-readable storage media, whose technical concepts are consistent with the foregoing method embodiments, and are all used to implement all or part of the steps in the foregoing method. The technical solutions of the devices and computer-readable storage media involved in this application will be further described below in conjunction with specific embodiments.
[0163] Please see Figure 9 , Figure 9 One embodiment of the current control board provided in this application includes a slave controller, a digital-to-analog converter, an analog-to-digital converter, and a current output circuit. This embodiment includes: The receiving unit 901 is used to receive the target current parameters sent by the master station in response to the synchronization interrupt signal generated by the slave station controller. The output unit 902 is used to generate an analog output control quantity based on the target current parameter, output a control voltage through a digital-to-analog converter, and control the current output circuit to output the load current. The acquisition unit 903 is used to periodically acquire the feedback voltage signal corresponding to the load current, and convert it into the actual output current through an analog-to-digital converter; The determining unit 904 is used to determine the current deviation based on the target current parameter and the actual output current, and to determine the deviation change parameter based on the current current deviation and the historical current deviation. The inference unit 905 is used to perform fuzzy inference based on the current current deviation and deviation change parameters to obtain the proportional parameter adjustment amount, integral parameter adjustment amount and differential parameter adjustment amount; The updating unit 906 is used to update the PID parameters according to the proportional parameter adjustment, integral parameter adjustment and derivative parameter adjustment to obtain the updated PID parameters, and calculate the current control correction based on the updated PID parameters. The transmitting unit 907 is used to update the analog output control quantity according to the current control correction quantity, and send the actual output current to the upper master station through the slave controller.
[0164] In this embodiment, the functions of each unit are as described above. Figures 1 to 8 The steps in the illustrated embodiments and sub-embodiments are corresponding and will not be repeated here.
[0165] Please see Figure 10 , Figure 10 One embodiment of the electronic device provided in this application includes: Processor 1001, memory 1002, input / output unit 1003, and bus 1004; The processor 1001 is connected to the memory 1002, the input / output unit 1003, and the bus 1004; The memory 1002 stores a program, which the processor 1001 calls to execute. Figure 1 The steps in the illustrated embodiment.
[0166] In this embodiment, the function of processor 1001 is the same as described above. Figures 1 to 8 The steps in the illustrated embodiments are the same and will not be repeated here.
[0167] This application also provides a computer-readable storage medium on which a program is stored. When the program is executed on a computer, it causes the computer to perform the aforementioned actions. Figures 1 to 8 The method in any possible implementation.
[0168] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0169] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.
[0170] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0171] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0172] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A current control method for a current control board, characterized in that, The current control board includes a slave controller, a digital-to-analog converter, an analog-to-digital converter, and a current output circuit. The current control method includes: In response to the synchronization interrupt signal generated by the slave controller, the target current parameters sent by the master station are received. An analog output control quantity is generated based on the target current parameter, and a control voltage is output through the digital-to-analog converter to control the current output circuit to output the load current. The feedback voltage signal corresponding to the load current is periodically acquired and converted into the actual output current by the analog-to-digital converter; The current current deviation is determined based on the target current parameter and the actual output current, and the deviation change parameter is determined based on the current current deviation and the historical current deviation. Based on the current current deviation and the deviation change parameters, fuzzy reasoning is performed to obtain the proportional parameter adjustment, integral parameter adjustment, and derivative parameter adjustment. The PID parameters are updated based on the proportional parameter adjustment, the integral parameter adjustment, and the derivative parameter adjustment to obtain the updated PID parameters, and the current control correction is calculated based on the updated PID parameters. The analog output control quantity is updated according to the current control correction quantity, and the actual output current is sent to the master station through the slave station controller.
2. The current control method according to claim 1, characterized in that, The step of performing fuzzy inference based on the current current deviation and the deviation change parameters to obtain the proportional parameter adjustment, integral parameter adjustment, and derivative parameter adjustment includes: The deviation fuzziness level is determined based on the correspondence between the current current deviation and the preset deviation range; The fuzziness level of the deviation change is determined based on the correspondence between the deviation change parameters and the preset change range; Based on the combination of the deviation fuzziness level and the deviation change fuzziness level, the proportional parameter fuzzy rule table, the integral parameter fuzzy rule table, and the differential parameter fuzzy rule table are queried respectively to obtain the proportional parameter fuzzy output value, the integral parameter fuzzy output value, and the differential parameter fuzzy output value. The fuzzy output values of the proportional parameter, the integral parameter, and the derivative parameter are numerically processed to obtain the adjustment amounts of the proportional parameter, the integral parameter, and the derivative parameter, respectively.
3. The current control method according to claim 2, characterized in that, The step of querying the proportional parameter fuzzy rule table, the integral parameter fuzzy rule table, and the differential parameter fuzzy rule table respectively based on the combination of the deviation fuzziness level and the deviation change fuzziness level to obtain the proportional parameter fuzzy output value, the integral parameter fuzzy output value, and the differential parameter fuzzy output value includes: The first index positions in the proportional parameter fuzzy rule table, the integral parameter fuzzy rule table, and the differential parameter fuzzy rule table are determined respectively based on the deviation fuzziness level; The second index positions in the proportional parameter fuzzy rule table, the integral parameter fuzzy rule table, and the differential parameter fuzzy rule table are determined respectively based on the fuzzy level of the deviation change; The rule units determined by the first index position and the second index position are read respectively to obtain the fuzzy output values of the proportional parameter, the integral parameter, and the derivative parameter.
4. The current control method according to claim 1, characterized in that, The PID parameters include proportional parameters, integral parameters, and derivative parameters. The step of updating the PID parameters based on the adjustment amounts of the proportional, integral, and derivative parameters to obtain updated PID parameters, and then calculating the current control correction based on the updated PID parameters, includes: Add the current proportional parameter to the adjusted proportional parameter to obtain the updated proportional parameter; Add the current integral parameter to the integral parameter adjustment amount to obtain the updated integral parameter; Add the current differential parameter to the differential parameter adjustment amount to obtain the updated differential parameter; Calculate the proportional control component based on the current current deviation and the updated proportional parameter; The integral control component is calculated based on the cumulative current deviation and the updated integral parameters, wherein the cumulative current deviation is obtained by accumulating the current current deviation and the current deviations corresponding to each control cycle before the current control cycle; Calculate the differential control component based on the deviation change parameter and the updated differential parameter; The proportional control component, the integral control component, and the derivative control component are superimposed to obtain the current control correction.
5. The current control method according to claim 1, characterized in that, After determining the current current deviation based on the target current parameter and the actual output current, and determining the deviation change parameter based on the current current deviation and the historical current deviation, and before performing fuzzy inference based on the current current deviation and the deviation change parameter to obtain the proportional parameter adjustment, integral parameter adjustment, and derivative parameter adjustment, the current control method further includes: The absolute value of the current current deviation is compared with a preset current deviation threshold. When the absolute value of the current current deviation is greater than the preset current deviation threshold, the cumulative deviation duration is defined as the duration during which the absolute value of the current current deviation is continuously greater than the preset current deviation threshold. When the duration of the deviation reaches the preset duration, the current output of the current output circuit is paused, and current output abnormality information is generated; The abnormal current output information is written into the communication interaction data and sent to the master station via the slave station controller.
6. The current control method according to claim 1, characterized in that, The periodic acquisition of the feedback voltage signal corresponding to the load current, and the conversion of it into the actual output current by the analog-to-digital converter, includes: Configure a hardware timer to periodically generate a sampling trigger signal; Based on the sampling trigger signal, the analog-to-digital converter is controlled to sample and convert the feedback voltage signal; In response to the conversion completion interrupt signal generated by the analog-to-digital converter, the sampled conversion value is read; Based on the preset mapping relationship between the sampled conversion value and the output current, the sampled conversion value is converted into the actual output current.
7. The current control method according to claim 1, characterized in that, Before receiving the target current parameters sent by the master station in response to the synchronization interrupt signal generated by the slave controller, the current control method further includes: Initialize the EtherCAT protocol stack, write detection data to the target register of the slave controller, and read feedback data; The access status of the target register is determined by comparing the detection data with the feedback data. When the access status is abnormal, a hardware reset is performed on the slave controller, and the target register is accessed again after the hardware reset; When re-accessing the target register fails, the initialization process of the EtherCAT protocol stack ends, and the error indicator light switches to the exception indication state.
8. The current control method according to claim 7, characterized in that, The step of comparing the detection data with the feedback data to determine the access status of the target register includes: When the detection data matches the feedback data, the access status of the target register is determined to be normal. When the detection data is inconsistent with the feedback data, the number of register accesses is accumulated, and the operation of writing the detection data to the target register and reading the feedback data is re-executed. When the number of register accesses reaches the preset number of accesses, and the detection data and the feedback data are still inconsistent, the access status is determined to be an abnormal status.
9. A current control board, characterized in that, For implementing the method of any one of claims 1 to 8, the current control board includes a slave controller, a digital-to-analog converter, an analog-to-digital converter, and a current output circuit, wherein the current control board includes: The receiving unit is used to receive the target current parameters sent by the master station in response to the synchronization interrupt signal generated by the slave station controller. The output unit is used to generate an analog output control quantity based on the target current parameter, output a control voltage through the digital-to-analog converter, and control the current output circuit to output the load current. The acquisition unit is used to periodically acquire the feedback voltage signal corresponding to the load current, and convert it into the actual output current through the analog-to-digital converter; The determining unit is used to determine the current deviation based on the target current parameter and the actual output current, and to determine the deviation change parameter based on the current current deviation and the historical current deviation. The inference unit is used to perform fuzzy inference based on the current current deviation and the deviation change parameters to obtain the proportional parameter adjustment amount, integral parameter adjustment amount and differential parameter adjustment amount; The updating unit is used to update the PID parameters according to the proportional parameter adjustment amount, the integral parameter adjustment amount and the derivative parameter adjustment amount to obtain the updated PID parameters, and to calculate the current control correction amount based on the updated PID parameters. The transmitting unit is used to update the analog output control quantity according to the current control correction quantity, and send the actual output current to the master station through the slave controller.
10. An electronic device, characterized in that, include: Processor, memory, input / output units, and bus; The processor is connected to the memory, the input / output unit, and the bus; The memory stores a program, and the processor calls the program to execute the method as described in any one of claims 1 to 8.