A method for calculating the execution time of PLC scanning tasks
By obtaining the enable end status and count value relationship of the on-delay timer, and judging errors and precise conditions, the problem of PLC scanning task execution time calculation error is solved, and more accurate scanning task time calculation is realized, and product quality is improved .
Patent Information
- Application Number
- CN202210693620.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-18
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2042-06-18
AI Technical Summary
There are large errors in the calculation method of the execution time of the existing PLC scanning task, resulting in errors in the output value of the control module and algorithm, causing fluctuations in the production line control parameters and reducing product quality.
By obtaining the operation status of the enable terminal of the on-delay timer and the size relationship between the count value and the set value, we judge the error conditions and the precise calculation conditions, and use specific steps to eliminate the timing error under the error conditions, and accurately calculate the conditions. Calculate the scan task execution time in real time.
The calculation error of PLC scanning task execution time is eliminated, the production line control parameters are stabilized, and the product quality is improved.
Smart Images

Figure CN115202284B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of program control systems, and in particular to a method for calculating the execution time of a PLC scanning task. Background Art
[0002] Toshiba PLC has three scanning tasks: super speed scanning task (SS), high speed scanning task (HS) and main scanning task (MS). Each time the PLC executes a scanning task, the CPU must perform batch I / O processing, program execution and synchronization processing in sequence. Since the execution time of each PLC scanning task is different, it is necessary to calculate the execution time of each scanning task in real time.
[0003] In the SS scanning task, at most 1 program can be created; in the HS scanning task, at most 128 programs can be created; in the MS scanning task, at most 256 programs can be created. PLC user programs are stored in the scanning task. In the user program, the calculation of the actual execution time of the scanning task involves the operation of multiple control modules and algorithms, such as PI control module, motor dynamic torque compensation calculation module and second flow control module. In the existing design, the on-delay timer Ton is mainly used to assist in calculating the actual execution time of the PLC scanning task. The calculation results often have large errors, resulting in errors in the output values of multiple control modules and algorithms, causing fluctuations in the control parameters of the production line and reducing product quality. Summary of the invention
[0004] In order to eliminate the calculation error of the execution time of a PLC scanning task, the present application provides a method for calculating the execution time of a PLC scanning task.
[0005] In a first aspect, the present application provides a method for calculating the execution time of a PLC scanning task, using an on-delay timer, the method comprising obtaining the operating state of an enabling end of the on-delay timer, obtaining the magnitude relationship between a count value of the on-delay timer and a set value of the on-delay timer;
[0006] According to the operating state and / or the size relationship,
[0007] Eliminating the timing error when the error condition is met includes assigning the calculated value of the scanning task execution time of the previous cycle to the calculated value of the scanning task execution time of the current cycle; and
[0008] When the precise calculation condition is met, the scanning task execution time is calculated in real time.
[0009] Further, the error condition includes:
[0010] a first error condition, the first error condition comprising the operating state being OFF;
[0011] or a second error condition, wherein the second error condition includes that the operating state is ON, and the magnitude relationship satisfies that the count value of the on-delay timer is equal to the set value of the on-delay timer;
[0012] The precise calculation conditions include:
[0013] The operating state is ON, and the magnitude relationship satisfies that the count value of the on-delay timer is less than the set value of the on-delay timer.
[0014] Further, when the first timing error condition is met, eliminating the timing error further includes:
[0015] Controlling the on-delay timer to stop timing;
[0016] Set the count value of the on-delay timer to 0;
[0017] Assigning the count value of the on-delay timer read in the current scanning cycle to the count value of the on-delay timer read in the previous scanning cycle;
[0018] The output terminal of the on-delay timer is set to OFF.
[0019] Further, when the second timing error condition is met, eliminating the timing error further includes:
[0020] Controlling the on-delay timer to stop timing;
[0021] Assigning the count value of the on-delay timer read in the current scanning cycle to the count value of the on-delay timer read in the previous scanning cycle;
[0022] The output terminal of the on-delay timer is set to ON.
[0023] Furthermore, when the precise calculation condition is met, the real-time calculation scanning task execution time also includes
[0024] Assigning the count value k of the on-delay timer read in the current scanning cycle to the count value k0 of the on-delay timer read in the previous scanning cycle;
[0025] The calculated value T of the scanning task execution time in the current cycle is assigned to the calculated value T0 of the scanning task execution time in the previous cycle.
[0026] Further, the timing unit t of the on-delay timer is obtained, and the current periodic scanning task execution time calculation value T=(k-k0)*t.
[0027] Further, the method further includes initializing the on-delay timer to enter an initial calculation interface, including the following steps:
[0028] Assigning a setting value of the on-delay timer to a fixed value;
[0029] Assigning the count value of the on-delay timer to 0;
[0030] The enable terminal of the on-delay timer is set to ON.
[0031] In a second aspect, the present application provides a device for calculating the execution time of a PLC scanning task, comprising:
[0032] An acquisition unit, used to acquire the running state of the enabling end of the on-delay timer, and acquire the magnitude relationship between the count value of the on-delay timer and the set value of the on-delay timer;
[0033] A judging unit, used for judging whether an error condition and / or an accurate calculation condition is satisfied according to the operating state and / or the size relationship;
[0034] An execution unit, used to eliminate the timing error when the error condition is met, including assigning the calculated value of the scanning task execution time of the previous cycle to the calculated value of the scanning task execution time of the current cycle;
[0035] It is used to calculate the execution time of the scanning task in real time when the precise calculation conditions are met, including calculating the calculated value of the execution time of the scanning task in the current cycle.
[0036] In a third aspect, the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the method steps described in the first aspect when executing the program.
[0037] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, characterized in that when the program is executed by a processor, the method steps described in any one of the first aspects are implemented.
[0038] Beneficial effects:
[0039] The present application obtains the operating state of the enabling end of the on-delay timer to obtain the size relationship between the count value of the on-delay timer and the set value of the on-delay timer; according to the operating state and / or the size relationship, when the precise calculation conditions are met, the scanning task execution time is calculated in real time, including the calculated value of the current cycle scanning task execution time; according to the operating state and / or the size relationship, the timing error is eliminated when the error conditions are met, including assigning the calculated value of the previous cycle scanning task execution time to the calculated value of the current cycle scanning task execution time, thereby eliminating the calculation error of the PLC scanning task execution time caused by the calculated value of the on-delay timer being kept at 0 or the set value N when the error conditions are met. The present application eliminates the calculation error of the PLC scanning task execution time, thereby eliminating the fluctuation of the production line control parameters and improving product quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0041] Figure 1 This is a flow chart of a method for calculating the execution time of a PLC scanning task provided in Example 1 of the present application;
[0042] Figure 2 It is the start-stop control logic diagram of the on-delay timer Ton provided in Example 1 of the present application;
[0043] Figure 3 This is a signal timing diagram of the on-delay timer Ton provided in Example 1 of the present application.
[0044] Figure 4 This is a schematic diagram of the structure of an electronic device provided in Example 3 of the present application. DETAILED DESCRIPTION
[0045] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0046] Example 1
[0047] In the existing design, the actual execution time of each PLC scanning task is calculated by the difference between the count value of the on-delay timer Ton in the current scanning cycle and the count value of the on-delay timer Ton in the previous scanning cycle. However, when the enable end of the on-delay timer Ton is OFF or the count value k of the on-delay timer Ton is equal to the set value N, the on-delay timer Ton will stop timing, that is, the count value remains at 0 or the set value N, causing a large error in the calculated scanning task execution time. The calculation results often have large errors, resulting in errors in the output values of multiple control modules and algorithms, causing fluctuations in production line control parameters and reducing product quality.
[0048] Specifically, in combination with Figure 1 , T is the calculated value of the execution time of the PLC scanning task in the current cycle, T0 is the calculated value of the execution time of the PLC scanning task in the previous cycle, k is the count value of the on-delay timer Ton read in the current cycle, k0 is the count value of the on-delay timer Ton read in the previous cycle, t is the timing unit of the on-delay timer Ton, which is 0.1ms in this example;
[0049] Combined with Figure 2 , the output terminal of the on-delay timer Ton is assigned to the coil End; the normally closed contact End is connected to the enable terminal IN of the on-delay timer Ton; PT is the set value of the on-delay timer Ton, N is a double integer and is assigned to PT, in this example, 2147483647; ET is the count value of the on-delay timer Ton, and the ET value is assigned to the variable k;
[0050] The on-delay timer Ton uses the minimum timing unit of 0.1ms, and the set value takes the maximum value of 2147483647. The output coil of the on-delay timer Ton and the enable terminal contact use the same signal End, that is, the enable terminal contact uses a normally closed signal and the output terminal coil uses End. When the enable terminal IN is OFF, the on-delay timer Ton does not perform the timing function. In the current scan cycle, the output terminal coil End is set to OFF, and the enable terminal contact is ON in the next scan cycle;
[0051] 1. The delay timer starts timing normally.
[0052] When the enable terminal of the on-delay timer is ON and the count value k is less than the set value N=2147483647, the calculated scan task execution time is an accurate value;
[0053] Assume that the count value k of Ton read in the current cycle is 1000, the count value k0 of Ton read in the previous cycle is 600, the calculated value of the execution time of the scanning task in the current cycle is T = (k-k0)*t, and substitute the data, T = (1000-600)*0.1 = 40 milliseconds.
[0054] The delay timer Ton is turned on to execute the timing function. In the current scanning cycle, the output terminal coil End remains OFF, and the enabling terminal contact remains ON in the next scanning cycle.
[0055] 2. Turn on the delay timer to stop timing
[0056] (1) When the enable terminal of the on-delay timer is ON
[0057] When the count value k of the on-delay timer is equal to the set value N = 2147483647,
[0058] The count value of the on-delay timer remains at 2147483647. The count value k of the on-delay timer Ton read in the current cycle is 2147483647. Assuming the count value k0 of the on-delay timer Ton read in the previous cycle is 2147483600, the calculated value of the current cycle scan task execution time T = (k-k0)*t, the input data T = (2147483647-2147483600)*0.1 = 4.7 milliseconds, which should be about 40 milliseconds normally. The current scan task has not been completed, the count value k has reached the set value, and the remaining execution time is not calculated, resulting in an error.
[0059] In the current cycle, the output of the on-delay timer TON is set to ON, then the enable end of the on-delay timer Ton in the next cycle is OFF, and the count value k0=2147483647. The on-delay timer still cannot time normally.
[0060] (2) When the enable terminal of the on-delay timer is OFF
[0061] When the enable terminal of the on-delay timer is OFF, the count value of the on-delay timer remains at 0. The count value k of Ton read in the current cycle is 0, the count value k0 of Ton read in the previous cycle is 2147483647, the calculated value of the scan task execution time in the current cycle is T = (k-k0)*t, and the input data is T = (0-2147483647)*0.1 = -214748364.7 milliseconds, which is a negative value.
[0062] In the current cycle, the output of the on-delay timer TON is set to OFF, then in the next cycle, the enable terminal of the on-delay timer Ton is ON, the count value k0=0, and the timer starts timing.
[0063] (3) The first cycle of the on-delay timer
[0064] When the enable end of the on-delay timer is ON and the timing has just begun, the count value k of the on-delay timer Ton read in the current cycle is 0, the count value k0 of the on-delay timer Ton read in the previous cycle is 0, and the calculated value of the scan task execution time in the current cycle is T = (k-k0)*t. The input data is T = (0-0)*0.1 = 0 milliseconds, which should normally be around 40 milliseconds.
[0065] Combined with Figure 3 When the enable terminal IN of the on-delay timer Ton is OFF, the on-delay timer does not count, the output terminal Q is set OFF, and the current count value k is initialized; when the enable terminal IN of the on-delay timer Ton is ON, the timer starts counting, and when the timer count value k is equal to the set value N, the timer stops counting and the output terminal Q is set ON.
[0066] The present application provides a method for calculating the execution time of a PLC scanning task, comprising the following steps:
[0067] S0, initialize the on-delay timer Ton;
[0068] To enter the initial calculation interface, the parameter initialization unit is used to initialize the on-delay timer Ton, specifically including:
[0069] S01, assigning the setting value PT of the on-delay timer Ton to a fixed value N;
[0070] S02, setting the count value ET of the on-delay timer Ton to 0;
[0071] S03, turn on the enable terminal IN of the on-delay timer Ton;
[0072] S1, start calculating the scanning task execution time;
[0073] S2, determine whether the enable terminal IN of the on-delay timer Ton is ON;
[0074] When the judgment result is no, execute steps S31-S36;
[0075] When the judgment result is yes, execute step S4;
[0076] <1> Eliminate the first timing error;
[0077] When the enable terminal of the on-delay timer Ton is set to OFF, the on-delay timer Ton stops timing, and the count value k of the on-delay timer Ton is reset and maintained to 0, resulting in a first timing error;
[0078] In order to eliminate the first timing error, an enable end logic judgment unit is used. The enable end logic judgment unit is connected to the on-delay timer Ton. When the enable end of the on-delay timer Ton is OFF, the on-delay timer Ton stops timing, and the calculated value of the PLC scanning task execution time of the previous cycle is assigned to the calculated value of the scanning task execution time of the current cycle, thereby eliminating the first timing error; in the current scanning cycle, the output end of the on-delay timer Ton is OFF, and the enable end IN of the on-delay timer Ton is ON in the next scanning cycle. The specific steps include:
[0079] S31, turn on the delay timer Ton and stop timing;
[0080] S32, setting the count value k of the on-delay timer Ton to 0;
[0081] S33, assigning the previous cycle scan task execution time calculation value T0 to the current cycle scan task execution time calculation value T, so that T = T0;
[0082] S34, assigning the count value k of the on-delay timer Ton read in the current scanning cycle to the count value k0 of the on-delay timer Ton read in the previous scanning cycle, so that k0=k;
[0083] S35, turning OFF the output terminal of the on-delay timer Ton;
[0084] S36, return to step S1;
[0085] When the enable end logic judgment unit is ON and the count value k of the on-delay timer Ton of the current scanning cycle is equal to the set value N of the on-delay timer Ton, the on-delay timer Ton stops timing, and the count value k of the on-delay timer Ton remains at a constant value N, resulting in a second timing error;
[0086] When the enable end logic judgment unit is ON and the count value k of the on-delay timer Ton of the current scan cycle is less than the set value N of the on-delay timer Ton, the on-delay timer Ton starts timing and calculates the execution time of each scan task of the PLC in real time.
[0087] S4, determining whether the count value k of the on-delay timer Ton is equal to the set value N of the on-delay timer Ton;
[0088] When the judgment result is yes, execute steps S51-S55;
[0089] When the judgment result is no, execute steps S61-S64;
[0090] <2> Eliminate the second timing error;
[0091] In order to eliminate the second timing error, the current count value logic judgment unit is used, that is, when the count value k of the on-delay timer Ton in the current scanning cycle is equal to the set value N of the on-delay timer Ton, the PLC scanning task execution time calculation value T0 of the previous cycle is assigned to the current cycle scanning task execution time calculation value T, thereby eliminating the second timing error; in the current scanning cycle, the output terminal of the on-delay timer Ton is set to ON, and the enable terminal IN of the on-delay timer Ton in the next scanning cycle is OFF; the specific steps include,
[0092] S51, turn on the delay timer Ton and stop timing;
[0093] S52, assigning the previous cycle scanning task execution time calculation value T0 to the current cycle scanning task execution time calculation value T, so that T = T0;
[0094] S53, assigning the count value k of the on-delay timer Ton read in the current scanning cycle to the count value k0 of the on-delay timer Ton read in the previous scanning cycle, so that k0=k;
[0095] S54, turning on the output terminal of the on-delay timer Ton;
[0096] S55, return to step S1;
[0097] <3> Real-time calculation of scanning task execution time
[0098] When the enable terminal of the on-delay timer Ton is ON and the count value k of the on-delay timer Ton in the current scanning cycle is less than the set value N of the on-delay timer Ton, the scanning task execution time is calculated in real time;
[0099] The time for the PLC to execute a scan task in the current cycle is calculated in real time through the current cycle scan task execution time calculation unit;
[0100] The calculation value of the current periodic scanning task execution time is: T = (k-k0)*t;
[0101] The count value k of the on-delay timer Ton read in the current scanning cycle is assigned to the count value k0 of the on-delay timer Ton of the previous scanning cycle; the calculated value T of the scanning task execution time of the current cycle is assigned to the calculated value T0 of the scanning task execution time of the previous cycle. The specific steps include:
[0102] S61, calculating the calculated value T = (k-k0)*t of the execution time of the current periodic scanning task;
[0103] S62, assigning the count value k of the on-delay timer Ton read in the current scanning cycle to the count value k0 of the on-delay timer Ton read in the previous scanning cycle, so that k0=k;
[0104] S63, assigning the current periodic scanning task execution time calculation value T to the previous periodic scanning task execution time calculation value T0, so that T0 = T;
[0105] S64, return to step S4;
[0106] By using a method for calculating the execution time of a PLC scanning task provided by the present application, when the error condition is met, the calculated value of the previous cycle is used, which effectively solves the problem that when the enabling end of the on-delay timer Ton is OFF or the count value of the on-delay timer Ton reaches the set value, the timer does not perform the timing function, resulting in a large error in the calculated execution time of the PLC scanning task;
[0107] The PLC scanning task execution time calculated by this method has high accuracy and can participate in the calculation of various control modules and algorithms of the PLC, thereby improving the calculation accuracy of the control modules and algorithms.
[0108] Example 2
[0109] Embodiment 2 provides a device for calculating the execution time of a PLC scanning task, comprising:
[0110] An acquisition unit, used to acquire the running state of the enabling end of the on-delay timer, and acquire the magnitude relationship between the count value of the on-delay timer and the set value of the on-delay timer;
[0111] A judging unit, used for judging whether an error condition and / or an accurate calculation condition is satisfied according to the operating state and / or the size relationship;
[0112] The error conditions include:
[0113] a first error condition, the first error condition comprising the operating state being OFF;
[0114] or a second error condition, wherein the second error condition includes that the operating state is ON, and the magnitude relationship satisfies that the count value of the on-delay timer is equal to the set value of the on-delay timer;
[0115] The precise calculation conditions include:
[0116] The running state is ON, and the magnitude relationship satisfies that the count value of the on-delay timer is less than the set value of the on-delay timer;
[0117] An execution unit for eliminating timing errors when error conditions are met, including
[0118] When the first timing error condition is met,
[0119] Controlling the on-delay timer to stop timing;
[0120] Set the count value of the on-delay timer to 0;
[0121] Assign the previous cycle scan task execution time calculation value T0 to the current cycle scan task execution time calculation value T;
[0122] Assigning the count value k of the on-delay timer read in the current scanning cycle to the count value k0 of the on-delay timer read in the previous scanning cycle;
[0123] The output terminal of the on-delay timer is set to OFF.
[0124] When the second timing error condition is met,
[0125] Controlling the on-delay timer to stop timing;
[0126] Assign the previous cycle scan task execution time calculation value T0 to the current cycle scan task execution time calculation value T;
[0127] Assigning the count value k of the on-delay timer read in the current scanning cycle to the count value k0 of the on-delay timer read in the previous scanning cycle;
[0128] The output terminal of the on-delay timer is set to ON.
[0129] When the precise calculation condition is met, the real-time calculation scanning task execution time includes
[0130] Calculate the calculated value T of the current periodic scanning task execution time;
[0131] Assigning the count value k of the on-delay timer read in the current scanning cycle to the count value k0 of the on-delay timer read in the previous scanning cycle;
[0132] The calculated value T of the scanning task execution time in the current cycle is assigned to the calculated value T0 of the scanning task execution time in the previous cycle.
[0133] Example 3
[0134] Based on the same inventive concept, embodiment 3 of the present invention provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the method for calculating the execution time of the PLC scanning task are implemented.
[0135] The algorithm and display provided herein are not inherently related to any particular computer, virtual system or other device. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious that the structure required for constructing such systems. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages can be utilized to realize the content of the present invention described herein, and the description of the above specific languages is for disclosing the best mode of the present invention.
[0136] Example 4
[0137] Combined with Figure 4 Based on the same inventive concept, embodiment 4 of the present invention provides an electronic device, including a memory 304, a processor 302, and a computer program stored in the memory 304 and executable on the processor 302, wherein the processor 302 implements the steps of the method for calculating the execution time of the above-mentioned PLC scanning task when executing the program.
[0138] Among them, Figure 4 In the embodiment of the present invention, a bus architecture (represented by bus 300) is shown, which may include any number of interconnected buses and bridges, and bus 300 links various circuits including one or more processors represented by processor 302 and memory represented by memory 304. Bus 300 may also link various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. Bus interface 306 provides an interface between bus 300 and receiver 301 and transmitter 303. Receiver 301 and transmitter 303 may be the same element, namely a transceiver, providing a unit for communicating with various other devices over a transmission medium. Processor 302 is responsible for managing bus 300 and general processing, while memory 304 may be used to store data used by processor 302 when performing operations.
[0139] The above is only an embodiment of the present application. The common sense such as the known specific structure and characteristics in the scheme is not described in detail here. The ordinary technicians in the relevant field know all the common technical knowledge in the technical field of the invention before the application date or priority date, can obtain all the existing technologies in the field, and have the ability to apply the conventional experimental means before that date. The ordinary technicians in the relevant field can improve and implement this scheme in combination with their own abilities under the enlightenment given by this application. Some typical known structures or known methods should not become obstacles for ordinary technicians in the relevant field to implement this application. It should be pointed out that for the technicians in this field, without departing from the structure of this application, several deformations and improvements can be made, which should also be regarded as the scope of protection of this application, which will not affect the effect of the implementation of this application and the practicality of the patent. The scope of protection required by this application shall be based on the content of its claims, and the specific implementation methods and other records in the specification can be used to explain the content of the claims.
Claims
1. A method for calculating the execution time of a PLC scanning task, using an on-delay timer, characterized in that: The method comprises: Acquire the running state of the enabling end of the on-delay timer, and acquire the magnitude relationship between the count value of the on-delay timer and the set value of the on-delay timer; According to the operating state and / or the size relationship, Eliminating the timing error when the error condition is met includes assigning the calculated value of the scanning task execution time of the previous cycle to the calculated value of the scanning task execution time of the current cycle; and When the precise calculation conditions are met, the execution time of the scanning task is calculated in real time; The error conditions include: a first timing error condition, the first timing error condition comprising the operating state being OFF; or a second timing error condition, wherein the second timing error condition includes that the operating state is ON, and the magnitude relationship satisfies that the count value of the on-delay timer is equal to the set value of the on-delay timer; The precise calculation conditions include: The running state is ON, and the magnitude relationship satisfies that the count value of the on-delay timer is less than the set value of the on-delay timer; When the first timing error condition is met, eliminating the timing error further includes: Controlling the on-delay timer to stop timing; Set the count value of the on-delay timer to 0; Assigning the count value of the on-delay timer read in the current scanning cycle to the count value of the on-delay timer read in the previous scanning cycle; Setting the output terminal of the on-delay timer to OFF; When the second timing error condition is met, eliminating the timing error further includes: Controlling the on-delay timer to stop timing; Assigning the count value of the on-delay timer read in the current scanning cycle to the count value of the on-delay timer read in the previous scanning cycle; Setting the output terminal of the on-delay timer to ON; When the precise calculation condition is met, the real-time calculation scanning task execution time also includes Assigning the count value k of the on-delay timer read in the current scanning cycle to the count value k0 of the on-delay timer read in the previous scanning cycle; The calculated value T of the scanning task execution time in the current cycle is assigned to the calculated value T0 of the scanning task execution time in the previous cycle.
2. A method for calculating the execution time of a PLC scanning task as claimed in claim 1, characterized in that: The timing unit t of the on-delay timer is obtained, and the current periodic scanning task execution time calculation value T=(k-k0)*t.
3. A method for calculating the execution time of a PLC scanning task as claimed in claim 1, characterized in that: The method further includes initializing the on-delay timer to enter an initial calculation interface, including the following steps: Assigning a setting value of the on-delay timer to a fixed value; Assigning the count value of the on-delay timer to 0; The enable terminal of the on-delay timer is set to ON.
4. A device for calculating the execution time of a PLC scanning task, the device being used to implement the method steps as claimed in any one of claims 1 to 3, characterized in that: include An acquisition unit, used to acquire the running state of the enabling end of the connection delay timer, and acquire the magnitude relationship between the count value of the connection delay timer and the set value of the connection delay timer; A judging unit, used for judging whether an error condition and / or an accurate calculation condition is satisfied according to the operating state and / or the size relationship; An execution unit, used to eliminate the timing error when the error condition is met, including assigning the calculated value of the scanning task execution time of the previous cycle to the calculated value of the scanning task execution time of the current cycle; It is used to calculate the execution time of the scanning task in real time when the precise calculation conditions are met, including calculating the calculated value of the execution time of the scanning task in the current cycle.
5. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method steps as claimed in any one of claims 1 to 3 are implemented.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method steps described in any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Novel timer
CN203504516U