Timer control method and device, electronic equipment and readable storage medium
By adding timer types parameters to the PLC timer instructions, the problem that R&D personnel need to remember a large number of timer numbers is solved, and the efficiency and convenience of timer programming is improved.
Patent Information
- Application Number
- CN202411478330.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-02-18
AI Technical Summary
When programming the timer of a programmable logic controller PLC, R&D personnel need to consult the user manual and memorize a large amount of data, resulting in low programming efficiency.
By adding timer type parameters to the timer instructions, R&D personnel are allowed to set timer type parameters according to programming requirements to select timers of the corresponding magnitude, avoiding the need to remember the numbers of each timer.
It improves the programming efficiency of R&D personnel in programmable logic controllers, reduces the threshold for use, and makes the setting of timers more convenient.
Smart Images

Figure CN119472485A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and in particular, to a timer control method, a timer control device, an electronic device, and a computer-readable storage medium. Background Art
[0002] Programmable Logic Controller (PLC) is a digital computing controller with a microprocessor for automated control. It can load control instructions into memory at any time for storage and execution. Programmable logic controller PLC can include functional modules such as timers. Specifically, timers are used to set and control various time parameters, including delay time, cycle time and other parameters, so as to coordinate and control the time sequence and operation sequence in the automated production process.
[0003] Timer instructions are one of the basic functions of PLC programming. Timer instructions can not only achieve precise time control, simplify the system development cycle, and realize component reuse, but also be one of the basic elements for building complex control logic, bringing important technical support and application value to industrial automation. For programmable logic controller (PLC) programming software from different manufacturers, there are certain differences in the design methods of timer instructions, which are usually related to the underlying programs written by the manufacturers.
[0004] Among them, since there are many types of timers in the programmable logic controller (PLC), R&D personnel need to distinguish the timers of each type by the timer number, which has the hidden danger of timer number conflict. R&D personnel need to consult the user manual and memorize a large amount of data, which is cumbersome, resulting in low efficiency in R&D personnel's programming of the programmable logic controller (PLC) timer. Summary of the invention
[0005] The embodiment of the present invention provides a timer control method, device, electronic device and computer-readable storage medium to solve the problem that in the process of programming the timer of a programmable logic controller (PLC), R&D personnel need to consult the user manual and memorize a large amount of data, which is cumbersome and leads to low efficiency in programming the timer of the programmable logic controller (PLC).
[0006] An embodiment of the present invention discloses a timer control method, wherein the timer is a timer in a programmable logic controller, and the timer includes timers of different magnitudes. The method includes:
[0007] Displaying an instruction writing interface of a timer instruction of the timer of the programmable logic controller; wherein the instruction writing interface includes timer parameters of the timer instruction; the timer parameters at least include a timer type parameter; the timer type parameter is used to determine the timer type, the timer type parameter is provided with a corresponding preset type parameter, and the preset type parameters are respectively used to characterize timer types of different magnitudes;
[0008] In response to a first setting parameter set for the timer type parameter through the instruction writing interface, taking the timer type corresponding to the preset type parameter matching the first setting parameter as the target timer type in the timer instruction;
[0009] A timer in the programmable logic controller corresponding to the target timer type in the timer instruction is used as a target timer.
[0010] Optionally, the timers of different magnitudes include at least the timers of different time magnitudes, and the timers of different time magnitudes include at least a second timer, a millisecond timer and a microsecond timer.
[0011] Optionally, the timer parameters also include at least other timer parameters, and the other timer parameters include at least a timer label parameter, a timing time parameter and a reset variable address parameter; the timer label parameter is allowed to be set to empty.
[0012] Optionally, after taking a timer in the programmable logic controller corresponding to the target timer type in the timer instruction as the target timer, the method further includes:
[0013] In response to a second setting parameter set for the other timer parameters through the instruction writing interface;
[0014] According to the second setting parameters of the other timer parameters in the timer instruction, the target timer in the programmable logic controller is controlled to execute the corresponding workflow.
[0015] Optionally, according to the second setting parameter of the other timer parameter in the timer instruction, controlling the target timer in the programmable logic controller to execute a corresponding workflow includes:
[0016] When the input address of the timer instruction is turned on, obtaining the system time as the reference time;
[0017] When the difference between the current system time and the reference time reaches the timing time, the target timer is triggered to output an enable signal to the output address of the timer instruction.
[0018] Optionally, according to the second setting parameter of the other timer parameter in the timer instruction, controlling the target timer in the programmable logic controller to execute a corresponding workflow includes:
[0019] When the reset address of the timer instruction is turned on, the timer parameter corresponding to the target timer is controlled to be reset.
[0020] Optionally, the timer instructions in the programmable logic controller are divided in time.
[0021] Optionally, the timer has a timer type, and the timer type includes at least an accumulation timer and a non-accumulation timer.
[0022] Optionally, according to the second setting parameter of the other timer parameter in the timer instruction, controlling the target timer in the programmable logic controller to execute a corresponding workflow includes:
[0023] According to the timer type and the second setting parameters of the other timer parameters in the timer instruction, the target timer in the programmable logic controller is controlled to execute a corresponding workflow.
[0024] The embodiment of the present invention further discloses a timer control device, wherein the timer is a timer in a programmable logic controller, the timer includes timers of different magnitudes, and the device includes:
[0025] A display module, used for displaying an instruction writing interface of a timer instruction of the timer of the programmable logic controller; wherein the instruction writing interface includes timer parameters of the timer instruction; the timer parameters at least include a timer type parameter; the timer type parameter is used to determine the timer type, the timer type parameter is provided with a corresponding preset type parameter, and the preset type parameters are respectively used to characterize timer types of different magnitudes;
[0026] A setting module, configured to respond to a first setting parameter set for the timer type parameter through the instruction writing interface, and use the timer type corresponding to the preset type parameter matching the first setting parameter as the target timer type in the timer instruction;
[0027] A determination module is used to use a timer in the programmable logic controller corresponding to the target timer type in the timer instruction as a target timer
[0028] Optionally, the timers of different magnitudes include at least the timers of different time magnitudes, and the timers of different time magnitudes include at least a second timer, a millisecond timer and a microsecond timer.
[0029] Optionally, the timer parameters also include at least other timer parameters, and the other timer parameters include at least a timer label parameter, a timing time parameter and a reset variable address parameter; the timer label parameter is allowed to be set to empty.
[0030] Optionally, the device further includes: a timer execution module, configured to:
[0031] In response to a second setting parameter set for the other timer parameters through the instruction writing interface;
[0032] According to the second setting parameters of the other timer parameters in the timer instruction, the target timer in the programmable logic controller is controlled to execute the corresponding work flow.
[0033] Optionally, the timer execution module is used to:
[0034] When the input address of the timer instruction is turned on, obtaining the system time as the reference time;
[0035] When the difference between the current system time and the reference time reaches the timing time, the target timer is triggered to output an enable signal to the output address of the timer instruction.
[0036] Optionally, the timer execution module is used to:
[0037] When the reset address of the timer instruction is turned on, the timer parameter corresponding to the target timer is controlled to be reset.
[0038] Optionally, the timer instructions in the programmable logic controller are divided in time.
[0039] In an embodiment of the present invention, the timer has a timer type, and the timer type at least includes an accumulation timer and a non-accumulation timer.
[0040] Optionally, the timer execution module is used to:
[0041] According to the timer type and the second setting parameters of the other timer parameters in the timer instruction, the target timer in the programmable logic controller is controlled to execute a corresponding workflow.
[0042] The embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0043] The memory is used to store computer programs;
[0044] The processor is used to implement the method described in the embodiment of the present invention when executing the program stored in the memory.
[0045] The embodiment of the present invention further discloses a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the embodiment of the present invention.
[0046] The embodiment of the present invention further discloses a computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, enables the processors to execute the method described in the embodiment of the present invention.
[0047] The embodiments of the present invention include the following advantages:
[0048] In an embodiment of the present invention, when setting a timer in a programmable logic controller, an instruction writing interface of a timer instruction of a timer of the programmable logic controller is displayed, wherein the instruction writing interface includes timer parameters of the timer instruction, the timer parameters at least include a timer type parameter, the timer type parameter is used to determine the timer type, the timer type parameter is set with a corresponding preset type parameter, and the preset type parameter is used to characterize timer types of different magnitudes, respectively. In response to a first setting parameter set for the timer type parameter through the instruction writing interface, the timer type corresponding to the preset type parameter matching the first setting parameter is used as the target timer type in the timer instruction, and the timer corresponding to the target timer type in the timer instruction in the programmable logic controller is used as the target timer. In an embodiment of the present invention, a timer type parameter is added to the timer parameter of the timer instruction, and the timer type parameter is used to distinguish timers of different timer types. In the process of programming the timer in the programmable logic controller, the R&D personnel can set the timer type parameter according to the programming requirements to select the timer of the corresponding magnitude. Compared with the related technical solutions, the R&D personnel do not need to distinguish the timer types by memorizing the numbers of each timer, so that the R&D personnel will set the timer type more conveniently, improve the programming efficiency of the R&D personnel for the timer in the programmable logic controller, and reduce the use threshold of the programmable logic controller. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 is a flowchart of a timer control method provided in an embodiment of the present invention;
[0050] Figure 2 is a schematic diagram of a timer instruction provided in an embodiment of the present invention;
[0051] Figure 3 It is a schematic diagram of the implementation logic of a timer instruction in an underlying program provided in an embodiment of the present invention;
[0052] Figure 4 is a schematic diagram of an example of a timer instruction ladder diagram provided in an embodiment of the present invention;
[0053] Figure 5 It is a timing diagram of a timer instruction ladder diagram programming example provided in an embodiment of the present invention;
[0054] Figure 6 is a structural block diagram of a timer control device provided in an embodiment of the present invention;
[0055] Figure 7 It is a schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention. DETAILED DESCRIPTION
[0056] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0057] In the specific implementation, according to different working conditions, it is necessary to design a variety of timers of different time levels according to the time resolution, such as microsecond timers, millisecond timers, second timers, etc. There are many timers, and the workload is large. It is necessary to distinguish the timers of each type by the timer number (label). There is a hidden danger of timer number conflict. R&D personnel need to consult the user manual of the timer of the programmable logic controller PLC and remember a lot of data, which is cumbersome. Therefore, how to design the timer instruction more conveniently and lower the threshold for using the timer of the programmable logic controller PLC is a development direction for optimizing the programming operation of the soft programmable logic controller PLC.
[0058] In response to the above problems, an embodiment of the present invention provides a timer control method, which adds a new parameter in the implementation structure of the timer instruction of the programmable logic controller PLC, namely, the timer type parameter, which is used to distinguish timers of different types, making the programming of the timer of the programmable logic controller PLC more convenient, thereby improving the programming efficiency of the timers in the programmable logic controller by R&D personnel.
[0059] Reference Figure 1 , shows a flowchart of a timer control method provided in an embodiment of the present invention, the timer is a timer in a programmable logic controller, the timer includes timers of different magnitudes, and the method may specifically include the following steps:
[0060] Step 101, displaying an instruction writing interface of a timer instruction of the timer of the programmable logic controller; wherein the instruction writing interface includes timer parameters of the timer instruction; the timer parameters include at least a timer type parameter; the timer type parameter is used to determine the timer type, the timer type parameter is provided with a corresponding preset type parameter, and the preset type parameters are respectively used to characterize timer types of different magnitudes.
[0061] Step 102: In response to a first setting parameter set for the timer type parameter through the instruction writing interface, a timer type corresponding to the preset type parameter matching the first setting parameter is used as a target timer type in the timer instruction.
[0062] In the specific implementation, a timer can be set in a programmable logic controller (PLC). The timer is a functional module used to implement time control. By setting timer instructions, R&D personnel can implement operations such as controlling the start, stop, and state switching of external devices. By selecting and setting the timer type and other timer parameters, R&D personnel can achieve precise time control and improve the automation level of the system.
[0063] The programmable logic controller PLC may include timers of different magnitudes, and the timers of different magnitudes may include at least timers of different time magnitudes. For example, the timers of different time magnitudes may include at least timers such as a second timer, a millisecond timer, and a microsecond timer.
[0064] At present, in the timer instructions of the programmable logic controller PLC, T1-T20 represents the second timer, T21-T30 represents the millisecond timer, and so on, and this method is used to distinguish the timer quantities of different time magnitudes. In the relevant technical scheme, the R&D personnel need to distinguish the timer types through the timer number parameters input later. The R&D personnel need to strictly abide by this rule when programming. There are restrictions when inputting parameters, and they cannot rely entirely on the R&D personnel to set them independently. The R&D personnel need to remember the usage rules of the timers of the relevant programmable logic controller PLC, which upgrades the programming threshold of the timer of the programmable logic controller PLC, which is relatively cumbersome.
[0065] In an embodiment of the present invention, a timer instruction may include multiple timer parameters, wherein the timer parameters may include at least a timer type parameter, and the timer type parameter is used to determine the type of the timer. Specifically, the timer type parameter refers to a timer that is switched to a different time magnitude by changing the first parameter of the timer, such as a microsecond timer, a millisecond timer, a second timer, etc., because the first parameter of the timer is used to represent the timer of different time magnitudes. The timer type parameter is a constant. When the first parameter is K1 (K represents a constant), the timer represents a second timer. When the first parameter is K2, the timer represents a millisecond timer. When the first parameter is K3, it represents a microsecond timer. The timer type parameter is provided with a corresponding preset type parameter, and the preset type parameters are used to characterize the types of timers of different magnitudes, and the timer type parameter is a constant type.
[0066] During the programming process, the instruction writing interface of the timer instruction of the timer of the programmable logic controller PLC can be displayed to the R&D personnel. The instruction writing interface is a user interface in the programming software of the programmable logic controller PLC, which is used to write and set various instructions, including timer instructions. The instruction writing interface can at least include the timer parameters of the timer instruction. The R&D personnel can set corresponding setting parameters (first setting parameters) for the timer parameters according to the actual programming requirements. If the setting parameters set by the R&D personnel have matching preset type parameters, the timer type corresponding to the preset type parameters can be matched, and the timer type of the required timer, that is, the target timer type, is determined.
[0067] In actual applications, according to different application scenarios, R&D personnel select timers of different time magnitudes. For example, for processing scenarios with high precision requirements, microsecond timers or millisecond timers can be selected. For processing scenarios with low precision requirements, second timers can be selected.
[0068] In an embodiment of the present invention, a new parameter is added to the timer instruction, that is, the timer type parameter, which is used to indicate different time magnitudes of the timer. The R&D personnel only need to know the corresponding relationship between the value of the timer type parameter and the time magnitude, and can easily switch the timers of different time magnitudes for use. For example, assuming that the preset type parameters K1, K2 and K3 of the timer type parameter represent the second timer, the millisecond timer and the microsecond timer respectively, if the R&D personnel need to set the timer as a millisecond timer, they only need to set the timer type parameter to K2, and they can determine that the required timer type is a millisecond timer. The related technical scheme requires the R&D personnel to remember which interval of the timer represents which time magnitude, for example, T1-T20 is a second timer, T21-T30 is a millisecond timer..., that is, the R&D personnel do not need to remember a lot of timer codes about the timer, which reduces the programming threshold. A timer can switch between timers of multiple time magnitudes by changing one of the parameters, which enhances the versatility. If in the related technical solution, ten or twenty timers are allocated to one time level, then as the time levels expand, more timer instructions will need to be developed, and the content about timer types that developers need to remember will also increase, which is inconvenient. In the embodiment of the present invention, developers only need to remember a few fixed timer type parameters to distinguish different time levels. Then, one timer is used to achieve switching between multiple time levels, which reduces the total number of timer instructions and lowers the programming threshold.
[0069] Step 103: Use a timer in the programmable logic controller that corresponds to the target timer type in the timer instruction as a target timer.
[0070] In an embodiment of the present invention, after determining the target timer type, a timer in the programmable logic controller PLC corresponding to the target timer type in the timer instruction is used as the target timer, and then the corresponding workflow can be implemented based on the target timer to complete the corresponding work, such as realizing the control of external devices.
[0071] In an embodiment of the present invention, when setting a timer in a programmable logic controller, an instruction writing interface of a timer instruction of a timer of the programmable logic controller is displayed, wherein the instruction writing interface includes timer parameters of the timer instruction, the timer parameters at least include a timer type parameter, the timer type parameter is used to determine the timer type, the timer type parameter is set with a corresponding preset type parameter, and the preset type parameter is used to characterize timer types of different magnitudes, respectively. In response to a first setting parameter set for the timer type parameter through the instruction writing interface, the timer type corresponding to the preset type parameter matching the first setting parameter is used as the target timer type in the timer instruction, and the timer corresponding to the target timer type in the timer instruction in the programmable logic controller is used as the target timer. In an embodiment of the present invention, a timer type parameter is added to the timer parameter of the timer instruction, and the timer type parameter is used to distinguish timers of different timer types. In the process of programming the timer in the programmable logic controller, the R&D personnel can set the timer type parameter according to the programming requirements to select the timer of the corresponding magnitude. Compared with the related technical solutions, the R&D personnel do not need to distinguish the timer types by memorizing the numbers of each timer, so that the R&D personnel will set the timer type more conveniently, improve the programming efficiency of the R&D personnel for the timer in the programmable logic controller, and reduce the use threshold of the programmable logic controller.
[0072] In one embodiment of the present invention, after taking the timer in the programmable logic controller corresponding to the target timer type in the timer instruction as the target timer, the method further includes:
[0073] In response to a second setting parameter set for the other timer parameters through the instruction writing interface;
[0074] According to the second setting parameters of the other timer parameters in the timer instruction, the target timer in the programmable logic controller is controlled to execute the corresponding workflow.
[0075] In a specific implementation, the timer parameters may also include other timer parameters, wherein the other timer parameters may include at least a timer label parameter, a timing time parameter, and a reset variable address parameter. The timer label parameter is used to identify different timers, and each timer has an independent identity in the program; the timing time parameter is used to set the timing length (set time) of the control timer; the reset variable address parameter is used to control the reset operation of the timer. When the reset variable address parameter is turned on, the timer is reset, and the timer parameters of the timer can be cleared. Among them, if the R&D personnel have already set the timer type parameter, the timer label parameter is allowed to be set to empty.
[0076] In an embodiment of the present invention, in response to the second setting parameters set by the R&D personnel for other timer parameters through the instruction writing interface, the target timer in the programmable logic controller can be controlled to execute the corresponding workflow according to the second setting parameters of other timer parameters in the timer instruction, thereby realizing corresponding control of the external device.
[0077] For example, refer to Figure 2 , is a schematic diagram of a timer instruction provided in an embodiment of the present invention. The timer instruction generally includes three parameters, namely, the timer number, the timing time, and the reset variable address. In the embodiment of the present invention, a new parameter is added to the timer instruction, that is, the timer type parameter. The timer type parameter is a constant type, indicating the timer type, such as Figure 2 As shown, the timer (TMR) may include four parameters, which are: a timer type parameter, a timer label parameter, a timing time parameter, and a reset variable address parameter.
[0078] In one embodiment of the present invention, according to the second setting parameter of the other timer parameter in the timer instruction, controlling the target timer in the programmable logic controller to execute a corresponding workflow includes:
[0079] When the input address of the timer instruction is turned on, obtaining the system time as the reference time;
[0080] When the difference between the current system time and the reference time reaches the timing time, the target timer is triggered to output an enable signal to the output address of the timer instruction.
[0081] In one embodiment of the present invention, according to the second setting parameter of the other timer parameters in the timer instruction, the target timer in the programmable logic controller is controlled to execute the corresponding work flow, and also includes: when the reset address of the timer instruction is turned on, the timer parameter corresponding to the target timer is controlled to be reset.
[0082] Reference Figure 3, is a schematic diagram of the implementation logic of a timer instruction in the bottom program provided in an embodiment of the present invention. First, it is determined whether the branch where the timer is located is conductive. If the branch where the timer is located is not conductive, the timer parameters of the timer are set, that is, the specific values of the timer parameters such as the timer type parameter, the timer label parameter, the timing time parameter and the reset variable address parameter of the timer instruction are set. If the branch where the timer is located is not conductive, the timer instruction is not started and the output does not work. When the timer instruction is conductive, the initial system time is recorded, and the initial system time is used as the reference time to control the timer to start timing. During the timer timing, the difference between the current system time and the reference time is calculated. If the difference is greater than or equal to the set time of the timer, it is determined that the set time has arrived, and the timer starts to output, such as outputting an enable signal to control an external device. This working mode is called a delayed on timer; if the difference is less than the set time of the timer, the timer continues to time, and the timer output does not work. If the reset variable (reset variable address parameter) of the timer instruction is conductive, the timer is cleared and the output does not work; if the reset variable is not conductive, the timer waits for work.
[0083] Reference Figure 4 , is a schematic diagram of an example of a timer instruction ladder diagram provided in an embodiment of the present invention, Figure 4 The following is a ladder diagram program containing timer instructions, where X7.0 represents the address of the normally open contact, indicating the input address (when the address is "1" in the timing diagram, it indicates that there is an input signal in the branch), X7.3 represents the reset address of the timer (when the address is "1" in the timing diagram, the timer will be reset, that is, the previous timing of the timer will become 0 and restart), and Y6.0 represents the address of the normally open coil, indicating the output address (when the address is "1" in the timing diagram, it indicates that there is an output in the branch).
[0084] Specifically, when X7.0 is turned on, the timer instruction starts. Figure 4 The first parameter of the timer instruction is K1 (define timer instruction number 1 as a second timer), the second parameter indicates that the timer number here is T1, the third parameter indicates that the timer setting time is 10 seconds, and the fourth parameter indicates that when X7.3 is turned on, the timer instruction is reset and the timer is cleared. After the timer counts for 10 seconds, the timer output works and Y6.0 is enabled. If X7.3 is turned on, the timer is reset and Y6.0 is not enabled. The timing diagram of the timer instruction ladder diagram example is as follows Figure 5As shown in the figure, after X7.0 is turned on, T1 is turned on. After T1 counts for 10 seconds, Y6.0 is turned on. After the timer works for a period of time, X7.3 is turned on, then T1 is reset and returns to zero, and the output of Y6.0 does not work. When X7.3 is not turned on, T1 works again and starts counting. After two seconds of counting, X7.3 is turned on again. Because T1 does not count for 10 seconds again, Y6.0 will not be turned on. When X7.0 is disconnected, the branch is not conducting, T1 does not work, and Y6.0 does not output.
[0085] In one embodiment of the present invention, the timer instruction in the programmable logic controller adopts time system division. Specifically, the time system division refers to 1 microsecond as the smallest unit of measurement, 1000 microseconds equals 1 millisecond, 1000 milliseconds equals 1 second, and the order of milliseconds and seconds is expanded in sequence, so that by changing the first parameter of the timer (indicating different time orders of the timer), the switching of timers of different time orders is realized.
[0086] In one embodiment of the present invention, according to the second setting parameter of the other timer parameter in the timer instruction, controlling the target timer in the programmable logic controller to execute a corresponding workflow includes:
[0087] According to the timer type and the second setting parameters of the other timer parameters in the timer instruction, the target timer in the programmable logic controller is controlled to execute a corresponding workflow.
[0088] Among them, the timer also has a timer type, and the timer type can include at least an accumulation type timer and a non-accumulation type timer. Specifically, according to whether the time of the timer can be accumulated, the timer type is divided into an accumulation type timer and a non-accumulation type timer. When the coil of the non-accumulation type timer is energized, the timer starts timing, stops timing and resets when the system or coil is powered off, and restarts timing when the coil is powered on again. When the coil of the accumulation type timer is energized, the timer starts timing, and when the coil is powered off, the timer stops timing but is not reset. When the coil is powered on again, the timer continues to accumulate time on the timing result when it was last powered on. The accumulation type timer must be reset with a reset instruction, and system power off will not reset the accumulation type timer.
[0089] The timer counts the square wave signal in the PLC to realize timing. According to the period of the square wave signal counted by the timer, the timing accuracy is divided into 1ms (milliseconds), 10ms, 100ms, etc. The status of the soft appliance of the PLC is stored in the storage unit of the PLC. The status storage of each input relay, output relay, and auxiliary relay occupies one "bit". The status data of the timer is relatively large, so it occupies more storage resources. The timer occupies one "bit" to store the contact status of its contacts, and occupies two 16-bit registers to store the timing setting value and the timing accumulated value (current value). The register storing the timing setting value is called the setting value register, and the register storing the current value is called the current value register. When the timing conditions of the timer are met, the value in the current value register begins to accumulate until the value in the current value register is equal to the value in the setting value register, and the output contact of the timer starts to act. When the input signal is OFF (closed) or the timer is reset, the current value register of the timer will return to zero and the output contact will be reset.
[0090] In an embodiment of the present invention, the operation of the timer is controlled according to timer parameters such as the timer type, timer type, timer label parameter, timing time parameter and / or reset variable address parameter of the set timer, which can improve the flexibility, versatility and maintainability of programming, lower the programming threshold and achieve precise time control.
[0091] In the embodiment of the present invention, a parameter (timer type parameter) is added to the implementation structure of the timer instruction to distinguish timers of different timer types (different time magnitudes), thereby avoiding the trouble and inconvenience caused by the need for R&D personnel to distinguish by memorizing the numbers of various types of timers in the related technical solutions. The timer instruction of a timer can realize multiple functions by changing one of the parameters, which enhances the versatility, reduces the total number of timer instructions, makes programming easier, solves the problem of needing to memorize a large number of numbers to distinguish timer types, and lowers the threshold for using programmable logic controllers (PLCs).
[0092] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0093] Reference Figure 6, shows a structural block diagram of a timer control device provided in an embodiment of the present invention, the timer is a timer in a programmable logic controller, the timer includes timers of different magnitudes, and the device may specifically include the following modules:
[0094] A display module 601 is used to display an instruction writing interface of a timer instruction of the timer of the programmable logic controller; wherein the instruction writing interface includes timer parameters of the timer instruction; the timer parameters at least include a timer type parameter; the timer type parameter is used to determine the timer type, the timer type parameter is provided with a corresponding preset type parameter, and the preset type parameters are respectively used to characterize timer types of different magnitudes;
[0095] A setting module 602, configured to respond to a first setting parameter set for the timer type parameter through the instruction writing interface, and to use the timer type corresponding to the preset type parameter matching the first setting parameter as the target timer type in the timer instruction;
[0096] The determination module 603 is used to use a timer in the programmable logic controller corresponding to the target timer type in the timer instruction as a target timer.
[0097] In one embodiment of the present invention, the timers of different magnitudes include at least the timers of different time magnitudes, and the timers of different time magnitudes include at least a second timer, a millisecond timer and a microsecond timer.
[0098] In one embodiment of the present invention, the timer parameters at least include other timer parameters, and the other timer parameters at least include a timer label parameter, a timing time parameter and a reset variable address parameter; the timer label parameter is allowed to be set to empty.
[0099] In one embodiment of the present invention, the device further includes: a timer execution module, configured to:
[0100] In response to a second setting parameter set for the other timer parameters through the instruction writing interface;
[0101] According to the second setting parameters of the other timer parameters in the timer instruction, the target timer in the programmable logic controller is controlled to execute the corresponding work flow.
[0102] In one embodiment of the present invention, the timer execution module is used to:
[0103] When the input address of the timer instruction is turned on, obtaining the system time as the reference time;
[0104] When the difference between the current system time and the reference time reaches the timing time, the target timer is triggered to output an enable signal to the output address of the timer instruction.
[0105] In one embodiment of the present invention, the timer execution module is used to:
[0106] When the reset address of the timer instruction is turned on, the timer parameter corresponding to the target timer is controlled to be reset.
[0107] In one embodiment of the present invention, the timer instructions in the programmable logic controller are divided in time.
[0108] In one embodiment of the present invention, the timer has a timer type, and the timer type at least includes an accumulation timer and a non-accumulation timer.
[0109] In one embodiment of the present invention, the timer execution module is used to:
[0110] According to the timer type and the second setting parameters of the other timer parameters in the timer instruction, the target timer in the programmable logic controller is controlled to execute a corresponding workflow.
[0111] In an embodiment of the present invention, when setting a timer in a programmable logic controller, an instruction writing interface of a timer instruction of a timer of the programmable logic controller is displayed, wherein the instruction writing interface includes timer parameters of the timer instruction, the timer parameters at least include a timer type parameter, the timer type parameter is used to determine the timer type, the timer type parameter is set with a corresponding preset type parameter, and the preset type parameter is used to characterize timer types of different magnitudes, respectively. In response to a first setting parameter set for the timer type parameter through the instruction writing interface, the timer type corresponding to the preset type parameter matching the first setting parameter is used as the target timer type in the timer instruction, and the timer corresponding to the target timer type in the timer instruction in the programmable logic controller is used as the target timer. In an embodiment of the present invention, a timer type parameter is added to the timer parameter of the timer instruction, and the timer type parameter is used to distinguish timers of different timer types. In the process of programming the timer in the programmable logic controller, the R&D personnel can set the timer type parameter according to the programming requirements to select the timer of the corresponding magnitude. Compared with the related technical solutions, the R&D personnel do not need to distinguish the timer types by memorizing the numbers of each timer, so that the R&D personnel will set the timer type more conveniently, improve the programming efficiency of the R&D personnel for the timer in the programmable logic controller, and reduce the use threshold of the programmable logic controller.
[0112] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0113] In addition, an embodiment of the present invention further provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned timer control method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0114] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above-mentioned timer control method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0115] An embodiment of the present invention also provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned timer control method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0116] Figure 7 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention.
[0117] The electronic device 700 includes but is not limited to: a radio frequency unit 701, a network module 702, an audio output unit 703, an input unit 704, a sensor 705, a display unit 706, a user input unit 707, an interface unit 708, a memory 709, a processor 710, and a power supply 711. Those skilled in the art will appreciate that Figure 7 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. In the embodiments of the present invention, the electronic device includes but is not limited to a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a wearable device, and a pedometer.
[0118] It should be understood that in the embodiment of the present invention, the radio frequency unit 701 can be used for receiving and sending signals during information transmission or communication. Specifically, after receiving downlink data from the base station, it is sent to the processor 710 for processing; in addition, uplink data is sent to the base station. Generally, the radio frequency unit 701 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, etc. In addition, the radio frequency unit 701 can also communicate with the network and other devices through a wireless communication system.
[0119] The electronic device provides users with wireless broadband Internet access through the network module 702, such as helping users to send and receive emails, browse web pages, and access streaming media.
[0120] The audio output unit 703 can convert the audio data received by the RF unit 701 or the network module 702 or stored in the memory 709 into an audio signal and output it as sound. Moreover, the audio output unit 703 can also provide audio output related to a specific function performed by the electronic device 700 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 703 includes a speaker, a buzzer, a receiver, etc.
[0121] The input unit 704 is used to receive audio or video signals. The input unit 704 may include a graphics processor (GPU) 7041 and a microphone 7042, and the graphics processor 7041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frame can be displayed on the display unit 706. The image frame processed by the graphics processor 7041 can be stored in the memory 709 (or other storage medium) or sent via the radio frequency unit 701 or the network module 702. The microphone 7042 can receive sound and can process such sound into audio data. The processed audio data can be converted into a format output that can be sent to a mobile communication base station via the radio frequency unit 701 in the case of a telephone call mode.
[0122] The electronic device 700 also includes at least one sensor 705, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 7061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 7061 and / or the backlight when the electronic device 700 is moved to the ear. As a kind of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary, which can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 705 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.
[0123] The display unit 706 is used to display information input by the user or information provided to the user. The display unit 706 may include a display panel 7061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0124] The user input unit 707 can be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the electronic device. Specifically, the user input unit 707 includes a touch panel 7071 and other input devices 7072. The touch panel 7071, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 7071 or near the touch panel 7071 using any suitable object or accessory such as a finger, stylus, etc.). The touch panel 7071 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the contact point coordinates, and then sends it to the processor 710, receives the command sent by the processor 710 and executes it. In addition, the touch panel 7071 can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic waves. In addition to the touch panel 7071, the user input unit 707 may also include other input devices 7072. Specifically, other input devices 7072 may include but are not limited to a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which are not described in detail here.
[0125] Furthermore, the touch panel 7071 may be overlaid on the display panel 7061. When the touch panel 7071 detects a touch operation on or near it, it transmits the information to the processor 710 to determine the type of the touch event. Then, the processor 710 provides a corresponding visual output on the display panel 7061 according to the type of the touch event. Figure 7 In the figure, the touch panel 7071 and the display panel 7061 are used as two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 7071 and the display panel 7061 can be integrated to realize the input and output functions of the electronic device, which is not limited here.
[0126] The interface unit 708 is an interface for connecting an external device to the electronic device 700. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 708 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the electronic device 700 or may be used to transmit data between the electronic device 700 and an external device.
[0127] The memory 709 can be used to store software programs and various data. The memory 709 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 709 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0128] The processor 710 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. It executes various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory 709, and calling data stored in the memory 709, so as to monitor the electronic device as a whole. The processor 710 may include one or more processing units; preferably, the processor 710 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 710.
[0129] The electronic device 700 may also include a power supply 711 (such as a battery) for supplying power to each component. Preferably, the power supply 711 may be logically connected to the processor 710 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system.
[0130] In addition, the electronic device 700 includes some functional modules not shown, which will not be described in detail here.
[0131] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0132] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0133] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
[0134] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0135] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0136] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0137] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0138] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0139] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.
[0140] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A timer control method, characterized in that: The timer is a timer in a programmable logic controller, the timer includes timers of different magnitudes, and the method includes: Displaying an instruction writing interface of a timer instruction of the timer of the programmable logic controller; wherein the instruction writing interface includes timer parameters of the timer instruction; the timer parameters at least include a timer type parameter; the timer type parameter is used to determine the timer type, the timer type parameter is provided with a corresponding preset type parameter, and the preset type parameters are respectively used to characterize timer types of different magnitudes; In response to a first setting parameter set for the timer type parameter through the instruction writing interface, taking the timer type corresponding to the preset type parameter matching the first setting parameter as the target timer type in the timer instruction; A timer in the programmable logic controller corresponding to the target timer type in the timer instruction is used as a target timer.
2. The method according to claim 1, characterized in that The timers of different magnitudes include at least the timers of different time magnitudes, and the timers of different time magnitudes include at least a second timer, a millisecond timer and a microsecond timer.
3. The method according to claim 1, characterized in that The timer parameters at least include other timer parameters, and the other timer parameters at least include a timer label parameter, a timing time parameter and a reset variable address parameter; the timer label parameter is allowed to be set to empty.
4. The method according to claim 3, characterized in that After taking the timer in the programmable logic controller corresponding to the target timer type in the timer instruction as the target timer, the method further includes: In response to a second setting parameter set for the other timer parameters through the instruction writing interface; According to the second setting parameters of the other timer parameters in the timer instruction, the target timer in the programmable logic controller is controlled to execute the corresponding workflow.
5. The method according to claim 4, characterized in that According to the second setting parameter of the other timer parameter in the timer instruction, controlling the target timer in the programmable logic controller to execute a corresponding work flow includes: When the input address of the timer instruction is turned on, obtaining the system time as the reference time; When the difference between the current system time and the reference time reaches the timing time, the target timer is triggered to output an enable signal to the output address of the timer instruction.
6. The method according to claim 5, characterized in that According to the second setting parameter of the other timer parameter in the timer instruction, controlling the target timer in the programmable logic controller to execute a corresponding work flow includes: When the reset address of the timer instruction is turned on, the timer parameter corresponding to the target timer is controlled to be reset.
7. The method according to claim 1, characterized in that The timer instructions in the programmable logic controller adopt time system division.
8. The method according to claim 4, characterized in that The timer has a timer type, and the timer type includes at least an accumulation type timer and a non-accumulation type timer.
9. The method according to claim 8, characterized in that According to the second setting parameter of the other timer parameter in the timer instruction, controlling the target timer in the programmable logic controller to execute a corresponding work flow includes: According to the timer type and the second setting parameters of the other timer parameters in the timer instruction, the target timer in the programmable logic controller is controlled to execute a corresponding workflow.
10. A timer control device, characterized in that: The timer is a timer in a programmable logic controller, the timer includes timers of different magnitudes, and the device includes: A display module, used for displaying an instruction writing interface of a timer instruction of the timer of the programmable logic controller; wherein the instruction writing interface includes timer parameters of the timer instruction; the timer parameters at least include a timer type parameter; the timer type parameter is used to determine the type of the timer, the timer type parameter is provided with a corresponding preset type parameter, and the preset type parameters are respectively used to characterize timer types of different magnitudes; A setting module, configured to respond to a first setting parameter set for the timer type parameter through the instruction writing interface and use the timer type corresponding to the preset type parameter matching the first setting parameter as the target timer type in the timer instruction; A determination module is used to use a timer in the programmable logic controller corresponding to the target timer type in the timer instruction as a target timer.
11. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the method according to any one of claims 1 to 9 when executing the program stored in the memory.
12. A computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 9.