[go: up one dir, main page]

KR102870758B1 - Apparatus and method to control real-time multiple task using python language - Google Patents

Apparatus and method to control real-time multiple task using python language

Info

Publication number
KR102870758B1
KR102870758B1 KR1020230105900A KR20230105900A KR102870758B1 KR 102870758 B1 KR102870758 B1 KR 102870758B1 KR 1020230105900 A KR1020230105900 A KR 1020230105900A KR 20230105900 A KR20230105900 A KR 20230105900A KR 102870758 B1 KR102870758 B1 KR 102870758B1
Authority
KR
South Korea
Prior art keywords
real
module
python
time
language
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
Application number
KR1020230105900A
Other languages
Korean (ko)
Other versions
KR20250024404A (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 KR1020230105900A priority Critical patent/KR102870758B1/en
Publication of KR20250024404A publication Critical patent/KR20250024404A/en
Application granted granted Critical
Publication of KR102870758B1 publication Critical patent/KR102870758B1/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/35Creation or generation of source code model driven
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/36Software reuse
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces

Landscapes

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

Abstract

파이썬(Python) 언어를 이용하여 실시간 다중 태스크(task)를 제어하는 장치에 있어서, 리눅스를 실시간성을 지원할 수 있는 운영체제로 패치(patch)하는 모듈(120, 102); 상기 파이썬 언어 기반으로 실시간 제약조건을 가진 실시간 태스크를 생성하는 제1 파이썬 모듈(100); 상기 파이썬 언어 기반으로 상기 이더캣 마스터 코어와 연동하여 이더캣 네트워크를 제어하는 제2 파이썬 모듈(110); 실시간 필드버스 인터페이스를 위해 IgH 이더캣(EtherCAT: Ethernet for Control Automation Technology) 마스터 모듈(114)과 연동된 이더캣 마스터 코어(112); 및 미리 설정된 언어 모듈을 통해 상기 제1 파이썬 모듈과 상기 제2 파이썬 모듈을 구동시키기 위한 라이브러리를 로딩하도록 구현되는 FFI(130)를 포함한다.A device for controlling real-time multi-tasks using the Python language, comprising: a module (120, 102) for patching Linux into an operating system capable of supporting real-time; a first Python module (100) for generating a real-time task with real-time constraints based on the Python language; a second Python module (110) for controlling an EtherCAT network by interworking with the EtherCAT master core based on the Python language; an EtherCAT master core (112) interworking with an IgH EtherCAT (Ethernet for Control Automation Technology) master module (114) for a real-time fieldbus interface; and an FFI (130) implemented to load a library for driving the first Python module and the second Python module through a preset language module.

Description

파이썬 언어를 이용하여 실시간 다중 태스크를 제어하는 장치 및 방법 {APPARATUS AND METHOD TO CONTROL REAL-TIME MULTIPLE TASK USING PYTHON LANGUAGE}Apparatus and method for controlling real-time multiple tasks using Python language {APPARATUS AND METHOD TO CONTROL REAL-TIME MULTIPLE TASK USING PYTHON LANGUAGE}

본 발명은 파이썬 언어를 이용하여 실시간 다중 태스크를 제어하는 장치 및 방법에 관한 것이다.The present invention relates to a device and method for controlling real-time multi-tasks using the Python language.

최근 인공지능 기술은 로봇, 사물 인터넷(IoT: Internet of Things), 자율주행 자동차 등 사회 및 산업 시설 전반에 적용되고 있으며, 이러한 기술의 구현을 위한 연구 및 개발은 주로 파이썬(Python) 언어를 기반으로 이루어지고 있다.Recently, artificial intelligence technology has been applied across social and industrial facilities, including robots, the Internet of Things (IoT), and self-driving cars. Research and development for the implementation of these technologies are primarily based on the Python language.

파이썬 언어는 직관적인 문법과 낮은 진입 장벽, 데이터 처리를 위한 다양한 라이브러리를 제공하며, 특히 텐서플로우(Tensorflow), 파이토치(Pytorch), 케라스(Keras)와 같은 인공지능 및 기계학습 라이브러리로 많이 활용된다.The Python language offers an intuitive syntax, a low barrier to entry, and a variety of libraries for data processing, and is particularly widely used for artificial intelligence and machine learning libraries such as TensorFlow, PyTorch, and Keras.

그러나 파이썬 언어는 인터프리터 언어의 특징으로 인해 처리 성능이 컴파일 언어인 C/C++와 비교하여 상대적으로 낮을 수 있으며, 이는 일부의 경우에 성능 문제를 야기할 수 있다. 이러한 문제를 해결하기 위해 C언어 기반의 확장 모듈, JIT(Just-in-Time) 컴파일러, 코드 최적화 등 다양한 접근방식을 활용할 수 있다. However, due to its interpreted nature, Python's processing performance can be relatively low compared to compiled languages like C/C++, which can lead to performance issues in some cases. To address these issues, various approaches can be utilized, including C-based extension modules, Just-in-Time (JIT) compilers, and code optimization.

또한 파이썬은 실시간 제약조건을 보장하지 못하는 문제가 있다. 실시간 제약조건은 시스템이 주어진 목표 시간에 따라 동작해야 하는 제약사항을 의미하며 제어 장치에 있어 필수적으로 요구되는 조건이다. 이는 외부 환경이나 사용자의 요구에 신속하게 응답하고, 주어진 목표 시간 내에 원하는 결과를 획득해야 함을 의미한다. 이러한 실시간 제약조건은 의료기기, 자동차의 안전 시스템, 제조 공정, 로봇 제어 시스템, 군사 장비와 같은 여러 산업 분야에서 중요한 역할을 하고 있으나, 파이썬은 실시간 제약조건을 충족하기 어려워 실시간 제어 시스템의 언어로 적용하기에는 한계점이 존재한다.Python also has the problem of not guaranteeing real-time constraints. Real-time constraints are constraints that require a system to operate within a given target time, and are essential for control devices. This means responding quickly to external conditions or user requests and achieving the desired results within a given target time. These real-time constraints play a crucial role in various industries, such as medical devices, automotive safety systems, manufacturing processes, robotic control systems, and military equipment. However, Python struggles to meet real-time constraints, limiting its application as a language for real-time control systems.

뿐만 아니라 산업용 필드버스로써 실시간 제어를 위한 직렬 통신 수단으로 사용되는 이더캣(EtherCAT)은 주로 PLC(Programmable Logic Controller) 또는 C/C++ 언어로 구현되며, PLC 또는 C/C++ 언어는 파이썬에서 직접적으로 사용하기 어려운 문제가 있다.In addition, EtherCAT, which is used as a serial communication means for real-time control as an industrial field bus, is mainly implemented in PLC (Programmable Logic Controller) or C/C++ language, and PLC or C/C++ language has the problem that it is difficult to use directly in Python.

이와 같이 파이썬 언어는 인공지능 및 기계학습 분야에서 많이 사용되지만, 실시간 제약조건을 충족해야 하는 기계장치의 제어 시스템이나 일부 산업용 필드버스와의 통합에서는 한계점이 존재하며 인공지능 응용이 통합된 제어 시스템에서의 활용이 제한되는 단점이 존재한다.Although the Python language is widely used in the fields of artificial intelligence and machine learning, it has limitations in control systems for mechanical devices that must meet real-time constraints or in integration with some industrial field buses, and its use in control systems that integrate artificial intelligence applications is limited.

한국등록특허공보 제10-2006211호Korean Patent Publication No. 10-2006211

본 발명은 상기와 같은 문제를 해결하기 위해 안출된 것으로, 본 발명의 목적은 파이썬 언어를 이용하여 실시간 다중 태스크를 제어하는 장치 및 방법을 제공하는 것이다.The present invention has been devised to solve the above problems, and the purpose of the present invention is to provide a device and method for controlling real-time multi-tasks using the Python language.

상기 목적을 달성하기 위한 본 발명의 일 실시예에 따른 파이썬(Python) 언어를 이용하여 실시간 다중 태스크(task)를 제어하는 장치는, 리눅스를 실시간성을 지원할 수 있는 운영체제로 패치(patch)하는 모듈(120, 102); 상기 파이썬 언어 기반으로 실시간 제약조건을 가진 실시간 태스크를 생성하는 제1 파이썬 모듈(100); 상기 파이썬 언어 기반으로 상기 이더캣 마스터 코어와 연동하여 이더캣 네트워크를 제어하는 제2 파이썬 모듈(110); 실시간 필드버스 인터페이스를 위해 IgH 이더캣(EtherCAT: Ethernet for Control Automation Technology) 마스터 모듈과 연동된 이더캣 마스터 코어(112) 및 미리 설정된 언어 모듈을 통해 상기 제1 파이썬 모듈과 상기 제2 파이썬 모듈을 구동시키기 위한 라이브러리를 로딩하도록 구현되는 FFI(130)를 포함한다.According to one embodiment of the present invention for achieving the above object, a device for controlling real-time multi-tasks using the Python language includes a module (120, 102) for patching Linux into an operating system capable of supporting real-time performance; a first Python module (100) for generating a real-time task with real-time constraints based on the Python language; a second Python module (110) for controlling an EtherCAT network by interworking with the EtherCAT master core based on the Python language; an EtherCAT master core (112) interworking with an IgH EtherCAT (Ethernet for Control Automation Technology) master module for a real-time fieldbus interface, and an FFI (130) implemented to load a library for driving the first Python module and the second Python module through a preset language module.

상기 목적을 달성하기 위한 본 발명의 일 실시예에 따른 파이썬(Python) 언어를 이용하여 실시간 다중 태스크(task)를 제어하는 방법은, 제1 파이썬 모듈(100)이 FFI(130)를 통해 RT-POSIX 라이브러리를 로딩하는 단계; 상기 로딩된 RT-POSIX 라이브러리를 사용하여 C언어로 작성된 함수들을 호출하여 실시간 제약조건을 가진 실시간 태스크를 생성하는 단계; 제2 파이썬 모듈(110)이 상기 FFI를 통해 이더캣 마스터 코어 라이브러리를 로딩하는 단계; 및 상기 로딩된 이더캣 마스터 코어 라이브러리를 사용하여 C언어로 작성된 함수들을 호출하여 이더캣 네트워크를 제어하는 단계;를 포함한다.A method for controlling real-time multi-tasks using the Python language according to one embodiment of the present invention for achieving the above object includes: a step in which a first Python module (100) loads an RT-POSIX library through an FFI (130); a step in which a real-time task having real-time constraints is created by calling functions written in the C language using the loaded RT-POSIX library; a step in which a second Python module (110) loads an EtherCAT master core library through the FFI; and a step in which an EtherCAT network is controlled by calling functions written in the C language using the loaded EtherCAT master core library.

상술한 본 발명의 일측면에 따르면, 파이썬 언어를 이용하여 실시간 다중 태스크를 제어하는 장치 및 방법을 제공함으로써, 파이썬 언어의 직관적인 문법과 낮은 진입 장벽, 다양한 라이브러리를 활용하여 제어 시스템 개발의 어려움을 개선하며 이를 통해 실시간 제어 시스템을 구축하는 프로세스가 간소화되고 효율성이 향상되는 효과가 있다.According to one aspect of the present invention described above, by providing a device and method for controlling real-time multi-tasks using the Python language, the difficulty of developing a control system is improved by utilizing the intuitive grammar, low entry barrier, and various libraries of the Python language, thereby simplifying the process of building a real-time control system and improving efficiency.

뿐만 아니라 파이썬 언어는 이미 다양한 분야에서 널리 사용되는 언어로써 인공지능 및 데이터 처리와 관련된 라이브러리와의 통합이 용이하여 실현 가능성이 높으며, 빠르고 유연한 개발이 가능하므로 제어 시스템 개발의 생산성과 유지보수성을 향상시키는데 도움이 된다.In addition, the Python language is already widely used in various fields, making it easy to integrate with libraries related to artificial intelligence and data processing, making it highly feasible. It also allows for fast and flexible development, helping to improve the productivity and maintainability of control system development.

도 1은 본 발명의 실시예에 따른 파이썬 언어를 이용하여 실시간 다중 태스크를 제어하는 소프트웨어 아키텍처를 나타낸 도면,
도 2는 파이썬 함수를 기능 래퍼를 통해 구현한 함수 리스트를 나타낸 도면,
도 3은 본 발명의 실시예에 따른 이더캣 마스터 코어의 클래스 다이어그램을 나타낸 도면,
그리고, 도 4는 본 발명의 실시예에 따른 파이썬 언어를 이용하여 실시간 다중 태스크를 제어하는 장치의 동작을 나타낸 순서도.
FIG. 1 is a diagram showing a software architecture for controlling real-time multi-tasks using the Python language according to an embodiment of the present invention;
Figure 2 is a diagram showing a list of functions that implement Python functions through function wrappers.
FIG. 3 is a drawing showing a class diagram of an EtherCAT master core according to an embodiment of the present invention;
And, Fig. 4 is a flowchart showing the operation of a device for controlling real-time multi-tasks using the Python language according to an embodiment of the present invention.

후술하는 본 발명에 대한 상세한 설명은, 본 발명이 실시될 수 있는 특정 실시예를 예시로서 도시하는 첨부 도면을 참조한다. 이들 실시예는 당업자가 본 발명을 실시할 수 있기에 충분하도록 상세히 설명된다. 본 발명의 다양한 실시예는 서로 다르지만 상호 배타적일 필요는 없음이 이해되어야 한다. 예를 들어, 여기에 기재되어 있는 특정 형상, 구조 및 특성은 일 실시예와 관련하여 본 발명의 정신 및 범위를 벗어나지 않으면서 다른 실시예로 구현될 수 있다. 또한, 각각의 개시된 실시예 내의 개별 구성요소의 위치 또는 배치는 본 발명의 정신 및 범위를 벗어나지 않으면서 변경될 수 있음이 이해되어야 한다. 따라서, 후술하는 상세한 설명은 한정적인 의미로서 취하려는 것이 아니며, 본 발명의 범위는, 적절하게 설명된다면, 그 청구항들이 주장하는 것과 균등한 모든 범위와 더불어 첨부된 청구항에 의해서만 한정된다. 도면에서 유사한 참조부호는 여러 측면에 걸쳐서 동일하거나 유사한 기능을 지칭한다.The following detailed description of the present invention refers to the accompanying drawings, which illustrate specific embodiments in which the present invention may be practiced. These embodiments are described in sufficient detail to enable those skilled in the art to practice the present invention. It should be understood that the various embodiments of the present invention, while different from each other, are not necessarily mutually exclusive. For example, specific shapes, structures, and characteristics described herein may be implemented in other embodiments without departing from the spirit and scope of the present invention. Furthermore, it should be understood that the positions or arrangements of individual components within each disclosed embodiment may be modified without departing from the spirit and scope of the present invention. Accordingly, the following detailed description is not intended to be limiting, and the scope of the present invention is defined only by the appended claims, along with the full scope of equivalents to which such claims are entitled, if properly described. Like reference numerals in the drawings designate the same or similar functionality throughout the several aspects.

본 발명에 따른 구성요소들은 물리적인 구분이 아니라 기능적인 구분에 의해서 정의되는 구성요소들로써 각각이 수행하는 기능들에 의해서 정의될 수 있다. 각각의 구성요소들은 하드웨어 또는 각각의 기능을 수행하는 프로그램 코드 및 프로세싱 유닛으로 구현될 수 있을 것이며, 두 개 이상의 구성요소의 기능이 하나의 구성요소에 포함되어 구현될 수도 있을 것이다. 따라서 이하의 실시예에서 구성요소에 부여되는 명칭은 각각의 구성요소를 물리적으로 구분하기 위한 것이 아니라 각각의 구성요소가 수행되는 대표적인 기능을 암시하기 위해서 부여된 것이며, 구성요소의 명칭에 의해서 본 발명의 기술적 사상이 한정되지 않는 것임에 유의하여야 한다.The components according to the present invention are defined by functional distinctions rather than physical distinctions, and can be defined by the functions each component performs. Each component may be implemented as hardware or program code and processing units that perform each function, and the functions of two or more components may be implemented by including them in a single component. Therefore, the names given to the components in the following embodiments are not intended to physically distinguish each component, but rather to suggest the representative functions performed by each component, and it should be noted that the technical spirit of the present invention is not limited by the names of the components.

이하에서는 도면들을 참조하여 본 발명의 바람직한 실시예들을 보다 상세하게 설명하기로 한다.Hereinafter, preferred embodiments of the present invention will be described in more detail with reference to the drawings.

도 1은 본 발명의 실시예에 따른 파이썬 언어를 이용하여 실시간 다중 태스크를 제어하는 장치의 소프트웨어 아키텍처를 나타낸 도면이다.FIG. 1 is a diagram showing the software architecture of a device for controlling real-time multi-tasks using the Python language according to an embodiment of the present invention.

제1 파이썬 모듈인 PyRT(Python-based Real-Time) 모듈(100) 및 실시간(RT: Real-Time)-POSIX(Portable Operating System Interface) 모듈(102)은 실시간 태스크를 생성하고 관리하는데 필요한 구성 요소를 나타내고, 제2 파이썬 모듈인 PyIgH(Python-based IgH) 모듈(110), 이더캣(EtherCAT: Ethernet for Control Automation Technology) 마스터 코어(Core)(112) 및 IgH 이더캣 마스터 모듈(114)은 이더캣 관련 구성 요소를 나타내고, RT-Preempt 커널(Kernel)(120)은 상기 RT-POSIX 모듈(102)과 함께 리눅스를 실시간성을 지원할 수 있는 운영체제로 패치(patch)하는 모듈이다.The first Python module, the PyRT (Python-based Real-Time) module (100) and the real-time (RT: Real-Time)-POSIX (Portable Operating System Interface) module (102), represent components required to create and manage real-time tasks, the second Python module, the PyIgH (Python-based IgH) module (110), the EtherCAT (EtherCAT: Ethernet for Control Automation Technology) master core (Core) (112), and the IgH EtherCAT master module (114), represent EtherCAT-related components, and the RT-Preempt kernel (Kernel) (120) is a module that patches Linux into an operating system capable of supporting real-time performance together with the RT-POSIX module (102).

이더캣 제어를 위한 실시간 응용 프로그램을 개발하기 위한 필수 구성 요소는 도 1에 점선으로 그룹핑하여 표시하였고, 이더캣 마스터 코어(112)의 라이브러리, 파이썬에서 동적 라이브러리를 사용할 수 있도록 하는 FFI(Foreign Function Interface)(130), 파이썬 모듈인 PyRT(Python-based Real-Time) 모듈(100) 및 PyIgH(Python-based IgH) 모듈(110)이 상기 필수 구성 요소에 포함된다.The essential components for developing a real-time application for EtherCAT control are grouped and indicated by dotted lines in Fig. 1, and include the library of the EtherCAT master core (112), the Foreign Function Interface (FFI) (130) that enables the use of dynamic libraries in Python, the Python module PyRT (Python-based Real-Time) module (100), and the Python module PyIgH (Python-based IgH) module (110).

이더캣 마스터 코어(112)는 실시간 필드버스 인터페이스를 위해 IgH 이더캣 마스터 모듈(114)과 연동되며, 사용자의 주의가 필요 없는 IgH 이더캣 마스터 API(Application Programing Interface) 및 라이브러리를 기반으로 이더캣 관련 시스템 레벨 루틴을 추상화하기 위해 개발되었다. 마스터 베이스(112-1)는 연결된 슬레이브에 따라 이더캣 마스터의 구성을 처리하고, 각 슬레이브는 각각의 슬레이브 베이스(112-4) 인스턴스에 의해 기술되어야 한다. 현재 형태에서 이더캣 마스터 코어(112)는 서보 드라이브를 지원한다.The EtherCAT master core (112) is interoperable with the IgH EtherCAT master module (114) for a real-time fieldbus interface, and was developed to abstract EtherCAT-related system-level routines based on the IgH EtherCAT master API (Application Programming Interface) and library that do not require user attention. The master base (112-1) handles the configuration of the EtherCAT master according to the connected slaves, and each slave must be described by its own slave base (112-4) instance. In its current form, the EtherCAT master core (112) supports servo drives.

PyRT 모듈(100)은 파이썬 언어 기반으로 실시간 제약조건을 가진 실시간 태스크(RT Task)를 생성하고, PyIgH 모듈(110)은 파이썬 언어 기반으로 이더캣 마스터 코어(112)와 연동하여 이더캣 네트워크를 제어한다.The PyRT module (100) creates a real-time task (RT Task) with real-time constraints based on the Python language, and the PyIgH module (110) controls the EtherCAT network by linking with the EtherCAT master core (112) based on the Python language.

FFI(130)는 미리 설정된 언어 모듈, 일례로 C타입(CTypes), CFFI(C Foreign Function Interface) 또는 SWIG(Simplified Wrapper and Interface Generator)로 구현될 수 있다. 본 발명의 실시예에 따른 FFI(130)는 C타입을 통해 PyRT 모듈(100)과 PyIgH 모듈(110)을 구동시키기 위한 함수를 호출하고 GIL(Global Interpreter Lock)을 해제하여 원하지 않는 지연이나 시스템 충돌을 방지하고, 필요한 동적 라이브러리, 즉 이더캣 마스터 코어 라이브러리, RT-POSIX 라이브러리를 파이썬에 로드한다.FFI (130) can be implemented as a preset language module, for example, CTypes, C Foreign Function Interface (CFFI), or Simplified Wrapper and Interface Generator (SWIG). FFI (130) according to an embodiment of the present invention calls a function for driving PyRT module (100) and PyIgH module (110) through CTypes, releases GIL (Global Interpreter Lock) to prevent unwanted delay or system crash, and loads necessary dynamic libraries, i.e., EtherCAT master core library and RT-POSIX library, into Python.

PyIgH 모듈(110)은 공유 라이브러리인 libethercat을 사용하여 도메인 활성화, 슬레이브 초기화, 분산 클럭 동기화, 데이터 교환 및 상태 확인 기능을 수행한다. 이하에서는 도 2를 통해 이러한 기능 래퍼(wrapper)에 대해 보다 상세히 설명하도록 한다.The PyIgH module (110) uses the shared library libethercat to perform domain activation, slave initialization, distributed clock synchronization, data exchange, and status check functions. Below, these functional wrappers will be described in more detail with reference to FIG. 2.

도 2는 파이썬 함수를 기능 래퍼를 통해 구현한 함수 리스트를 나타낸 도면이고, 도 3은 본 발명의 실시예에 따른 이더캣 마스터 코어의 클래스 다이어그램을 나타낸 도면이다.FIG. 2 is a diagram showing a list of functions that implement Python functions through function wrappers, and FIG. 3 is a diagram showing a class diagram of an EtherCAT master core according to an embodiment of the present invention.

ecat_init_slave() 함수는 이더캣 슬레이브를 초기화하기 위해 호출되며, 다음과 같은 몇 가지 중요한 단계를 수행한다.The ecat_init_slave() function is called to initialize an EtherCAT slave and performs several important steps:

먼저 ecrt_request_master() 함수를 사용하여 이더캣 마스터 인스턴스에 실시간 사용자 공간 동작을 요청하고, 이를 통해 응용 프로그램은 이더캣 시스템을 사용할 수 있다. First, the ecrt_request_master() function is used to request real-time user-space operations from the EtherCAT master instance, which allows the application to use the EtherCAT system.

다음으로 ecrt_master_create_domain() 함수를 사용하여 프로세스 데이터 교환을 위한 프로세스 데이터 도메인을 생성한다. 상기 프로세스 데이터 도메인은 실시간으로 슬레이브 간에 데이터를 전송하는 데 사용되는 프로토콜인 PDO(Process data object)를 등록하고 주기적으로 교환하는 데 중요하며, 이후 ecrt_master_slave_config() 함수를 사용하여 슬레이브 구성 객체를 생성한다. 상기 ecrt_master_slave_config() 함수는 별칭과 위치를 입력으로 사용하며 지정된 주소를 가진 슬레이브의 벤더 식별자(ID: Identifier)와 제품 코드를 지정된 값과 비교한다. 이때 벤더 ID와 제품 코드가 지정된 값과 불일치할 경우에는 슬레이브가 구성되지 않고 오류가 발생한다.Next, the ecrt_master_create_domain() function is used to create a process data domain for process data exchange. The process data domain is important for registering and periodically exchanging PDO (Process data object), a protocol used to transfer data between slaves in real time, and then the ecrt_master_slave_config() function is used to create a slave configuration object. The ecrt_master_slave_config() function takes an alias and a location as input and compares the vendor identifier (ID) and product code of the slave with the specified address with the specified values. If the vendor ID and product code do not match the specified values, the slave is not configured and an error occurs.

ecrt_slave_config_pdos() 함수는 마스터에 대한 전체 PDO 매핑 구성을 지정하는데 사용되며, 생성된 도메인에 대한 PDO 항목은 ecrt_domain_reg_pdo_entry_list() 함수를 사용하여 등록된다. 이는 이더캣 슬레이브를 초기화하는 과정에서 중요한 단계에 해당한다. The ecrt_slave_config_pdos() function is used to specify the entire PDO mapping configuration for the master, and the PDO entries for the created domain are registered using the ecrt_domain_reg_pdo_entry_list() function. This is a crucial step in the process of initializing an EtherCAT slave.

마지막으로, ecrt_slave_config_dc() 함수를 사용하여 분산 클럭의 사용을 활성화하고 구성한다. 이는 이더캣 슬레이브 장치의 동기 통신을 보장하며, 데이터는 순환 작업 중에 따라야 할 중요한 시퀀스를 수신한다. 즉, 이더넷(Ethernet) 장치 버퍼로부터 저장된 데이터그램을 가져오고 이더캣 프레임의 상태 또는 작업 카운터를 결정한다.Finally, the ecrt_slave_config_dc() function is used to enable and configure the distributed clock. This ensures synchronous communication between EtherCAT slave devices, and data is received in a sequence that must be followed during cyclic operation. This involves retrieving stored datagrams from the Ethernet device buffer and determining the status or operation counter of the EtherCAT frame.

이러한 프로세스는 ecat_master_receive() 함수, ecat_domain_process() 함수 순으로 마스터 및 슬레이브의 상태를 확인하는 즉시 수행된다. 데이터는 데이터그램을 처리하고 다음 명령 집합을 작성한 후 전송되며, 이는 장치의 버퍼로 다시 복사되고 ecat_domain_queue() 함수를 사용하여 슬레이브로 다시 전송된다. 상기 ecat_domain_queue() 함수는 큐에 있는 모든 데이터그램을 전송하는 cat_master_send() 함수의 다음 호출에서 데이터그램을 교환할 수 있도록 데이터그램을 대기열에 넣는다.This process is performed immediately after checking the status of the master and slave using the ecat_master_receive() function, followed by the ecat_domain_process() function. The data is transmitted after processing the datagram and creating the next set of commands, which are then copied back to the device's buffer and transmitted back to the slave using the ecat_domain_queue() function. The ecat_domain_queue() function enqueues the datagram so that it can be exchanged in the next call to the cat_master_send() function, which transmits all datagrams in the queue.

분산 클럭 동기화는 ecat_write_apptime() 함수를 사용하여 슬레이브 장치의 DC 동기화와 일치하도록 구현된다. 상태 확인은 마스터의 상태, 슬레이브 장치의 제품 코드 및 공급업체(vendor) ID와 같은 특정 정보와 상태를 결정하는 데 사용되며, 이것은 ecat_get_slave_info() 함수, get_master_status() 함수, check_slave_state() 함수이다.Distributed clock synchronization is implemented to match the DC synchronization of slave devices using the ecat_write_apptime() function. Status checks are used to determine specific information and status, such as the master's status, the slave device's product code, and the vendor ID. These functions are ecat_get_slave_info() , get_master_status() , and check_slave_state() .

이러한 기능들은 도 3의 마스터 베이스 클래스(112-1) 및 슬레이브 베이스 클래스(112-4)의 메소드로 구현된다.These functions are implemented as methods of the master base class (112-1) and slave base class (112-4) of FIG. 3.

이더캣 통신을 활성화하려면 PDO 도메인 매핑을 직접 등록해야 하며, 이러한 작업을 완화하기 위해 슬레이브 베이스 클래스(112-4)를 구현한다. 아울러 이더캣 도메인 관리 및 디버깅의 편의를 위해 슬레이브 별 데이터 송수신 작업을 구분하여 2개의 도메인을 구성하여 생성한다.Enabling EtherCAT communication requires manually registering PDO domain mappings. To facilitate this task, a slave base class (112-4) is implemented. Furthermore, to facilitate EtherCAT domain management and debugging, two domains are created to distinguish data transmission and reception tasks for each slave.

슬레이브 베이스 클래스(112-4)는 마스터-슬레이브 관계 설정 기능을 수행하도록 구성되며, 상기 마스터-슬레이브 관계 설정 기능은 일례로 PDO 매핑, DC 활성화, 슬레이브 상태 확인 등이 될 수 있다.The slave base class (112-4) is configured to perform a master-slave relationship establishment function, and the master-slave relationship establishment function may be, for example, PDO mapping, DC activation, slave status check, etc.

슬레이브 서보 클래스(112-2)는 슬레이브 베이스 클래스(112-4)에 상속되는 자식 클래스를 의미하며, CANOpen-over-EtherCAT(CoE)를 사용하는 서보 드라이버용 클래스로써 기능한다. 반면, 슬레이브 IO(Input/Output) 클래스는 디지털 또는 아날로그 입출력 장치의 제어를 담당하는 또 다른 자식 클래스를 의미한다.The slave servo class (112-2) is a child class inherited from the slave base class (112-4) and functions as a class for a servo driver using CANOpen-over-EtherCAT (CoE). On the other hand, the slave IO (Input/Output) class is another child class responsible for controlling digital or analog input/output devices.

도 4는 본 발명의 실시예에 따른 파이썬 언어를 이용하여 실시간 다중 태스크를 제어하는 장치의 동작을 나타낸 순서도이다.FIG. 4 is a flowchart showing the operation of a device for controlling real-time multi-tasks using the Python language according to an embodiment of the present invention.

본 발명의 실시예에 따른 실시간 다중 태스크 제어 장치의 제1 파이썬 모듈인 PyRT 모듈은 FFI를 통해 RT-POSIX 라이브러리를 로딩하고,(S402) S402에서 로딩한 라이브러리를 사용하여 C언어로 작성된 함수들을 호출하여 실시간 제약조건을 가진 실시간 태스크를 생성한다.(S404)The PyRT module, which is the first Python module of the real-time multi-task control device according to an embodiment of the present invention, loads the RT-POSIX library through FFI (S402), and calls functions written in the C language using the library loaded in S402 to create a real-time task with real-time constraints (S404).

상기 실시간 다중 태스크 제어 장치의 제2 파이썬 모듈인 PyIgH 모듈은 FFI를 통해 이더캣 마스터 코어 라이브러리를 로딩하고,(S406) S406에서 로딩한 라이브러리를 사용하여 C언어로 작성된 함수들을 호출하여 이더캣 네트워크를 제어한다.(S408)The PyIgH module, which is the second Python module of the above real-time multi-task control device, loads the EtherCAT master core library through FFI (S406) and controls the EtherCAT network by calling functions written in C using the library loaded in S406 (S408).

위와 같은 본 발명의 파이썬 언어를 이용한 실시간 다중 태스크 제어 방법은 다양한 컴퓨터 구성요소를 통하여 수행될 수 있는 프로그램 명령어의 형태로 구현되어 컴퓨터 판독 가능한 기록 매체에 기록될 수 있다. 상기 컴퓨터 판독 가능한 기록 매체는 프로그램 명령어, 데이터 파일, 데이터 구조 등을 단독으로 또는 조합하여 포함할 수 있다. The real-time multi-task control method of the present invention using the Python language as described above may be implemented in the form of program commands that can be executed by various computer components and recorded on a computer-readable recording medium. The computer-readable recording medium may include program commands, data files, data structures, etc., either singly or in combination.

상기 컴퓨터 판독 가능한 기록 매체에 기록되는 프로그램 명령어는 본 발명을 위하여 특별히 설계되고 구성된 것들이거나 컴퓨터 소프트웨어 분야의 당업자에게 공지되어 사용 가능한 것일 수도 있다. The program commands recorded on the above computer-readable recording medium may be specially designed and configured for the present invention or may be known and available to those skilled in the art of computer software.

컴퓨터 판독 가능한 기록 매체의 예에는, 하드 디스크, 플로피 디스크 및 자기 테이프와 같은 자기 매체, CD-ROM, DVD 와 같은 광기록 매체, 플롭티컬 디스크(floptical disk)와 같은 자기-광 매체(magneto-optical media), 및 ROM, RAM, 플래시 메모리 등과 같은 프로그램 명령어를 저장하고 수행하도록 특별히 구성된 하드웨어 장치가 포함된다.Examples of computer-readable recording media include magnetic media such as hard disks, floppy disks, and magnetic tapes, optical recording media such as CD-ROMs and DVDs, magneto-optical media such as floptical disks, and hardware devices specifically configured to store and execute program instructions such as ROM, RAM, and flash memory.

프로그램 명령어의 예에는, 컴파일러에 의해 만들어지는 것과 같은 기계어 코드뿐만 아니라 인터프리터 등을 사용해서 컴퓨터에 의해서 실행될 수 있는 고급 언어 코드도 포함된다. 상기 하드웨어 장치는 본 발명에 따른 처리를 수행하기 위해 하나 이상의 소프트웨어 모듈로서 작동하도록 구성될 수 있으며, 그 역도 마찬가지이다.Examples of program instructions include not only machine language codes, such as those generated by a compiler, but also high-level language codes that can be executed by a computer using an interpreter or the like. The hardware device may be configured to operate as one or more software modules to perform processing according to the present invention, and vice versa.

이상에서는 본 발명의 다양한 실시예에 대하여 도시하고 설명하였지만, 본 발명은 상술한 특정의 실시예에 한정되지 아니하며, 청구범위에서 청구하는 본 발명의 요지를 벗어남이 없이 당해 발명이 속하는 기술분야에서 통상의 지식을 가진 자에 의해 다양한 변형실시가 가능한 것은 물론이고, 이러한 변형실시들은 본 발명의 기술적 사상이나 전망으로부터 개별적으로 이해되어져서는 안될 것이다.Although various embodiments of the present invention have been illustrated and described above, the present invention is not limited to the specific embodiments described above, and various modifications can be made by a person having ordinary skill in the art to which the present invention pertains without departing from the gist of the present invention as claimed in the claims, and such modifications should not be understood individually from the technical idea or prospect of the present invention.

Claims (5)

파이썬(Python) 언어를 이용하여 실시간 다중 태스크(task)를 제어하는 장치에 있어서,
리눅스를 실시간성을 지원할 수 있는 운영체제로 패치(patch)하는 모듈(120, 102);
상기 파이썬 언어 기반으로 실시간 제약조건을 가진 실시간 태스크를 생성하는 제1 파이썬 모듈(100);
상기 파이썬 언어 기반으로 이더캣 마스터 코어와 연동하여 이더캣 네트워크를 제어하는 제2 파이썬 모듈(110);
실시간 필드버스 인터페이스를 위해 IgH 이더캣(EtherCAT: Ethernet for Control Automation Technology) 마스터 모듈(114)과 연동된 이더캣 마스터 코어(112); 및
미리 설정된 언어 모듈을 통해 상기 제1 파이썬 모듈과 상기 제2 파이썬 모듈을 구동시키기 위한 라이브러리를 로딩하도록 구현되는 FFI(Foreign Function Interface)(130)를 포함하고,
상기 제1 파이썬 모듈은 상기 FFI를 통해 실시간(RT: Real-Time)-POSIX(Portable Operating System Interface) 라이브러리를 로딩하고, 로딩된 라이브러리를 사용하여 C언어로 작성된 함수들을 호출함을 특징으로 하는, 실시간 다중 태스크 제어 장치.
In a device that controls real-time multi-tasks using the Python language,
A module (120, 102) that patches Linux into an operating system capable of supporting real-time;
A first Python module (100) that creates a real-time task with real-time constraints based on the above Python language;
A second Python module (110) that controls the EtherCAT network by linking with the EtherCAT master core based on the above Python language;
An EtherCAT master core (112) linked to an IgH EtherCAT (Ethernet for Control Automation Technology) master module (114) for a real-time fieldbus interface; and
Includes an FFI (Foreign Function Interface) (130) implemented to load a library for driving the first Python module and the second Python module through a preset language module,
A real-time multi-task control device characterized in that the first Python module loads a real-time (RT: Real-Time)-POSIX (Portable Operating System Interface) library through the FFI and calls functions written in the C language using the loaded library.
삭제delete 제1항에 있어서,
상기 제2 파이썬 모듈은 상기 FFI를 통해 이더캣 마스터 코어 라이브러리를 로딩하고, 로딩된 라이브러리를 사용하여 C언어로 작성된 함수들을 호출함을 특징으로 하는, 실시간 다중 태스크 제어 장치.
In the first paragraph,
A real-time multi-task control device characterized in that the second Python module loads the EtherCAT master core library through the FFI and calls functions written in the C language using the loaded library.
제1항에 있어서,
상기 미리 설정된 언어 모듈은 C타입(CTypes) 언어 모듈을 포함하며, 상기 FFI는 상기 C타입 언어 모듈로 구현됨을 특징으로 하는, 실시간 다중 태스크 제어 장치.
In the first paragraph,
A real-time multi-task control device, characterized in that the above preset language module includes a C-type (CTypes) language module, and the FFI is implemented with the C-type language module.
파이썬(Python) 언어를 이용하여 실시간 다중 태스크(task)를 제어하는 방법에 있어서,
제1 파이썬 모듈(100)이 FFI(Foreign Function Interface)(130)를 통해 실시간(RT: Real-Time)-POSIX(Portable Operating System Interface) 라이브러리를 로딩하는 단계;
상기 로딩된 RT-POSIX 라이브러리를 사용하여 C언어로 작성된 함수들을 호출하여 실시간 제약조건을 가진 실시간 태스크를 생성하는 단계;
제2 파이썬 모듈(110)이 상기 FFI를 통해 이더캣(EtherCAT: Ethernet for Control Automation Technology) 마스터 코어 라이브러리를 로딩하는 단계; 및
상기 로딩된 이더캣 마스터 코어 라이브러리를 사용하여 C언어로 작성된 함수들을 호출하여 이더캣 네트워크를 제어하는 단계;를 포함하는, 실시간 다중 태스크 제어 방법.
A method for controlling real-time multi-tasks using the Python language,
A step in which the first Python module (100) loads a real-time (RT)-POSIX (Portable Operating System Interface) library through FFI (Foreign Function Interface) (130);
A step of creating a real-time task with real-time constraints by calling functions written in C language using the above-loaded RT-POSIX library;
A step in which the second Python module (110) loads the EtherCAT (Ethernet for Control Automation Technology) master core library through the FFI; and
A real-time multi-task control method, comprising: a step of controlling an EtherCAT network by calling functions written in C language using the above-mentioned loaded EtherCAT master core library.
KR1020230105900A 2023-08-11 2023-08-11 Apparatus and method to control real-time multiple task using python language Active KR102870758B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020230105900A KR102870758B1 (en) 2023-08-11 2023-08-11 Apparatus and method to control real-time multiple task using python language

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020230105900A KR102870758B1 (en) 2023-08-11 2023-08-11 Apparatus and method to control real-time multiple task using python language

Publications (2)

Publication Number Publication Date
KR20250024404A KR20250024404A (en) 2025-02-18
KR102870758B1 true KR102870758B1 (en) 2025-10-14

Family

ID=94824756

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020230105900A Active KR102870758B1 (en) 2023-08-11 2023-08-11 Apparatus and method to control real-time multiple task using python language

Country Status (1)

Country Link
KR (1) KR102870758B1 (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113360262A (en) 2021-06-08 2021-09-07 山东浪潮科学研究院有限公司 Quantum computing task scheduling method based on micro-service

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10114660B2 (en) * 2011-02-22 2018-10-30 Julian Michael Urbach Software application delivery and launching system
KR102006211B1 (en) 2018-02-13 2019-08-02 국방과학연구소 Method and apparatus for generating xml script used in first simulator by converting python script used in second simulator

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113360262A (en) 2021-06-08 2021-09-07 山东浪潮科学研究院有限公司 Quantum computing task scheduling method based on micro-service

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Marco Cereia 외 2인, "Performance of a Real-Time EtherCAT Master Under Linux", IEEE TRANSACTIONS ON INDUSTRIAL INFORMATICS, VOL. 7, NO. 4, pp. 679-687, (2011.09.05)*
Zikun Yu, "An EtherCAT-Based Real-Time Control System Design for a Remote-Direct-Drive 2-DOF Manipulator", Northeastern University Dissertations, (2019.08.31)*

Also Published As

Publication number Publication date
KR20250024404A (en) 2025-02-18

Similar Documents

Publication Publication Date Title
CN103814333B (en) For the method and apparatus to programmable control unit programming and configuration
US20110182300A1 (en) Network Traffic Shaping for Reducing Bus Jitter on a Real Time Controller
EP3361331B1 (en) Method and apparatus for controlling and managing an industry process
CN115335807A (en) Method and device for managing automation programs of an industrial automation platform
US10909285B2 (en) Method for creating a model compatible with a simulation device
US20070294662A1 (en) Integrated Service Method of Distribution Software for Robot Development Based on Open Internet Network
EP3908893A1 (en) Automation code generator for interoperability across industrial ecosystems
CN115167265B (en) PLC application package generation method, PLC application package operation method and related device
JP2023055628A (en) Method and apparatus for commissioning updated applications for industrial automation equipment
KR102870758B1 (en) Apparatus and method to control real-time multiple task using python language
CN117743214A (en) IO device control method, device and storage medium
US7669002B1 (en) System and method for providing an application with memory access methods
CN114327628B (en) Hierarchical control method, system, terminal device and storage medium
CN116009994A (en) Function block calling method, device, equipment and medium of industrial control configuration software
US20240311139A1 (en) Plc-based support for zero-downtime upgrades of control functions
CN114675594A (en) Heterogeneous PLC cooperation control system, method, device, equipment and medium
CN119293120A (en) IEC task data consistency synchronization method, device, electronic device and storage medium
CN117806852A (en) Interface calling method, device, storage medium and processor
CN113760347B (en) Data processing
Hadlich et al. Common communication model for distributed automation systems
CN110788458A (en) Control method and system of stud welding equipment, storage medium and electronic equipment
CN114390042A (en) Industrial communication method, industrial communication system, device, and storage medium
JPH03248204A (en) Control method for programmable controller
CN114564241A (en) Hardware device access method and device, computer device and storage medium
Delgado et al. On the in-controller performance of an open source EtherCAT master using open platforms

Legal Events

Date Code Title Description
PA0109 Patent application

St.27 status event code: A-0-1-A10-A12-nap-PA0109

PA0201 Request for examination

St.27 status event code: A-1-2-D10-D11-exm-PA0201

D13-X000 Search requested

St.27 status event code: A-1-2-D10-D13-srh-X000

E902 Notification of reason for refusal
PE0902 Notice of grounds for rejection

St.27 status event code: A-1-2-D10-D21-exm-PE0902

PG1501 Laying open of application

St.27 status event code: A-1-1-Q10-Q12-nap-PG1501

E13-X000 Pre-grant limitation requested

St.27 status event code: A-2-3-E10-E13-lim-X000

P11-X000 Amendment of application requested

St.27 status event code: A-2-2-P10-P11-nap-X000

D22 Grant of ip right intended

Free format text: ST27 STATUS EVENT CODE: A-1-2-D10-D22-EXM-PE0701 (AS PROVIDED BY THE NATIONAL OFFICE)

PE0701 Decision of registration

St.27 status event code: A-1-2-D10-D22-exm-PE0701

F11 Ip right granted following substantive examination

Free format text: ST27 STATUS EVENT CODE: A-2-4-F10-F11-EXM-PR0701 (AS PROVIDED BY THE NATIONAL OFFICE)

PR0701 Registration of establishment

St.27 status event code: A-2-4-F10-F11-exm-PR0701

PR1002 Payment of registration fee

St.27 status event code: A-2-2-U10-U11-oth-PR1002

Fee payment year number: 1

U11 Full renewal or maintenance fee paid

Free format text: ST27 STATUS EVENT CODE: A-2-2-U10-U11-OTH-PR1002 (AS PROVIDED BY THE NATIONAL OFFICE)

Year of fee payment: 1

PG1601 Publication of registration

St.27 status event code: A-4-4-Q10-Q13-nap-PG1601

Q13 Ip right document published

Free format text: ST27 STATUS EVENT CODE: A-4-4-Q10-Q13-NAP-PG1601 (AS PROVIDED BY THE NATIONAL OFFICE)