KR20190114510A - Method for Processing Branch Command in PLC - Google Patents

Method for Processing Branch Command in PLC Download PDF

Info

Publication number
KR20190114510A
KR20190114510A KR1020180037324A KR20180037324A KR20190114510A KR 20190114510 A KR20190114510 A KR 20190114510A KR 1020180037324 A KR1020180037324 A KR 1020180037324A KR 20180037324 A KR20180037324 A KR 20180037324A KR 20190114510 A KR20190114510 A KR 20190114510A
Authority
KR
South Korea
Prior art keywords
plc
register
branch
processing function
instruction processing
Prior art date
Application number
KR1020180037324A
Other languages
Korean (ko)
Other versions
KR102091134B1 (en
Inventor
박창우
Original Assignee
엘에스산전 주식회사
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 엘에스산전 주식회사 filed Critical 엘에스산전 주식회사
Priority to KR1020180037324A priority Critical patent/KR102091134B1/en
Publication of KR20190114510A publication Critical patent/KR20190114510A/en
Application granted granted Critical
Publication of KR102091134B1 publication Critical patent/KR102091134B1/en

Links

Images

Classifications

    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B19/00Programme-control systems
    • G05B19/02Programme-control systems electric
    • G05B19/04Programme control other than numerical control, i.e. in sequence controllers or logic controllers
    • G05B19/05Programmable logic controllers, e.g. simulating logic interconnections of signals according to ladder diagrams or function charts
    • G05B19/056Programming the PLC
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B2219/00Program-control systems
    • G05B2219/10Plc systems
    • G05B2219/13Plc programming
    • G05B2219/13004Programming the plc
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B2219/00Program-control systems
    • G05B2219/10Plc systems
    • G05B2219/13Plc programming
    • G05B2219/13083Jumps

Abstract

The present invention relates to a processing method of extending a moving offset value of branch commands having limited moving support of an MPU used in a PLC without changes of hardware specifications. The method for processing a branch command of a PLC comprises: (A) a step of generating PLC operation commands by compilation when a PLC program in which branch commands are used is written, calculating an offset value of branch commands to store the offset value in a first register of an MPU, and generating a jump command processing function for performing a jump command; (B) a step of using a PLC to sequentially perform PLC operation commands written in an area of an operating system when progressed in a run mode; (C) a step of storing a current PLC program position where the jump command processing function occurs while performing the PLC operation commands in a second register of the MPU; (D) a step of calling the jump command processing function to branch to an address where a command address table is stored; and (E) a step of calculating the current program position stored in the second register and a moving offset stored in the first register to jump to a calculated value as an address value based on the called jump command processing function.

Description

PLC의 브랜치 명령어 처리 방법{Method for Processing Branch Command in PLC}Method for Processing Branch Command in PLC

본 발명은 PLC(Programmable Logic Controller)의 브랜치 명령어 처리 방법에 관한 것으로, 구체적으로, PLC에 사용하는 MPU의 제한적인 이동 지원을 갖는 브랜치(Branch) 명령어들의 이동 오프셋 값을 확장하는 처리 방법에 관한 것이다.The present invention relates to a branch instruction processing method of a programmable logic controller (PLC), and more particularly, to a processing method of extending movement offset values of branch instructions having limited movement support of an MPU used in a PLC. .

산업용 제어 시스템으로 PLC가 많이 사용되고 있는데, 입력 모듈에서 입력 데이터를 읽은 후 프로그램을 처음부터 끝까지 한번 수행하고, 그 수행 결과를 출력 모듈에 쓰는 일련의 동작을 한 스캔이라고 하며, 이를 반복하여 수행하는 역할을 하는 것이 PLC 스캔 프로그램이다.PLC is widely used as an industrial control system. After reading the input data from the input module, the program is executed once from the beginning to the end, and the result of writing the result to the output module is called one scan. Is a PLC scan program.

PLC에는 수 많은 함수(Function)나 함수블록이 있으며, 이는 다양한 연산 또는 기능을 수행하기 위한 PLC 명령어이다. 그리고 PLC에서 컴파일 영역의 명령어들을 수행하여 처리하는 과정을 런(Run)이라 한다.There are many functions or function blocks in the PLC, and these are PLC instructions for performing various operations or functions. The process of executing and processing commands in the compilation area in the PLC is called a run.

즉, 사용자가 미쓰비시사의 GX Works2, LS산전사의 XG5000등과 같은 래더 프로그램인 PADT(Programming and Debugging Tool)를 활용해 작성한 PLC 프로그램을 PLC가 동작하기 위한 형식으로 컴파일한다. PLC는 컴파일된 PLC 동작 명령어들을 MPU(Micro Processor Unit)에서 제공하는 PLC 명령어들을 이용해 구동하게 된다.That is, the user compiles a PLC program written using PADT (Programming and Debugging Tool), which is a ladder program such as Mitsubishi's GX Works2 and LSIS's XG5000, into a format for PLC operation. The PLC drives the compiled PLC operation instructions using PLC instructions provided by the MPU (Micro Processor Unit).

이처럼, PLC는 사용자가 작성한 PLC 프로그램에 따라 MPU의 명령어 조합으로 이동, 연산, 처리 등의 동작을 수행하게 된다. 이때, MPU의 성능, 제조사 등에 따라 지원하는 명령어, 동작 가능한 범위와 같은 여러 가지 차이점이 생긴다.As such, the PLC performs operations such as movement, operation, and processing by the combination of instructions of the MPU according to the PLC program written by the user. At this time, there are various differences such as the instructions supported by the MPU performance, the manufacturer, and the operable range.

도1은 종래에 사용자가 PADT를 이용해 작성한 PLC 프로그램을 PLC에서 구동하는 처리 과정을 설명하기 위한 도면이다.BRIEF DESCRIPTION OF THE DRAWINGS Fig. 1 is a view for explaining a process of driving a PLC program created by a user using a PADT in a conventional PLC.

도1을 참조하면, 사용자가 PADT(10)를 이용해 MPU의 명령어 조합(1)으로 PLC 프로그램을 작성하면, PADT(10)는 컴파일러 내부에서 사용자가 작성된 PLC 프로그램을 기반으로 각 동작에 따른 처리 과정을 컴파일(2)하여 PLC 동작 명령어들을 생성한다(12). 이때, PADT(10)는 컴파일되는 명령어가 브랜치(Branch) 명령어인 경우 현재 프로그램 위치에서 이동되는 만큼의 오프셋(offset) 값을 계산하게 된다.Referring to FIG. 1, when a user writes a PLC program with the instruction combination 1 of the MPU using the PADT 10, the PADT 10 processes a process according to each operation based on a PLC program written by the user in the compiler. (2) to generate PLC operation instructions (12). At this time, if the instruction to be compiled is a branch instruction, the PADT 10 calculates an offset value as much as moving from the current program position.

그리고 PADT(10)는 컴파일된 PLC 동작 명령어들을 PLC의 운영체제 영역에 쓰기(3)하는 과정을 수행한다.The PADT 10 performs a process of writing (3) the compiled PLC operation instructions to the operating system area of the PLC.

PLC(20)는 런(Run) 모드로 진행하면, 운영체제 영역에 쓰기된 PLC 동작 명령어들을 MPU에서 제공하는 PLC 명령어들을 이용해 구동하며 처리한다. 이때, PLC 동작 명령어들 중 BEQ, BCC 등과 같은 브랜치 명령어들은 수행 조건에 따라 PADT 컴파일러에서 계산된 오프셋(offset) 값을 기반으로 운영체제(O/S) 영역 내부에서 이동(분기)(4)하며 구동되게 된다.When the PLC 20 proceeds to the run mode, the PLC 20 operates and processes PLC operation instructions written in the operating system area using PLC instructions provided by the MPU. At this time, branch instructions such as BEQ, BCC, etc. among PLC operation instructions are driven by moving (branching) (4) inside the operating system (O / S) area based on the offset value calculated by the PADT compiler according to the execution condition. Will be.

한편, MPU의 브랜치 명령어들은 16비트(bit)(-32766~+32768)까지만 지원한다. 이때, MPU의 성능, 제조사 등에 따라 32비트까지 지원하는 경우도 있으나, 본 명세서에서는 용이한 설명을 위해 16비트까지만 지원하는 경우로 한정하여 설명하도록 한다.Branch instructions of the MPU, on the other hand, support only 16 bits (-32766 to +32768). In this case, although it may support up to 32 bits depending on the performance, manufacturer, etc. of the MPU, in the present specification, only the case of supporting up to 16 bits will be described for easy description.

MPU의 브랜치 명령어들이 16비트까지만 지원한다는 것은 브랜치 명령어들이 동작하기 위해 PLC 운영체제 영역 내부에서 이동할 때, 16비트를 넘는 위치로의 이동이 불가능한 것을 말한다. 따라서, 계산된 오프셋 값이 16 비트를 넘는 경우, 해당 브랜치 명령어의 동작은 불가능하게 된다.The branch instructions of the MPU support only up to 16 bits, meaning that when the branch instructions move inside the PLC operating system area to operate, it is impossible to move to a position over 16 bits. Therefore, if the calculated offset value exceeds 16 bits, the operation of the branch instruction is impossible.

따라서, 사용자가 작성한 PLC 프로그램에서 브랜치 명령어가 16비트 이상의 값으로 처리해야 하는 경우는 원하는 주소 값으로 이동이 불가능하게 된다. 실제로 16비트 이상의 값은 음수 값으로 처리되어 PLC가 비정상적인 상태로 빠지게 된다.Therefore, if a branch instruction needs to be processed with a value of 16 bits or more in a PLC program written by a user, it is impossible to move to a desired address value. In fact, values greater than 16 bits are treated as negative values, causing the PLC to fall into an abnormal state.

도2는 종래에 사용자가 작성한 PLC 프로그램에서 브랜치 명령어가 16비트 이상 값으로 처리해야 하는 경우에 올바르게 이루어지는 동작을 나타낸 도면이고, 도3은 종래에 사용자가 작성한 PLC 프로그램에서 브랜치 명령어가 16비트 이상 값으로 처리해야 하는 경우에 실제로 이루어지는 동작을 나타낸 도면이다.FIG. 2 is a diagram illustrating an operation performed correctly when a branch instruction needs to be processed with a 16-bit or higher value in a conventionally created PLC program. FIG. 3 illustrates a branch instruction having a 16-bit or higher value in a conventionally created PLC program. This is a diagram showing an operation actually performed when processing is required.

PLC 운영체제 영역의 총 프로그램 사이즈는 0x8000 이상이고, 사용자는 프로그램 시작 시 임의의 변수가 원하는 값이 되었을 때 모든 프로그램을 수행하고자 한다고 가정한다.It is assumed that the total program size of the PLC operating system area is 0x8000 or more, and the user wants to execute all programs when any variable reaches the desired value at the start of the program.

그리고 사용자는 PADT(10)를 이용하여 PLC 운영체제 영역 “A00010”의 위치에서 브랜치 명령어 “BEQ”에 의해 16비트가 넘는 “A09000”으로 이동하도록 PLC 프로그램을 작성하였다면, PLC(20)는 브랜치 명령어 “BEQ”를 수행하여 도2에서 도시하고 있는 것과 같이 PLC 운영체제 영역 “A09000”으로 이동(5)하여 PLC 동작 명령어들이 처리되어야 한다.If the user has written a PLC program using the PADT 10 to move from the position of the PLC operating system area “A00010” to the “A09000” over 16 bits by the branch instruction “BEQ”, the PLC 20 reads the branch instruction “ BEQ ”to move to the PLC operating system area“ A09000 ”(5) as shown in FIG. 2 to process PLC operation commands.

그러나, 실제로 PLC(20)는 MPU에서 브랜치 명령어가 16비트까지만 지원되므로, “A08000” 이상의 값이 음수로 처리되게 된다.In practice, however, since the PLC 20 only supports up to 16 bits of branch instructions in the MPU, a value greater than “A08000” is treated as a negative number.

즉, 실제로는 도2에서와 같이 PLC(20)는 PLC 운영체제 영역 “A09000”으로 이동하지 못하고, 도 3에서 도시하고 있는 것과 같이 “A09000”이 음수로 처리되어 엉뚱한 주소 값으로 이동(6)하게 되어 PLC(20)의 심각한 오동작이 발생하게 된다. That is, as shown in FIG. 2, the PLC 20 does not move to the PLC operating system area “A09000”, and as shown in FIG. 3, “A09000” is treated as a negative number to move to the wrong address value (6). As a result, serious malfunction of the PLC 20 occurs.

본 발명은, 이와 같은 문제를 해결하기 위하여, PLC에 사용하는 MPU의 제한적인 이동 지원을 갖는 브랜치(Branch) 명령어들의 이동 오프셋 값을 하드웨어 스팩 자체의 변경 없이 확장하는 처리 방법을 제공하는 것을 목적으로 한다.In order to solve such a problem, an object of the present invention is to provide a processing method of extending a shift offset value of branch instructions having limited movement support of an MPU used in a PLC without changing a hardware specification itself. do.

본 발명의 목적들은 이상에서 언급한 목적으로 제한되지 않으며, 언급되지 않은 본 발명의 다른 목적 및 장점들은 하기의 설명에 의해서 이해될 수 있고, 본 발명의 실시예에 의해 보다 분명하게 이해될 것이다. 또한, 본 발명의 목적 및 장점들은 특허 청구 범위에 나타낸 수단 및 그 조합에 의해 실현될 수 있음을 쉽게 알 수 있을 것이다.The objects of the present invention are not limited to the above-mentioned objects, and other objects and advantages of the present invention, which are not mentioned above, can be understood by the following description, and more clearly by the embodiments of the present invention. Also, it will be readily appreciated that the objects and advantages of the present invention may be realized by the means and combinations thereof indicated in the claims.

이와 같은 목적을 달성하기 위하여, 본 발명의 PLC의 브랜치 명령어 처리 방법은, (A) 브랜치 명령어가 사용되는 PLC 프로그램이 작성되면, 컴파일을 통해 PLC 동작 명령어들을 생성하며, 브랜치 명령어의 오프셋(offset) 값을 계산하여 MPU의 제1 레지스터에 저장하고, 점프 명령어를 수행하는 점프 명령어 처리함수를 생성하는 단계, (B) PLC를 이용하여, 런(Run) 모드로 진행되면 운영체제 영역에 쓰기된 PLC 동작 명령어들을 순차적으로 수행하는 단계, (C) 상기 수행 중 점프 명령어 처리함수가 나온 현재 PLC 프로그램 위치를 MPU의 제2 레지스터에 저장하는 단계, (D) 점프 명령어 처리 함수를 호출하여 명령어 주소 테이블에 저장되는 주소로 분기하는 단계, 및 (E) 상기 호출된 점프 명령어 처리 함수를 기반으로 상기 제2 레지스터에 저장된 현재 프로그램 위치와 상기 제1 레지스터에 저장된 이동할 만큼의 오프셋을 연산해 연산된 값을 주소 값으로 점프하는 단계를 포함한다.In order to achieve the above object, the branch instruction processing method of the PLC of the present invention, (A) when a PLC program using a branch instruction is created, generates PLC operation instructions through compilation, offset of the branch instruction (offset) Computing a value and storing it in a first register of the MPU, and generating a jump instruction processing function for performing a jump instruction, (B) PLC operation written in the operating system area when the run mode is executed using the PLC Executing the instructions sequentially; (C) storing the current PLC program position from which the jump instruction processing function is generated in the second register of the MPU; and (D) calling the jump instruction processing function and storing the instruction in the instruction address table. Branching to a second address, and (E) a current program position stored in the second register based on the called jump instruction processing function. The comprises the step of jumping to a value calculated by calculating the offset of the move as stored in the first register with the address value.

또한, 상기 (B) 단계는 상기 운영체제 영역에 쓰기되는 상기 PLC 동작 명령어들의 끝부분에 상기 점프 명령어 처리 함수를 복사하는 것을 특징으로 한다. In addition, the step (B) is characterized in that to copy the jump instruction processing function to the end of the PLC operation instructions to be written to the operating system area.

또한, 상기 점프 명령어 처리함수는 명령어 주소 테이블에 분기되는 주소 값을 저장하는 것을 특징으로 한다.The jump instruction processing function may store an address value branched to an instruction address table.

또한, 상기 (C) 단계는 팝(POP) 동작을 수행하여 PLC 프로그램 위치를 MPU의 제2 레지스터에 저장하는 것을 특징으로 한다.In addition, the step (C) is characterized in that to store the PLC program location in the second register of the MPU by performing a POP (POP) operation.

또한, 상기 (D) 단계는 점프 명령어 처리 함수를 호출하는 단계와, 상기 호출된 점프 명령어 처리 함수의 명령어 주소 테이블에서 바이너리 파일에 저장된 명령어의 주소를 확인하는 단계와, 상기 확인된 주소로 분기하는 단계를 포함한다.In addition, the step (D) includes the steps of calling a jump instruction processing function, checking an address of an instruction stored in a binary file in an instruction address table of the called jump instruction processing function, and branching to the identified address. Steps.

또한, 상기 (D) 단계에서 분기되는 점프 명령어 처리 함수의 주소는 MPU에서 브랜치 명령어가 지원되는 범위 내에 포함된다.In addition, the address of the jump instruction processing function branched in the step (D) is included in the range supported by the branch instruction in the MPU.

또한, 상기 (E) 단계는 상기 제1 레지스터의 저장된 값과 상기 제2 레지스터에 저장된 값을 서로 더하는 단계와, 상기 연산된 이동 위치 값을 상기 제2 레지스터에 저장하는 단계와, 상기 제2 레지스터에 저장된 이동할 위치값을 스택에 저장하는 단계와, 상기 스택에 저장된 주소 값으로 이동하는 단계를 포함한다. The step (E) may further include adding a stored value of the first register and a value stored in the second register, storing the calculated shift position value in the second register, and storing the second register. And storing the position value to be stored in the stack in the stack, and moving to the address value stored in the stack.

전술한 바와 같은 본 발명에 의하면, 본 발명의 PLC의 브랜치 명령어 처리 방법은, MPU에서 16비트 이상 처리가 필요한 브랜치 명령어 사용 시 MPU 변경 없이 브랜치(Branch) 명령어들의 이동 오프셋 값을 확장하여 동작하도록 구현할 수 있는 효과가 있다.According to the present invention as described above, the branch instruction processing method of the PLC of the present invention, when using a branch instruction that requires 16-bit or more processing in the MPU to be implemented to extend the movement offset values of the branch (branch) instructions without changing the MPU. It can be effective.

또한, 컴파일에서 간접 컴파일 방식으로 구현해 처리가 가능하므로 PLC의 운영체제 영역의 수정 없이 컴파일러 만의 수정으로 미 지원되는 MPU의 브랜치 명령어의 이동 오프셋 값을 확장할 수 있어, 유지보수에 효율적이다.In addition, since it can be implemented by indirect compilation in the compile process, it is possible to extend the shift offset value of branch instructions of the unsupported MPU by modifying the compiler alone without modifying the operating system area of the PLC, which is efficient for maintenance.

상술한 효과와 더불어 본 발명의 구체적인 효과는 이하 발명을 실시하기 위한 구체적인 사항을 설명하면서 함께 기술한다. In addition to the effects described above, the specific effects of the present invention will be described together with the following description of specifics for carrying out the invention.

도1은 종래에 사용자가 PADT를 이용해 작성한 PLC 프로그램을 PLC에서 구동하는 처리 과정을 설명하기 위한 도면
도2는 종래에 사용자가 작성한 PLC 프로그램에서 브랜치 명령어가 16비트 이상 값으로 처리해야 하는 경우에 올바르게 이루어지는 동작을 나타낸 도면
도3은 종래에 사용자가 작성한 PLC 프로그램에서 브랜치 명령어가 16비트 이상 값으로 처리해야 하는 경우에 실제로 이루어지는 동작을 나타낸 도면
도4는 본 발명의 실시예에 따른 PLC의 브랜치 명령어 처리 방법을 설명하기 위한 흐름도
도5는 도4에서 컴파일된 PLC 동작 명령어들을 PLC의 운영체제 영역에 쓰기한 것을 나타낸 도면
도6은 도4에서 점프 명령어 처리 함수에 의해 오프셋 값으로 점프되는 내부 명령어 처리를 나타낸 도면
BRIEF DESCRIPTION OF THE DRAWINGS Fig. 1 is a view for explaining a process of driving a PLC program written by a user using a PADT in a conventional PLC.
FIG. 2 is a view showing an operation performed correctly when a branch instruction needs to be processed with a value of 16 bits or more in a conventional PLC program written by a user.
FIG. 3 is a view showing an operation actually performed when a branch instruction needs to be processed with a value of 16 bits or more in a conventionally created PLC program.
4 is a flowchart illustrating a branch instruction processing method of a PLC according to an embodiment of the present invention.
FIG. 5 is a diagram illustrating writing PLC operation instructions compiled in FIG. 4 to an operating system area of a PLC. FIG.
FIG. 6 is a diagram illustrating internal command processing jumped to an offset value by a jump command processing function in FIG. 4; FIG.

전술한 목적, 특징 및 장점은 첨부된 도면을 참조하여 상세하게 후술되며, 이에 따라 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자가 본 발명의 기술적 사상을 용이하게 실시할 수 있을 것이다. 본 발명을 설명함에 있어서 본 발명과 관련된 공지 기술에 대한 구체적인 설명이 본 발명의 요지를 불필요하게 흐릴 수 있다고 판단되는 경우에는 상세한 설명을 생략한다. 이하, 첨부된 도면을 참조하여 본 발명에 따른 바람직한 실시예를 상세히 설명하기로 한다. 도면에서 동일한 참조부호는 동일 또는 유사한 구성요소를 가리키는 것으로 사용된다.The above objects, features, and advantages will be described in detail with reference to the accompanying drawings, whereby those skilled in the art to which the present invention pertains may easily implement the technical idea of the present invention. In describing the present invention, when it is determined that the detailed description of the known technology related to the present invention may unnecessarily obscure the gist of the present invention, the detailed description will be omitted. Hereinafter, exemplary embodiments of the present invention will be described in detail with reference to the accompanying drawings. In the drawings, the same reference numerals are used to indicate the same or similar components.

이하에서는, 본 발명의 바람직한 실시예에 따른 PLC의 브랜치 명령어 처리 방법에 관하여 도면을 참조하여 상세하게 설명하도록 한다.Hereinafter, a branch instruction processing method of a PLC according to a preferred embodiment of the present invention will be described in detail with reference to the accompanying drawings.

도4는 본 발명의 실시예에 따른 PLC의 브랜치 명령어 처리 방법을 설명하기 위한 흐름도이다.4 is a flowchart illustrating a branch instruction processing method of a PLC according to an embodiment of the present invention.

도4를 참조하여 설명하면, 먼저 사용자가 PADT를 이용하여 MPU의 명령어 조합으로 브랜치 명령어를 사용하는 PLC 프로그램을 작성한다(S10). 이때, 브랜치(branch)는 가지라는 뜻으로, 저장소에서 여러 가지가 뻗어 나와서 각각의 사용가 사용할 수 있게끔 하는 것이다. 즉, 한 원격 저장소를 사용하다 보면 여러 명의 소스코드의 버전이 달라질 수 있는데, 이를 방지하기 위한 기능이 브랜치이다. 브랜치 명령어는 이러한 브랜치를 사용할 수 있도록 하기 위한 명령어로서 점프와 비슷한 명령을 수행시키는 명령어이다. 작성되는 브랜치 명령어는 삽입, 연산, 조건문 처리 등을 포함한다.Referring to FIG. 4, first, a user writes a PLC program using branch instructions as a combination of instructions of an MPU using a PADT (S10). In this case, a branch means a branch, which means that several branches from the repository are made available to each use. In other words, when using one remote repository, the version of several source codes may be different. The function to prevent this is branch. Branch instructions are commands that enable you to use these branches and perform jump-like instructions. The branch instructions that are written include inserts, operations, and conditional statements.

PADT(100)는 컴파일러 내부에서 사용자가 작성된 PLC 프로그램을 기반으로 각 동작에 따른 처리 과정을 컴파일하여 PLC 동작 명령어들을 생성한다(S20). 이때, 컴파일되는 명령어가 브랜치(Branch) 명령어인 경우 현재 프로그램 위치에서 이동되는 만큼의 오프셋(offset) 값이 계산되며, PADT(100)는 계산된 오프셋(offset) 값은 MPU의 제1 레지스터(ER0)에 저장한다. 그리고 PADT(100)는 점프 명령어를 수행하는 점프 명령어 처리함수를 생성한다.The PADT 100 generates PLC operation instructions by compiling processing according to each operation based on a PLC program written by a user in the compiler (S20). In this case, when the compiled instruction is a branch instruction, an offset value as much as being moved from the current program position is calculated, and the calculated offset value of the PADT 100 is the first register ER0 of the MPU. ). The PADT 100 generates a jump instruction processing function that performs a jump instruction.

상기 생성되는 점프 명령어 처리함수는 명령어 주소 테이블에 분기되는 주소 값을 저장한다. 따라서, PLC(200)는 운영체제 영역에 쓰기된 PLC 동작 명령어들을 순차적으로 수행하다가 점프 명령어 처리함수가 나오면, 실제 명령어 코드가 있는 코드 블록으로 분기를 하게 되는데, 이때 명령어 주소 테이블에서 바이너리 파일에 저장된 명령어의 주소로 분기하게 된다.The generated jump instruction processing function stores an address value branched to the instruction address table. Therefore, the PLC 200 sequentially executes PLC operation instructions written in the operating system area, and when a jump instruction processing function is issued, branches to the code block in which the actual instruction code is located. In this case, the instruction stored in the binary file in the instruction address table is used. Branch to the address of.

이어서, PADT(10)는 컴파일된 PLC 동작 명령어들을 PLC의 운영체제 영역에 쓰기하고, 생성된 점프 명령어 처리 함수를 PLC 동작 명령어의 끝부분에 복사한다(S30).Subsequently, the PADT 10 writes the compiled PLC operation instructions to the operating system area of the PLC, and copies the generated jump instruction processing function to the end of the PLC operation instruction (S30).

도5는 도4에서 컴파일된 PLC 동작 명령어들을 PLC의 운영체제 영역에 쓰기한 것을 나타낸 도면이다.FIG. 5 is a diagram illustrating writing PLC operation instructions compiled in FIG. 4 to an operating system area of a PLC.

도 5에서 도시하고 있는 것과 같이, 컴파일된 PLC 동작 명령어들은 PLC의 운영체제 영역에 쓰기되고(210), 생성된 점프 명령어 처리 함수는 PLC 동작 명령어의 끝부분에 복사되었다(220). 이때, 운영체제 영역에 쓰기된 컴파일된 PLC 동작 명령어들 중 계산된 오프셋(offset) 값(#xx)은 MPU의 제1 레지스터(ER0)에 저장되고, 생성된 점프 명령어 처리함수(JUMP BRA_JMP)는 점프 명령어 임을 나타내고 있다(201).As shown in FIG. 5, the compiled PLC operating instructions are written to the operating system area of the PLC (210), and the generated jump instruction processing function is copied to the end of the PLC operating instruction (220). In this case, the calculated offset value (#xx) among the compiled PLC operating instructions written in the operating system area is stored in the first register ER0 of the MPU, and the jump instruction processing function JUMP BRA_JMP is jumped. It is a command (201).

PLC(20)는 런(Run) 모드로 진행하면, 운영체제 영역에 쓰기된 PLC 동작 명령어들을 순차적으로 수행하며, MPU에서 제공하는 PLC 명령어들을 이용해 구동하며 처리한다(S90).When the PLC 20 proceeds to the run mode, the PLC 20 sequentially executes PLC operation instructions written in the operating system area, and drives and processes the PLC instructions provided by the MPU (S90).

그리고 PLC(200)는 PLC 동작 명령어들을 순차적으로 수행하다가 점프 명령어 처리함수가 나오면(S40), 점프 명령어 처리함수가 나온 현재 PLC 프로그램 위치를 팝(POP) 동작을 수행하여 MPU의 제2 레지스터(ER1)에 저장한다(S50).Then, the PLC 200 sequentially executes PLC operation instructions, and when a jump instruction processing function comes out (S40), performs a pop operation on the current PLC program position from which the jump instruction processing function came out and performs a second register (ER1) of the MPU. In step S50).

이어서, PLC(200)는 점프 명령어 처리 함수(BRA_JUM)를 호출하고 명령어 주소 테이블에서 바이너리 파일에 저장된 명령어의 주소를 확인한다. 그리고 확인된 주소로 분기하게 된다(S60). 이때, 분기되는 점프 명령어 처리 함수(BRA_JUM)의 주소는 MPU에서 브랜치 명령어가 지원되는 16비트 내에 포함된다. 즉, 도 5에서와 같이 점프 명령어 처리 함수 호출 전 저장되었던 프로그램 위치가 “A00000”이면, 최대 분기될 수 있는 주소는 “A32000”이 된다.Subsequently, the PLC 200 calls the jump instruction processing function BRA_JUM and checks the address of the instruction stored in the binary file in the instruction address table. And branched to the confirmed address (S60). In this case, the address of the branched jump instruction processing function BRA_JUM is included in 16 bits in which branch instructions are supported in the MPU. That is, as shown in FIG. 5, when the program location stored before the jump instruction processing function call is “A00000”, the maximum branchable address is “A32000”.

호출된 점프 명령어 처리 함수에서는 현재 프로그램 위치와 이동할 만큼의 오프셋을 연산해 해당 값으로 점프하는 동작을 수행한다. 즉, 제1 레지스터(ER0)의 저장된 값과 제2 레지스터(ER1)에 저장된 값을 서로 더하여, 제2 레지스터(ER1)에 저장한다(S70). 이때, 제1 레지스터(ER0)는 컴파일 과정에서 계산된 오프셋 값을 저장하고 있으며, 제2 레지스터(ER1)는 점프 명령어 처리 함수 호출 전의 PLC 프로그램의 위치를 저장하고 있다.The called jump instruction processing function calculates an offset as much as the current program position and moves to jump to the value. That is, the stored value of the first register ER0 and the value stored in the second register ER1 are added to each other and stored in the second register ER1 (S70). In this case, the first register ER0 stores the offset value calculated during the compilation process, and the second register ER1 stores the position of the PLC program before the jump instruction processing function is called.

이처럼, 오프셋 값과 PLC 프로그램의 위치가 더해짐에 따라, 그 결과값은 브랜치 명령어가 이동되는 만큼의 이동 오프셋 값을 가지게 된다. 그리고 결과값에 따른 오프셋 값은 점프 명령어에 의해 분기되게 됨에 따라, MPU의 성능에 따른 이동 범위(16비트)에 제약을 받지 않게 된다.As such, as the offset value and the position of the PLC program are added, the result value has a moving offset value as much as the branch instruction is moved. As the offset value according to the result value is branched by the jump instruction, the offset value is not limited by the moving range (16 bits) according to the performance of the MPU.

이는, MPU에서 이동 범위의 제약으로 인해, 절대 주소로는 제약 범위 이상의 처리가 불가능한 것을 점프 함수를 이용하여 절대 주소를 상대 주소로 변경함으로써, MPU에서 지원되는 이동 범위가 넘는 위치를 갖는 오프셋 값으로 이동처리가 가능하게 된다.This is because, due to the limitation of the movement range in the MPU, the absolute address cannot be processed beyond the constraint range. By using the jump function, the absolute address is changed to a relative address, so that the offset value has a position beyond the movement range supported by the MPU. Movement processing becomes possible.

따라서, PLC(200)는 연산된 이동할 위치값을 스택에 저장하고, 스택에 저장된 주소 값으로 이동한다(S80)Therefore, the PLC 200 stores the calculated movement position value on the stack and moves to the address value stored on the stack (S80).

도6은 도4에서 점프 명령어 처리 함수에 의해 오프셋 값으로 점프되는 내부 명령어 처리를 나타낸 도면이다.FIG. 6 is a diagram illustrating internal command processing jumped to an offset value by a jump command processing function in FIG. 4.

이어서, PLC(20)는 운영체제 영역에 쓰기된 PLC 동작 명령어들을 순차적으로 수행하며, MPU에서 제공하는 PLC 명령어들을 이용해 구동하며 처리한다(S90).Subsequently, the PLC 20 sequentially executes PLC operation instructions written in the operating system area, drives and processes the PLC instructions provided by the MPU (S90).

이를 통해, MPU에서 16비트 이상 처리가 필요한 브랜치 명령어 사용 시 MPU 변경 없이 브랜치(Branch) 명령어들의 이동 오프셋 값을 상대 주소로 변경함으로써, MPU에서 지원되는 이동 범위가 넘는 위치를 갖는 오프셋 값으로 확장하여 동작하도록 구현할 수 있게 된다.In this way, when using branch instructions that require more than 16-bit processing in the MPU, the shift offset values of the branch instructions are changed to relative addresses without changing the MPU, thereby extending them to offset values having positions beyond the movement range supported by the MPU. It can be implemented to work.

또한, 컴파일에서 간접 컴파일 방식으로 구현해 처리가 가능하므로 PLC의 운영체제 영역의 수정 없이 컴파일러 만의 수정으로 미 지원되는 MPU의 브랜치 명령어의 이동 오프셋 값을 확장할 수 있어, 유지보수에 효율적이다.In addition, since it can be implemented by indirect compilation in the compile process, it is possible to extend the shift offset value of branch instructions of the unsupported MPU by modifying the compiler alone without modifying the operating system area of the PLC, which is efficient for maintenance.

전술한 본 발명은, 본 발명이 속하는 기술 분야에서 통상의 지식을 가진 자에게 있어 본 발명의 기술적 사상을 벗어나지 않는 범위 내에서 여러 가지 치환, 변형 및 변경이 가능하므로 전술한 실시예 및 첨부된 도면에 의해 한정되는 것이 아니다.The present invention described above is capable of various substitutions, modifications, and changes without departing from the spirit of the present invention for those skilled in the art to which the present invention pertains. It is not limited by.

100: PADT 200: PLC100: PADT 200: PLC

Claims (7)

(A) 브랜치 명령어가 사용되는 PLC 프로그램이 작성되면, 컴파일을 통해 PLC 동작 명령어들을 생성하며, 브랜치 명령어의 오프셋(offset) 값을 계산하여 MPU의 제1 레지스터에 저장하고, 점프 명령어를 수행하는 점프 명령어 처리함수를 생성하는 단계;
(B) PLC를 이용하여, 런(Run) 모드로 진행되면 운영체제 영역에 쓰기된 PLC 동작 명령어들을 순차적으로 수행하는 단계;
(C) 상기 수행 중 점프 명령어 처리함수가 나온 현재 PLC 프로그램 위치를 MPU의 제2 레지스터에 저장하는 단계;
(D) 점프 명령어 처리 함수를 호출하여 명령어 주소 테이블에 저장되는 주소로 분기하는 단계; 및
(E) 상기 호출된 점프 명령어 처리 함수를 기반으로 상기 제2 레지스터에 저장된 현재 프로그램 위치와 상기 제1 레지스터에 저장된 이동할 만큼의 오프셋을 연산해 연산된 값을 주소 값으로 점프하는 단계를 포함하는
PLC의 브랜치 명령어 처리 방법.
(A) When a PLC program using a branch instruction is created, PLC operation instructions are generated by compiling, the offset value of the branch instruction is calculated, stored in the first register of the MPU, and a jump for performing a jump instruction. Generating an instruction processing function;
(B) sequentially executing PLC operation commands written in the operating system area when the system is in a run mode using the PLC;
(C) storing the current PLC program position from which the jump instruction processing function is output in the second register of the MPU;
(D) calling a jump instruction processing function to branch to an address stored in the instruction address table; And
(E) calculating a current program position stored in the second register and a moving offset offset stored in the first register based on the called jump instruction processing function, and jumping the calculated value to an address value;
How to handle branch instruction of PLC.
제1 항에 있어서,
상기 (B) 단계는
상기 운영체제 영역에 쓰기되는 상기 PLC 동작 명령어들의 끝부분에 상기 점프 명령어 처리 함수를 복사하는 것을 특징으로 하는 PLC의 브랜치 명령어 처리 방법.
According to claim 1,
Step (B) is
The branch instruction processing method of a PLC, characterized in that for copying the jump instruction processing function to the end of the PLC operation instructions written in the operating system area.
제1 항에 있어서,
상기 점프 명령어 처리함수는 명령어 주소 테이블에 분기되는 주소 값을 저장하는 것을 특징으로 하는 PLC의 브랜치 명령어 처리 방법.
According to claim 1,
The jump instruction processing function is a branch instruction processing method of a PLC, characterized in that for storing the address value branched to the instruction address table.
제 1 항에 있어서,
상기 (C) 단계는 팝(POP) 동작을 수행하여 PLC 프로그램 위치를 MPU의 제2 레지스터에 저장하는 것을 특징으로 하는 PLC의 브랜치 명령어 처리 방법.
The method of claim 1,
Step (C) is a branch instruction processing method of a PLC, characterized in that to perform a POP operation to store the PLC program location in the second register of the MPU.
제1 항에 있어서,
상기 (D) 단계는
점프 명령어 처리 함수를 호출하는 단계와,
상기 호출된 점프 명령어 처리 함수의 명령어 주소 테이블에서 바이너리 파일에 저장된 명령어의 주소를 확인하는 단계와,
상기 확인된 주소로 분기하는 단계를 포함하는 PLC의 브랜치 명령어 처리 방법.
According to claim 1,
Step (D) is
Calling a jump instruction processing function,
Checking an address of an instruction stored in a binary file from an instruction address table of the called jump instruction processing function;
A branch instruction processing method of a PLC comprising the step of branching to the confirmed address.
제5 항에 있어서,
상기 (D) 단계에서 분기되는 점프 명령어 처리 함수의 주소는 MPU에서 브랜치 명령어가 지원되는 범위 내에 포함되는 PLC의 브랜치 명령어 처리 방법.
The method of claim 5,
The branch instruction processing method of the PLC, wherein the address of the jump instruction processing function branched in the step (D) is included in a range supported by the branch instruction in the MPU.
제1 항에 있어서,
상기 (E) 단계는
상기 제1 레지스터의 저장된 값과 상기 제2 레지스터에 저장된 값을 서로 더하는 단계와,
상기 연산된 이동 위치 값을 상기 제2 레지스터에 저장하는 단계와,
상기 제2 레지스터에 저장된 이동할 위치값을 스택에 저장하는 단계와,
상기 스택에 저장된 주소 값으로 이동하는 단계를 포함하는 PLC의 브랜치 명령어 처리 방법.
According to claim 1,
Step (E) is
Adding the stored value of the first register with the value stored in the second register;
Storing the calculated shift position value in the second register;
Storing a shift position value stored in the second register on a stack;
A branch instruction processing method of a PLC comprising moving to an address value stored in the stack.
KR1020180037324A 2018-03-30 2018-03-30 Method for Processing Branch Command in PLC KR102091134B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020180037324A KR102091134B1 (en) 2018-03-30 2018-03-30 Method for Processing Branch Command in PLC

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020180037324A KR102091134B1 (en) 2018-03-30 2018-03-30 Method for Processing Branch Command in PLC

Publications (2)

Publication Number Publication Date
KR20190114510A true KR20190114510A (en) 2019-10-10
KR102091134B1 KR102091134B1 (en) 2020-03-19

Family

ID=68206170

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020180037324A KR102091134B1 (en) 2018-03-30 2018-03-30 Method for Processing Branch Command in PLC

Country Status (1)

Country Link
KR (1) KR102091134B1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117573589A (en) * 2024-01-16 2024-02-20 南京实点电子科技有限公司 CC-Link IE field network basic protocol plug-in IO configuration and configuration method thereof

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR950024039A (en) * 1994-01-31 1995-08-21 서상기 PLC (PLC) and control method thereof
KR20140003084A (en) * 2012-06-29 2014-01-09 엘에스산전 주식회사 Apparatus and method for processing data

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR950024039A (en) * 1994-01-31 1995-08-21 서상기 PLC (PLC) and control method thereof
KR20140003084A (en) * 2012-06-29 2014-01-09 엘에스산전 주식회사 Apparatus and method for processing data

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117573589A (en) * 2024-01-16 2024-02-20 南京实点电子科技有限公司 CC-Link IE field network basic protocol plug-in IO configuration and configuration method thereof
CN117573589B (en) * 2024-01-16 2024-04-09 南京实点电子科技有限公司 CC-Link IE field network basic protocol plug-in IO configuration and configuration method thereof

Also Published As

Publication number Publication date
KR102091134B1 (en) 2020-03-19

Similar Documents

Publication Publication Date Title
US8464236B2 (en) Data consistency in data processing systems
JP2009146229A (en) Programmable controller system
JP2006227681A (en) Debug device, debug method and program
US20190196798A1 (en) Executable program creation device, executable program creation method, and executable program creation program
CN107024900B (en) Method for optimally compiling PLC commands
CN113590177A (en) Control flow flattening confusion method for position-independent codes
KR102091134B1 (en) Method for Processing Branch Command in PLC
JP2009157533A (en) Programmable controller system
JP2019016037A (en) Program creation apparatus
JP5619331B1 (en) Programming device and execution code generation method
JP6295914B2 (en) Programmable controller system, its support device, programmable controller
JP6483507B2 (en) Control program creating apparatus and control program debugging method
EP3660602B1 (en) Testing code for an industrial control program in an ancillary environment
JP5082797B2 (en) Software partial test system
JP2002055848A (en) Program execution procedure and storage medium with the program execution procedure stored therein
KR20140003084A (en) Apparatus and method for processing data
JP2013041546A (en) Debug support program, debug support method and debug support system
JP4784355B2 (en) Programmable controller system, programmable controller debugging method, programming support program, programmable controller debug control program
JP4802775B2 (en) Controller support device and programmable controller
JP2007188366A (en) Compiler
JP2011216056A (en) Programmable controller and peripheral device thereof
JP2002063045A (en) Changing method of operating program
KR20080044652A (en) Method for debugging by using stack of cpu
JP3019330B2 (en) Compiling device
US7743371B1 (en) System and method for dynamically loading object modules

Legal Events

Date Code Title Description
A201 Request for examination
E902 Notification of reason for refusal
E701 Decision to grant or registration of patent right