Automatic generation method, test method and visual test system for PLC (programmable logic controller) codes of excavator control program
Technical Field
The invention relates to an automatic generation method, a test method and a visual test system of a PLC code of an excavator control program, and belongs to the technical field of engineering machinery.
Background
In recent years, with the appearance and development of high and new technologies, the technical level of engineering machinery is continuously improved, and the engineering machinery industry provides powerful guarantee for national infrastructure, and belongs to one of the fields of national emphasis on encouraging development. With the continuous development of national economy and the arrival of the era of internet, electronic information technology and artificial intelligence, more requirements are put forward on the development of the engineering machinery industry, traditional engineering machinery products are more and more developed towards automation and intellectualization by manual operation, and software development not only occupies larger proportion in the development process of the whole product, but also has more and more complex programs.
Because the working environment conditions of the engineering machinery are generally severe and the duration of single operation is very long, the controller and the program operation are required to be reliable and stable enough, the excavator control program in the traditional engineering machinery industry is mainly realized by manually writing PLC codes, the method is stable and feasible after practice verification, but the action types of the existing engineering machinery excavator are relatively fixed, the control program has a simple logic structure, most of the control programs belong to the condition of single input and single output, namely, one instruction is operated to carry out a corresponding action, the development environment based on IEC61131-3 is generally adopted, a sequence structure is generally adopted, a programming language of a ladder diagram or a function block diagram is used, although the development of the engineering machinery control system is convenient, the software functions are more and more abundant along with the improvement of the intelligent requirement of the control system, programs will also become more complex and existing approaches have become increasingly difficult to meet with current technology developments in terms of flexibility and development efficiency.
In addition, in the engineering machinery industry, the excavator has more action instructions, and the requirements on the control system in the aspects of real-time performance and accuracy are higher and higher, so that the control effect needs to be verified at the early stage of program development, and the investment of manpower and material resources in the test process of a prototype is reduced. At present, the mainstream method is to directly adopt real vehicle verification or use an analog simulation test platform with simple functions, the control effect cannot be visually displayed, the visualization capability is poor, the detail display aiming at the action process is rough, meanwhile, the requirements of different environment working conditions on a machine are different, and the practical problems are also key factors for restricting the debugging of control program parameters.
With the improvement of the intellectualization requirement of the control system, the control program becomes more and more complex, and the flexibility and the development efficiency of the software are more and more emphasized by developers. The existing manual program compiling mode developers need to master the use of a software development platform skillfully, and also need to spend a great deal of energy to solve the non-technical problem in the coding process, so that the development efficiency is low, the errors are more, and the system is difficult to adapt to the system with complex subsequent functions. Due to poor readability of the handwritten codes and the fact that writing styles of everyone are different, much inconvenience is brought to later maintenance and experience reference. After the program is compiled, the simulation test precision is low, the simulation modeling process is complex, the visualization capability is poor, the human-computer interaction cannot obtain an intuitive control effect, the controlled dynamic change process cannot be seen as soon as possible before the program real vehicle test, meanwhile, the complex environmental working condition cannot be simulated, the full verification of the road environment is lacked, and the time and the labor are wasted completely depending on the real vehicle test in the later period.
Disclosure of Invention
The invention aims to provide an automatic generation method, a test method and a visual test system of a PLC code of an excavator control program.
In order to achieve the purpose, the technical scheme adopted by the invention is as follows:
the invention provides a method for automatically generating PLC codes of an excavator control program on one hand,
building a control strategy model according to the user requirement;
setting a solver according to the built control strategy model, and carrying out error troubleshooting and parameter configuration on the control strategy model;
selecting a compiling environment according to the target controller;
packaging the built control strategy model to automatically generate a PLC code;
and placing the generated PLC codes in the selected compiling environment for integration to generate an executable program file.
Preferably, a basic module in the simulink model library is called to build a control strategy model according to user requirements.
Preferably, the built control strategy model is subjected to error troubleshooting through simulation operation of a solver.
Preferably, the parameter configuration includes setting a solver step length, setting a system target file generated by a PLC code, setting an annotation option, and setting a report format.
Preferably, a solver of the control strategy model is set to a fixed step length;
and setting the basic sampling period of the control strategy model to be consistent with the interrupt period of the target controller hardware chip.
Preferably, the first and second liquid crystal materials are,
the comment setting option is to configure whether the generated PLC code contains a comment or not; and configuring whether the generated PLC codes contain the used basic module description;
the report format setting means that the configured and generated report has a hyperlink which jumps from a code to a position corresponding to the model; configuring whether to generate a traceability report; and configuring whether to automatically open a report after the compiling of the control strategy model is finished.
Another aspect of the present invention provides a visual test system for an excavator control program, including: the system comprises a vision host, a semi-physical simulation cabinet, a development host, a controller to be tested and a driving simulation operation console;
the visual host is used for building a real-time simulation model of the engineering machinery;
the semi-physical simulation cabinet is used for processing and converting signals in the test process;
the development host is used for configuring the board card in the semi-physical simulation cabinet and creating a test case based on the engineering machinery simulation model;
the controller to be tested is used for storing and running the compiled executable program file, establishing communication with the semi-physical simulation cabinet, controlling the driving simulation operation console to execute corresponding operation actions and testing and verifying the executable program file of the control strategy;
the driving simulation operation platform is used for simulating an engineering machinery cab and executing corresponding operation actions according to a test instruction issued by the controller to be tested.
Preferably, the view host comprises an environment model, a dynamics model, a UDP communication module, a hydraulic system model and a VR interface module;
the environment model is used for simulating a terrain three-dimensional model of an excavator real working scene;
the dynamic model is used for simulating a three-dimensional model of the excavator;
the UDP communication module is used for transmitting control output signals of each model built in the view host to the semi-physical simulation cabinet, driving a corresponding board card to act, and transmitting signals generated by the board card to a corresponding controlled object model in the view host;
the hydraulic system model is used for simulating the actions of all hydraulic circuits of the excavator;
and the VR interface module is used for transmitting the visual signals of the models to the driving simulation operation console.
Preferably, the semi-physical simulation cabinet comprises: the PXI bus backboard comprises an Ethernet communication board card, a PXI real-time controller, a bus simulation board card I, an analog quantity simulation board card I, a digital quantity simulation board card II, an analog quantity simulation board card II and a bus simulation board card II which are connected with the PXI bus backboard through the PXI bus;
the Ethernet communication board card is used for outputting a control signal generated by the semi-physical simulation cabinet to the vision host and transmitting an output signal of the vision host to the semi-physical simulation cabinet;
the first bus simulation board card is used for transmitting and interacting CAN bus information between the semi-physical simulation cabinet and the driving simulation operation console;
the analog quantity simulation board card I is used for transmitting and interacting a handle voltage analog quantity signal between the semi-physical simulation cabinet and the driving simulation operation console;
the first digital quantity simulation board card is used for transmission and interaction of pedal switch digital quantity signals between the semi-physical simulation cabinet and the driving simulation operation platform;
the second digital quantity simulation board card is used for transmitting and interacting digital quantity signals between the semi-physical simulation cabinet and the controller to be tested;
the analog quantity simulation board card II is used for transmitting and interacting analog quantity signals between the semi-physical simulation cabinet and the controller to be tested;
the second bus simulation board card is used for transmitting and interacting CAN bus information between the semi-physical simulation cabinet and the controller to be tested;
the PXI real-time controller is used for receiving and analyzing data on the Ethernet and sending the data to the development host through a TCP communication protocol.
Preferably, the driving simulation operation console comprises a visual display, virtual reality glasses, an instrument display, an operation panel, a left operation handle, an accelerator pedal, a brake pedal and a right operation handle;
the visual display and the virtual reality glasses are used for displaying a 3D simulation effect;
the instrument display is used for displaying the running state data of the excavator;
the operation panel is used for an operator to send a control signal to the semi-physical simulation cabinet;
the left operating handle is used for sending command signals for opening the small arm, closing the small arm and rotating left and right;
the right operating handle is used for sending command signals for lifting the big arm, lowering the big arm and turning over the bucket;
the accelerator pedal is used for sending an accelerator opening degree signal;
the brake pedal is used for sending a brake control signal.
Preferably, the VR interface module is further used for establishing communication between the virtual reality glasses and the real-time simulation model of the engineering machinery, and displaying the full-view simulation result.
A third aspect of the present invention provides a method for testing an excavator control program, including:
downloading the compiled excavator control program to a controller to be tested in the visual test system;
configuring a semi-physical simulation cabinet in the visual test system according to a test purpose and a test range, and building an engineering machinery real-time simulation model according to an excavator structure principle and a schematic diagram of a hydraulic system;
and creating a test case, sequentially operating corresponding operating equipment through a driving simulation operating console according to the test case to perform simulation test and result display, and checking whether the excavator control program can normally run or not and whether result output meets requirements or not.
Preferably, the excavator control program is compiled using the method described above.
Preferably, the result display mode includes:
displaying the automatic test execution result of the development host;
3D simulation effect display is carried out through a visual display of a driving simulation console;
and the combination of (a) and (b),
and displaying the immersive full-view simulation result through the VR interface module.
The invention has the beneficial effects that:
(1) according to the invention, the functional requirement logic of a user can be built through the basic module of the simulink, the PLC codes of the control program of the engineering mechanical excavator can be generated intuitively and quickly, the visual simulation verification can be carried out, the error can be found without waiting for the installation test link, the control effect can be felt intuitively, the logical deviation can be found and the error can be modified as soon as possible, the program can be corrected more easily, and the bug can be found to improve the working efficiency.
(2) The invention combines the graphical programming characteristic based on the model, so that the program is convenient to read, the understanding and the experience reuse are convenient, the model is divided by the hierarchy of the design function, the management of complex design is realized, the generated code has consistency, and the generated code automatically conforms to the relevant standard.
(3) The test system of the invention makes the test verification more comprehensive by constructing abundant environment models, and is very suitable for the simulation verification requirements of the engineering machinery industry.
Drawings
FIG. 1 is a flow chart of an automatic generation method of PLC codes of an excavator control program according to the present invention;
FIG. 2 is a model diagram of a work gear voltage analytic control strategy built on the basis of simulink;
FIG. 3 is a system architecture for visually testing a control program of an excavator according to the present invention;
FIG. 4 is a configuration diagram of a driving simulation console in the visual testing system of the present invention;
FIG. 5 is a test flow diagram of the present invention.
Detailed Description
The invention is further described below. The following examples are only for illustrating the technical solutions of the present invention more clearly, and the protection scope of the present invention is not limited thereby.
One embodiment of the present invention provides an automatic generation method of PLC codes of an excavator control program, referring to fig. 1, including:
step 1, building a control strategy model according to customer requirements;
step 2, setting a solver according to the built control strategy model, and carrying out error check on the built control strategy model through simulation operation; after the investigation is finished, parameter configuration is carried out;
step 3, according to IDE (Integrated Development Environment) Environment matched with controller hardware used in the test stage, selecting system target file generated by code, which controls global code generation and directly controls file generation type of code;
step 4, configuring a code annotation generation style, determining whether the generated code contains annotations and the used basic module description, and conveniently tracing and checking the corresponding relation between the module and the code because a subsequently generated report contains hyperlinks which can jump from the code to the corresponding part of the model;
step 5, configuring a report generation format, and determining whether to generate a traceability report or not and whether to automatically open a report after the control strategy model is compiled;
step 6, according to the size or complexity of the model function, the model can be packaged into one or split into a plurality of subsystems, compiling is started, right-click is performed on the divided control strategy model, a PLC Code is selected, then the PLC Code is automatically generated under the current working path by selecting the Generator Code for Subsystem, and then the generated PLC Code is placed under the selected compiling environment to be linked to Generate an executable program file;
and 7, testing and verifying the generated executable program file in a visual testing environment.
In the embodiment, a basic module in a simulink model library is called to build a control strategy model according to user requirements. FIG. 2 is a model diagram of a work gear voltage analytic control strategy built based on simulink.
In the embodiment, an output result is generated by artificially giving an input signal during simulation operation, and if the output result is inconsistent with the expectation of the customer requirement, the error is modified until the requirement is met; another type of error belongs to parameter setting errors, such as misutilization of the data types uint8 and uint16, which results in the simulation operation being unable to be calculated and also needs to be manually modified.
In this embodiment, the parameter configuration includes solver setting, such as selecting a fixed step length or a variable step length, system target file setting for code generation (such as generating an embedded C code or a PLC code), comment option setting, and report format setting.
In this embodiment, since the program runs in the controller at a Fixed period, the solver of the control strategy model is set to a Fixed Step length (Fixed-Step), and the basic sampling period of the model is also set to be consistent with the interrupt period of the controller hardware chip (generally set to 0.01S).
In this embodiment, the IDE environment is determined by the target device that controls the generation code of the policy model, and 3 scodessys 3.5 is selected according to the PLC code compilation version of the target controller.
Another embodiment of the present invention provides a visual test system for an excavator control program, which downloads a compiled executable program file to the visual test system for test verification, so that a developer can test a control strategy before loading. A visual test system of an excavator control program is shown in figure 3 and comprises a vision host (1), a semi-physical simulation cabinet (2), a development host (3), a controller to be tested (19) and a driving simulation operation platform (12).
The visual host (1) is used for building and operating a real-time simulation model and comprises the following parts: the system comprises an environment model (4), a dynamic model (5), a UDP communication module (6), a hydraulic system model (7) and a VR interface module (8).
The environment model mainly refers to a terrain three-dimensional model, and simulates surrounding environments such as terrain and landform in the actual working scene of the excavator.
The dynamic model mainly refers to a three-dimensional model of the vehicle and simulates the running condition of the vehicle.
The hydraulic system model simulates the actions of each hydraulic circuit, including the expansion and the rotation of a hydraulic valve, an oil cylinder and the like.
Information interaction exists among the models, input signals of each model come from other models, and the output of each model influences other models.
The UDP communication module follows an Ethernet communication protocol, is a popular local area network standard, and is used for transmitting control output signals of each model of the simulation environment built in the view host (1) to the semi-physical simulation cabinet (2) to drive the corresponding board card to act, and each physical signal generated by the board card is returned to the corresponding controlled object model in the view host (1) through the UDP communication module to realize control, so that closed-loop feedback is formed.
And the VR interface module is used for transmitting the visual signals to the driving simulation operation console, so that a user can feel the simulation model visually and auditorily and obtain the virtual operation process of the control object in an immersion manner.
Semi-physical simulation rack (2) are used for setting up semi-physical simulation test hardware environment, are responsible for the processing and the conversion of signal, include: the PXI bus backboard (10) comprises an Ethernet communication board card (9), a PXI real-time controller (11), a bus simulation board card I (13), an analog quantity simulation board card I (14), a digital quantity simulation board card I (15), a digital quantity simulation board card II (16), an analog quantity simulation board card II (17) and a bus simulation board card II (18) which are connected with the PXI bus through the PXI bus.
The Ethernet communication board card (9) is used for outputting a control signal generated by the semi-physical simulation cabinet (2) to the visual host (1) and transmitting a UDP module output signal to the semi-physical simulation cabinet (2).
The bus simulation board card I (13) is used for processing transmission and interaction of CAN bus information between the semi-physical simulation cabinet (2) and the driving simulation operation platform (12).
The analog quantity simulation board I (14) is used for processing transmission and interaction of analog quantity signals such as handle voltage and the like between the semi-physical simulation cabinet (2) and the driving simulation operation platform (12).
The digital quantity simulation board card I (15) is used for processing transmission and interaction of digital quantity signals such as pedal switches and the like between the semi-physical simulation cabinet (2) and the driving simulation operation platform (12).
And the digital quantity simulation board card II (16) is used for processing transmission and interaction of digital quantity signals between the semi-physical simulation cabinet (2) and the controller to be tested (19).
And the analog quantity simulation board card II (17) is used for processing the transmission and interaction of analog quantity signals between the semi-physical simulation cabinet (2) and the controller to be tested (19).
And the second bus simulation board card (18) is used for processing the transmission and interaction of CAN bus information between the semi-physical simulation cabinet (2) and the controller to be tested (19).
The PXI real-time controller (11) is used for receiving and analyzing data on the Ethernet and sending the data to the development host (3) through a TCP communication protocol.
The development host (3) is used for configuring a software environment of the semi-physical simulation test, and comprises the following components: configuring and building a test project for a board card in the semi-physical simulation cabinet; and receiving the data transmitted by the PXI real-time controller (11) to compile and execute the test case.
The controller to be tested (19) is used for storing and running the compiled executable program file, and establishing communication with the semi-physical simulation cabinet (2) through the signal simulation board card to test and verify the control strategy.
The driving simulation operation console (12) is used for simulating a cab of the engineering machinery, so that testers can obtain immersive driving experience, and the driving simulation operation console (12) receives a test instruction issued by the controller to be tested through the signal simulation board card and executes corresponding operation actions.
Referring to fig. 4, the driving simulation console (12) mainly includes an immersive display device and a driving simulation device, wherein the immersive display device includes a visual display (20) and virtual reality glasses (21); the driving simulation apparatus includes an instrument display (22), an operation panel (23), a left operation handle (24), an accelerator pedal (25), a brake pedal (26), and a right operation handle (27).
The visual display (20) and the virtual reality glasses (21) are used for displaying a 3D simulation effect, operating engineering machinery which is 'in the scene', and observing a virtual prototype.
The meter display (22) is used to display vehicle operating status data consistent with the functioning of the meters on a normal vehicle.
The operation panel (23) is used for an operator to send control signals to the semi-physical simulation cabinet, such as high-low speed switching, fan dust cleaning and the like.
The left operating handle (24) is used for sending command signals of arm opening, arm closing, left-right rotation and the like.
The accelerator pedal (25) is used for sending an accelerator opening degree signal.
The brake pedal (26) is used for sending a brake control signal.
The right operating handle (27) is used for sending command signals of raising the boom, lowering the boom, turning the bucket and the like.
In this embodiment, the simulation test result can be presented in the following three forms: firstly, displaying an automatic test execution result of a development host; secondly, performing 3D simulation effect display through a visual display of the driving simulation console; and thirdly, establishing communication between the virtual reality glasses and the real-time simulation model by utilizing the VR interface module, and displaying an immersive full-view simulation result.
Based on the visual test system, the general steps of testing the compiled excavator control program are as follows, referring to fig. 5:
downloading the compiled excavator control program to a controller to be tested;
according to the test purpose and the test range, software and hardware configuration is carried out; the hardware configuration mainly includes setting the board cards according to the types of signals to be tested, such as analog quantity, digital quantity and quantity. The software configuration mainly comprises the step of compiling corresponding environment models, dynamics models and hydraulic system models to adapt to the requirements of the test system.
And establishing a vision model (an environment model, a dynamic model and a hydraulic system model) on a vision host according to a vehicle structure principle and a schematic diagram of a hydraulic system, and establishing communication with the virtual reality glasses through a VR interface module.
And creating a test case, sequentially operating corresponding operating equipment through a driving simulation operating console according to the test case to perform simulation test, and checking whether the control program can normally run or not and whether the result output meets the requirements or not.
The test process is as follows:
and a control signal generated when the development host (3) executes the test case is sent to the semi-physical simulation cabinet, and the controller to be tested establishes communication with the semi-physical simulation cabinet through the signal simulation board card to test and verify the control logic.
After receiving digital quantity, analog quantity and bus signals in a semi-physical simulation cabinet board card, a controller to be tested controls a corresponding analog quantity input/output port, a corresponding digital quantity input/output port and a corresponding bus port to perform data exchange with the simulation board card through internal logic operation, a generated control signal is output to a visual host (1) through an Ethernet communication board card (9), and the control signal is sent to a corresponding controlled object (a dynamic model (5) and a hydraulic system model (7)) through a UDP communication module (6) to realize control.
The method comprises the steps of utilizing a model-based PLC code automatic generation method and a visual testing device to realize construction and testing of the excavator control program, building a control strategy model by analyzing and modeling demand functions, automatically generating PLC codes meeting requirements through parameter configuration, compiling the excavator control program, and jointly compiling the generated codes to generate an executable program file in a compiling environment; virtual reality is introduced into the simulation testing device through visual human-computer interaction, so that an operator can operate a virtual prototype more truly. The code generation process is relatively simple to operate, a large amount of working time can be saved compared with a traditional manual coding mode, the readability of software is high, the later-period maintenance and tracking are facilitated, the working efficiency is high, the functions in the visual testing device are rich, the operation is convenient and visual, and the positive promotion effect on the testing and verification of the program is achieved.
The method realizes the generation of the control logic PLC code through a model modeling mode, and simultaneously carries out simulation verification on the control program by combining a visual dynamics testing device, has the following five differences with the traditional manual code compiling and simulation testing, has strong readability of graphical programming, is convenient for finding problems, is easy to quickly understand the logic thought of the program even in later maintenance, and has higher development efficiency; secondly, the codes are generated quickly and conveniently, the error probability is extremely low, the codes generated by the model conforming to the modeling rule automatically meet the rule of the target language, and the practical test is feasible; thirdly, the portability is strong, after the model-based control logic program is built, different target IDE environments are selected for different target equipment platforms without modifying the control logic model, and the universality of the program is stronger; fourthly, the visual performance of simulation verification is strong, a testing device carries professional dynamic simulation software to construct a 3D excavator model, and the engineering machinery can be operated in an on-the-spot manner by combining virtual reality glasses, so that the running effect of a control program can be intuitively felt, and the dynamic response process of the system can be comprehensively known in a systematic manner; and fifthly, the testable environment has rich working conditions, various working conditions can be conveniently verified by constructing different road models, the environment working conditions are convenient to replace, the test result is more sufficient, and the improvement and optimization of the program are greatly facilitated.
The above description is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, several modifications and variations can be made without departing from the technical principle of the present invention, and these modifications and variations should also be regarded as the protection scope of the present invention.