Use Python with RMP EtherCAT Master for Industrial Automation Applications

April 1, 2021

 • 
by 
Shota Nemoto

Introduction

The standard RMP EtherCAT master can be used to create a PLC application in C# or C++ using the RapidCode API. Using the RapidCodeRemote API, you can utilize all of the functionality in the RapidCode API but from your preferred gRPC supported language (such as Python, Java, or Ruby). The RapidCodeRemote API communicates with an instance of the RapidServer running on either Windows or INtime that manages the RMP. 

Essentially, a machine can be built using a gRPC supported language of choice. The language will still have access to all of RapidCode for things like executing motion commands, setting up user limits, triggering and monitoring I/O, and more via the RapidCodeRemote API. 

Why Python?

Python is one of the most popular programming languages available today. It provides extremely readable code, which helps to significantly reduce development time and makes applications far easier to maintain. Its programs are often simpler as engineers don’t have to concern themselves too much with troublesome concepts like memory management, unlike C++. Simpler programs lead to fewer bugs, happier engineers, and happier clients. This has led to Python’s widespread usage in many areas such as Web development, Data Science, and Artificial Intelligence.

Many powerful libraries and frameworks are available in Python. Using a library can save an enormous amount of development time. Need to use machine learning? Use PyTorch, Tensorflow, or Pandas. Need to add computer vision to your application? Use OpenCV or Scikit-Image. Need to make graphs and charts to visualize some data? Use Matplotlib or Seaborn. For practically every engineering problem in software, there is an available library that can help. These libraries are well-tested, actively maintained, and using one means one less thing for your team to worry about.

Traditional IEC 61131-3 programming languages (Ladder Diagram, Structured Text, Instruction List, Function Block Diagram, Sequential Function Chart) for Programmable Logic Controllers (PLCs) in the industrial automation industry have no access to these libraries and tools. There may exist some powerful PLC programs made by some clever engineers, but these are not widely available on the internet and must be passed around on flashdrives or emailed zip archives like back in the Stone Age. PLCs programmed in C++ may have access to these libraries, but C++ applications have the danger of being buried in a sea of dangling pointers, memory leaks, and spaghetti code. Additionally, Python education is also very commonplace, meaning you can find at least ten engineers that can develop and maintain a Python application for each engineer that knows Ladder programming or Structured Text.

Using Python allows you to create cleaner, simpler, and easily testable programs with short development cycles. 

The RMP Architecture with Python

In order to use the RMP with Python, the RapidServer uses gRPC framework to listen for request messages from client applications. The RapidServer binds to a specified IP address and port number and accepts connectsion from clients. Client applications can send request messages to ask the RapidServer to execute a batch of RapidCode actions. The execution result will be returned from the Server to the client within a response message. The format of these messages is defined within proto files, and gRPC provides protobuf compilers that can use these files to generate the necessary code for clients to create and interpret these messages.

The overall architecture consists of three processes: 

  1. The RMP EtherCAT Master running on INtime: This directly communicates with all devices on the EtherCAT network (drives, I/O modules, etc.). This is responsible for commanding all drive motion, I/O outputs, and sending and receiving data over the network.
  2. The RapidServer running on Windows or INtime: This listens for gRPC request messages, directs the RMP to fulfill the request, then sends a response message. The RapidCodeRemote API is essentially defined entirely within the rapidcode.proto file which specifies the format of the gRPC request and response messages. Internally, the RapidServer uses the RapidCode API to direct the RMP.
  3. Your Python application: This application must conform to the gRPC message format specified within the rapidcode.proto file in order to communicate with the RapidServer.

On this page

start developing today!

1000+ customers have already automated with help of our products and team