KR102102335B1 - Dual memory structure and method for processing message of PLC using thereof - Google Patents
Dual memory structure and method for processing message of PLC using thereof Download PDFInfo
- Publication number
- KR102102335B1 KR102102335B1 KR1020180014330A KR20180014330A KR102102335B1 KR 102102335 B1 KR102102335 B1 KR 102102335B1 KR 1020180014330 A KR1020180014330 A KR 1020180014330A KR 20180014330 A KR20180014330 A KR 20180014330A KR 102102335 B1 KR102102335 B1 KR 102102335B1
- Authority
- KR
- South Korea
- Prior art keywords
- message
- memory
- area
- read
- stored
- 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.)
- Active
Links
- 230000015654 memory Effects 0.000 title claims abstract description 245
- 238000012545 processing Methods 0.000 title claims abstract description 27
- 230000009977 dual effect Effects 0.000 title claims abstract description 18
- 238000000034 method Methods 0.000 title claims description 25
- 238000004891 communication Methods 0.000 claims abstract description 12
- 238000003672 processing method Methods 0.000 claims abstract description 10
- 238000012795 verification Methods 0.000 claims description 7
- 238000010200 validation analysis Methods 0.000 claims description 5
- 230000008569 process Effects 0.000 description 16
- 238000010586 diagram Methods 0.000 description 6
- 230000000694 effects Effects 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 238000012790 confirmation Methods 0.000 description 1
- 238000013480 data collection Methods 0.000 description 1
- 230000003111 delayed effect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000007257 malfunction Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 238000012163 sequencing technique Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G05—CONTROLLING; REGULATING
- G05B—CONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
- G05B19/00—Programme-control systems
- G05B19/02—Programme-control systems electric
- G05B19/04—Programme control other than numerical control, i.e. in sequence controllers or logic controllers
- G05B19/05—Programmable logic controllers, e.g. simulating logic interconnections of signals according to ladder diagrams or function charts
-
- G—PHYSICS
- G05—CONTROLLING; REGULATING
- G05B—CONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
- G05B9/00—Safety arrangements
- G05B9/02—Safety arrangements electric
- G05B9/03—Safety arrangements electric with multiple-channel loop, i.e. redundant control systems
-
- G—PHYSICS
- G05—CONTROLLING; REGULATING
- G05B—CONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
- G05B2219/00—Program-control systems
- G05B2219/10—Plc systems
- G05B2219/15—Plc structure of the system
- G05B2219/15051—Dual port memory
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Automation & Control Theory (AREA)
- Storage Device Security (AREA)
- Programmable Controllers (AREA)
Abstract
본 발명은 PLC(Programmable Logic Controller) 메모리 모듈에 저장하고 있는 메시지 영역을 접근하기 위한 통신 모듈에서 이중 메모리 구조 및 이를 통해 2개 이상의 타스크에서 공용 메시지의 접근 시 메시지의 충돌을 방지하여 메시지를 보호하는 PLC의 메시지 처리 방법에 관한 것이다. 본 발명의 이중 메모리 구조를 이용한 PLC의 메시지 처리 방법은, 메시지 처리를 위해 인터럽트 및 타스크가 메모리에 접근하여 메시지를 쓰거나 읽을 수 있도록 데이터 통신을 수행하는 PLC의 메시지 처리 방법에 있어서, (A) 메시지를 쓰기 위해 인터럽트가 이중 메모리 구조를 갖는 제 1 메모리 및 제 2 메모리의 메시지 영역에 접근하는 단계, (B) 상기 접근한 메시지 영역과 대응되는 읽기 플래그 영역에 각각 저장되어 있는 읽기 플래그 정보를 확인하는 단계, (C) 상기 읽기 플래그 정보의 확인을 통해, 상기 접근한 메시지 영역을 타스크에서 읽고 있는지 확인하는 단계, (D) 상기 접근한 메시지 영역을 타스크에서 읽고 있지 않으면, 상기 제 1 메모리 및 상기 제 2 메모리에 저장된 쓰기 오더 정보를 확인하는 단계, 및 (E) 상기 쓰기 오더 정보의 확인을 통해, 상기 제 1 메모리 및 상기 제 2 메모리 중 저장 순서가 늦은 메시지 영역에 메시지를 쓰기하는 단계를 포함한다.The present invention provides a double memory structure in a communication module for accessing a message area stored in a programmable logic controller (PLC) memory module and through this, prevents message collision when accessing a common message from two or more tasks to protect the message. It is related to the message processing method of PLC. The message processing method of a PLC using the dual memory structure of the present invention is a message processing method of a PLC performing data communication so that interrupts and tasks can access the memory to write or read messages for message processing (A) messages Interrupt accessing the message areas of the first memory and the second memory having a dual memory structure to write, (B) checking the read flag information stored in each of the read flag area corresponding to the accessed message area Step, (C) confirming whether the read message area is being read by a task by checking the read flag information, (D) if the accessed message area is not read by a task, the first memory and the first 2 Checking the write order information stored in the memory, and (E) by checking the write order information And writing a message in a message area of which the storage order is late among the first memory and the second memory.
Description
본 발명은 PLC(Programmable Logic Controller) 메모리 모듈에 저장하고 있는 메시지 영역을 접근하기 위한 방법에 관한 것으로, 구체적으로, 이중 메모리 구조 및 이를 통해 2개 이상의 타스크에서 공용 메시지의 접근 시 메시지의 충돌을 방지하여 메시지를 보호하는 PLC의 메시지 처리 방법에 관한 것이다.The present invention relates to a method for accessing a message area stored in a PLC (Programmable Logic Controller) memory module, specifically, to prevent a message collision when accessing a public message in two or more tasks through the dual memory structure It relates to the message processing method of the PLC to protect the message.
PLC(Programmable Logic Controller)는 프로그램 가능한 논리적인 컨트롤러로서, 수치연산, 논리 연산, 시퀀싱(sequencing) 제어, 타이머(timer), 카운터(counter) 등의 기능을 내장하고 프로그램과 각종 데이터를 저장할 수 있는 메모리를 갖추어 각종 자동화 기계 및 프로세서를 제어할 수 있는 특수 컴퓨터이다. 이에 PLC는 장치 제어, 장치 수치 셋팅, 시간 제어, 실시간 감시, 실시간 데이터 수집 및 안전장치 가동 등 다양한 작업에 적용될 수 있다.PLC (Programmable Logic Controller) is a programmable logic controller that has built-in functions such as numerical operation, logical operation, sequencing control, timer, and counter, and can store programs and various data. It is equipped with a special computer that can control various automation machines and processors. Accordingly, PLC can be applied to various tasks such as device control, device numerical setting, time control, real-time monitoring, real-time data collection, and operation of safety devices.
PLC는 자동화 설비 등의 기계로 신호를 제공하기 위한 아날로그 출력모듈과 기계로부터 오는 신호를 입력 받기 위한 아날로그 입력모듈을 구비하고 있다.The PLC is equipped with an analog output module for providing a signal to a machine such as an automation facility and an analog input module for receiving a signal from a machine.
이처럼 아날로그 입력모듈과 아날로그 출력모듈을 통해 신호를 송수신하기 위한 통신모듈은 PLC의 다양한 모듈 가운데서도 그 중요성이 점점 더 강조되고 있는 추세이다.As such, the importance of the communication module for transmitting and receiving signals through the analog input module and the analog output module is increasingly emphasized among various modules of the PLC.
도 1 은 종래에 PLC(Programmable Logic Controller) 메시지 처리 과정을 간략하게 도시한 구성도이다. 그리고 도 2 는 종래에 타스크에서 메시지 처리하는 과정을 설명하기 위한 흐름도이고, 도 3 은 종래에 인터럽트에서 메시지 처리하는 과정을 설명하기 위한 흐름도이다. 1 is a configuration diagram briefly showing a conventional PLC (Programmable Logic Controller) message processing process. And Figure 2 is a flow chart for explaining the process of processing a message in a conventional task, Figure 3 is a flow chart for explaining the process of processing a message in a conventional interrupt.
도면을 참조하여 설명하면, 메시지 처리를 위해 인터럽트(10) 및 타스크(20)가 메모리(30)에 접근하여 메시지를 쓰거나 읽을 수 있도록 데이터 통신을 수행한다.Referring to the drawings, data processing is performed so that the interrupt 10 and the
이때, 메모리(30)는 메시지(메시지1~N)를 저장하는 복수의 메시지 영역(31)과, 각 메시지 영역에 저장되어 있는 메시지의 유효성을 나타내는 유효성 정보(Valid1~N)를 저장하는 유효성 영역(32)으로 구성된다. 그리고 인터럽트(10)는 메모리의 메시지 영역(31)에 메시지 쓰기를 수행하고, 타스크(20)는 메모리의 메시지 영역(31)에서 메시지 읽기를 수행한다. At this time, the
이때, 인터럽트(10)는 도 2에서 도시하고 있는 것과 같이, 메시지가 발생되면 메시지 영역(31)에 메시지 쓰기를 한다(S11). At this time, the interrupt 10 writes a message to the
이어 메시지 쓰기가 완료되면 메시지가 저장된 메시지 영역(31)에 대응하는 유효성 영역(32)에 메시지가 유효한 것으로 설정한다(S12). 예로서, 저장된 메시지가 유효하면 유효성 영역(32)에 'TRUE'를 설정하고, 유효하지 않으면 유효성 영역(32)에 'FALSE'를 설정한다.Subsequently, when writing of the message is completed, the message is set to be valid in the
또한, 타스크(20)는 도 3에서 도시하고 있는 것과 같이, 메시지 영역(31)에서 메시지를 읽기 전에 먼저 메시지 영역(31)에 대응하는 유효성 영역(32)에 저장되어 있는 유효성 정보(ValidN)를 확인하여 메시지 영역(31)에 저장되어 있는 메시지가 유효한지를 확인한다(S21). 예로서 유효성 정보가 'TRUE'이면 메시지가 유효한 것으로 판단하고, 'FALSE'이면 메시지가 유효하지 않은 것으로 판단한다.In addition, as shown in FIG. 3, the
유효성 확인 결과, 유효한 것으로 판단되면 메시지 영역(31)에 저장되어 있는 메시지를 읽는다(S22).As a result of validation, if it is determined that it is valid, the message stored in the
그리고 메시지 영역(31)에 저장되어 있는 메시지의 읽기가 완료되면, 메시지 영역(31)에 대응하는 유효성 영역(32)에 저장되어 있는 유효성 정보를 유효하지 않음으로 설정한다(S23). 예로서, 유효성 정보를 'TRUE'에서 'FALSE'로 변경한다.Then, when reading of the message stored in the
이와 같은 종래의 PLC(Programmable Logic Controller) 메시지 처리 과정에서는 타스크(20)가 메시지를 읽어가는 동안 인터럽트(10)가 발생하는 경우, 동일한 메시지 영역(31)에 메시지 쓰기가 이루어질 수 있다.In the conventional PLC (Programmable Logic Controller) message processing process, if the
이에 따라, 읽어온 메시지가 일부는 인터럽트(10) 발생 전 메시지가 되고 일부는 인터럽트(10) 발생 후 메시지가 되는 경우가 발생 된다. Accordingly, a part of the read message is a message before the occurrence of the
도 4 는 종래에 PLC(Programmable Logic Controller) 통신 모듈의 메시지 처리 과정에서 나타나는 문제점을 설명하기 위한 구성도로서, 도 4(a)는 인터럽트 발생 전 메시지N의 데이터를 나타낸 메모리이고, 도 4(b)는 인터럽트 발생 후 메시지N의 데이터를 나타낸 메모리이다.4 is a configuration diagram for explaining a problem occurring in a message processing process of a programmable logic controller (PLC) communication module in the related art. FIG. 4 (a) is a memory showing data of message N before an interrupt occurs, and FIG. 4 (b) ) Is the memory that shows the data of message N after an interrupt occurs.
도 4를 참조하여 설명하면, 최초 인터럽트 발생 전에는 도 4(a)에서 도시된 것과 같이 메모리(30)의 메시지N 영역에 데이터1~데이터N 까지 저장되어 있으며, 타스크(20)는 메모리(30)의 메시지N 영역에서 데이터1~데이터N까지 읽기를 수행하고자 한다.Referring to FIG. 4, before the first interrupt occurs,
이에 타스크(20)는 메모리(30)의 메시지N 영역에 저장하고 있는 데이터1, 2를 읽어온 후, 데이터3을 읽어야 하는 시점에서 인터럽트가 발생하면, 인터럽트가 끝날 때까지 대기하게 된다. 만약 인터럽트(10)가 메모리(30)의 메시지N 영역에 새로운 데이터N1~NN까지 쓰기한 후 인터럽트가 끝나게 되면, 메모리(30)의 메시지N 영역에는 도 4(b)와 같이 데이터N1~NN 까지 변경되어 저장되게 된다.Accordingly, the
타스크(20)는 인터럽트(10)가 끝난 후, 메시지N 영역에 저장된 데이터를 이어서 읽게 되며, 앞서 데이터1, 2를 읽은 상태이므로 데이터3부터 읽게 된다. 그러나 현재 메모리(30)의 메시지N 영역은 인터럽트(3) 쓰기로 인해 도 4(b)와 같이 데이터N1~NN 까지 변경되어 저장되어 있으므로, 데이터N3~NN까지를 읽어오게 된다. The
이처럼, 동일한 메시지 영역에서 타스크(20) 및 인터럽트(10)가 발생하는 경우, 타스크(20)에서 읽어지는 메시지를 보호할 수 있는 장치가 없다.As such, when the
이에 따라, 타스크(20)는 도 4(c)에서 도시하고 있는 것과 같이 메모리N 영역에서 읽어온 데이터는 데이터1, 2, N3~NN으로 인터럽트 발생 전 데이터(31)와 발생 후 데이터(32)가 섞이게 되는 문제점이 발생된다.Accordingly, the
이와 같이, 종래는 한 타스크에서 공용 메시지를 읽어가는 동안 인터럽트가 같은 영역에 메시지를 쓰기할 때 서로 충돌이 발생하여 잘못된 메시지가 읽어지게 되어 부하단에 연결된 회로는 비정상적인 동작을 수행할 수 있게 된다.As described above, in the related art, when an interrupt writes a message in the same area while reading a common message in one task, a conflict occurs with each other, so that the wrong message is read, and the circuit connected to the load stage can perform an abnormal operation.
본 발명은, PLC(Programmable Logic Controller) 메모리 모듈에 저장하고 있는 메시지 영역을 접근하기 위한 통신 모듈에서 이중 메모리 구조 및 이를 통해 2개 이상의 타스크에서 공용 메시지의 접근 시 메시지의 충돌을 방지하여 메시지를 보호하는 PLC의 메시지 처리 방법을 제공하는 것을 목적으로 한다.The present invention provides a double memory structure in a communication module for accessing a message area stored in a PLC (Programmable Logic Controller) memory module and protects a message by preventing collision of messages when a public message is accessed from two or more tasks. An object of the present invention is to provide a method for processing a PLC message.
본 발명의 목적들은 이상에서 언급한 목적으로 제한되지 않으며, 언급되지 않은 본 발명의 다른 목적 및 장점들은 하기의 설명에 의해서 이해될 수 있고, 본 발명의 실시예에 의해 보다 분명하게 이해될 것이다. 또한, 본 발명의 목적 및 장점들은 특허 청구 범위에 나타낸 수단 및 그 조합에 의해 실현될 수 있음을 쉽게 알 수 있을 것이다.The objects of the present invention are not limited to the objects mentioned above, and other objects and advantages of the present invention not mentioned can be understood by the following description, and will be more clearly understood by the embodiments of the present invention. In addition, it will be readily appreciated that the objects and advantages of the present invention can be realized by means of the appended claims and combinations thereof.
이와 같은 문제를 해결하기 위하여, 본 발명의 이중 메모리 구조는 메시지 처리를 위해 인터럽트 및 타스크가 메모리에 접근하여 메시지를 쓰거나 읽을 수 있도록 데이터 통신을 수행하는 PLC의 메시지 구조에 있어서, 상기 메모리는 동일한 구조의 제 1 및 제 2 메모리를 갖는 이중 메모리 구조로 이루어지고, 상기 제 1 및 제 2 메모리는 메시지를 저장하는 복수의 메시지 영역과, 각 메시지 영역에 저장되어 있는 메시지의 유효성을 나타내는 유효성 정보를 저장하는 유효성 영역과, 상기 타스크에서 대응하는 각 메시지 영역에 저장되어 있는 메시지를 상기 타스크가 읽는 중이라는 것을 나타내는 읽기 플래그 정보를 저장하는 읽기 플래그 영역과, 상기 인터럽트에서 대응하는 각 메시지 영역에 저장되어 있는 메시지의 저장 순서를 나타내는 쓰기 오더 정보를 저장하는 쓰기 플래그 영역을 포함한다.In order to solve this problem, the dual memory structure of the present invention is a message structure of a PLC that performs data communication so that interrupts and tasks can access the memory to write or read messages for message processing. It consists of a dual memory structure having the first and second memories of the first, and the first and second memories store a plurality of message areas for storing messages and validity information indicating the validity of the messages stored in each message area. A validity area to be read, a read flag area for storing read flag information indicating that the task is reading messages stored in each message area corresponding to the task, and a message area stored in each message area corresponding to the interrupt. Write order indicating the order in which messages are stored Information includes a flag area for storing a letter.
또한, 상기 메시지 영역은 상기 인터럽트가 메시지 쓰기를 수행하고, 상기 타스크가 메시지 읽기를 수행한다.Further, in the message area, the interrupt writes a message, and the task reads a message.
또한, 상기 읽기 플래그 정보는 상기 타스크가 상기 읽기 플래그 정보 쓰기를 수행한다.Further, in the read flag information, the task writes the read flag information.
또한, 상기 쓰기 오더 정보는 상기 인터럽트가 상기 쓰기 오더 정보의 쓰기를 수행한다.In addition, in the write order information, the interrupt writes the write order information.
또한, 상기 인터럽트는 제 1 메모리에 저장되어 있는 쓰기 오더 정보와 제 2 메모리에 저장되어 있는 쓰기 오더 정보를 비교하여, 이전 메시지가 먼저 저장된 메시지 영역에 새로운 메시지를 쓰기 한다.In addition, the interrupt compares the write order information stored in the first memory with the write order information stored in the second memory, and writes a new message to the message area in which the previous message was first stored.
이와 같은 문제를 해결하기 위하여, 본 발명의 이중 메모리 구조를 이용한 PLC의 메시지 처리 방법은, 메시지 처리를 위해 인터럽트 및 타스크가 메모리에 접근하여 메시지를 쓰거나 읽을 수 있도록 데이터 통신을 수행하는 PLC의 메시지 처리 방법에 있어서, (A) 메시지를 쓰기 위해 인터럽트가 이중 메모리 구조를 갖는 제 1 메모리 및 제 2 메모리의 메시지 영역에 접근하는 단계, (B) 상기 접근한 메시지 영역과 대응되는 읽기 플래그 영역에 각각 저장되어 있는 읽기 플래그 정보를 확인하는 단계, (C) 상기 읽기 플래그 정보의 확인을 통해, 상기 접근한 메시지 영역을 타스크에서 읽고 있는지 확인하는 단계, (D) 상기 접근한 메시지 영역을 타스크에서 읽고 있지 않으면, 상기 제 1 메모리 및 상기 제 2 메모리에 저장된 쓰기 오더 정보를 확인하는 단계, 및 (E) 상기 쓰기 오더 정보의 확인을 통해, 상기 제 1 메모리 및 상기 제 2 메모리 중 저장 순서가 늦은 메시지 영역에 메시지를 쓰기하는 단계를 포함한다. In order to solve this problem, the message processing method of the PLC using the dual memory structure of the present invention, the message processing of the PLC performing data communication so that interrupts and tasks can access the memory to write or read messages for message processing. In the method, (A) in order to write a message, the interrupt accesses the message areas of the first memory and the second memory having a dual memory structure, and (B) each stored in a read flag area corresponding to the accessed message area. Checking the read flag information being read, (C) checking whether the accessed message area is being read by the task by checking the read flag information, and (D) if the task is not reading the accessed message area. , Checking write order information stored in the first memory and the second memory, and (E) And writing a message to a message area in which the storage order is delayed among the first memory and the second memory through the confirmation of the write order information.
또한, 상기 (C) 단계는 (C1) 상기 제 1 메모리 및 상기 제 2 메모리의 상기 접근한 메시지 영역에 대응되는 읽기 플래그 정보를 각각 확인하는 단계와, (C2) 상기 읽기 플래그 정보 확인 결과, 상기 제 1 메모리 및 상기 제 2 메모리의 메시지 영역이 상기 타스크에 의해 모두 읽히고 있지 않으면, 상기 메시지 영역에 저장된 메시지의 유효성을 확인하는 단계와, (C3) 상기 유효성 확인 결과, 상기 제 1 메모리 및 제 2 메모리의 메시지 영역 중 유효하지 않은 메모리의 메시지 영역으로 메시지를 쓰기하고, 상기 메시지를 유효한 메시지로 표시하는 단계를 포함한다.In addition, the step (C) may include (C1) checking read flag information corresponding to the accessed message areas of the first memory and the second memory, respectively, and (C2) the result of checking the read flag information. If the message areas of the first memory and the second memory are not all read by the task, checking the validity of the message stored in the message area, and (C3) the validation result, the first memory and the second And writing a message to an invalid message area of the memory message area, and displaying the message as a valid message.
또한, 상기 (C2) 단계는 상기 읽기 플래그 정보 확인 결과, 상기 제 1 메모리 및 상기 제 2 메모리의 메시지 영역 중 상기 타스크에 의하여 어느 하나만 읽히고 있지 않으면, 읽히고 있지 않은 메시지 영역으로 메시지를 쓰기하고, 상기 메시지를 유효한 메시지로 표시하는 단계를 포함한다.In addition, in step (C2), when the read flag information is confirmed, if only one of the message areas of the first memory and the second memory is not read by the task, the message is written to the unread message area, and the And marking the message as a valid message.
또한, 상기 (C3) 단계는 상기 유효성 확인 결과, 상기 제 1 메모리 및 상기 제 2 메모리 모두 유효하지 않으면 임의로 선택된 하나의 메모리의 메시지 영역으로 메시지를 쓰기하고, 상기 메시지를 유효한 메시지로 표시하는 단계와, 상기 메시지가 쓰기된 메모리의 쓰기 오더 정보를 나머지 메모리의 쓰기 오더 정보보다 최근 순서로 표시하는 단계를 포함한다.In addition, step (C3) may include writing a message into a message area of a randomly selected memory and displaying the message as a valid message if both the first memory and the second memory are invalid as a result of the validation check. And displaying the write order information of the memory in which the message is written in a more recent order than the write order information of the remaining memories.
또한, 상기 (C3) 단계는 상기 유효성 확인 결과, 상기 제 1 메모리 및 상기 제 2 메모리 모두 유효하면 상기 제 1 메모리 및 상기 제 2 메모리에 저장되어 있는 쓰기 오더 정보를 각각 확인하여 메시지의 저장 순서를 확인하는 단계를 포함한다. In addition, in the step (C3), if both the first memory and the second memory are valid as a result of the validity check, write order information stored in the first memory and the second memory are respectively checked to determine a message storage order. And confirming.
또한, 상기 (E) 단계는 상기 쓰기한 메시지를 유효한 메시지로 표시하는 단계와, 상기 메시지가 쓰기된 메모리의 쓰기 오더 정보를 나머지 메모리의 쓰기 오더 정보보다 최근 순서로 표시하는 단계를 포함한다.In addition, the step (E) includes displaying the written message as a valid message, and displaying the write order information of the memory in which the message is written in a more recent order than the remaining memory write order information.
이와 같은 문제를 해결하기 위하여, 본 발명의 이중 메모리 구조를 이용한 PLC의 메시지 처리 방법은, 메시지 처리를 위해 인터럽트 및 타스크가 메모리에 접근하여 메시지를 쓰거나 읽을 수 있도록 데이터 통신을 수행하는 PLC의 메시지 처리 방법에 있어서, (a) 메시지를 읽기 위해 타스크가 이중 메모리 구조를 갖는 제 1 메모리 및 제 2 메모리의 메시지 영역에 접근하는 단계, (b) 상기 접근한 메시지 영역 내에 저장되어 있는 유효성 정보를 확인하여, 유효한 메시지 영역을 확인하는 단계; 및 (c) 상기 유효한 메시지 영역에 저장되어 있는 메시지를 읽기하는 단계를 포함한다.In order to solve this problem, the message processing method of the PLC using the dual memory structure of the present invention, the message processing of the PLC performing data communication so that interrupts and tasks can access the memory to write or read messages for message processing. In the method, (a) the task to access the message area of the first memory and the second memory having a dual memory structure to read the message, (b) by checking the validity information stored in the accessed message area , Identifying a valid message area; And (c) reading a message stored in the valid message area.
또한, 상기 (c) 단계는 상기 확인된 유효한 메시지 영역 중 상기 제 1 메모리 및 상기 제 2 메모리에 저장된 쓰기 오더 정보를 비교하여, 상기 제 1 메모리 및 상기 제 2 메모리 중 저장 순서가 늦은 메시지 영역을 확인하는 단계와, 상기 쓰기 오더 정보의 확인 결과, 가장 최근에 저장된 메시지를 읽기하는 단계를 포함한다.In addition, step (c) compares the write order information stored in the first memory and the second memory among the valid message areas identified, and displays a message area in which the storage order of the first memory and the second memory is late. And a step of checking and reading the most recently stored message as a result of checking the write order information.
또한, 상기 (c) 단계는 상기 메시지 영역에서 상기 타스크에 의해 메시지를 읽기하고, 동시에 읽기 플래그 정보를 상기 타스크에서 메시지 읽고 있음으로 표시하는 단계와, 상기 메시지 읽기가 완료되면, 상기 메시지를 유효하지 않은 메시지로 표시하고, 동시에 읽기 플래그 정보를 메시지 읽고 있지 않음으로 표시하는 단계를 포함한다.In addition, step (c) reads a message by the task in the message area, and simultaneously displays read flag information as reading the message in the task, and when reading the message is completed, the message is not valid. And displaying the read flag information as not reading the message.
전술한 바와 같은 본 발명에 의하면, 본 발명의 이중 메모리 구조 및 이를 이용한 PLC의 메시지 처리 방법은, 메시지와 메시지 관리구조를 이중화함으로써 2개 이상의 타스크에서 공용 메시지 영역을 접근할 때 각 메모리 구조에 설정되는 플래그 값을 통해 동시에 접근하지 못하도록 제어함으로써, 메시지의 충돌을 방지하여 공용 메시지를 보호할 수 있다.According to the present invention as described above, the dual memory structure of the present invention and the message processing method of the PLC using the same are set in each memory structure when the common message area is accessed by two or more tasks by duplication of the message and the message management structure. By preventing access at the same time through the flag value, the public message can be protected by preventing collision of messages.
또한, 충돌로 인한 읽어지는 메시지의 오류를 방지할 수 있어, 부하단에 연결된 회로의 오동작을 예방할 수 있다.In addition, it is possible to prevent an error in a message read due to a collision, thereby preventing a malfunction of a circuit connected to a load terminal.
상술한 효과와 더불어 본 발명의 구체적인 효과는 이하 발명을 실시하기 위한 구체적인 사항을 설명하면서 함께 기술한다. In addition to the above-described effects, the concrete effects of the present invention will be described together while describing the specific matters for carrying out the invention.
도 1 은 종래에 PLC(Programmable Logic Controller) 메시지 처리 과정을 간략하게 도시한 구성도
도 2 는 종래에 타스크에서 메시지 처리하는 과정을 설명하기 위한 흐름도
도 3 은 종래에 인터럽트에서 메시지 처리하는 과정을 설명하기 위한 흐름도
도 4 는 종래에 PLC(Programmable Logic Controller) 통신 모듈의 메시지 처리 과정에서 나타나는 문제점을 설명하기 위한 구성도
도 5 는 본 발명의 실시예에 따른 PLC(Programmable Logic Controller) 메시지 처리 과정을 간략하게 도시한 구성도
도 6 은 본 발명의 실시예에 따른 인터럽트에서 메시지 처리하는 과정을 설명하기 위한 흐름도
도 7 은 본 발명의 실시예에 따른 타스크에서 메시지 처리하는 과정을 설명하기 위한 흐름도1 is a schematic diagram showing a conventional PLC (Programmable Logic Controller) message processing process
2 is a flowchart illustrating a process of processing a message in a task in the related art.
3 is a flowchart illustrating a process of processing a message in an interrupt in the related art
4 is a configuration diagram for explaining a problem occurring in the message processing process of the PLC (Programmable Logic Controller) communication module in the prior art
5 is a configuration diagram briefly showing a PLC (Programmable Logic Controller) message processing process according to an embodiment of the present invention
6 is a flowchart illustrating a process of processing a message in an interrupt according to an embodiment of the present invention
7 is a flowchart illustrating a process of processing a message in a task according to an embodiment of the present invention
전술한 목적, 특징 및 장점은 첨부된 도면을 참조하여 상세하게 후술되며, 이에 따라 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자가 본 발명의 기술적 사상을 용이하게 실시할 수 있을 것이다. 본 발명을 설명함에 있어서 본 발명과 관련된 공지 기술에 대한 구체적인 설명이 본 발명의 요지를 불필요하게 흐릴 수 있다고 판단되는 경우에는 상세한 설명을 생략한다. 이하, 첨부된 도면을 참조하여 본 발명에 따른 바람직한 실시예를 상세히 설명하기로 한다. 도면에서 동일한 참조부호는 동일 또는 유사한 구성요소를 가리키는 것으로 사용된다.The above-described objects, features, and advantages will be described in detail below with reference to the accompanying drawings, and accordingly, a person skilled in the art to which the present invention pertains can easily implement the technical spirit 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 subject matter of the present invention, the detailed description will be omitted. Hereinafter, preferred 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.
이하에서는, 도 5 내지 도 9를 참조하여 본 발명의 몇몇 실시예에 따른 이중 메모리 구조를 이용한 PLC의 메시지 처리 방법에 대해 설명하도록 한다.Hereinafter, a message processing method of a PLC using a dual memory structure according to some embodiments of the present invention will be described with reference to FIGS. 5 to 9.
도 5 는 본 발명의 실시예에 따른 PLC(Programmable Logic Controller) 메시지 처리 과정을 간략하게 도시한 구성도이다. 5 is a configuration diagram briefly showing a PLC (Programmable Logic Controller) message processing process according to an embodiment of the present invention.
도 5를 참조하여 설명하면, 메시지 처리를 위해 인터럽트(100) 및 타스크(200)가 이중 메모리 구조를 갖는 제 1, 2 메모리(300)(400) 중 어느 하나에 접근하여 메시지를 쓰거나 읽을 수 있도록 데이터 통신을 수행한다. 이때, 제 1 메모리(300)와 제 2 메모리(400)는 동일한 구조를 가진다.Referring to FIG. 5, in order to process a message, the interrupt 100 and the
그리고 제 1, 2 메모리(300)(400)는 각각 복수의 메시지 영역(310)(410)과, 유효성 영역(320)(420)과, 읽기 플래그 영역(330)(430)과, 쓰기 플래그 영역(340)(440)을 포함하여 구성된다.The first and
메시지 영역(310)(410)은 메시지(메시지1~N)를 저장하는데, 인터럽트(100)는 제 1, 2 메모리(300)(400)의 메시지 영역(310)(410)에 메시지 쓰기를 수행하고, 타스크(200)는 제 1, 2 메모리(300)(400)의 메시지 영역(310)(410)에서 메시지 읽기를 수행한다.The
그리고 유효성 영역(320)(420)은 각 메시지 영역에 저장되어 있는 메시지의 유효성을 나타내는 유효성 정보(Valid1~N)를 저장한다. 예로서 메시지가 유효한 것으로 판단되면 유효성 정보로 'TRUE'를 저장하고, 메시지가 유효하지 않은 것으로 판단되면 유효성 정보로 'FALSE'를 저장한다. 이때, 유효성 정보로 설정되는 변수는 하나의 실시예로서, 서로 다름을 구분하기 위한 변수일 뿐 이에 한정되지는 않는다. In addition, the
또한 읽기 플래그 영역(330)(340)은 타스크(200)에서 대응하는 메시지 영역에 저장되어 있는 메시지를 읽는 중이라는 것을 나타내는 읽기 플래그 정보(ReadFlagr1~N)를 저장한다. 이때, 상기 읽기 플래그 정보는 타스크(200)에서만 쓰기하고, 인터럽트(100)에서는 읽기만 한다. 그리고 인터럽트(100)에서는 읽기 플래그 정보가 메시지 읽은 중인 경우 대응하는 메시지 영역에는 메시지 쓰기를 하지 않는다. In addition, the
예로서, 읽기 플래그 정보가 'TRUE'인 경우 타스크(200)에서 읽는 중이라는 것을 의미하며, 'FALSE'인 경우 타스크(200)에서 읽고 있지 않다는 의미이다. 이때, 읽기 플래그 정보로 설정되는 변수는 하나의 실시예로서, 서로 다름을 구분하기 위한 변수일 뿐 이에 한정되지는 않는다. For example, if the read flag information is 'TRUE', it means that the
또한 쓰기 플래그 영역(340)(440)은 인터럽트(100)에서 대응하는 메시지 영역에 저장되어 있는 메시지의 저장 순서를 나타내는 쓰기 오더 정보(WriteOrder1~N)를 저장한다. 이때, 쓰기 오더 정보는 순서를 구분하기 위해 크기를 갖는 값으로 설정하고, 그 크기가 클수록 메시지가 최근에 저장된 것을 의미한다. 그러나 이는 하나의 실시예로서, 쓰기 오더 정보는 서로 크기를 구분하기 위한 변수일 뿐 이에 한정되지는 않는다. 또한 상기 쓰기 오더 정보는 인터럽트(100)에서만 쓰기하고, 타스크(200)에서는 읽기만 한다.In addition, the
인터럽트(100)는 제 1 메모리(300)에 저장되어 있는 쓰기 오더 정보와 제 2 메모리(400)에 저장되어 있는 쓰기 오더 정보를 비교하여, 이전 메시지가 먼저 저장된 메시지 영역에 새로운 메시지를 쓰기 한다. 예로서, 제 1 메모리(300)에 저장되어 있는 쓰기 오더 정보와 제 2 메모리(400)에 저장되어 있는 쓰기 오더 정보를 비교하여, 큰 값을 가지는 메모리(300)(400)의 메시지가 최근에 저장된 메시지라는 것을 의미한다.The interrupt 100 compares the write order information stored in the
도 6 은 본 발명의 실시예에 따른 인터럽트에서 메시지 처리하는 과정을 설명하기 위한 흐름도이다.6 is a flowchart illustrating a process of processing a message in an interrupt according to an embodiment of the present invention.
도 6을 참조하여 설명하면, 먼저 인터럽트(100)는 제 1 메모리(300) 및 제 2 메모리(400)의 읽기 플래그 영역(330)(340)에 각각 저장되어 있는 읽기 플래그 정보(ReadFlagrN)를 확인한다(S101). 이때, 읽기 플래그 정보(ReadFlagrN)는 대응되는 메시지를 타스크(200)가 읽는 중이라는 것을 나타내는 정보이다. 예로서, 타스크(200)에서 대응되는 메시지를 읽고 있는 중이라면 읽기 플래그 정보(ReadFlagrN)로 'TRUE'가 저장되고, 대응되는 메시지를 읽고 있는 상태가 아니면 읽기 플래그 정보(ReadFlagrN)로 'FALSE'가 저장된다.Referring to FIG. 6, first, the interrupt 100 checks read flag information (ReadFlagrN) stored in the read
따라서, 제 1 메모리(300)의 읽기 플래그 영역(330)에 저장되어 있는 읽기 플래그 정보(ReadFlagrN)가 'TRUE'이면, 이에 대응되는 제 1 메모리(300)의 메시지 영역(310)에 저장되어 있는 메시지(메시지N)를 타스크(200)가 읽고 있는 중이므로, 인터럽트(100)는 대응하는 메시지 영역에 메시지 쓰기를 하지 않는다. 또한 읽기 플래그 정보(ReadFlagrN)가 'FALSE'이면 메시지(메시지N)를 읽고 있는 상태가 아니므로, 인터럽트(100)는 대응하는 메시지 영역에 메시지 쓰기를 할 수 있다.Therefore, if the read flag information (ReadFlagrN) stored in the read
이에 상기 읽기 플래그 정보 확인 결과(S102), 제 1, 2 메모리(300)(400)의 플래그 영역(330)에 저장되어 있는 읽기 플래그 정보(ReadFlagrN)가 모두 'FALSE'이면, 대응하는 제 1, 2 메모리(300)(400)의 메시지 영역(310)(410) 모두에 메시지 쓰기가 가능하므로, 인터럽트(100)는 어떠한 메시지 영역에 메시지를 쓰기 하여도 상관없다.Accordingly, if the read flag information check result (S102), the read flag information (ReadFlagrN) stored in the
이 경우, 인터럽트(100)는 타스크(200)에서 메시지 영역에 저장되어 있는 메시지를 읽은 적이 있는지를 확인하기 위해 메시지의 유효성을 확인한다(S103). 즉, 인터럽트(100)는 상기 읽기 플래그 정보(ReadFlagrN)가 'FALSE'로 확인된 읽기 플래그 영역(330)(430)에 대응하여 제 1 메모리(300) 및 제 2 메모리(400)의 유효성 영역(320)(420)에 각각 저장되어 있는 유효성 정보(ValidN)를 확인한다.In this case, the interrupt 100 checks the validity of the message in order to confirm whether the
이때, 유효성 정보(ValidN)는 메시지 영역(310)(410)에 저장되어 있는 메시지의 유효성을 나타내는 정보이다. 예로서 유효한 메시지의 경우는 유효성 정보로 'TRUE'가 저장되고, 유효하지 않은 메시지의 경우는 유효성 정보로 'FALSE'가 저장된다.At this time, the validity information (ValidN) is information indicating the validity of the message stored in the message area (310, 410). For example, in the case of a valid message, 'TRUE' is stored as validity information, and in the case of an invalid message, 'FALSE' is stored as validity information.
상기 유효성 정보 확인 결과(S104), 제 1, 2 메모리(300)(400)의 유효성 영역(320)(420)에 저장되어 있는 유효성 정보(ValidN)가 모두 'FALSE'로 유효하지 않으면, 타스크(200)에서 제 1, 2 메모리(300)(400)의 메시지를 모두 읽어갔다는 의미로 인터럽트는 어떠한 메시지 영역에도 메시지를 쓰기 하여도 상관없다.If the validity information verification result (S104), the validity information (ValidN) stored in the
이에, 제 1, 2 메모리(300)(400)의 쓰기 플래그 영역(340)(440) 중 임의로 선택된 하나의 쓰기 플래그 영역에 저장된 쓰기 오더 정보(WriteOrderN)는 '1'을, 나머지 하나의 쓰기 플래그 영역에 저장된 쓰기 오더 정보(WriteOrderN)는 '0'을 설정한다(S105). 이때, 쓰기 오더 정보는 순서를 구분하기 위해 크기를 갖는 값으로 설정하고, 그 크기가 클수록 메시지가 최근에 저장된 것을 의미한다. 그러나 이는 하나의 실시예로서, 쓰기 오더 정보는 서로 크기를 구분하기 위한 변수일 뿐 이에 한정되지는 않는다. 또한 상기 쓰기 오더 정보는 인터럽트(100)에서만 쓰기하고, 타스크(200)에서는 읽기만 한다.Accordingly, the write order information (WriteOrderN) stored in one write flag area randomly selected from the
이어 인터럽트(100)는 쓰기 오더 정보가 1로 설정된 제 1 메모리(300)(또는 제 2 메모리(400))의 메시지 영역(310)(또는 (410))에 메시지 쓰기를 한다(S106). 그리고 메시지 쓰기가 된 제 1 메모리(300)의 유효성 정보(ValidN)를 'TRUE'로 설정하여, 타스크(200)에서 읽어가지 않은 메시지임을 표시한다(S107).Subsequently, the interrupt 100 writes a message to the message area 310 (or 410) of the first memory 300 (or the second memory 400) in which the write order information is set to 1 (S106). Then, the validity information (ValidN) of the
한편, 상기 유효성 정보 확인 결과(S104), 제 1, 2 메모리(300)(400)의 유효성 영역(320)(420)에 저장되어 있는 유효성 정보(ValidN)가 모두 유효('TRUE')하면, 타스크(200)에서 제 1, 2 메모리(300)(400)의 메시지를 모두 읽어가지 않았다는 의미이다.On the other hand, if all of the validity information (ValidN) stored in the validity check result (S104), the
이 경우, 인터럽트(100)는 제 1, 2 메모리(300)(400)에 저장된 메시지 중 나중에 저장된 메시지 영역(310)(410)에 메시지 쓰기를 하기 위해, 메시지의 저장 순서를 나타내는 쓰기 오더 정보(WriteOrder1~N)의 크기를 비교한다(S108). 이때, 쓰기 오더 정보의 크기가 클수록 메시지가 최근에 저장된 것으로 한다. 참고로, 제 1, 2 메모리(300)에 저장된 쓰기 오더 정보가 서로 같은 경우는 존재하지 않으므로, 이에 따른 기재는 생략한다.In this case, in order to write a message to the
이에 상기 비교결과(S108), 제 1 메모리(300)에 저장된 쓰기 오더 정보(WriteOrderN)가 제 2 메모리(400)에 저장된 쓰기 오더 정보(WriteOrderN) 보다 큰 경우, 제 2 메모리(400)에 저장된 쓰기 오더 정보는 제 1 메모리(300)에 저장된 쓰기 오더 정보에 1을 더한 값(제 1 메모리(300)의 쓰기 오더 정보 + 1)을 설정하고(S109), 제 2 메모리(400)의 대응하는 메시지 영역(320)에 메시지(메시지N)를 쓰기 한다(S110). Accordingly, when the comparison result (S108), the write order information (WriteOrderN) stored in the
이때, 상기 비교를 통해 제 1 메모리(300)에 저장된 쓰기 오더 정보(WriteOrderN)가 더 크다는 것은 제 1 메모리(300)에 저장된 메시지가 제 2 메모리(400)에 저장된 메시지보다 최근에 저장된 메시지를 의미한다. 따라서 저장 순서가 늦은 제 2 메모리(200)에 메시지(메시지N) 쓰기를 하고, 제 2 메모리(400)에 저장된 쓰기 오더 정보를 제 1 메모리(300)에 저장된 쓰기 오더 정보보다 더 크게 설정하여 이제는 제 2 메모리(400)에 저장된 메시지가 최근에 저장된 메시지임을 재설정하게 된다.In this case, the larger write order information (WriteOrderN) stored in the
그리고 메시지 쓰기가 된 제 2 메모리(400)의 유효성 정보(ValidN)를 'TRUE'로 설정하여, 타스크(200)에서 읽어가지 않은 메시지임을 표시한다(S111).Then, the validity information (ValidN) of the
또한, 상기 유효성 정보 확인 결과(S104), 제 1 메모리(300)의 유효성 영역(320)에 저장되어 있는 유효성 정보(ValidN)가 유효하지 않고('FALSE'), 제 2 메모리(400)의 유효성 영역(420)에 저장되어 있는 유효성 정보(ValidN)가 유효('TRUE')하면, 타스크(200)에서 제 1 메모리(300)의 메시지는 읽어갔고, 제 2 메모리(400)의 메시지는 읽어가지 않았다는 의미이다.In addition, the validity information verification result (S104), the validity information (ValidN) stored in the
그러므로, 타스크(200)에서 메시지를 읽어간 제 1 메모리(300)의 메시지 영역(320)에 메시지 쓰기를 하여야 한다.Therefore, it is necessary to write a message in the
따라서, 인터럽트(100)는 제 1 메모리(300)에 저장된 쓰기 오더 정보에 제 2 메모리(400)에 저장된 쓰기 오더 정보에 1을 더한 값(제 2 메모리(400)의 쓰기 오더 정보 + 1)을 설정하고(S112), 제 1 메모리(400)의 대응하는 메시지 영역(320)에 메시지(메시지N)를 쓰기 한다(S113). Accordingly, the interrupt 100 adds 1 to the write order information stored in the
즉, 제 1 메모리(300)에 저장된 쓰기 오더 정보를 제 2 메모리에 저장된 쓰기 오더 정보보다 더 크게 되도록 설정함으로써, 제 1 메모리(300)에 저장된 메시지가 제 2 메모리(400)에 저장된 메시지보다 최근에 저장된 메시지라는 것을 표시하게 된다.That is, by setting the write order information stored in the
그리고 메시지 쓰기가 된 제 1 메모리(300)의 유효성 정보(ValidN)를 'TRUE'로 설정하여, 타스크(200)에서 읽어가지 않은 메시지임을 표시한다(S114).Then, the validity information (ValidN) of the
또한, 상기 유효성 정보 확인 결과(S104), 제 1 메모리(300)의 유효성 영역(320)에 저장되어 있는 유효성 정보(ValidN)가 유효하고('TRUE'), 제 2 메모리(400)의 유효성 영역(420)에 저장되어 있는 유효성 정보(ValidN)가 유효하지 않으면('FALSE'), 타스크(200)에서 제 1 메모리(300)의 메시지는 읽어가지 않았고, 제 2 메모리(400)의 메시지는 읽어갔다는 의미이다.In addition, the validity information verification result (S104), the validity information (ValidN) stored in the
그러므로, 타스크(200)에서 메시지를 읽어간 제 2 메모리(300)의 메시지 영역(320)에 메시지 쓰기를 하여야 하며, 이는 전술한 S109 단계 내지 S111 단계를 통해 이루어지게 된다(S109 ~ S111).Therefore, it is necessary to write a message in the
한편, 상기 읽기 플래그 정보 확인 결과(S102), 제 1 메모리(300)의 읽기 플래그 정보(ReadFlagrN)가 'FALSE'이고, 제 2 메모리(400)의 읽기 플래그 정보(ReadFlagrN)가 'TRUE'이면, 제 2 메모리(400)의 메시지는 현재 타스크(200)에서 읽기 중이며, 제 1 메모리(300)의 메시지는 타스크(200)에서 읽고 있지 않은 상태로, 인터럽트(100)는 제 2 메모리(400)에는 메시지 쓰기가 불가능하며, 제 1 메모리(300)에만 메시지 쓰기가 가능하다.Meanwhile, if the read flag information check result (S102), the read flag information (ReadFlagrN) of the
따라서, 인터럽트(100)는 전술한 S112 단계 내지 S114 단계를 통해 제 2 메모리(400)에 메시지를 쓰기 한다(S112 ~ S114).Therefore, the interrupt 100 writes a message to the
마지막으로 상기 읽기 플래그 정보 확인 결과(S102), 제 1 메모리(300)의 읽기 플래그 정보(ReadFlagrN)가 'TRUE'이고, 제 2 메모리(400)의 읽기 플래그 정보(ReadFlagrN)가 'FALSE'이면, 제 1 메모리(300)의 메시지는 현재 타스크(200)에서 읽기 중이며, 제 2 메모리(400)의 메시지는 타스크(200)에서 읽고 있지 않은 상태로, 인터럽트(100)는 제 1 메모리(300)에는 메시지 쓰기가 불가능하며, 제 2 메모리(400)에만 메시지 쓰기가 가능하다.Finally, if the read flag information check result (S102), the read flag information (ReadFlagrN) of the
따라서, 인터럽트(100)는 전술한 S109 단계 내지 S111 단계를 통해 제 1 메모리(400)에 메시지를 쓰기 한다(S109 ~ S111).Therefore, the interrupt 100 writes a message to the
이처럼, 메시지와 메시지 관리구조를 이중화함으로써 인터럽트(100)는 타스크와 공용 메시지 영역을 접근할 때, 읽기 플래그 정보 및 쓰기 오더 정보를 통해 타스크의 접근 여부를 확인할 수 있어 동시에 접근하지 못하도록 제어함으로써, 메시지의 충돌을 방지하여 공용 메시지를 보호할 수 있다.As described above, when the message and the message management structure are duplicated, the interrupt 100 can check whether a task is accessed through read flag information and write order information when accessing the task and the common message area, thereby controlling access to the message at the same time. You can protect the public message by preventing the collision.
한편, 도 7 은 본 발명의 실시예에 따른 타스크에서 메시지 처리하는 과정을 설명하기 위한 흐름도이다.Meanwhile, FIG. 7 is a flowchart illustrating a process of processing a message in a task according to an embodiment of the present invention.
도 7을 참조하여 설명하면, 먼저 타스크(200)는 제 1, 2 메모리(300)의 유효성 영역(320)(420)에 각각 저장되어 있는 유효성 정보(ValidN)를 확인한다(S201). 이때, 유효성 정보(ValidN)는 메시지 영역(310)(410)에 저장되어 있는 메시지의 유효성을 나타내는 정보이다. 예로서 유효한 메시지의 경우는 유효성 정보로 'TRUE'가 저장되고, 유효하지 않은 메시지의 경우는 유효성 정보로 'FALSE'가 저장된다.Referring to FIG. 7, first, the
따라서, 제 1 메모리(300)의 유효성 영역(320)에 저장되어 있는 유효성 정보(ValidN)가 'TRUE'이면, 이에 대응되는 제 1 메모리(300)의 메시지 영역(310)에 저장되어 있는 메시지(메시지N)가 유효하다는 의미이며, 또한 제 2 메모리(400)의 유효성 영역(410)에 저장되어 있는 유효성 정보(ValidN)가 'TRUE'이면, 이에 대응되는 제 2 메모리(400)의 메시지 영역(410)에 저장되어 있는 메시지(메시지N)가 유효하다는 의미이다.Accordingly, if the validity information (ValidN) stored in the
이에 상기 유효성 정보 확인 결과(S202), 제 1, 2 메모리(300)(400)의 유효성 영역(320)(420)에 저장되어 있는 유효성 정보(ValidN)가 모두 'TRUE'이면, 제 1, 2 메모리(300)(400)의 메시지 영역(310)(410)에 저장되어 있는 메시지가 모두 유효하므로, 타스크(200)는 어떠한 메시지를 읽어도 상관없다.Accordingly, if the validity information verification result (S202), the validity information (ValidN) stored in the
이 경우, 타스크(200)는 최근에 저장된 메시지를 읽기 위해, 메시지의 저장 순서를 나타내는 쓰기 오더 정보(WriteOrder1~N)를 확인한다(S203). 즉, 타스크(200)는 상기 유효성이 확인된 메시지에 대응하여 제 1 메모리(300) 및 제 2 메모리(400)의 쓰기 플래그 영역(340)(440)에 각각 저장되어 있는 쓰기 오더 정보(WriteOrderN)를 확인한다. 이때, 쓰기 오더 정보의 크기가 클수록 저장된 메시지가 최근에 저장된 것을 의미한다.In this case, the
상기 확인 결과(S204), 제 1 메모리(300)에 저장되어 있는 쓰기 오더 정보((WriteOrderN))가 제 2 메모리(300)에 저장되어 있는 쓰기 오더 정보(WriteOrderN)보다 크면, 제 1 메모리(300)에 저장된 메시지가 제 2 메모리(400)에 저장된 메시지보다 최근에 저장된 메시지이므로, 타스크(200)는 최근에 저장된 제 1 메모리(300)에 저장된 메시지를 읽어온다.If the check result (S204), the write order information ((WriteOrderN)) stored in the
이를 위해, 먼저 제 1 메모리(300)의 읽기 플래그 정보(ReadFlagrN)를 'TRUE'로 설정하여 제 1 메모리(300)에 저장된 메시지가 현재 읽고 있는 상태인 것을 표시한다(S205). 그리고 타스크(200)는 제 1 메모리(300)의 메시지 영역(310)에 저장되어 있는 메시지(메시지N)를 읽는다(S206).To this end, first, the read flag information (ReadFlagrN) of the
이어 읽기가 끝난 제 1 메모리(300)의 유효성 정보(ValidN)를 'FALSE'로 설정하여 메시지가 유효하지 않음을 표시하고(S207), 또한 제 1 메모리(300)의 읽기 플래그 정보(ReadFlagrN)를 'FALSE'로 설정하여 제 1 메모리(300)의 메시지가 타스크(200)에서 읽고 있지 않은 상태임을 표시한다(S208).Subsequently, the validity information (ValidN) of the read
또한 상기 확인 결과(S204), 제 1 메모리(300)에 저장되어 있는 쓰기 오더 정보(WriteOrderN)가 제 2 메모리(300)에 저장되어 있는 쓰기 오더 정보(WriteOrderN)보다 작으면, 제 2 메모리(300)에 저장된 메시지가 제 1 메모리(300)에 저장된 메시지보다 최근에 저장된 메시지이므로, 타스크(200)는 최근에 저장된 제 2 메모리(400)에 저장된 메시지를 읽어온다. 이때, 제 1, 2 메모리(300)에 저장된 쓰기 오더 정보가 서로 같은 경우는 존재하지 않으므로, 이에 따른 기재는 생략한다.In addition, if the check result (S204), the write order information (WriteOrderN) stored in the
이를 위해, 먼저 제 2 메모리(400)의 읽기 플래그 정보(ReadFlagrN)를 'TRUE'로 설정하여 제 2 메모리(400)에 저장된 메시지가 현재 읽고 있는 상태인 것을 표시한다(S209). 그리고 타스크(200)는 제 2 메모리(400)의 메시지 영역(410)에 저장되어 있는 메시지(메시지N)를 읽는다(S210).To this end, first, the read flag information (ReadFlagrN) of the
이어 읽기가 끝난 제 2 메모리(400)의 유효성 정보(ValidN)를 'FALSE'로 설정하여 메시지가 유효하지 않음을 표시하고(S211), 또한 제 2 메모리(400)의 읽기 플래그 정보(ReadFlagrN)를 'FALSE'로 설정하여 제 2 메모리(400)의 메시지가 타스크(200)에서 읽고 있지 않은 상태임을 표시한다(S212).Subsequently, the validity information (ValidN) of the
한편, 상기 유효성 정보 확인 결과(S202), 제 1 메모리(300)의 유효성 영역(320)에 저장되어 있는 유효성 정보(ValidN)가 'TRUE'이고, 제 2 메모리(400)의 유효성 영역(320)에 저장되어 있는 유효성 정보(ValideN)가 'FALSE'이면, 제 1 메모리(300)의 메시지 영역(310)에 저장되어 있는 메시지(메시지N)은 유효하고, 제 2 메시지(400)의 메시지 영역(410)에 저장되어 있는 메시지(메시지N)는 유효하지 않다는 의미이다.Meanwhile, the validity information verification result (S202), the validity information (ValidN) stored in the
따라서, 타스크(200)는 유효한 메시지(메시지N)를 저장하고 있는 제 1 메모리(300)의 메시지 영역(310)의 메시지(메시지N)를 읽기 위해, 제 1 메모리(300)의 읽기 플래그 정보(ReadFlagrN)를 'TRUE'로 설정하여 제 1 메모리(300)에 저장된 메시지가 현재 읽고 있는 상태인 것을 표시한다(S205). Therefore, the
그리고 타스크(200)는 제 1 메모리(300)의 메시지 영역(310)에 저장되어 있는 메시지(메시지N)를 읽는다(S206).Then, the
이어 읽기가 끝난 제 1 메모리(300)의 유효성 정보(ValidN)를 'FALSE'로 설정하여 메시지가 유효하지 않음을 표시하고(S207), 또한 제 1 메모리(300)의 읽기 플래그 정보(ReadFlagrN)를 'FALSE'로 설정하여 제 1 메모리(300)의 메시지가 타스크(200)에서 읽고 있지 않은 상태임을 표시한다(S208).Subsequently, the validity information (ValidN) of the read
또한, 상기 유효성 정보 확인 결과(S202), 제 1 메모리(300)의 유효성 영역(320)에 저장되어 있는 유효성 정보(ValidN)가 'FALSE'이고, 제 2 메모리(400)의 유효성 영역(320)에 저장되어 있는 유효성 정보(ValideN)가 'TRUE'이면, 제 1 메모리(300)의 메시지 영역(310)에 저장되어 있는 메시지(메시지N)은 유효하지 않고, 제 2 메시지(400)의 메시지 영역(410)에 저장되어 있는 메시지(메시지N)는 유효하다는 의미이다.In addition, the validity information verification result (S202), the validity information (ValidN) stored in the
따라서, 타스크(200)는 유효한 메시지(메시지N)를 저장하고 있는 제 2 메모리(400)의 메시지 영역(410)의 메시지(메시지N)를 읽기 위해, 제 2 메모리(400)의 읽기 플래그 정보(ReadFlagrN)를 'TRUE'로 설정하여 제 2 메모리(400)에 저장된 메시지가 현재 읽고 있는 상태인 것을 표시한다(S209). 그리고 타스크(200)는 제 2 메모리(400)의 메시지 영역(410)에 저장되어 있는 메시지(메시지N)를 읽는다(S210).Therefore, the
이어 읽기가 끝난 제 2 메모리(400)의 유효성 정보(ValidN)를 'FALSE'로 설정하여 메시지가 유효하지 않음을 표시하고(S211), 또한 제 2 메모리(400)의 읽기 플래그 정보(ReadFlagrN)를 'FALSE'로 설정하여 제 2 메모리(400)의 메시지가 타스크(200)에서 읽고 있지 않은 상태임을 표시한다(S212).Subsequently, the validity information (ValidN) of the
이처럼, 메시지와 메시지 관리구조를 이중화함으로써 타스크(200)는 자신이 제 1 메모리(300) 또는 제 2 메모리(400)에서 메시지를 읽어올 때, 읽기 플래그 정보 및 쓰기 오더 정보를 통해 자신이 메시지를 읽고 있는 중임을 표시하여 인터럽트(100)의 접근을 차단하도록 제어함으로써, 메시지의 충돌을 방지하여 공용 메시지를 보호할 수 있다.As described above, by duplicating the message and message management structure, the
전술한 본 발명은, 본 발명이 속하는 기술 분야에서 통상의 지식을 가진 자에게 있어 본 발명의 기술적 사상을 벗어나지 않는 범위 내에서 여러 가지 치환, 변형 및 변경이 가능하므로 전술한 실시예 및 첨부된 도면에 의해 한정되는 것이 아니다.The above-described invention, the above-described embodiments and the accompanying drawings because it is possible for a person having ordinary skill in the art to which the present invention pertains, various substitutions, modifications and changes are possible without departing from the technical spirit of the present invention. It is not limited by.
100 : 인터럽트 200 : 타스크
300 : 메모리 310, 410 : 메시지 영역
320, 420 : 유효성 영역 330, 430 : 읽기 플래그 영역
340, 440 : 쓰기 플래그 영역100: interrupt 200: task
300:
320, 420:
340, 440: Write flag area
Claims (14)
상기 메모리는 동일한 구조의 제 1 및 제 2 메모리를 갖는 이중 메모리 구조로 이루어지고,
상기 제 1 및 제 2 메모리는
메시지를 저장하는 복수의 메시지 영역과,
각 메시지 영역에 저장되어 있는 메시지의 유효성을 나타내는 유효성 정보를 저장하는 유효성 영역과,
상기 타스크에서 대응하는 각 메시지 영역에 저장되어 있는 메시지를 상기 타스크가 읽는 중이라는 것을 나타내는 읽기 플래그 정보를 저장하는 읽기 플래그 영역과,
상기 인터럽트에서 대응하는 각 메시지 영역에 저장되어 있는 메시지의 저장 순서를 나타내는 쓰기 오더 정보를 저장하는 쓰기 플래그 영역을 포함하고,
상기 읽기 플래그 정보는 상기 타스크에서만 쓰기하고, 상기 인터럽트에서는 읽기만 하고, 상기 인터럽트에서는 읽기 플래그 정보가 메시지 읽은 중인 경우 대응하는 메시지 영역에 메시지 쓰기를 하지 않으며,
상기 쓰기 오더 정보는 순서를 구분하기 위해 크기를 갖는 값으로 설정하고, 그 크기가 클수록 메시지가 최근에 저장된 것을 의미하며, 상기 인터럽트가 제 1 메모리에 저장되어 있는 쓰기 오더 정보와 제 2 메모리에 저장되어 있는 쓰기 오더 정보를 비교하여, 이전 메시지가 먼저 저장된 메시지 영역에 새로운 메시지를 쓰기 하는 이중 메모리 구조.
In the dual memory structure that performs data communication so that interrupts and tasks can access memory to write or read messages for message processing,
The memory consists of a dual memory structure having first and second memories of the same structure,
The first and second memories
A plurality of message areas for storing messages,
A validity area for storing validity information indicating the validity of a message stored in each message area,
A read flag area for storing read flag information indicating that the task is reading a message stored in each message area corresponding to the task;
A write flag area for storing write order information indicating a storage order of messages stored in each message area corresponding to the interrupt,
The read flag information is written only in the task, the interrupt is read only, and the read flag information is not written in the corresponding message area when the read flag information is being read in the interrupt,
The write order information is set to a value having a size in order to distinguish the order, and the larger the size, the more recently the message is stored, and the interrupt is stored in the write order information and the second memory stored in the first memory. Dual memory structure that writes a new message in the message area where the previous message is stored first by comparing the existing write order information.
상기 메시지 영역은 상기 인터럽트가 메시지 쓰기를 수행하고, 상기 타스크가 메시지 읽기를 수행하는 이중 메모리 구조.
According to claim 1,
The message area is a dual memory structure in which the interrupt writes a message and the task reads a message.
(A) 메시지를 쓰기 위해 인터럽트가 이중 메모리 구조를 갖는 제 1 메모리 및 제 2 메모리의 메시지 영역에 접근하는 단계;
(B) 상기 접근한 메시지 영역과 대응되는 읽기 플래그 영역에 각각 저장되어 있는 읽기 플래그 정보를 확인하는 단계;
(C) 상기 읽기 플래그 정보의 확인을 통해, 상기 접근한 메시지 영역을 타스크에서 읽고 있는지 확인하는 단계;
(D) 상기 접근한 메시지 영역을 타스크에서 읽고 있지 않으면, 상기 제 1 메모리 및 상기 제 2 메모리에 저장된 쓰기 오더 정보를 확인하는 단계; 및
(E) 상기 쓰기 오더 정보의 확인을 통해, 상기 제 1 메모리 및 상기 제 2 메모리 중 저장 순서가 늦은 메시지 영역에 메시지를 쓰기하는 단계를 포함하고,
상기 (C) 단계는
(C1) 상기 제 1 메모리 및 상기 제 2 메모리의 상기 접근한 메시지 영역에 대응되는 읽기 플래그 정보를 각각 확인하는 단계와,
(C2) 상기 읽기 플래그 정보 확인 결과, 상기 제 1 메모리 및 상기 제 2 메모리의 메시지 영역이 상기 타스크에 의해 모두 읽히고 있지 않으면, 상기 메시지 영역에 저장된 메시지의 유효성을 확인하는 단계와,
(C3) 상기 유효성 확인 결과, 상기 제 1 메모리 및 제 2 메모리의 메시지 영역 중 유효하지 않은 메모리의 메시지 영역으로 메시지를 쓰기하고, 상기 메시지를 유효한 메시지로 표시하는 단계를 포함하는 PLC의 메시지 처리 방법.
In the message processing method of PLC that performs data communication so that interrupts and tasks can access memory to write or read messages for message processing,
(A) interrupt to access the message area of the first memory and the second memory having a dual memory structure to write a message;
(B) checking the read flag information stored in the read flag area corresponding to the accessed message area, respectively;
(C) confirming whether the task is reading the accessed message area by checking the read flag information;
(D) if the task is not reading the accessed message area, checking the write order information stored in the first memory and the second memory; And
(E) through the verification of the write order information, writing a message to a message area in a storage order of the first memory and the second memory, which is late,
Step (C) is
(C1) checking read flag information corresponding to the accessed message area of the first memory and the second memory, respectively;
(C2) checking the validity of the message stored in the message area when the read flag information check result shows that the message areas of the first memory and the second memory are not all read by the task;
(C3) As a result of the validation, writing a message to a message area of an invalid memory among the message areas of the first memory and the second memory, and displaying the message as a valid message. .
상기 (C2) 단계는
상기 읽기 플래그 정보 확인 결과, 상기 제 1 메모리 및 상기 제 2 메모리의 메시지 영역 중 상기 타스크에 의하여 어느 하나만 읽히고 있지 않으면, 읽히고 있지 않은 메시지 영역으로 메시지를 쓰기하고, 상기 메시지를 유효한 메시지로 표시하는 단계를 포함하는 PLC의 메시지 처리 방법.
The method of claim 6,
Step (C2) is
As a result of checking the read flag information, if only one of the message areas of the first memory and the second memory is not being read by the task, writing a message into a message area that is not being read and displaying the message as a valid message Message processing method of the PLC, including.
상기 (C3) 단계는
상기 유효성 확인 결과, 상기 제 1 메모리 및 상기 제 2 메모리 모두 유효하지 않으면 임의로 선택된 하나의 메모리의 메시지 영역으로 메시지를 쓰기하고, 상기 메시지를 유효한 메시지로 표시하는 단계와,
상기 메시지가 쓰기된 메모리의 쓰기 오더 정보를 나머지 메모리의 쓰기 오더 정보보다 최근 순서로 표시하는 단계를 포함하는 PLC의 메시지 처리 방법.
The method of claim 6,
Step (C3) is
Writing a message to a message area of a randomly selected memory if both the first memory and the second memory are invalid as a result of the validation, and displaying the message as a valid message;
And displaying the write order information of the memory in which the message is written in a more recent order than the write order information of the remaining memories.
상기 (C3) 단계는
상기 유효성 확인 결과, 상기 제 1 메모리 및 상기 제 2 메모리 모두 유효하면 상기 제 1 메모리 및 상기 제 2 메모리에 저장되어 있는 쓰기 오더 정보를 각각 확인하여 메시지의 저장 순서를 확인하는 단계를 포함하는 PLC의 메시지 처리 방법.
The method of claim 6,
Step (C3) is
When the validity check result shows that both the first memory and the second memory are valid, check the write order information stored in the first memory and the second memory, respectively, and confirm the storage order of the message. How messages are handled.
상기 (E) 단계는
상기 쓰기한 메시지를 유효한 메시지로 표시하는 단계와,
상기 메시지가 쓰기된 메모리의 쓰기 오더 정보를 나머지 메모리의 쓰기 오더 정보보다 최근 순서로 표시하는 단계를 포함하는 PLC의 메시지 처리 방법.
The method of claim 6,
Step (E) is
Displaying the written message as a valid message,
And displaying the write order information of the memory in which the message is written in a more recent order than the write order information of the remaining memories.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
KR1020180014330A KR102102335B1 (en) | 2018-02-06 | 2018-02-06 | Dual memory structure and method for processing message of PLC using thereof |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
KR1020180014330A KR102102335B1 (en) | 2018-02-06 | 2018-02-06 | Dual memory structure and method for processing message of PLC using thereof |
Publications (2)
Publication Number | Publication Date |
---|---|
KR20190094778A KR20190094778A (en) | 2019-08-14 |
KR102102335B1 true KR102102335B1 (en) | 2020-04-20 |
Family
ID=67621849
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
KR1020180014330A Active KR102102335B1 (en) | 2018-02-06 | 2018-02-06 | Dual memory structure and method for processing message of PLC using thereof |
Country Status (1)
Country | Link |
---|---|
KR (1) | KR102102335B1 (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR102263387B1 (en) * | 2020-01-20 | 2021-06-09 | 엘에스일렉트릭(주) | Plc memory device and data process method thereof |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
FR2730833B1 (en) * | 1995-02-16 | 1997-03-28 | Gemplus Card Int | SECURE UPDATE OF EEPROM MEMORY |
KR20020021523A (en) * | 2000-09-15 | 2002-03-21 | 임승룡 | Structure of controlling apparatus for high speed operation of control program and controlling method for the same |
KR100596394B1 (en) * | 2004-12-13 | 2006-07-04 | 한국전자통신연구원 | Redundant Shared Memory Access Control Method and Device in Unix System |
KR100827720B1 (en) * | 2006-10-16 | 2008-05-07 | 엠텍비젼 주식회사 | Dual port memory with access control device, memory system with dual port memory and access control method of dual port memory |
-
2018
- 2018-02-06 KR KR1020180014330A patent/KR102102335B1/en active Active
Also Published As
Publication number | Publication date |
---|---|
KR20190094778A (en) | 2019-08-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US5206938A (en) | Ic card with memory area protection based on address line restriction | |
CN104143065A (en) | Safety intelligent terminal equipment and information processing method | |
CN106155596B (en) | Data writing method and device | |
CA2549453A1 (en) | Method and apparatus for synchronizing an industrial controller with a redundant controller | |
CN101714124B (en) | Memory protection method, information processing apparatus | |
US20080016415A1 (en) | Evaluation system and method | |
CN104111870A (en) | Interrupt processing device and method | |
KR20090043823A (en) | Memory system that can detect external attacks | |
CN102207913B (en) | The control method and device of write-protect in embedded system | |
CN113220229B (en) | Online I/O undisturbed configuration method for distributed control system | |
EP3895939A1 (en) | Electronic control device and security verification method for electronic control device | |
KR102102335B1 (en) | Dual memory structure and method for processing message of PLC using thereof | |
EP2645249A1 (en) | Information processing apparatus, and method of controlling information processing apparatus | |
CN105279094A (en) | NAND Flash operation processing method, NAND Flash operation processing device and logic device | |
CN114760276B (en) | Method and device for downloading data and secure element | |
CN103077104A (en) | Verification method, device and system for on-chip system | |
CN108334337B (en) | Low-delay instruction dispatcher with automatic management function and filtering guess access method | |
KR100525537B1 (en) | Applied Program Bungle Detection Apparatus and Method by Interrupt | |
CN112288990A (en) | Method, system, medium and device for generating internet of things event based on internet of things data | |
JP4001652B2 (en) | IC card | |
CN116955048B (en) | Method, device and computer storage medium for chip calibration and debugging information management | |
CN117112047B (en) | USB equipment management and control method, equipment and storage medium | |
JP7358772B2 (en) | Control device, control method, control program | |
US20050283555A1 (en) | Computer system and method for transmitting interrupt messages through a parallel communication bus | |
US20050007828A1 (en) | Memory device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A201 | Request for examination | ||
PA0109 | Patent application |
Patent event code: PA01091R01D Comment text: Patent Application Patent event date: 20180206 |
|
PA0201 | Request for examination | ||
PG1501 | Laying open of application | ||
E902 | Notification of reason for refusal | ||
PE0902 | Notice of grounds for rejection |
Comment text: Notification of reason for refusal Patent event date: 20190826 Patent event code: PE09021S01D |
|
E90F | Notification of reason for final refusal | ||
PE0902 | Notice of grounds for rejection |
Comment text: Final Notice of Reason for Refusal Patent event date: 20200226 Patent event code: PE09021S02D |
|
E701 | Decision to grant or registration of patent right | ||
GRNT | Written decision to grant | ||
PE0701 | Decision of registration |
Patent event code: PE07011S01D Comment text: Decision to Grant Registration Patent event date: 20200413 |
|
PR0701 | Registration of establishment |
Comment text: Registration of Establishment Patent event date: 20200413 Patent event code: PR07011E01D |
|
PR1002 | Payment of registration fee |
Payment date: 20200413 End annual number: 3 Start annual number: 1 |
|
PG1601 | Publication of registration | ||
PR1001 | Payment of annual fee |
Payment date: 20240327 Start annual number: 5 End annual number: 5 |