CN107329764A - A kind of multitask GCPLC systems and the method that application and development is realized using the system - Google Patents

A kind of multitask GCPLC systems and the method that application and development is realized using the system Download PDF

Info

Publication number
CN107329764A
CN107329764A CN201710534495.XA CN201710534495A CN107329764A CN 107329764 A CN107329764 A CN 107329764A CN 201710534495 A CN201710534495 A CN 201710534495A CN 107329764 A CN107329764 A CN 107329764A
Authority
CN
China
Prior art keywords
module
task
control
gcplc
icon
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201710534495.XA
Other languages
Chinese (zh)
Inventor
王宜怀
陈建明
朱仕浪
彭涛
司萧俊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou University
Original Assignee
Suzhou University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou University filed Critical Suzhou University
Priority to CN201710534495.XA priority Critical patent/CN107329764A/en
Publication of CN107329764A publication Critical patent/CN107329764A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/34Graphical or visual programming
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4812Task transfer initiation or dispatching by interrupt, e.g. masked
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The present invention relates to a kind of multitask figure componentization programmable logic controller (PLC) GCPLC systems, the programming mode dragged using figure, simplify the pattern of programming, and multitask system is introduced, realize the synchronous of multitask, communication and interrupt mechanism using lightweight event, lightweight messages queue etc..The invention further relates to a kind of method applied using the GCPLC system developments.

Description

A kind of multitask GCPLC systems and the method that application and development is realized using the system
Technical field
The present invention relates to programmable logic controller (PLC) field, more particularly to a kind of multitask figure componentization FPGA control Device system processed and the method that application and development is realized using the system.
Background technology
PLC plays an important role in industrial automation always so far from proposition.It is that one kind is industrial certainly for realization Dynamicization and design data input/output logic control device, it can realize logical operation, sequential operation, timing and The functions such as counting.Meanwhile, it also has programmable memory.Therefore PLC can not only control all kinds of industrial processes Or plant equipment, but also easily code therein can be modified to adapt to different industrial production demands.
At present, there are hundreds of PLC manufacturers, thousands of kinds of PLC products in the world.It is mainly used in automobile (23%), grain The industries such as food processing (16.4%), chemistry/pharmacy (14.6%), metal/mine (11.5%), paper pulp/papermaking (11.3%).Press According to region can be divided into the U.S., Japan, European three schools product.The product of each school all has the characteristic of oneself, its In, the U.S. is PLC big producer, there is hundreds of PLC business mens, and famous has General Electric (CE) company, A-B companies, Dezhou Instrument (TI) company, Mo Dikang (MODICON) company.There are the TE companies of France, the west gate of Germany in the famous PLC manufacturers in Europe Sub (SIEMENS) company, AEG companies etc..Also there are many famous PLC manufacturers in Japan, such as famous Mitsubishi, ohm Dragon, Panasonic, Fuji etc..The product of these producers occupies very big share in small-sized PLC markets.
For many years PLC with perfect in shape and function, easy to use, antijamming capability and it is highly reliable, can online modification control program, It is convenient with computer interface, analog quantity, the function with the powerful such as high-speed counting and stationkeeping ability can be controlled to exist always Occupy indispensable status in Industry Control.In industries such as chemical industry, oil, machinery, metallurgy, electric power, light industry, weaving, food It is widely used.
However as the variation developed rapidly with the market demand of Industry Control, traditional PLC is gradually manifested Shortcoming:Compatibility and autgmentability are poor;Construct open hardware systems relatively difficult;Staff grasps PLC trapezoidal pattern programming Need by the very long training time;PLC performs the ability of the processing speed of large-scale task and the synchronous coordination work of multitask It is very poor;Some manufacturers have monopolized PLC production so that the growth rate of PLC cost performance is slow.These factors are all limited PLC development.
PLC programing system provides the user writing and compilation facility for ladder diagram.The normal operation of equipment is, it is necessary to PLC The close fit of hardware and software exploitation.Hardware refers to the mechanical part and electric part of equipment, and software development refers to PLC PLC trapezoid figure programs on controller.At present there is provided two kind equipments that are generally divided into of trapezoid figure program editting function, a class is Trapezoid figure program programs special equipment, and a class is the PLC programing systems based on PC.
Trapezoid figure program programming special equipment is the exploitation dedicated for PLC ladder diagram editors of PLC manufacturers manufacture Environment is general to support the programming of IL instruction catalogues and configuration programming.It exist in-convenience in use, programming language is single, service life has The problems such as limiting and be unfavorable for the popularization of PLC device.
The content of the invention
This application provides a kind of multitask figure componentization programmable logic controller (PLC) GCPLC systems, by using figure The programming mode of shape dragging, simplifies the pattern of programming, and realize synchronous, the communication of multitask by introducing multitask system And interrupt mechanism.
In a first aspect, this application provides a kind of multitask figure componentization programmable logic controller (PLC) GCPLC systems, bag Performing module and development module are included,
The performing module includes the digital tube module of PWM module, LED, input/output module, power module, JTAG moulds Block, reseting module, 485 modules, 232 modules and CAN module and bottom layer driving module;
The development module includes:Icon control module, icon control connection and setup module, code display module, volume Translate module and download program module;
The bottom layer driving module is used to complete GCPLC system drive functions;
The icon control module is used to provide the icon control required for exploitation;
Icon control connection and setup module are used for the attribute for setting the icon control chosen, and by the icon chosen Control is attached as required;
The code display module is used for after the completion of icon control connection and setup module connect each icon, Generate and show corresponding code;
Collector is used for after the code display module shows corresponding code, when confirmation is without mistaking, to current Program is compiled and linked;
Described program download module is used for the machine code file download that collector is compiled to generation.
Further, the bottom layer driving module specifically includes universal drive module and multitask drive module;
The universal drive module is used to realize to PWM module, the digital tube modules of LED, input/output module, power supply mould Block, JTAG modules, reseting module, 485 modules, the driving function of 232 modules and CAN module;
The multitask, which performs drive module, to be used to drive the multitask of GCPLC systems to perform, and the multitask performs bag Include synchronization between task, the communication between task and the interruption of task.
Preferably, realize the synchronization between task using lightweight event, using lightweight messages queue realize task it Between communication, the interruption of task is realized using Interrupt Service Routine.
Preferably, the icon control includes performing control, Sensor Control, communication control, flow control and task Control.
Preferably, the icon control is represented using TreeView tree structures.
Preferably, the interconnection between the icon control is realized using Bezier.
Preferably, described program download module calls Jlink to realize that a key is downloaded by the way of order line.
Second aspect, the multitask figure componentization programmable logic controller (PLC) is utilized this application provides one kind The method of GCPLC system developments application, comprises the following steps:
Step 1:Main task is created using icon control module and icon control connection and setup module, in main task just Beginningization bottom layer driving module;
Step 2:Multiple subtasks are created using icon control module and icon control connection and setup module, each is configured Synchronization, communication and interrupt function between the association attributes of task and multitask;
Step 3:Generated using code display module and show corresponding code;
Step 4:Link generation machine code is compiled using collector;
Step 5:Write-in is downloaded to machine code using download module.
Preferably, the subtask includes PWM, LED and UART task, and wherein PWM tasks are used for the frequency according to initialization Umber of pulse and then stop that rate output is specified, LED tasks are used to indicate current running status, and UART tasks come from for reception In debugging software data and according to instruction handled.
Brief description of the drawings
Fig. 1 is the multitask GCPLC system schematics of the present invention;
Fig. 2 is the code refreshing schematic flow sheet of code display module;
Fig. 3 is the schematic diagram after main task is set up
Fig. 4 is the change schematic diagram for adding interface after LED
Fig. 5 is to add lightweight event schematic diagram for task
Fig. 6 is to set up multiple tasks schematic diagram using GCPLC
Embodiment
Describe the specific embodiment of present inventive concept in detail now with reference to accompanying drawing.
As shown in figure 1, the GCPLC systems of the present invention include development module and performing module two parts, wherein, it is described to perform Module includes the digital tube module of pulse width modulation (PWM) module, LED, input/output module, power module, JTAG modules, multiple Position module, 485 modules, 232 modules, CAN module and bottom layer driving module, the development module further comprise icon Control module, icon control connection and setup module, code display module, collector and download program module.
Wherein, the bottom layer driving module be used for complete GCPLC system drive functions, specifically include universal drive module and Multitask drive module.
● universal drive module
The universal drive module is used to realize to PWM module, the digital tube modules of LED, input/output module, power supply mould Block, JTAG modules, reseting module, 485 modules, 232 modules and CAN module drive function.
● multitask performs drive module
The multitask, which performs drive module, to be used to drive the multitask of GCPLC systems to perform, and the embodiment of the present invention is with more Exemplified by tasking operating system MQX, MQX driving file in comprising app, bsp, config, include, kernel (kernel), These files are made concrete function explanation, as shown in table 1 by psp, io, string totally eight files below.
Table 1MQX folder contents and explanation
In above-mentioned file directory, the mission function that user writes is deposited under app files, is programming under multitask system Master file folder.Driving design under this document folder is as shown in table 2.
Table 2app folder contents and explanation
In above-mentioned table 2, task_xxx.c files are not single, and it is a kind of general designation, in multiple of User Defined After business, multiple task_xxx.c files can be generated.
● icon control module
The present invention abandons the trapezoidal pattern programming method that traditional PLC is used, then devises that developer's threshold is lower, more hold The control of intelligible form of icons.Icon control Module Division is further execution control, Sensor Control, led to by the present invention Believe control, flow control, 5 major classes of task controls, it is tree-like using TreeView according to classification using this five classes control as root node Control represents all icon controls, thereby produces tree icon control case, ultimately forms icon control module.
Perform control mainly needs operation to be performed including some, and such as switch interrupts, lightweight event position set, set Delay, setting IO input/output etc.;Sensor Control includes the sensor that GCPLC needs, and such as ultrasonic sensor, AD are passed Sensor etc.;Communication control includes the control related to hardware core board communications, such as I2C, SPI, UART;Flow control is then It is related to program execution, so judging comprising IF, condition is circulated, count the control of circulation etc;Task controls are for addition Designed during task, the control in the control module is that dynamic increases, and only after user's addition task, just can in task controls Corresponding icon.When needing to increase certain control, it is only necessary to set the respective attributes of the control, database is stored in. And for each user program, task controls therein are also different.
● icon control is connected and setup module
Icon control is connected and setup module is to carry out that control is dilatory, line, the module of program sequence design.When from icon It is each independent between each control, even if setting the attribute of control, these controls are still when control module hauls out control So do not possess actual functional capability, when only the entrance at the top and bottom of each control and exit point being connected, these controls Just can really it work.
In general, the icon control in addition to the beginning Start and end End of flow control has entrance and gone out Mouth point.When being patterned programming, different icon controls can be connected with each other by user according to demand, you can complete Graphic programming.Each control is linked in sequence by different, it will the completely different program of generation.The present invention is special according to this Levy, by icon control be divided into general icon control (IcoForGeneral), multiple-limb icon control (IcoForSwitch, IcoForSwitchend) class, circulation icon control class and judge icon control class at (IcoForLoop) (IcoForJudgeStart, IconForJudgEnd), by taking IcoForGeneral classes as an example, when general icon control is carried out mutually The value of each field and differed when even operating, in IcoForGeneral classes, the primary fields information of IcoForGeneral classes is such as Shown in table 3.What preceding 7 row was represented in table 3 is IcoForGeneral class self-informations, and remaining field is used to represent general icon Corresponding Connecting quantity when control is interconnected.
The primary fields information of table 3IcoForGeneral classes
When icon is connected, from the angle of father's icon control (hereinafter referred to as father's control), for linking objective subgraph The different type of control (hereinafter referred to as child control) is marked, father's control is illustrated in combination with the relevant field in table 3 The variation relation of field value when the value of field and corresponding icon control are interconnected in IcoForGemral classes:
(1) if child control type is IconForGeneral, the type of the sub-icon control of father's control TypeForchild values are IcoForGeneral, and the Child fields of father's control are child control icon type.Because child control is IconForGeneral types, its without branched structure, so corresponding ChildLTorFdot, ChildLCaseNumdot with And the relevant field such as ChildLIorLdot is all NULL;
(2) if child control type is if controls, field TypeForChild values are IcoForJudgeStart;Field Child values are the instance objects of correspondence child control type;Remaining field information is then with child control type It is identical during IconForGeneral.
(3) if child control type is end controls, field TypeForChild values are IcoForJudgeEnd;Field Child values are the instance objects of correspondence child control type;If what is be connected into is the true attachment point of IcoForJudgeEnd child controls, Then field ChildLTorFdot values are true entrance;Otherwise it is false entrance.Remaining field information is then with child control type It is identical during IconForGeneral.
(4) if child control type is IcoForLoop, the TypeForChild field values of father's control are IcoForLoop;Child field values are the instance objects of correspondence child control type;If what is be connected into is IcoForLoop icon controls The entrance of part, then ChildLTorFdot values are access point;If what is be connected into is being recycled into for IcoForLoop icon controls Mouth point, then ChildLTorFdot values are circulation access point;Remaining field information is then with child control type It is identical during IconForGeneral.
(5) if child control type is Switch controls, field TypeForChild values are IcoForSwitch;Field Child values are the instance objects of correspondence child control type.Remaining field information is then with child control type It is identical during IconForGeneral.
(6) if child control type is SwitchEnd controls, field TypeForchild values are IcoForSwitchEnd;Field Child values are the instance objects of correspondence child control type;Field ChildLCaseNumdot is The branch's sequence number for the SwitchEnd controls being currently connected into.Remaining field information is then with child control type It is identical during IconForGeneral.
Meanwhile, can be by double-clicking each control to edit the attribute of the control, so that PWM is initialized as an example, as click PWM When initializing control, " PWM initialization " property window will be jumped out, PWM output frequency can be configured in the window, user can To be easy to grasp.Other controls also have respective property window, and the allocation window of control is also similar.
Icon control interconnecting operation is the process that icon control mutually interconnects, and lock out operation is to separate icon two-by-two Process.Assuming that it is X and Y to be now to icon control of the connection with separating, wherein X is father's control, and Y is child control.Below will be right Both operations are explained in detail.
Interconnection between icon control realizes that its main flow is as follows using Bezier:
(1) icon control type, instance objects and the X for preserving X connect point coordinates.
(2) the clear X of ResetChild methods of father's control child control field is used, and Y icon type is written to X realities In the child control field of example object.
(3) the clear Y of ResetParent methods of child control father's control field is used, and by X icon control type to Y In father's control field of instance objects, the coordinate of Y attachment points is finally recorded.
(4) coordinate a little and the coordinate of Y attachment points are connected according to X, the connection between X to Y is drawn using Bezier Line.
(5) refresh airlink and setup module again, and regenerate source code.
And the separation between icon control refers to cancel the connection between X and Y icon controls, the present invention passes through ResetParent and ResetChild methods are realized.Assuming that being now to be separated icon control X and Y, then X only needs to adjust Child control information is emptied with ResetChild methods, Y only needs to call ResetParent methods to empty father's control information.
● code display module
Control connect and setup module each icon is envisioned according to oneself be linked in sequence after the completion of, if do not appointed What is referred to the function of modification, it is more likely that so that the program of last programming can not normally be run, and only icon connects Connecing also can be so that developer feels to feel uncertain very much.In order to solve these problems, code viewing area is devised.The generation that the region is shown Code is one-to-one with the connection mode of control link block.The more new technological process such as Fig. 2 for the code that code display module is shown It is shown.
From figure 2 it can be seen that the flow of code update is divided into two parts by code update algorithm, so split according to According to being that all global variables are stored in main task, and the correlative code of subtask is created and also carried out in main task.And Only there be the local code and its other codes related to current task in subtask, this design method causes in whole program Global variable and local variable be difficult to obscure, error probability is low.
● collector
Collector is that after the dragging and connection of icon control is completed, when confirmation program is without mistaking, present procedure is entered The module of row compiling.The module process new by creating, in process CMD come call GNU provide make instruments, compiler Graphical programs are compiled and linked with connector, two kinds of machine code files of HEX and ELF are ultimately produced.In the mistake of compiling Cheng Zhong, in order to more intuitively show the information of compiling and the compiling result of final program, devises visual compiling mould Block.GCPLC graphical programming environment realizes the display of compiling information using the mode of cross-thread calls, so that carry out The execution of program elsewhere is not interfered with during compiling, the fluency of whole system operation, the information of collector is enhanced Output includes compiling correct information output and the information output of mistake, and so that correct information is exported as an example, its key job is as follows.
As can be seen that compiling information carries out cross-thread calls using the mode of commission, when receiving the volume from Make instruments Translate after information, p_OutputDataReceived function call invoke methods, which wake up, entrusts ReadStdOutput, and information is defeated Go out, and ReadStdOutAction methods are that addition self-defined information " compiling successfully " will be tied successfully in the case of compiling is correct Fruit is exported to interface.
● download program module
Main flow in the market is programmed into device and all employs figure and be programmed into device is led to by USB interface or serial ports with PC Letter, while realizing the download of program by writing interface with frame structure that target MCU communicates.Under this frame structure, Detail programming device is received from the PC operational orders sent and data, after being parsed to order, is communicated with target MCU, Target MCU is allowed to complete corresponding feature operation.For different target MCU, by PC traditional text formula IDE or It is independently written software and sends the information such as pass down the line write device target MCU model.The present invention designs the configurable of open loop environment Also in compliance with this design philosophy during machine code download unit.
For the user using multitask system development environment, when completing writing and being compiled into machine for graphical programs After device code, then open the IDE of text type and be downloaded using its write-in functions carried, this method is time-consuming to take Overcome aobvious clumsiness;Opposite, it is independently written software and is not integrated in the traditional text formula IDE of some fixation, and The product that each chip factory commercial city can be directed to the write-in agreement researched and developed using oneself company releases corresponding write device and independence Software is write, facilitates user to carry out machine code download, while this kind of Embedded Middleware of also similar Segger companies is provided Business is independently written software for what some standards write-in agreement was released.
It will thus be seen that for the equipment of any a use standard or non-standard write-in agreement, can all there is one The specific software that is independently written is fully able to complete its code write-in functions.
Each installation kit for being independently written software is analyzed again, inventor has found, be independently written software in installation During can't edit the registry or system environment variable, it is only necessary to call the related dll file under installation directory and match somebody with somebody Operation can be completed by putting message file.
So that the JLink under the Wimdows platforms that Segger companies provide is independently written software as an example, after its installation Installation directory is as shown in table 3-3.
Table 4JLink installation directory fileinfos
As can be seen from Table 4, software is independently written in units of installation kit after installation, can copy other set to It is standby upper, it is not necessary to which that configuration can be run again.
In order that downloading process becomes more transparent, the present invention calls Jlink to realize real meaning by the way of order line A key in justice is downloaded, and is so not only eliminated cumbersome download configuration operation, is more improved the speed of download program, it is realized Code it is as follows:
In above-mentioned code, order line is transferred using CmdProcess classes, and opens J-Flash softwares, is then turned on The engineering " MK60DN512.jflash " set, and set downloading mode to be automatic, allow write device start automatic detection and under Load program, provides the follow-up prompting provided again after the completion of download.
GCPLC systems are intended to apply in the Industry Control of multitask demand.Therefore in addition to above-mentioned several basic modules, Further contemplate and multitask system is dissolved into development module.Still so that MQX is realized as an example, the co-ordination of multitask in MQX Key is synchronization, communication and the interrupt management between each task.
Before main task is set up, should MQX clear and definite first start-up course.In operation MQX embedded system, The start-up course of MQX engineerings can be divided into chip and start and MQX os startings, wherein the start-up course of hardware and NOS (nothings Operating system) unanimously, the start-up course of chip is removed, the first step that MQX starts is to enter Main functions, into Main functions Afterwards, MQX entrance function is recalled, and starts undying operation, task scheduling and management is subsequently entered.Therefore MQX figure below The first step of shapeization programming is project of setting up and main task.The interface set up after main task is as shown in Figure 3.Left side is icon in figure Control module, centre is that icon is set and link block, and right side is that code brush is shown and refresh module, and lower section is compiling information window Mouthful.
As can be seen that only having " Main " icon in current Graphics dragging and linkage interface, this represents currentitem Only has the main task task_main of a task, i.e. MQX systems in mesh.The groundwork that task_main will be done is as follows:
(1) lightweight event group is created;
(2) related global variable is initialized;
(3) driving of correlation module is initialized;
(4) ISR (interruption) of user is installed
(5) switch interrupts and other tasks are created
(6) self-blocking task is started
Due to an only main task in current whole project, the code of now CodeWindow part generation is as follows:
In above-mentioned code, due to only having a main task task_main in current project, other tasks are not created, Therefore lightweight event group is only created in code and starts self-blocking task two.
After main task has been created, other custom tasks just can be added according to demand, and configuration is needed in the task of addition Three underlying attributes related to task, first is to select to provide the user in the task type to be added, current GCPLC systems The task of four types, respectively lampet task, LED tasks, PWM tasks and communication task.Needed simultaneously after good task is selected Add in the priority that the explanation and the task of task need, in MQX, its bigger priority of priority value of task is more Small, system provides 9-16 optional priority for user, and (Main tasks have highest priority 8, so priority is from 9 Start).
Task association attributes is configured and has clicked on after determination, the task and its phase can be generated in figure dragging join domain Interface is closed, by taking LED tasks in scheming as an example, in the main interface of development environment, independent window can be added for LED tasks, is used for LED tasks are configured according to the demand of oneself wherein, as shown in Figure 4.
And it is determined that after can change templates.c in MQX driving files under app files first in generation Code, code now is as follows.
LED tasks successful add items are can be seen that from code above, and its association attributes has also been configured Into, it can be seen that here its priority is configured to 10, and task stack size is also configured as default size.
As can be seen from Figure 4 the code that right side CodeWindow is shown has occurred that change, and LED is now shown and appoints The default code that business is generated after creating.It is as follows:
#include " 01_app_include.h " // application task public head file
void task_led(uint32_t initial_data)
{
MQX_TICK_STRUCT mqx_tick1,mqx_tick2;
uint8_t StartData;
uint8_t EndData;
uint8_t TempData;
_time_get_ticks(&mqx_tick1);
_time_get_ticks(&mqx_tick2);
TempData=StartData;
// above code is automatically generated by system, please don't arbitrarily be changed
}
From above-mentioned code, it can be seen that after LED is set up, system can generate a series of variables for the task and perform language Sentence, this exactly thing to be done of development environment, as far as possible so that whole process is more more transparent to user, makes user unnecessary Understand specific code to realize, and only need to the execution flow of understanding program, so that whole development process is more straight See, it is readily appreciated that.
When there are multiple tasks in a project, how the synchronization and the progress that communicates in software environment to each task Setting is the basis of real multiple tasks co-ordination.MQX lightweight event is used in GCPLC multitask systems (Lightweight Event) realizes the synchronization between task, and its idiographic flow is as follows:
1. the preparatory stage
(1) lightweight event group is created.A global light weight defined in the header file included on demand in mission function Level event structure body variable.Due to only needing a lightweight event group just can expire in most cases, in unitem The demand of the whole engineering of foot, therefore following acquiescence generation is added in the predefined header file app_include.h of MQX files Code:
LWEVENT_STRUCT lwevent_group;// lightweight event group
Then, _ lwevent_create function creation lightweight event groups are passed through in some task.It is noted that Position of the task comprising initializing light magnitude event group function in ready task queue, it is necessary to need to use this prior to those The task of lightweight event group, this, which is accomplished by this task, has higher priority or under the conditions of All factors being equal, preference will be give to level prior to other Task creation.Corresponding lightweight event group can be automatically created when for example in being saved 3.1 creating main task, because task_main Task has highest priority relative to other tasks.
(2) name lightweight event position., it is necessary to which which first needs to use in determination program before using lightweight event Event and their corresponding event positions.Then the event bit mask in the predefined header file that task is included to corresponding event Word carries out macrodefinition, and to facilitate identification with using, detailed process is as follows:
Combobox on the right of selection task all tasks and can be shown in combobox in the current engineering of automatically retrieval, with Exemplified by current selection PWM tasks, its corresponding lightweight event name is named as Event_PWM, it is noted herein that thing The best mode of the name of part name is in the form of Event+ task names, so to strengthen the readability of program.Following " whether Automatic clear " attribute indicate the event position whether after the completion of execution automatic clear, this attribute is suitable for whole project The situation of only one of which task.As shown in Figure 5.
After determination is clicked on, the operation can change content in app_include.h, according to of current existing event position Number is automatic to be incremented by, and the part of modification is as follows:
LWEVENT_STRUCT lwevent_group;// lightweight event group
#define Event_PWM((1uL)<<(1)) //PWM events position
As can be seen that with the addition of three event positions in the engineering of citing altogether at present from above-mentioned code, and their tool Body numerical value is gradually incremental, is not in the situation of repetition.
2. the application stage
, just can be in the project using these lightweight event positions, to light weight after being added for task and naming event position The operation of level event position has following three kinds:
(1) lightweight event position is set:This step is carried out in the task of trigger event.As required in task Ad-hoc location pass through _ lwevent_set function pairs institute trigger event corresponding event location position.
(2) lightweight event position is waited:This step is carried out in the task of the event of wait.In the task of the event of wait It is middle need to pass through before synchronous code _ function such as lwevent_wait_for obtains qualified lightweight event position.
(3) lightweight event position is reset:This step is also to be carried out in the task of the event of wait.If lightweight event position Without from attribute is reset, then this function pair event position need to be called to reset after lightweight event location position is waited, to respond down The arrival of secondary event.Corresponding event position is removed using _ lwevent_clear functions in lightweight event position is reset.
For three kinds of above-mentioned operations, the stationary problem of task is solved, it is necessary to design dedicated for management lightweight thing The control of part, it can be seen from the above-mentioned description to lightweight event action type, lightweight event control is also required to provide above-mentioned Three kinds of operations, and can be combined from different tasks.
Similar with when the preparatory stage creating lightweight event group, when setting position, the forms also can the current work of automatically retrieval All tasks present in journey, and shown in combobox, it can be seen that each task can correspond to three kinds of differences State, selection any of which state will generate corresponding code, this is sentenced exemplified by PWM, selection waited event Position, it will the following code of generation:
void task_pwm(uint32_t initial_data)
{
_lwevent_wait_for(&lwevent_group,Event_PWM,FALSE,NULL);
// start PWM
ftm_pwmstart(0);
ftm_pwmstart(1);
ftm_pwmstart(2);
while(true){}
}
In above-mentioned code, _ lwevent_wait_for (s &lwevent_group, Event_PWM, FALSE, NULL) this Sentence is the code that is generated behind setting event position, and this task_pwm task for representing current can infinitely be waited after going at this Lightweight event positions of the Event_PWM until being provided with the task in other task, otherwise following program statement will not be obtained Perform.
By way of lightweight event position, the synchronization and communication of realizing task that can be stable with convenient, it is adapted to The characteristic of GCPLC uniprocessor multitasks, can realize the association of each task by taking the minimum program space and cpu resource Adjust work.
After the completion of the Synchronization Design of task, it can be carried out between each task in now GCPLC multitasks system It is synchronous, but be due to that lightweight event position can only transmit the number of 12 system.Therefore, it is also desirable to realize task in development environment Communication, the design process of task communication is equally divided into preparatory stage and application stage by the present invention, chatting in detail below State:
1. the preparatory stage
, it is necessary to specify the maximum number of messages that can be accommodated in corresponding message queue before using lightweight messages queue Mesh, and single message size.Maximum number of messages indicates the maximum number for the message that can be accommodated simultaneously in current message queue Mesh, single message indicates the control shared by each message.Meanwhile, the two parameters be calculate lightweight shared by space according to According to its circular is as follows:
Lightweight messages queue space=sizeof (LWMSGQ_STRUCT)/sizeof (uint_32)+maximum number of messages * Single message size
According to features described above, it can be 3 that the maximum message number set in the initial message queue of design, which is, while There is provided three kinds of different types of type of messages in development environment, these three data types disclosure satisfy that most of project substantially Demand.Click on after determining, following code will be added in app_include.h:
#define NUM_MESSAGES 3
#define MSG_SIZE uint32_t
extern uint_32
server_queue[sizeof(LWMSGQ_STRUCT)/sizeof(uint_32)+NUM_MESSAGES*MSG_ SIZE];
Meanwhile, in the corresponding task of initializing light magnitude message queue, following code will be generated:
_lwmsgq_init((pointer)server_queue,NUM_MESSAGES,MSG_SIZE);
So far, the initial work of lightweight messages has just been completed, and next can enter the application stage.
2 application stages
The application mode of lightweight messages queue is divided into two kinds:
(1) need send message task in call _ lwmsgq_send functions to lightweight messages queue send disappear Breath.When queue full, according to the value for sending mark, task is operated accordingly.
(2) need receive message task in call _ lwmsgq_receive functions from lightweight messages queue receive Message.If now message queue non-NULL, task deletes first message from message queue, information then is copied into user Buffering area, this message also just becomes a resource of task, if now queue empty, and task blocking is simultaneously waited.
If current operation takes out data, and put it into lightweight to send from corresponding variable or array In message queue;If receiving, then data are taken out from lightweight messages queue and are abandoned in corresponding variable.
The present invention multitask system by the way of Interrupt Service Routine (Interrupt Service Routine) come Realize and interrupt.Abbreviation ISR, is also generally referred to as interrupt processing function.In this interrupt mode.Provided in MQX for interruption A kind of mechanism, to interrupt the program being currently executing, and preserves current CPU state (CPU internal registers), then go to hold One interrupt handling routine of row, then recovers CPU state, by CPU return to perform interrupt before state, while so that in Program before disconnected is continued executing with.
MQX Interrupt Service Routines are divided into two relatively independent parts of kernel ISR (_ int_kernel_isr) and user ISR. Kernel ISR is associated with par-ticular processor, positioned at PSP files, for realizing hardware interrupts to user ISR mapping, typically Realized by assembler language, to ensure quick responses of the MQX to interrupt event.
In the case where using ISR as Interrupt Service Routine, the interruption in the case of design multitask needs to follow certain Rule.
First, user ISR be able to will be called correctly, must be called in system initialization
_ int_install_isr () function, user ISR is installed in sparse interrupt vector table.
_ int_install_isr () function has three parameters, respectively interrupt vector number, Interrupt Service Routine entrance The parameter that location (i.e. interrupt function title), Interrupt Service Routine are used.
For example, being installed for the ISR of the Interrupt Service Routine of serial ports 1 (UART1_RX_ISR), wrapped in MQX self-starting tasks Containing following sentence:
_int_install_isr(INT_UART4_RX_TX,UART4_RX_ISR,NULL);The ISR of // installation serial ports 4
In above-mentioned code, argument " INT_UART4_RX_TX ":For the interrupt vector number of serial ports 4 (this place is 69).Argument “UART4_RX_ISR”:The function name for the Interrupt Service Routine of serial ports 4 write for user;Argument " NULL ":For UART4_RX_ Parameter first address used in ISR, is set to " NULL ", i.e., UART4_RX_ISR does not need parameter here.
Therefore, according to the above-mentioned pair of description with ISR, the present invention is devised and Interrupt Service Routine in software development environment Related control, is operated, is still done below by taking PWM interruption as an example accordingly dedicated for the interruption for each task Narration in detail.
3 road PWM outputs are had in PWM module, two kinds of selections are provided per the outputs of PWM all the way, in respectively opening and closing It is disconnected.Each PWM outputs are required for installing respective interruption, are also such for other modules.Set every interrupt all the way simultaneously Click on after determining, a series of code will be generated, it should be noted that the installation of interruption is that in taks_main tasks, it is former Reason is similar with creating lightweight event group.Higher priority is also required to because interrupting and installing.
Attribute will generate following code after being provided with determination:
// 4. install user ISR
_int_install_isr(INT_FTM0,ftm0_isr,NULL);//ftm0 ISR
_int_install_isr(INT_FTM1,ftm1_isr,NULL);//ftm0 ISR
_int_install_isr(INT_FTM2,ftm2_isr,NULL);//ftm0 ISR
// open interruption
enable_ftm_int(0);
enable_ftm_int(1);
enable_ftm_int(2);
Above-mentioned code Notable, the control of Interrupt Service Routine, which is not only generated, is mounted with that the ISR of user is related Code, and automatically turned on corresponding modules interrupts.The purpose for the arrangement is that the operation outside multitask system is relative Transparent in user, user is only it should be understood that the operation related to multi-job operation, so as to reduce the difficulty of programming.
The invention also provides a kind of method of utilization multitask GCPLC system developments application.
First, main task is created using icon control module and icon control connection and setup module, in main task just Beginningization bottom layer driving module, wherein more crucial PWM initialization includes PWM module number, PWM passages and PWM frequency.
Then PWM, LED, UART task are created, the association attributes of configuration task, wherein PWM tasks are responsible for according to initialization The umber of pulse specified of rate-adaptive pacemaker then stop, LED tasks be responsible for indicating current running status (if normal operation according to 1-60 digital loops are converted), UART tasks are responsible for receiving the data for coming from debugging software and carried out not according to different instructions With processing;Fig. 6 shows the establishment schematic diagram of main task, PWM, LED, UART task.
Then by each task code refreshing Area generation to one's name task code;
After the completion of graphic programming, collector is compiled link and the generation of machine code;
After machine code is generated, download module is downloaded write-in to machine code.
Above example is merely to illustrate the present invention, and not limitation of the present invention, about the common skill of technical field Art personnel, without departing from the spirit and scope of the present invention, can also make a variety of changes and modification, therefore all etc. Same technical scheme falls within scope of the invention, and scope of patent protection of the invention should be defined by the claims.

Claims (9)

1. a kind of multitask figure componentization programmable logic controller (PLC) GCPLC systems, including performing module and development module,
The performing module includes the digital tube module of PWM module, LED, input/output module, power module, JTAG modules, multiple Position module, 485 modules, 232 modules and CAN module and bottom layer driving module;
The development module includes:Icon control module, icon control connection and setup module, code display module, compiling mould Block and download program module;
The bottom layer driving module is used to complete GCPLC system drive functions;
The icon control module is used to provide the icon control required for exploitation;
Icon control connection and setup module are used for the attribute for setting the icon control chosen, and by the icon control chosen It is attached as required;
The code display module is used for after the completion of icon control connection and setup module connect each icon, generation And show corresponding code;
Collector is used for after the code display module shows corresponding code, when confirmation is without mistaking, to present procedure It is compiled and links;
Described program download module is used for the machine code file download that collector is compiled to generation.
2. the GCPLC systems described in claim 1, it is characterised in that:
The bottom layer driving module specifically includes universal drive module and multitask drive module;
The universal drive module be used to realizing to PWM module, the digital tube modules of LED, input/output module, power module, JTAG modules, reseting module, 485 modules, the driving function of 232 modules and CAN module;
The multitask, which performs drive module, to be used to drive the multitask of GCPLC systems to perform, and the multitask, which is performed, to be included appointing The interruption of communication between synchronization, task and task between business.
3. the GCPLC systems described in claim 2, it is characterised in that:The synchronization between task is realized using lightweight event, profit Communication between realizing task with lightweight messages queue, the interruption of task is realized using Interrupt Service Routine.
4. the GCPLC systems described in claim 1, it is characterised in that:
The icon control includes performing control, Sensor Control, communication control, flow control and task controls.
5. the GCPLC systems described in claim 3, it is characterised in that:
The icon control is represented using TreeView tree structures.
6. the GCPLC systems described in claim 1, it is characterised in that:
Interconnection between the icon control is realized using Bezier.
7. the GCPLC systems described in claim 1, it is characterised in that:
Described program download module calls Jlink to realize that a key is downloaded by the way of order line.
8. a kind of method of the GCPLC system developments application described in utilization claim 1-7, comprises the following steps:
Step 1:Main task is created using icon control module and icon control connection and setup module, is initialized in main task Bottom layer driving module;
Step 2:Multiple subtasks are created using icon control module and icon control connection and setup module, each task is configured Association attributes and multitask between synchronization, communication and interrupt function;
Step 3:Generated using code display module and show corresponding code;
Step 4:Link generation machine code is compiled using collector;
Step 5:Write-in is downloaded to machine code using download module.
9. the method for the development and application described in claim 8, it is characterised in that:
The subtask includes PWM, LED and UART task, and wherein PWM tasks are used for what is specified according to the rate-adaptive pacemaker of initialization Umber of pulse and then stopping, LED tasks are used to indicate current running status, and UART tasks, which are used to receive, comes from debugging software Data are simultaneously handled according to instruction.
CN201710534495.XA 2017-07-03 2017-07-03 A kind of multitask GCPLC systems and the method that application and development is realized using the system Pending CN107329764A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710534495.XA CN107329764A (en) 2017-07-03 2017-07-03 A kind of multitask GCPLC systems and the method that application and development is realized using the system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710534495.XA CN107329764A (en) 2017-07-03 2017-07-03 A kind of multitask GCPLC systems and the method that application and development is realized using the system

Publications (1)

Publication Number Publication Date
CN107329764A true CN107329764A (en) 2017-11-07

Family

ID=60198333

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710534495.XA Pending CN107329764A (en) 2017-07-03 2017-07-03 A kind of multitask GCPLC systems and the method that application and development is realized using the system

Country Status (1)

Country Link
CN (1) CN107329764A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023165206A1 (en) * 2022-03-04 2023-09-07 麒麟软件有限公司 Method for adapting domestic operating system to ceph

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102855135A (en) * 2012-04-23 2013-01-02 苏州大学 Graphical component-based sensing network development platform and method
US20140059518A1 (en) * 2012-08-24 2014-02-27 Velocio Networks, Inc. Method for Object Oriented Programming of Programmable Logic Controllers in Graphical Programming Languages
CN104978170A (en) * 2014-04-03 2015-10-14 中国科学院软件研究所 Multi-agent system generating method based on graphical expression
CN105117210A (en) * 2015-07-28 2015-12-02 苏州大学 WSCN-oriented graphical programming system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102855135A (en) * 2012-04-23 2013-01-02 苏州大学 Graphical component-based sensing network development platform and method
US20140059518A1 (en) * 2012-08-24 2014-02-27 Velocio Networks, Inc. Method for Object Oriented Programming of Programmable Logic Controllers in Graphical Programming Languages
CN104978170A (en) * 2014-04-03 2015-10-14 中国科学院软件研究所 Multi-agent system generating method based on graphical expression
CN105117210A (en) * 2015-07-28 2015-12-02 苏州大学 WSCN-oriented graphical programming system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
程玉娟: ""嵌入式实时操作***MQX的内核分析及应用研究"", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *
顾志峰: ""基于KW01的WSCN节点图形化编程软件的设计与应用"", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023165206A1 (en) * 2022-03-04 2023-09-07 麒麟软件有限公司 Method for adapting domestic operating system to ceph

Similar Documents

Publication Publication Date Title
EP2169547B1 (en) Compilation model for programmable logic controllers (PLC).
Nordstrom et al. Metamodeling-rapid design and evolution of domain-specific modeling environments
Agrawal et al. An end-to-end domain-driven software development framework
US10705511B2 (en) Abstraction layers for automation applications
Perchat et al. Component based framework to create mobile cross-platform applications
US20100138808A1 (en) Embedded system design device and a method thereof using a target independent model
JP2009238231A (en) Software development method using metadata expanded under component base environment and its development system
Mannadiar et al. Domain-specific engineering of domain-specific languages
US8074200B2 (en) Method and system for providing tooling instructions through parameterization as an aid for software application development
CN107329764A (en) A kind of multitask GCPLC systems and the method that application and development is realized using the system
Edwards et al. Automated analysis and code generation for domain-specific models
Fricke et al. Industrie 4.0 with MS-excel?
Prayati et al. A methodology for the development of distributed real-time control applications with focus on task allocation in heterogeneous systems
US20230041718A1 (en) Automated code generation based on pseudo-code
Sampson Process-oriented patterns for concurrent software engineering
Rieder et al. A methodology to specify three-dimensional interaction using Petri Nets
Kacsuk et al. The GRED graphical editor for the GRADE parallel program development environment
Moser et al. A novel domain-specific language for the robot welding automation domain
Mohan et al. Temporal analysis for adapting concurrent applications to embedded systems
Cota et al. Development of an Open Source Chemical Process Simulator.
CN116204165A (en) QT engineering development plug-in and engineering graphical development system and method based on same
Kozaczynski et al. Architecture specification support for component integration
Lamberský et al. Development of Simulink blockset for embedded system with complex peripherals
Hoheisel Workflow management for loosely coupled simulations
Bangsow et al. SimTalk and Dialogs

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20171107

RJ01 Rejection of invention patent application after publication