Input and output setting method and system of embedded system, and storage medium
By generating data communication packets of piecewise linear functions in the embedded system, the input-output relationship of the embedded system can be controlled, solving the problem of code modification required in traditional methods and realizing flexible input-output settings.
Patent Information
- Application Number
- CN202411307417.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2025-01-07
AI Technical Summary
In traditional embedded systems, changing the input-output relationship requires modifying the code, resulting in complex settings for input-output relationships that are inconvenient to change frequently.
By obtaining the preset input-output relationship of the object being set, performing linearization processing to obtain a piecewise linear function, generating a data communication packet, and sending it to the object being set to control it to input and output signals according to the new input-output relationship, thus avoiding changes to the application code.
It enables simple and convenient modification of the input-output relationships of an embedded system without changing the application code, making it suitable for embedded systems that require frequent changes.
Smart Images

Figure CN119276185A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of embedded systems, and in particular to an input and output setting method, system and storage medium of an embedded system. Background Art
[0002] Embedded system (short for embedded computer system) is a special computer system that is application-centric, based on modern computer technology, and can flexibly tailor software and hardware modules according to user needs (function, reliability, cost, volume, power consumption, environment, etc.). In traditional embedded systems where a single input determines the output, the corresponding relationship between input and output is implemented by code in the design and cannot be changed. If the corresponding relationship between input and output needs to be changed, the code needs to be changed. This is quite inconvenient for embedded systems that need to frequently change the input-output relationship, and setting the input-output relationship of the system is quite inconvenient. Summary of the invention
[0003] The present invention provides an input / output setting method, system and storage medium for an embedded system, which can solve the problem in the related art that for an embedded system which needs to frequently change the input / output relationship, setting the input / output relationship of the system needs to be achieved by changing the code, resulting in a relatively complex application.
[0004] The present invention provides an input and output setting method for an embedded system, the method comprising:
[0005] According to the preset input-output relationship of the set object, the corresponding piecewise linear function is obtained;
[0006] According to the obtained piecewise linear function, a data communication packet of the input and output setting relationship of the set object is obtained;
[0007] The data communication packet is sent to the set object, and the set object is controlled to implement signal input and signal output according to the input and output setting relationship corresponding to the data communication packet.
[0008] Optionally, obtaining a corresponding piecewise linear function according to a preset input-output relationship of the set object includes:
[0009] Get the preset input and output relationship of the set object;
[0010] Linearizing the preset input-output relationship to obtain a corresponding piecewise linear curve;
[0011] According to the piecewise linear curve, a corresponding piecewise linear function is obtained.
[0012] Optionally, obtaining a corresponding piecewise linear function according to the piecewise linear curve includes:
[0013] According to the obtained piecewise linear curve, determine the number n of all linear segments of the piecewise linear curve; wherein n is an integer greater than or equal to 1;
[0014] According to the obtained piecewise linear curve, the minimum input value min of each linear segment is obtained. n and the maximum input value max n ;
[0015] Calculate the slope constant a of each linear segment n and the intercept constant b n ;
[0016] According to the slope constant a of each linear segment n and the intercept constant b n , and the minimum input value min of each linear segment n and the maximum input value max n , and obtain a piecewise linear function corresponding to the piecewise linear curve.
[0017] Optionally, the piecewise linear function is as follows:
[0018]
[0019] Wherein, a1 and b1 are the first slope constant and the first intercept constant of the first linear segment function of the piecewise linear function f(x), respectively;
[0020] min1 and max1 are respectively the first function minimum input value and the first function maximum input value of the first linear segment function of the piecewise linear function f(x);
[0021] a2 and b2 are respectively the second slope constant and the second intercept constant of the second linear segment function of the piecewise linear function f(x);
[0022] min2 and max2 are respectively the second function minimum input value and the second function maximum input value of the second linear segment function of the piecewise linear function f(x);
[0023] a n , b n They are the nth slope constant and the nth intercept constant of the nth linear segment function of the piecewise linear function f(x);
[0024] min n 、max n are respectively the nth function minimum input value and the nth function maximum input value of the nth linear segment function of the piecewise linear function f(x); n is an integer greater than or equal to 1.
[0025] Optionally, acquiring a data communication packet of an input-output setting relationship of the set object according to the obtained piecewise linear function includes:
[0026] According to the obtained piecewise linear function, each linear segment function of the piecewise linear function is determined;
[0027] The slope constant a of each linear segment function is n , intercept constant b n 、Minimum input value of the function min n 、The maximum input value of the function max n Convert to obtain the corresponding fractional data set; where n is an integer greater than or equal to 1;
[0028] Based on the obtained data set in fractional form, a data communication package of the input and output setting relationship of the set object is obtained.
[0029] Optionally, the fractional data set includes the slope constants a of all the linear segment functions of the piecewise linear function. n The fractional form of data, intercept constant b n Fractional data, function minimum input value min n Fractional data, function maximum input value max n Fractional data; where n is an integer greater than or equal to 1.
[0030] Optionally, the data communication packet includes:
[0031] Data packet header identification;
[0032] Data length;
[0033] The number of segments n of the linear segment function of the piecewise linear function;
[0034] The numerator and denominator of the first slope constant a1 of the first linear segment function after fractional processing, the numerator and denominator of the first intercept constant b1 after fractional processing, the numerator and denominator of the first function minimum input value min1 after fractional processing, and the numerator and denominator of the first function maximum input value max1 after fractional processing;
[0035] The numerator and denominator of the second slope constant a2 of the second linear segment function after fractional processing, the numerator and denominator of the second intercept constant b2 after fractional processing, the numerator and denominator of the second function minimum input value min2 after fractional processing, and the numerator and denominator of the second function maximum input value max2 after fractional processing;
[0036] …
[0037] The nth slope constant a of the nth linear segment function nThe numerator and denominator after fractional processing, and the nth intercept constant b n The numerator and denominator after fractional processing, the minimum input value of the nth function min n The numerator and denominator after fractional processing, and the maximum input value of the nth function max n The numerator and denominator after fractional processing;
[0038] Verify the data.
[0039] In addition, the present invention provides an input and output setting system for an embedded system, comprising:
[0040] A linear function acquisition module, used to obtain a corresponding piecewise linear function according to a preset input-output relationship of a set object;
[0041] A setting relationship acquisition module, used for acquiring a data communication packet of an input-output setting relationship of the set object according to the obtained piecewise linear function;
[0042] The setting relationship execution module is used to send the data communication package to the set object, and control the set object to implement signal input and signal output according to the input and output setting relationship corresponding to the data communication package.
[0043] In addition, the present invention also proposes a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, all or part of the method steps in the input and output setting method of the embedded system described above are implemented.
[0044] In addition, the present invention also proposes an electronic device, including a memory and a processor, wherein the memory stores a computer program running on the processor, and when the processor executes the computer program, all or part of the method steps in the input and output setting method of the embedded system as described above are implemented.
[0045] The beneficial effects brought about by the technical solution provided by the present invention include:
[0046] When it is necessary to set the input-output setting relationship of the set object, the preset input-output relationship of the set object can be linearized as needed to obtain the corresponding piecewise linear function; and the piecewise linear function corresponding to the preset input-output relationship is processed to obtain the key data of the piecewise linear function to obtain the data communication package of the input-output setting relationship of the set object; and the set object can obtain the corresponding input-output setting relationship based on these data communication packages. In this way, for embedded systems that need to frequently change the input-output relationship, when it is necessary to change the input-output setting relationship of the set object, it is only necessary to transmit the data communication package of the key data of the piecewise linear function of the linearized preset input-output relationship that needs to be changed to the set object, and the set object can run according to the required input-output setting relationship, which is simple and convenient, and there is no need to change the application code. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0048] Figure 1 A schematic diagram showing the steps of the method for setting input and output of an embedded system according to an embodiment of the present invention;
[0049] Figure 2 A schematic diagram of a case where the embedded system in the input and output setting method of the embedded system according to an embodiment of the present invention is set as a motor variable frequency control system;
[0050] Figure 3 The schematic diagram of the input and output setting relationship of the motor variable frequency control system in the input and output setting method of the embedded system according to the embodiment of the present invention is Figure 1 ;
[0051] Figure 4 The schematic diagram of the input and output setting relationship of the motor variable frequency control system in the input and output setting method of the embedded system according to the embodiment of the present invention is Figure 2 ;
[0052] Figure 5 This is a simplified structural diagram of the input and output setting system of the embedded system described in an embodiment of the present invention. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0054] In the conventional technology, in the conventional embedded system where the single input determines the output, the corresponding relationship between the input and output is implemented by code in the design and cannot be changed. If the corresponding relationship between the input and output needs to be changed, the code needs to be changed. This is quite inconvenient for the embedded system that needs to change the input and output relationship frequently. In order to solve the above technical problems, the present invention proposes an input and output setting method and system for an embedded system.
[0055] like Figure 1 As shown, the present invention provides an input and output setting method for an embedded system, which is applied to an embedded system that needs to frequently change the input and output relationship. The method may specifically include the following steps:
[0056] S100, obtaining a corresponding piecewise linear function according to a preset input-output relationship of a set object;
[0057] S200, obtaining a data communication packet of an input-output setting relationship of a set object according to the obtained piecewise linear function;
[0058] S300, sending a data communication packet to the set object, and controlling the set object to implement signal input and signal output according to the input and output setting relationship corresponding to the data communication packet.
[0059] When it is necessary to set the input-output setting relationship of the set object, the preset input-output relationship of the set object can be linearized as needed to obtain the corresponding piecewise linear function; and the piecewise linear function corresponding to the preset input-output relationship is processed to obtain the key data of the piecewise linear function to obtain the data communication package of the input-output setting relationship of the set object; and the set object can obtain the corresponding input-output setting relationship based on these data communication packages. In this way, for embedded systems that need to frequently change the input-output relationship, when it is necessary to change the input-output setting relationship of the set object, it is only necessary to transmit the data communication package of the key data of the piecewise linear function of the linearized preset input-output relationship that needs to be changed to the set object, and the set object can run according to the required input-output setting relationship, which is simple and convenient, and there is no need to change the application code.
[0060] Furthermore, in step S100, according to the preset input-output relationship of the set object, a corresponding piecewise linear function is obtained, which may further include the following steps:
[0061] S110: Obtain a preset input-output relationship of the set object.
[0062] When the input-output relationship of the embedded system needs to be changed, the input-output relationship that needs to be implemented is the preset input-output relationship.
[0063] S120 , linearizing the preset input-output relationship to obtain a corresponding piecewise linear curve.
[0064] Under normal circumstances, the input-output relationship (preset input-output relationship) of the embedded system is a nonlinear relationship. By linearizing the preset input-output relationship, a linearized multi-segment curve (i.e., a piecewise linear curve) can be obtained. For example, the preset input-output relationship can be linearized using the AD segmented calculation method; the preset input-output relationship can also be linearized using the piecewise linear approximation method, that is, the nonlinear curve of the preset input-output relationship can be divided into several small segments according to certain characteristics and requirements, and the points on each small segment are connected with straight lines to approximate the curve, thereby obtaining a piecewise linear curve. In addition, other linearization methods can also be used to convert the nonlinear curve of the preset input-output relationship into a piecewise linear curve.
[0065] S130. Obtain a corresponding piecewise linear function according to the piecewise linear curve.
[0066] In a rectangular coordinate system, each linear segment of the piecewise linear curve obtained after linearization can be calculated to obtain a linear segment function corresponding to each linear segment. By combining the linear segment function corresponding to each linear segment of the piecewise linear curve, a piecewise linear function composed of all the linear segment functions corresponding to the piecewise linear curve can be obtained.
[0067] Furthermore, in step S130, obtaining a corresponding piecewise linear function according to the piecewise linear curve may further include the following steps:
[0068] S132. Determine the number n of all linear segments of the piecewise linear curve according to the obtained piecewise linear curve.
[0069] According to the number of linear segments on the piecewise linear curve, the number n of all linear segments of the piecewise linear curve can be obtained. Moreover, the larger the number n of all linear segments of the piecewise linear curve is, the more linear segments the piecewise linear curve has, and the higher the accuracy of the linearization processing is.
[0070] S134. According to the obtained piecewise linear curve, obtain the minimum input value min of each linear segment n and the maximum input value max n .
[0071] The minimum input value min that passes through each linear segment n and the maximum input value max n , the input boundary value of each linear segment can be obtained, and the input boundary value of the corresponding linear segment function can be obtained.
[0072] S136. Calculate the slope constant a of each linear segment n and the intercept constant b n .
[0073] The slope constant a through the linear segment n and the intercept constant b n , we can get the straight line function of this linear segment.
[0074] S138, according to the slope constant a of each linear segment n and the intercept constant b n , and the minimum input value min for each linear segment n and the maximum input value max n , and obtain the piecewise linear function corresponding to the piecewise linear curve.
[0075] After obtaining the slope constant, intercept constant, minimum input value, and maximum input value of a linear segment, a corresponding linear segment function can be obtained. After obtaining the linear segment functions of all segments (i.e., n segments) of the piecewise linear curve, the piecewise linear function of the piecewise linear curve can be obtained.
[0076] Moreover, the piecewise linear function is as follows:
[0077]
[0078] Wherein, a1 and b1 are the first slope constant and the first intercept constant of the first linear segment function of the piecewise linear function f(x), respectively;
[0079] min1 and max1 are respectively the first function minimum input value and the first function maximum input value of the first linear segment function of the piecewise linear function f(x);
[0080] a2 and b2 are respectively the second slope constant and the second intercept constant of the second linear segment function of the piecewise linear function f(x);
[0081] min2 and max2 are respectively the second function minimum input value and the second function maximum input value of the second linear segment function of the piecewise linear function f(x);
[0082] a n , b n They are the nth slope constant and the nth intercept constant of the nth linear segment function of the piecewise linear function f(x);
[0083] min n 、max n are respectively the nth function minimum input value and the nth function maximum input value of the nth linear segment function of the piecewise linear function f(x); n is an integer greater than or equal to 1.
[0084] In addition, in step S200, obtaining the data communication packet of the input-output setting relationship of the set object according to the obtained piecewise linear function may further include the following steps:
[0085] S210. Determine each linear segment function of the piecewise linear function according to the obtained piecewise linear function.
[0086] That is, based on the above piecewise linear function f(x), we can get the linear segment function corresponding to each linear segment. And according to each linear segment function, we can get its slope constant a n , intercept constant b n 、Minimum input value of the function min n 、The maximum input value of the function max n .
[0087] S220, the slope constant a for each linear segment function n , intercept constant b n 、Minimum input value of the function min n 、The maximum input value of the function max n Perform the conversion to obtain the corresponding fractional data set; where n is an integer greater than or equal to 1.
[0088] In getting the slope constant a of all the linear segment functions of the piecewise linear function f(x) n , intercept constant b n 、Minimum input value of the function min n 、The maximum input value of the function max n After that, these values can be converted into fractions to obtain the slope constant a n The fractional value of the intercept constant b n The fractional value of the function, the minimum input value min n The fractional value of the function, the maximum input value max n The fractional value of . Thus, the slope constant a of all linear segment functions of the piecewise linear function f(x) can be obtained. n , intercept constant b n、Minimum input value of the function min n 、The maximum input value of the function max n , get the slope constant a of all linear segment functions n , intercept constant b n 、Minimum input value of the function min n 、The maximum input value of the function max n A collection of numerical values in fractional form (fractional data set).
[0089] S230. Obtain a data communication package of the input and output setting relationship of the set object according to the obtained fractional data set.
[0090] According to the slope constant a of all linear segment functions n , intercept constant b n 、Minimum input value of the function min n 、The maximum input value of the function max n The set of fractional values (fractional data set) can be used to obtain the slope constant a of each linear segment function. n The numerator and denominator of the fractional value, the intercept constant b n The numerator and denominator of the fractional value, the minimum input value of the function min n The numerator and denominator of the fractional value, the maximum input value of the function max n The numerator and denominator of the numerical value in fractional form are packaged and set as a data communication package of the input and output setting relationship of the set object.
[0091] Furthermore, the fractional form data set includes the slope constants a of all linear segment functions of the piecewise linear function. n Fractional data (i.e. the slope constant a of the linear segment function) n The numerator and denominator of the fractional value), the intercept constant b n The fractional form of the data (i.e. the intercept constant b of the linear segment function) n The numerator and denominator of the fractional value), the minimum input value of the function min n Fractional data (i.e. the minimum input value of the linear segment function min n The numerator and denominator of the fractional value), the maximum input value of the function max n Fractional data (i.e. the maximum input value of the linear segment function max n The numerator and denominator of the fractional value of ); where n is an integer greater than or equal to 1.
[0092] Moreover, the above-mentioned data communication packet may include the following contents:
[0093] Data packet header identification;
[0094] Data length;
[0095] The number of segments n of the linear segment function of the piecewise linear function;
[0096] the numerator and denominator of the first slope constant a1 of the first linear segment function after fractional processing (i.e., the numerator and denominator of the numerical value of the first slope constant a1 in fractional form), the numerator and denominator of the first intercept constant b1 after fractional processing (i.e., the numerator and denominator of the numerical value of the first intercept constant b1 in fractional form), the numerator and denominator of the minimum input value min1 of the first function after fractional processing (i.e., the numerator and denominator of the numerical value of the minimum input value min1 of the first function in fractional form), the numerator and denominator of the maximum input value max1 of the first function after fractional processing (i.e., the numerator and denominator of the numerical value of the maximum input value max1 of the first function in fractional form);
[0097] The numerator and denominator of the second slope constant a2 of the second linear segment function after fractional processing (i.e., the numerator and denominator of the numerical value of the second slope constant a2 in fractional form), the numerator and denominator of the second intercept constant b2 after fractional processing (i.e., the numerator and denominator of the numerical value of the second intercept constant b2 in fractional form), the numerator and denominator of the second function minimum input value min2 after fractional processing (i.e., the numerator and denominator of the numerical value of the second function minimum input value min2 in fractional form), the numerator and denominator of the second function maximum input value max2 after fractional processing (i.e., the numerator and denominator of the numerical value of the second function maximum input value max2 in fractional form);
[0098] …
[0099] The nth slope constant a of the nth linear segment function n The numerator and denominator after fractional processing (i.e. the nth slope constant a n The numerator and denominator of the fractional value), the nth intercept constant b n The numerator and denominator after fractional processing (i.e. the nth intercept constant b n The numerator and denominator of the fractional value), the minimum input value of the nth function min n The numerator and denominator after fractional processing (i.e. the minimum input value of the nth function min n The numerator and denominator of the fractional value), the maximum input value of the nth function max n The numerator and denominator after fractional processing (i.e. the maximum input value of the nth function max n numerator and denominator of a fractional value);
[0100] Verification data (a data segment specially set up in the data communication packet to check whether the data packet is correct and complete).
[0101] In addition, in the above step S300, sending a data communication packet to the set object and controlling the set object to implement signal input and signal output according to the input and output setting relationship corresponding to the data communication packet may include the following steps:
[0102] S310, the slope constant a of all linear segment functions including the piecewise linear function n The numerator and denominator of the fractional value, the intercept constant b n The numerator and denominator of the fractional value, the minimum input value of the function min n The numerator and denominator of the fractional value, the maximum input value of the function max n The data communication packet consisting of the numerator and denominator of the numerical value in the form of a fraction is sent to the set object;
[0103] S320, controlling the set object to configure the input-output setting relationship according to the data communication package, so that the corresponding functional relationship of the input-output setting relationship is the above-mentioned piecewise linear function f(x);
[0104] S330, controlling the set object to implement signal input and signal output according to the input-output setting relationship formed by the above-mentioned piecewise linear function f(x).
[0105] Moreover, if Figure 2 As shown, the embedded system that needs to frequently change the input-output relationship can be a motor frequency conversion control system, that is, the motor frequency conversion control system can be regarded as an embedded motor control system. The motor frequency conversion control system may include a microprocessor (i.e., an embedded controller), a motor drive module connected to the microprocessor, and a motor connected to the motor drive module. Among them, the microprocessor can be a set object, and the input-output setting relationship formed by the above-mentioned piecewise linear function f(x) can be configured in the microprocessor, so that the microprocessor controls the motor drive module to drive the motor, so that the motor output speed of the motor reaches the output target speed.
[0106] In the motor variable frequency control system, the motor output target speed (motor output speed) is determined by the motor input signal. Common types of motor input signals include VSP (voltage control speed), PWM (duty cycle), and frequency. The input-output setting relationship between these motor input signals and the motor output speed is usually a fixed and relatively simple relationship. As shown in the following embodiments:
[0107] Specifically, Figure 3As shown, in one embodiment, the number of segments n of the linear segment function of the piecewise linear function is 3; the numerator of the first slope constant a1 of the first linear segment function after fractional processing is 0 and the denominator is 1; the numerator of the numerical value in fractional form of the first intercept constant b1 is 0 and the denominator is 1; the numerator of the numerical value in fractional form of the minimum input value min1 of the first function is 0 and the denominator is 1; the numerator of the numerical value in fractional form of the maximum input value max1 of the first function is 1 and the denominator is 10;
[0108] The numerator of the second slope constant a2 of the second linear segment function after fractional processing is 17 and the denominator is 16; the numerator of the fractional value of the second intercept constant b2 is 3 and the denominator is 20; the numerator of the fractional value of the minimum input value min2 of the second function is 1 and the denominator is 10; the numerator of the fractional value of the maximum input value max2 of the second function is 9 and the denominator is 10;
[0109] The third slope constant a3 of the third linear segment function has a numerator of 0 and a denominator of 1 after fractional processing; the numerator of the fractional value of the third intercept constant b3 is 1 and the denominator is 1; the numerator of the fractional value of the minimum input value min3 of the third function is 9 and the denominator is 10; the numerator of the fractional value of the maximum input value max3 of the third function is 1 and the denominator is 1. At this time, the piecewise linear function f(x) corresponding to the input-output setting relationship between the motor input signal and the motor output speed is as follows: Figure 3 As shown, the X-axis is input and the Y-axis is output, and the units are both %.
[0110] In addition, if Figure 4 As shown, in another embodiment, the number of segments n of the linear segment function of the piecewise linear function is 4; the numerator of the first slope constant a1 of the first linear segment function after fractional processing is 0 and the denominator is 1; the numerator of the numerical value in fractional form of the first intercept constant b1 is 0 and the denominator is 1; the numerator of the numerical value in fractional form of the minimum input value min1 of the first function is 0 and the denominator is 1; the numerator of the numerical value in fractional form of the maximum input value max1 of the first function is 1 and the denominator is 10;
[0111] The second slope constant a2 of the second linear segment function has a numerator of 3 and a denominator of 2 after fractional processing; the numerator of the fractional value of the second intercept constant b2 is 3 and the denominator is 20; the numerator of the fractional value of the minimum input value min2 of the second function is 1 and the denominator is 10; the numerator of the fractional value of the maximum input value max2 of the second function is 2 and the denominator is 5;
[0112] The third slope constant a3 of the third linear segment function has a numerator of 8 and a denominator of 11 after fractional processing; the numerator of the fractional value of the third intercept constant b3 is 3 and the denominator is 5; the numerator of the fractional value of the minimum input value min3 of the third function is 2 and the denominator is 5; the numerator of the fractional value of the maximum input value max3 of the third function is 19 and the denominator is 20;
[0113] The numerator of the fourth slope constant a1 of the fourth linear segment function after fractional processing is 0 and the denominator is 1; the numerator of the fractional value of the fourth intercept constant b1 is 1 and the denominator is 1; the numerator of the fractional value of the minimum input value min1 of the fourth function is 19 and the denominator is 20; the numerator of the fractional value of the maximum input value max1 of the fourth function is 1 and the denominator is 1;
[0114] At this time, the piecewise linear function f(x) corresponding to the input-output setting relationship between the motor input signal and the motor output speed is as follows: Figure 4 As shown, the X-axis is input and the Y-axis is output, and the units are both %.
[0115] In addition, if Figure 5 As shown, the present invention provides an input-output setting system 100 for an embedded system, which is applied to an embedded system that needs to frequently change the input-output relationship. Specifically, the input-output setting system 100 for an embedded system may include the following contents:
[0116] A linear function acquisition module 102, used to obtain a corresponding piecewise linear function according to a preset input-output relationship of a set object;
[0117] A setting relationship acquisition module 104, used for acquiring a data communication packet of an input-output setting relationship of a set object according to the obtained piecewise linear function;
[0118] The setting relationship execution module 106 is used to send a data communication packet to the set object, and control the set object to implement signal input and signal output according to the input and output setting relationship corresponding to the data communication packet.
[0119] The input / output setting system 100 of the embedded system described in this embodiment corresponds to the input / output setting method of the embedded system described above. The functions of each module in the input / output setting system 100 of the embedded system in this embodiment are described in detail in the corresponding method embodiment and will not be repeated here.
[0120] Based on the same inventive concept, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, all or part of the method steps in the input and output setting method of the above-mentioned embedded system are implemented.
[0121] The present invention implements all or part of the process in the above method, and can also be completed by instructing related hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of each method embodiment can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, USB flash drive, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.
[0122] Based on the same inventive concept, an embodiment of the present application also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program running on the processor, and when the processor executes the computer program, all or part of the method steps in the input and output setting method of the above-mentioned embedded system are implemented.
[0123] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of a computer device, and uses various interfaces and lines to connect various parts of the entire computer device.
[0124] The memory can be used to store computer programs and / or models. The processor realizes various functions of the computer device by running or executing the computer programs and / or models stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and at least one application required for a function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created according to the use of the mobile phone (such as audio data, video data, etc.). In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0125] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, servers or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program codes.
[0126] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), servers, and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as a combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0127] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0128] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0129] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A method for setting input and output of an embedded system, characterized in that: The method comprises: According to the preset input-output relationship of the set object, the corresponding piecewise linear function is obtained; According to the obtained piecewise linear function, a data communication packet of the input and output setting relationship of the set object is obtained; The data communication packet is sent to the set object, and the set object is controlled to implement signal input and signal output according to the input and output setting relationship corresponding to the data communication packet.
2. The method for setting input and output of an embedded system according to claim 1, characterized in that: The step of obtaining a corresponding piecewise linear function according to a preset input-output relationship of the set object includes: Get the preset input and output relationship of the set object; Linearizing the preset input-output relationship to obtain a corresponding piecewise linear curve; According to the piecewise linear curve, a corresponding piecewise linear function is obtained.
3. The input and output setting method of the embedded system according to claim 2, characterized in that: The step of obtaining a corresponding piecewise linear function according to the piecewise linear curve comprises: According to the obtained piecewise linear curve, determine the number n of all linear segments of the piecewise linear curve; wherein n is an integer greater than or equal to 1; According to the obtained piecewise linear curve, the minimum input value min of each linear segment is obtained. n and the maximum input value max n ; Calculate the slope constant a of each linear segment n and the intercept constant b n ; According to the slope constant a of each linear segment n and the intercept constant b n , and the minimum input value min of each linear segment n and the maximum input value max n , and obtain a piecewise linear function corresponding to the piecewise linear curve.
4. The method for setting input and output of an embedded system according to claim 3, characterized in that: The piecewise linear function is as follows: Wherein, a1 and b1 are the first slope constant and the first intercept constant of the first linear segment function of the piecewise linear function f(x), respectively; min1 and max1 are respectively the first function minimum input value and the first function maximum input value of the first linear segment function of the piecewise linear function f(x); a2 and b2 are respectively the second slope constant and the second intercept constant of the second linear segment function of the piecewise linear function f(x); min2 and max2 are respectively the second function minimum input value and the second function maximum input value of the second linear segment function of the piecewise linear function f(x); a n 、b n They are the nth slope constant and the nth intercept constant of the nth linear segment function of the piecewise linear function f(x); min n 、max n They are the nth function minimum input value and the nth function maximum input value of the nth linear segment function of the piecewise linear function f(x); n is an integer greater than or equal to 1.
5. The input and output setting method of the embedded system according to claim 3, characterized in that: The step of obtaining a data communication packet of an input-output setting relationship of the set object according to the obtained piecewise linear function comprises: According to the obtained piecewise linear function, each linear segment function of the piecewise linear function is determined; The slope constant a of each linear segment function is n , intercept constant b n 、Minimum input value of the function min n 、The maximum input value of the function max n Convert to obtain the corresponding fractional data set; where n is an integer greater than or equal to 1; Based on the obtained data set in fractional form, a data communication package of the input and output setting relationship of the set object is obtained.
6. The method for setting input and output of an embedded system according to claim 5, characterized in that: The fractional data set includes the slope constants a of all the linear segment functions of the piecewise linear function. n The fractional form of data, intercept constant b n Fractional data, function minimum input value min n Fractional data, function maximum input value max n Fractional data; where n is an integer greater than or equal to 1.
7. The method for setting input and output of an embedded system according to claim 6, characterized in that: The data communication package includes: Data packet header identification; Data length; The number of segments n of the linear segment function of the piecewise linear function; The numerator and denominator of the first slope constant a1 of the first linear segment function after fractional processing, the numerator and denominator of the first intercept constant b1 after fractional processing, the numerator and denominator of the first function minimum input value min1 after fractional processing, and the numerator and denominator of the first function maximum input value max1 after fractional processing; The numerator and denominator of the second slope constant a2 of the second linear segment function after fractional processing, the numerator and denominator of the second intercept constant b2 after fractional processing, the numerator and denominator of the second function minimum input value min2 after fractional processing, and the numerator and denominator of the second function maximum input value max2 after fractional processing; …… The nth slope constant a of the nth linear segment function n The numerator and denominator after fractional processing, and the nth intercept constant b n The numerator and denominator after fractional processing, the minimum input value of the nth function min n The numerator and denominator after fractional processing, and the maximum input value of the nth function max n The numerator and denominator after fractional processing; Verify the data.
8. An input and output setting system for an embedded system, characterized in that: include: A linear function acquisition module, used to obtain a corresponding piecewise linear function according to a preset input-output relationship of a set object; A setting relationship acquisition module, used for acquiring a data communication packet of an input-output setting relationship of the set object according to the obtained piecewise linear function; The setting relationship execution module is used to send the data communication package to the set object, and control the set object to implement signal input and signal output according to the input and output setting relationship corresponding to the data communication package.
9. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, all or part of the method steps in the input and output setting method of the embedded system as claimed in any one of claims 1 to 7 are implemented.
10. An electronic device, characterized in that: It comprises a memory and a processor, wherein the memory stores a computer program running on the processor, and when the processor executes the computer program, all or part of the method steps in the input and output setting method of the embedded system as claimed in any one of claims 1 to 7 are implemented.