Programming method, device, smart phone and system of programmable logic controller
By pre-installing an app on a smartphone, PLC control programs can be written and downloaded using wireless communication technology, solving the problems of inconvenient portability and poor versatility of PLC programming devices, and realizing portable and universal PLC programming.
Patent Information
- Application Number
- CN202011464016.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-14
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2040-12-14
AI Technical Summary
Existing programmable logic controller (PLC) programming equipment is inconvenient to carry, and the dedicated equipment from different manufacturers is not interchangeable, resulting in poor flexibility.
Using mobile devices with touchscreens, such as smartphones, allows for the writing and downloading of PLC control programs via pre-installed apps. The programs are downloaded to the PLC wirelessly, employing unified standards and protocols, which simplifies the programming process.
It achieves portability and versatility in PLC programming, simplifies equipment structure, eliminates the need for dedicated programming cables, and is suitable for most smartphones.
Smart Images

Figure CN114625063B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the control technical field, and in particular to a programming method of a programmable logic controller, and a programming device and a programming system applying the programming method of the programmable logic controller. BACKGROUND
[0002] The existing programmable logic controller generally uses a personal computer to develop and download programs, and is limited by hardware facilities, and has the characteristics of inconvenience in carrying, the need of special equipment (programming cable, etc.), the difficulty in generalization of special equipment of various manufacturers, poor flexibility, etc. SUMMARY
[0003] The present application aims at overcoming the defects of the prior art, and provides a programming method of a programmable logic controller, which is used for a mobile device with a touch screen, and has simple operation and good versatility.
[0004] To achieve the above-mentioned purpose, the present application adopts the following technical scheme:
[0005] A programming method of a programmable logic controller, which is used for a mobile device with a touch screen, includes a plurality of selected program modules, each program module includes an input port for storing the address value or constant connected thereto, a unique function module code for distinguishing the program module, a port number for outputting the execution result data of the program module, and a PLC underlying program corresponding to the program module; a visual interface is included, so that a user selects the selected program module through the touch screen of the mobile device, and sets the input port of the program module to realize a PLC control program, wherein the PLC control program includes a plurality of selected and set program modules arranged in sequence, the input port of a subsequent program module can be set as the address value corresponding to the port number of a previous program module, and the subsequent program module is associated with the previous program module; and a corresponding PLC program download package of the PLC control program is generated and downloaded to the programmable logic controller.
[0006] Preferably, the PLC control program includes one or more program module groups, each program module group includes at least one program module; when the same program module group includes a plurality of program modules, the program modules in the program module group are sequentially associated.
[0007] Preferably, the step of generating the PLC program download package comprises: allocating a space and an address storing a port number of each program module of the PLC control program; sequentially obtaining a PLC underlying program corresponding to each program module of the PLC control program, replacing an address corresponding to a saved execution result data in the PLC underlying program with an address allocated to the port number of the program module, and replacing an address corresponding to obtained input port data in the PLC underlying program with an address of a port number of a previous program module associated with the input port data according to a setting, or replacing the obtained input port data with a corresponding constant, to obtain a program module download program corresponding to each program module; and packaging the program module download programs corresponding to the program modules into the PLC program download package.
[0008] Preferably, different program module groups are independent of each other, a program module group generated later can include a project element for referencing a program module of a previously generated program module group, a user can add the project element and select a program module in the previously generated program module group corresponding to the project element, a program module adjacent to the project element in the same program module group can be associated with the project element, and when generating the PLC program download package, the project element does not need to be allocated a space and an address of a port number of a corresponding program module, and for the program module associated with the project element, a PLC underlying address of the program module associated with the project element is obtained, and an address corresponding to obtained input port data in the PLC underlying address is replaced with an address of a port number of a program module corresponding to the project element.
[0009] Preferably, the plurality of selected program modules include program modules belonging to an input and output module group, and the input and output module group includes any one or more of a switch value input module, a switch value output module, an analog value input module, and an analog value output module.
[0010] Preferably, the plurality of selected program modules include program modules belonging to a timer module group, and the timer module group includes any one or more of a day alarm clock module, a year alarm clock module, a turn-on delay module, a turn-off delay module, a turn-on and turn-off delay module, a keep-on module, a pulse width output module, and a cycle output module.
[0011] Preferably, the plurality of selected program modules include program modules belonging to an operator module group, and the operator module group includes any one or more of an addition module, a subtraction module, a multiplication module, a division module, a square root module, a greater than module, a less than module, an equal to module, a not module, an and module, an or module, an exclusive or module, a latching relay module, a pulse relay module, a counter module, and a threshold trigger module.
[0012] Preferably, the switch quantity input module is used for acquiring the switch state of the hardware port, the switch quantity input module comprises an input port capable of being set as an IO port of hardware; the switch quantity output module is used for outputting the calculation result to the corresponding port, the switch quantity output module comprises an output port number capable of being set as an IO port of hardware; the analog quantity input module is used for acquiring the value of the hardware analog quantity acquisition port, the analog quantity input module comprises an input port capable of being set as an IO port of hardware; and the analog quantity output module is used for outputting the calculation result to the hardware analog quantity port, the analog quantity output module comprises an output port number capable of being set as an IO port of hardware.
[0013] Preferably, the latch relay module, i.e. RS trigger, comprises a latch relay module trigger signal input port for receiving a trigger signal and a latch relay module reset signal input port for receiving a reset signal, when the latch relay module trigger signal input port detects the trigger signal, the RS trigger outputs an effective signal and keeps, and when the latch relay module reset signal input port monitors the reset signal, the RS trigger outputs a reset signal; and the pulse relay module comprises an input port for receiving a trigger signal, and when the trigger signal is detected, the output signal is reversely output.
[0014] Preferably, the counter module comprises a trigger signal input port, a direction input port and a reset input port, the direction input port is used for controlling the working mode of the counter module to be an add mode or a subtract mode, in the add mode, when the counter module detects the trigger signal, the output value of the counter module is added by 1, in the subtract mode, when the trigger signal is detected, the output value of the counter is reduced by 1, and when the reset signal is detected, the output value of the counter is reset to 0.
[0015] The application further provides a programming device of a programmable logic control device, which comprises a processor, a touch screen display and a memory, and the processor executes the programming method of the programmable logic controller.
[0016] The application further provides a smart phone comprising a touch screen display, wherein the smart phone is installed with an APP for implementing the programming method of the programmable logic controller.
[0017] The application further provides a programming system of a programmable logic controller, which comprises a smart phone and a PLC, the smart phone is installed with an APP for implementing the programming method of the programmable logic controller, the smart phone is built-in with a first wireless communication module, the PLC is built-in with a second wireless communication module, the first wireless communication module and the second wireless communication module are network connected, and the generated PLC control program is downloaded to the PLC through the APP.
[0018] The programming method of the programmable logic controller of the application is used for a mobile device with a touch screen, such as a smart phone, so that a user selects a program module to be selected through the touch screen of the mobile device, and the parameter configuration of the program module is performed to generate and download the PLC control program.
[0019] The programming system of the programmable logic controller of the application uses the APP pre-installed on the smart phone to realize the writing of the PLC control program, and downloads the PLC control program to the PLC through the wireless communication mode to realize the parameter configuration of the PLC, which is convenient to carry and does not need to be equipped with a special programming cable. BRIEF DESCRIPTION OF DRAWINGS
[0020] Figure 1 is a schematic diagram of the visual interface of the APP pre-installed on the smart phone of the application, which at least shows the composition of the input and output module group;
[0021] Figure 2 is a schematic diagram of the visual interface of the APP pre-installed on the smart phone of the application, which at least shows the composition of the timer module group;
[0022] Figure 3 is a schematic diagram of the visual interface of the APP pre-installed on the smart phone of the application, which at least shows the composition of the operator module group;
[0023] Figure 4 is a schematic diagram of the visual interface of the APP pre-installed on the smart phone of the application, which at least shows that the input and output module group further includes an analog output module;
[0024] Figure 5 is a schematic diagram of one embodiment of the PLC control program of the application;
[0025] Figure 6 is a schematic diagram of another embodiment of the PLC control program of the application;
[0026] Figure 7 is a schematic diagram of a third embodiment of the PLC control program of the application. DETAILED DESCRIPTION
[0027] The programming method of the programmable logic controller of the application is not limited to the description of the following embodiments.
[0028] The programming system of the programmable logic controller of the application comprises a smart phone and a PLC, the smart phone is installed with an APP for implementing the programming method of the programmable logic controller of the application, a PLC control program corresponding to the PLC is generated through the pre-installed APP on the smart phone; the wireless communication connection between the smart phone and the PLC is established, and then the generated PLC control program is downloaded to the PLC through the APP to complete the programming of the PLC. Of course, the smart phone can first establish the wireless communication connection with the PLC to generate the PLC control program and then download it to the PLC.
[0029] The programming method of the programmable logic controller of the application is used for a mobile device with a touch screen, such as a smart phone, and comprises a plurality of selected program modules, each program module comprises an input port for storing the address value or constant connected thereto, a unique function module code for distinguishing the program module, a port number for outputting the execution result data of the program module, and a PLC underlying program corresponding to the program module.
[0030] The programming method comprises the following steps: a visual interface is provided, a user selects the selected program module through the touch screen of the mobile device, and the input port of the program module is set to implement the PLC control program; the PLC control program comprises a plurality of selected and set program modules arranged in sequence, the input port of the subsequent program module can be set to the address value corresponding to the port number of the previous program module, and the subsequent program module is associated with the previous program module.
[0031] The PLC control program is generated to download the corresponding PLC program download package to the programmable logic controller.
[0032] The programming method of the programmable logic controller of the application enables a user to select the selected program module through the touch screen of the mobile device and configure the parameters of the program module to generate and download the PLC control program, compared with the traditional programming method of the programmable logic controller, the programming method is convenient to carry, does not need to be equipped with a dedicated programming cable, and simplifies the structure. The programming system of the programmable logic controller using the programming method of the application uses the pre-installed APP on the smart phone to implement the writing of the PLC control program and downloads the PLC control program to the PLC through the wireless communication mode to realize the parameter configuration of the PLC, which is convenient to carry and does not need to be equipped with a dedicated programming cable. In addition, the smart phone adopts a unified standard and protocol, and the programmable logic controller also adopts a unified standard and protocol, so that the programmable logic controller can be compatible with most of the existing smart phones without great changes, and the universality of the programming method of the programmable logic controller of the application is significantly improved.
[0033] The following is an embodiment of the programming method of the programmable logic controller of the application.
[0034] The programming method of the programmable logic controller comprises the following steps:
[0035] The step of generating the PLC program download package comprises the following steps: allocating a space and an address for each program module of the PLC control program to store a port number of the program module; sequentially obtaining a PLC bottom program corresponding to each program module of the PLC control program, replacing an address corresponding to the PLC bottom program for storing an execution result data with an address allocated by the port number of the program module, and replacing an address corresponding to the PLC bottom program for obtaining input port data with an address of a port number of a previous program module associated with the input port data according to a setting, or replacing the input port data with a corresponding constant, to obtain a program module download program corresponding to each program module; and packing the program module download programs corresponding to each program module into the PLC program download package.
[0036] Further, the APP provides at least three selected module groups, which are an input and output module group, a timer module group, and an operator module group; wherein the input and output module group comprises a switch value input module, an analog value input module, and a switch value output module; the timer module group comprises a day alarm clock module, a turn-on delay module, a turn-off delay module, a turn-on and turn-off delay module, a keep-on module, a pulse output module, a cycle output module, and a year alarm clock module; and the operator module group comprises a non-module, an and module, an or module, an exclusive or module, a latch relay module, a pulse relay module, and a counter module.
[0037] Further, the input and output module group further comprises an analog value output module; and the operator module further comprises an add module, a subtract module, a multiply module, a divide module, a square root module, a greater than module, a less than module, an equal to module, and a threshold trigger module.
[0038] Preferably, as shown in Fig. Figure 1 In the graphical interface of the APP, each program module group corresponds to a different tab, and each tab is provided with a plurality of graphical modules, each graphical module corresponding to a program module, and a user can select different program modules by selecting graphical modules in different tabs and edit the program modules.
[0039] In order to better understand the selected program modules provided by the APP, some main program modules will be described as follows:
[0040] (1)Switching quantity input module, get the switching state (on or off) of the corresponding port, for example, if the user needs to get the state of the I0.1 port of a hardware, the PLC control program generated needs to include a switching quantity input module, which includes the input port of the hardware IO port that can be set, and the port number of the selected input port is I0.1. The switching quantity input module can be used by other program modules in the PLC control program.
[0041] (2) Switching quantity output module, output the calculation result of the PLC control program to the corresponding port. The switching quantity output module includes the output port number of the hardware IO port that can be set. For example, if the user needs to use the calculation result of the PLC control program to control the output of Q0.1, the user needs to add a switching quantity output module to the PLC control program, select the corresponding port number as Q0.1, and set the input port of the switching quantity output module as needed. When the PLC executes the PCL control program, the switching quantity output module outputs the input of the input port to Q0.1, which controls the action of the corresponding relay of Q0.1.
[0042] (3) Analog quantity input module, used to acquire the value of the hardware analog quantity acquisition port. The analog quantity input module includes the input port of the hardware IO port that can be set. Any hardware has several analog quantity acquisition ports, which are used to detect 0V-10V and convert them into digital type 0-10000mV. For example, a power system is connected to AI0.1 on a certain hardware. When the user writes the PLC control program, the analog quantity input module is added, and the port number of the corresponding input port is selected as AI0.1. This can be used to detect the voltage value of the power system for subsequent calculation and processing.
[0043] (4) Day alarm clock module, used to set the start time and end time (format: hour-minute-second), including a start time input port for setting the start time and an end time input port for setting the end time. A certain hardware (PLC) has a built-in calendar clock. The PLC control program includes a day alarm clock module. When executed, it determines whether the calendar clock is within the time range set by the day alarm clock module. If so, it outputs a valid signal to the corresponding port number address. For example, a hardware (PLC) that needs to be turned on at a certain time, such as 18:00-07:00, the day alarm clock module outputs a valid signal during this time period, which is connected to the hardware (PLC) through a relay to turn on the lamp.
[0044] (5) Year alarm module, for setting start date and end date (format: year-month-day), including start date input port for setting start date and end date input port for setting end date, certain hardware (PLC) built-in calendar clock, PLC control program including year alarm module, when executed, judging whether the calendar clock is in the time range set by the year alarm module, if yes, outputting valid signal, for example, for controlling the hardware (PLC) running in the time range, the PLC control program of the year alarm module sets the time range 2019.3.1-2020.2.1, then in this time range, the year alarm module outputs valid signal to the corresponding port number address, and the device is controlled to run in this time range through the relay connected with the PLC.
[0045] (6) Turn-on delay module, the input of this module includes start signal input port, delay signal input port and pause signal input port, when the start signal of the start signal input port is valid, this module delays according to the delay time of the delay signal input port, and after the delay is over, a valid signal is outputted, for example, for controlling the segmented running of the device, when the user starts the device, the device 1 starts immediately, and the device 2 runs after the device 1 runs for a period of time, this module can be introduced into the PLC control program, after the user presses the start button, the PLC control program controls the device 1 to start immediately, and then delays according to the delay time, after the delay is over, this module outputs valid signal to the corresponding port number address, and the device 2 is controlled to run through the relay connected with the PLC. The pause signal of the pause signal input port is used for pausing the timing of this module, and after the pause signal is removed, the module continues to delay.
[0046] (7) Turn-off delay module, the input of this module includes trigger signal input port, delay time input port and pause signal input port, when the start signal of the trigger signal input port is valid, this module outputs valid signal immediately, when the start signal of the trigger signal input port is invalid, this module delays according to the delay time of the delay time input port, and after the time arrives, invalid signal is outputted to the corresponding port number address, for example, for controlling the stop operation of the cooling fan, when the user stops the running of the device, the cooling fan cannot stop immediately, and should be stopped after the heat of the device is completely dissipated, at this time, this module can be introduced into the PLC control program, when the user starts the device, this module outputs valid signal, and the cooling fan is controlled to run through the relay connected with the PLC, when the user turns off the device, this module delays for a period of time, and then outputs valid signal to make the cooling fan stop. The pause signal of the pause signal input port is used for pausing the timing of this module, and after the pause signal is removed, the module continues to delay.
[0047] (8) Turn-on off delay module, the input of this module includes start signal input port, turn-on time input port, off time input port and pause signal input port, when the start signal of start signal input port is valid, this module delays according to the turn-on time of turn-on time input port, after the delay is over, outputs valid signal, when the start signal is invalid, this module delays according to the off time of off time input port, after the delay is over, outputs invalid signal to the corresponding port number address, the combination function of turn-on delay module and off delay module is similar, for example, applied to the control of cooling fan, some large equipment, when starting, should ensure that other components start first and then start the cooling fan, and when the equipment stops, the cooling fan should be stopped after other components stop and cool down, introducing this module in PLC control program can realize the above control.
[0048] (9) Keep-on module, this module is similar to turn-on delay module, the difference between the two is that: the signal input of the former is trigger signal, and the input of the latter is start signal, this module runs when the input signal is valid and invalid.
[0049] (10) Pulse width output module, this module is similar to off delay module, the difference between the two is that: the signal input of the former is start signal, and the signal input of the latter is trigger signal.
[0050] (11) Cycle output module, the input of this module includes trigger signal input port, turn-on delay input port, off delay input port and reset signal input port, when checking the trigger signal of trigger signal input port, this module delays according to the off time of off delay input port and then outputs valid signal, then delays according to the turn-on time of turn-on delay input port and outputs invalid signal to the corresponding port number address, and then outputs in turn, the reset signal of reset signal input port controls the stop of this module, for example, applied to control the flicker of alarm lamp, when PLC monitors fault signal, PLC control program executes this module to control alarm lamp.
[0051] (12) Non-module, including input port receiving input signal, this module outputs to the corresponding port number address after taking the inverse of input signal, that is, when the input is valid signal, the output is invalid signal, when the input is invalid signal, the output is valid signal, for example, used for shutdown operation of switch control equipment, introducing this module in PLC control program, when the button is not pressed, this module outputs valid signal, the equipment runs, when the button is pressed, this module detects valid signal input, then outputs invalid signal after taking the inverse, controls the shutdown of equipment.
[0052] (13) And the module, it includes receiving 2-way switch quantity input input port, this module includes 2-way switch quantity input, when 2-way signal is all valid signal, output signal is valid to corresponding port number address, for example, apply to the safety chain of equipment, when 2 safety signals on the line are valid, the equipment can be started, otherwise the equipment cannot be started, introduce this module in the PLC of equipment, make 2-way switch quantity input of this module connect to 2 safety signals, when 2 safety signals are all valid, this module outputs valid signal, and the PLC can start the equipment.
[0053] (14) Or the module, it includes receiving 2-way switch quantity input input port, this module includes 2-way switch input, when 2-way signal is valid signal, then this module outputs valid signal to corresponding port number address, for example, apply to the double-point start of equipment, press one button can start the equipment, introduce this module in the PLC of equipment, make 2-way input signal of this module connect to 2 different start buttons, press any one button, this module outputs valid signal, then the PLC controls the equipment to start.
[0054] (15) Xor module, it includes receiving 2-way switch quantity input input port, this module includes 2-way switch quantity input, when 2-way signal is different, output valid signal to corresponding port number address, that is to say, one-way input valid signal and the other input invalid signal, this module outputs valid signal, both input valid signal or invalid signal, this module outputs invalid signal.
[0055] (16) Latch relay module, that is, RS trigger, the input switch quantity signal is locked and reset, when detecting trigger signal, RS trigger outputs valid signal and keeps (even if the trigger signal disappears, it does not affect the output of RS trigger), when monitoring reset signal, RS trigger outputs reset signal, the output of latch relay module is output to the address corresponding to the port number.
[0056] (17) Pulse relay module, it includes receiving trigger signal input port, when detecting trigger signal, the output signal is reversed, that is to say, when detecting a trigger signal, if the current output signal is invalid, it becomes output valid signal, when detecting trigger signal again, because the previous output signal is valid, it becomes output invalid signal, the output of pulse relay module is output to the address corresponding to the port number.
[0057] (18) A counter module, the counter module comprises a trigger signal input port, a direction input port and a reset input port, the direction input port is used to control the working mode of the counter module to be an add mode or a subtract mode, in the add mode, when the counter module detects a trigger signal, the value of the output of the counter module is added by 1, in the subtract mode, when the trigger signal is detected, the value of the output of the counter is subtracted by 1, when the reset signal is detected, the value of the output of the counter is reset to 0, and the output value is output to the address corresponding to the port number of the counter module.
[0058] Obviously, the add module, the subtract module, the multiplication module and the division module all comprise two digital input ports, and after corresponding addition, subtraction, multiplication and division, the result is output to the address corresponding to the port number of the program module; the square root module comprises one digital input port, and after square root operation, the result is output to the address corresponding to the port number of the program module; the greater than module, the less than module and the equal to module comprise two digital input ports, and after corresponding greater than, less than and equal to comparison, the on-off result is output to the address corresponding to the port number of the program module.
[0059] (19) An analog output module, used for outputting a numerical value to a hardware analog output port, the analog output module comprises a port number capable of being set as an output of an IO port of the hardware, and the input port of the analog output module can be the output data of some operator modules, such as an add module, a subtract module, a multiplication module, a division module, a counter module, an integrator or other program modules, and the function is to send the input data to the corresponding analog output hardware port, and the output port is directly connected with the input port, and the output of other program modules is output to the hardware port.
[0060] (20) A threshold trigger, used for judging whether an input numerical value exceeds a range, and if the input numerical value exceeds the range, the threshold trigger outputs to other program modules according to setting, the input port of the threshold trigger can be the output data of some operator modules, such as an add module, a subtract module, a multiplication module, a division module, a counter module, an integrator or other program modules, and the function is to judge the input data according to the set maximum limit value and the minimum limit value, and if the input data exceeds the range, the output result is sent to the remaining program modules for processing.
[0061] The PLC control program comprises one or more program module groups, each program module group comprises at least one program module, and when a plurality of program modules are included in the same program module group, the program modules in the program module group are sequentially associated. By dividing different program module groups, the diversified arrangement and design between unrelated programs are facilitated.
[0062] Further, the different program module groups are independent of each other, the program module group generated later can include a project element for referencing the program module of the program module group generated earlier, the user can add the project element and select the program module in the program module group generated earlier corresponding to the project element; the program module adjacent to the project element in the same program module group can be associated with the project element, when the PLC program download package is generated, the project element does not need to be allocated the space and address of the port number of the corresponding program module, for the program module associated with the project element, the PLC underlying address of the program module associated with the project element is obtained, and the address corresponding to the input port data in the PLC underlying address is replaced by the address of the port number of the program module corresponding to the associated project element. The project element replaces the previous program module, so that the program module groups can be associated, and the repeated program module setting is avoided.
[0063] Specifically, as shown in FIG. 1, it is one embodiment of the PLC control program. Figure 5
[0064] The PLC control program includes two program module groups, each of which includes three program modules, one of which includes program module E1, program module E2 and program module E3, program module E1 is associated with program module E2, and program module E2 is associated with program module E3; the other program module group includes program module E4, program module E5 and program module E6, program module E4 is associated with program module E5, and program module E5 is associated with program module E6. Further, the program module E1 and the program module E4 are both on-off input modules, the program module E3 and the program module E6 are both on-off output modules, the program module E2 is a cycle output module, and the program module E5 is a non-module.
[0065] Specifically, as shown in FIG. 2, it is another embodiment of the PLC control program. Figure 6
[0066] The PLC control program includes two program module groups, one of which includes three program modules, which are program module E1 (on-off input module), program module E2 (on-delay module) and program module E3 (on-off output module), and the other program module group includes program module E4 (on-off output module), and the program module E1 of the previous program module group is referenced by the program module group.
[0067] Further, when the PLC control program of the embodiment is generated, the port number address of the first program module in the first line is 0, the port number address of the program module following it is 1, and so on; the port number address of the first port number in the second line is followed by the port number address of the last program module in the previous line (if the program module is a referenced program module, the address is not counted) and is added by 1; as shown in FIG. 3.Figure 6 As shown in the figure, the input port Trg of E2 is connected to E1, then the address data stored in the input port of E2 is 0, the second input port is constant 1 (1 second), the third port is constant 0 (False is 0), the input of E3 is connected to E2, thus the data stored in the input port of E3 is the port number address of E2, that is 1, so that the output of E1 is connected to the input of E2, the output of E2 is connected to the input of E3, that is, E1, E2 and E3 are sequentially associated.
[0068] As shown in the figure, the input port Trg of E2 is connected to E1, then the address data stored in the input port of E2 is 0, the second input port is constant 1 (1 second), the third port is constant 0 (False is 0), the input of E3 is connected to E2, thus the data stored in the input port of E3 is the port number address of E2, that is 1, so that the output of E1 is connected to the input of E2, the output of E2 is connected to the input of E3, that is, E1, E2 and E3 are sequentially associated. Figure 7 As shown in the figure, the input port Trg of E2 is connected to E1, then the address data stored in the input port of E2 is 0, the second input port is constant 1 (1 second), the third port is constant 0 (False is 0), the input of E3 is connected to E2, thus the data stored in the input port of E3 is the port number address of E2, that is 1, so that the output of E1 is connected to the input of E2, the output of E2 is connected to the input of E3, that is, E1, E2 and E3 are sequentially associated.
[0069] The hardware circuit of the alarm system is built: I0.0 of the product is connected to the fault signal, I0.1 is connected to the reset button, Q0.0 controls the main circuit, and Q0.1 controls the alarm lamp.
[0070] The function requirement of the PLC control program of the embodiment is: when the system detects the fault signal, the main circuit is turned off, and the alarm lamp is controlled to flash, when the reset button is pressed, the alarm is removed, and the main circuit is restored.
[0071] The PLC control program of the embodiment uses the on-off input module, the on-off output module, the latch relay module and the cycle output module, when the on-off input module (network label E1, port number set to I0.0) detects the fault signal, the start of the cycle output module (network label E2, 1 second on, 1 second off) is controlled, the cycle output module controls the output of the on-off output module (network label E3, port number set to Q0.1); at the same time, when the on-off input module (E1) detects the fault, the signal is sent to the latch relay module (network label E4) at the same time, the stored relay locks the signal, and the output of the on-off output module (network label E6, port number set to Q0.0) is controlled after the signal is inverted by the non-module (network label E5), the main circuit is turned off; the on-off input module (network label E7, port number I0.1) is connected to the reset pin R of the latch relay module (E4) and the reset pin Rs of the cycle output module (E2) respectively, when the user presses the reset button, E4 and E2 are reset, the latch relay output signal is invalid, the effective signal is output after inversion by the non-module (E5), the on-off output module (E6) is controlled to output the effective signal, and the main circuit is turned on.
[0072] The wireless communication connection between the smart phone and the PLC is established, and the PLC program download package is downloaded.
[0073] Preferably, the wireless communication can be realized by WiFi, Bluetooth or NFC.
[0074] Preferably, the smartphone communicates wirelessly with the PLC via WiFi. After the smartphone and PLC are successfully connected, the smartphone opens a TCP connection to the port opened by the WiFi module of the PLC (for example, IP address 192.168.1.1, port number 9999).
[0075] Preferably, when the smartphone is connected to the PLC via WiFi, the PLC identification code is input into the smartphone. The identification code includes the WiFi account and password. The smartphone can establish a wireless communication connection with the PLC using the account and password.
[0076] Preferably, when the smartphone establishes a wireless communication connection with the PLC via NFC, the PLC identification code can be input into the smartphone to establish a wireless communication connection, or the smartphone scans the PLC's QR code to obtain its PLC identification code to establish a wireless communication connection.
[0077] Preferably, when the smartphone establishes a wireless communication connection with the PLC via Bluetooth, the PLC identification code can be input into the smartphone, the identification code including the Bluetooth address and pairing code, and the smartphone realizes a wireless communication connection with the PLC via the Bluetooth address and pairing code.
[0078] Step 3: Download the generated control program to the PLC through the APP to complete the PLC programming.
[0079] Preferably, the structure of each program module of the PLC control program includes: (a) a plurality of input ports (one or more ports, usually no more than 4), each input port stores the address value of its connection (the address value is as follows: Figure 5 、 6 E1, E2, E3, etc. shown are used to obtain the data of the address stored in the port number of the remaining program modules to which it is connected) or constants (for example, the delay module has a delay time parameter); (b) the function module code, which is a unique identifier to distinguish the program module; (c) the port number used to output its execution result data, which refers to the storage address corresponding to the program module, that is, an output data address, and the data of the program module is stored here. For the switch input module, switch output module, and analog input module, the above modules all have corresponding hardware port numbers, and the data of the hardware port number is stored here.
[0080] It should be noted that after the smartphone establishes a connection with the PLC, the PLC program download package containing the PLC underlying program of each program module is sent to the PLC through the wireless communication interface through the APP. When the PLC is running, the function of each program module is executed in a round-robin manner, and the result is saved in the RAM of the corresponding program module. For example, Figure 7The PLC control program shown, when the PLC running program module E1, first acquires the PLC bottom layer program corresponding to the program module E1, enters the corresponding function (on-off quantity input execution function), acquires the port number of the program module in the function, and saves the value in the corresponding RAM (i.e. the address corresponding to the port number, marked RE1), by which the first program module function has been executed, then the program module E2 is executed, first acquires the PLC bottom layer program corresponding to the program module E2, enters the corresponding function (loop output execution function), acquires the address or constant of its input port in the function and executes (the address connected by port 1 is E1, so the data RE1 of the corresponding RAM is acquired, and the address connected by port 4 is E7, so the data RE7 of the RAM corresponding to the port number address of E7 is acquired), after the acquisition is completed, the operation is performed, and the result is saved to the corresponding RAM (marked as RE2), and the like is sequentially performed.
[0081] Preferably, the PLC can also upload instructions to a smart phone to view the working state of the PLC.
[0082] The application further discloses a programming system of a programmable logic controller, which comprises a smart phone and a PLC.
[0083] Preferably, the first wireless communication module and the second wireless communication module are WiFi modules, Bluetooth modules or NFC modules.
[0084] Preferably, the PLC further comprises a signboard, the signboard being marked with the identification of the PLC, and / or the Bluetooth address and pairing code of the PLC, and / or a two-dimensional code; the two-dimensional code comprising the identification code of the PLC, and / or the Bluetooth address and pairing code of the PLC.
[0085] The above is a further detailed description of the application in combination with specific preferred embodiments, and the specific implementation of the application cannot be limited to these descriptions. For ordinary skilled persons in the technical field to which the application belongs, a number of simple deductions or replacements can be made without departing from the concept of the application, and all of them should be regarded as falling within the protection scope of the application.
Claims
1. A method for programming a programmable logic controller for a mobile device with a touch screen, characterized in that: It includes multiple program modules to be selected, each program module includes an input port for storing the address value or constant connected thereto, a unique function module code for distinguishing the program module, a port number for outputting the execution result data thereof, and a PLC bottom-level program corresponding to the program module; The system includes a visual interface that allows a user to select a program module through a touch screen of a mobile device and set an input port of the program module to implement a PLC control program, wherein the PLC control program includes a plurality of selected and set program modules arranged in sequence, and the input port of a subsequent program module can be set to an address value corresponding to the port number of a previous program module, thereby associating the subsequent program module with the previous program module; The PLC control program includes one or more program module groups, each program module group includes at least one program module; when the same program module group includes multiple program modules, the program modules in the program module group are sequentially associated; When the PLC control program includes multiple program module groups, different program module groups are independent of each other. A later-generated program module group can include a project element for referencing a program module of a previously-generated program module group, allowing a user to add a project element and select a program module in the previously-generated program module group corresponding to the project element. Program modules adjacent to a project element in the same program module group can be associated with the project element. When generating a PLC program download package, there is no need to allocate space and addresses for port numbers of corresponding program modules to the project elements. For a program module associated with a project element, the PLC bottom-level address of the program module associated with the project element is obtained, and the address corresponding to the input port data in the PLC bottom-level address is replaced with the address of the port number of the program module corresponding to the associated project element. Download the PLC program download package corresponding to the PLC control program to the programmable logic controller.
2. The method for programming a programmable logic controller according to claim 1, wherein: The steps of generating a PLC program download package include: Allocate space and addresses for storing port numbers of various program modules to various program modules of the PLC control program; Sequentially obtain the PLC bottom-level program corresponding to each program module of the PLC control program, replace the corresponding address for storing execution result data in the PLC bottom-level program with the address assigned by the port number of the program module, and replace the corresponding address for obtaining input port data in the PLC bottom-level program with the address of the port number of the previous program module associated with the input port data, or replace the obtained input port data with a corresponding constant, to obtain the program module download program corresponding to each program module; The program module download programs corresponding to each program module are packaged into a PLC program download package.
3. The method for programming a programmable logic controller according to claim 1, wherein: The plurality of program modules to be selected include program modules belonging to an input / output module group, and the input / output module group includes any one or more of a switch input module, a switch output module, an analog input module, and an analog output module.
4. The method for programming a programmable logic controller according to claim 1, wherein: The multiple program modules to be selected include program modules belonging to a timer module group, and the timer module group includes any one or more of a daily alarm module, a yearly alarm module, an on-delay module, an off-delay module, an on-off delay module, a keep-on module, a pulse width output module, and a cyclic output module.
5. The method for programming a programmable logic controller according to claim 1, wherein: The multiple program modules to be selected include program modules belonging to an operator module group, and the operator module group includes any one or more of an addition module, a subtraction module, a multiplication module, a division module, a square root module, a greater than module, a less than module, an equal to module, a negation module, an AND module, an OR module, an XOR module, a latch relay module, a pulse relay module, a counter module and a threshold trigger module.
6. The method for programming a programmable logic controller according to claim 3, wherein: The switch input module is used to obtain the switch status of the hardware port, and the switch input module includes an input port that can be set as an IO port of the hardware; The switch output module is used to output the calculation result to the corresponding port, and the switch output module includes a port number that can be set as the output of the hardware IO port; The analog input module is used to obtain the value of the hardware analog acquisition port, and the analog input module includes an input port that can be set as a hardware IO port; The analog output module is used to output the calculation result to the hardware analog port. The analog output module includes a port number that can be set as the output of the hardware IO port.
7. The method for programming a programmable logic controller according to claim 5, wherein: The latching relay module is an RS trigger, which includes a latching relay module trigger signal input port for receiving a trigger signal and a latching relay module reset signal input port for receiving a reset signal. When the trigger signal input port of the latch relay module detects a trigger signal, the RS trigger outputs a valid signal and holds it; when the reset signal input port of the latch relay module detects a reset signal, the RS trigger outputs a reset signal; The pulse relay module includes an input port for receiving a trigger signal, and when the trigger signal is detected, the output signal is output in reverse.
8. The method for programming a programmable logic controller according to claim 5, wherein: The counter module includes a trigger signal input port, a direction input port and a reset input port. The direction input port is used to control the working mode of the counter module to be an addition mode or a subtraction mode. In the addition mode, when the counter module detects a trigger signal, the output value of the counter module is increased by 1. In the subtraction mode, when the trigger signal is detected, the output value of the counter is reduced by 1. When the reset signal is detected, the output value of the counter is reset to 0.
9. A programming device for a programmable logic control device, characterized in that: The programmable logic controller comprises a processor, a touch screen display and a memory, wherein the processor executes the programming method of the programmable logic controller according to any one of claims 1 to 8.
10. A smart phone, comprising a touch screen display, characterized in that: The smartphone is installed with an APP that implements the programming method of the programmable logic controller described in any one of claims 1 to 8.
11. A programming system for a programmable logic controller, characterized in that: It includes a smart phone and a PLC, the smart phone is installed with an APP that implements the programming method of the programmable logic controller described in any one of claims 1 to 8, the smart phone has a built-in first wireless communication module, the PLC has a built-in second wireless communication module, the first wireless communication module and the second wireless communication module are connected to the network, and the generated PLC control program is downloaded to the PLC through the APP.
Citation Information
Patent Citations
Development method of PLC graphical editor based on XML technology
CN111782199A