Introduction :
There are often such conversations:
Customer: Does Beifu have a edge computing controller?
Me: We have controllers, do you have algorithms?
Customer: I don't have an algorithm, do you?
Me: What are you going to be?The following conversation was divided.Indeed, the topic of artificial intelligence is huge and inexplicable, and the concept of edge computing is in full swing.However, automation engineers often feel that they can't find a way to explore. The author tries to understand AI technology, machine learning, edge computing, predictive maintenance and other popular words from the perspective of factory application, as well as edge computing and machine learning products and principles provided by TwinCAT.This article is purely my personal understanding, which is both immature and verbose.If there are any inappropriate aspects, please leave a message.To avoid being misled, readers should also remember to check the correction information in the comment area.
Keywords:
AI technology, machine learning, neural network, edge computing, predictive maintenance
________________________________________
Text of the document
The full text is 4700 words and takes about 5 minutes to read:
1 TwimCAT machine learning and edge computing
1.1 Explanation of terms
(1) AI technology and predictive maintenance
Predictive maintenance, as the name suggests, is to give early warning and conduct maintenance before equipment failure occurs.For mechanical components, failure usually does not occur suddenly, but there is a gradual deterioration process, which eventually affects the function of the entire machine.If we can detect anomalies from various clues at the beginning of hidden dangers, analyze the causes and conduct maintenance, this is the "predictive maintenance" required for key equipment and components in factories.The foundation of "predictive maintenance" is "anomaly detection".Detecting signals is not difficult, but it is difficult to determine whether the current state is normal or abnormal based on one or more signals.For example, an experienced maintenance technician can tell whether the motor is normal or abnormal just by listening to its sound, and may know where the problem lies, whether it needs lubrication or bearing replacement, or whether the motor needs to be disassembled for overhaul.This maintenance technician has a set of "anomaly detection algorithms" in his mind.His brain is certainly intelligent, not artificial intelligence, but natural intelligence.Everyone is naturally intelligent.It may take years of learning for a person to acquire a set of "algorithms" and reach the level of the experienced technician.Note that this learning must be done in practice, not with a set of ready-made formulas that can be applied universally. Instead, it is necessary to deal with problems in practice, draw lessons, gain experience, deal with problems again, and revise the experience. Only by using both hands and brains can one become an experienced technician after three to five years or even seven to eight years of practice.If we want to let "machines" replace experienced technicians to give maintenance advice, we need to use artificial intelligence, or AI technology.For different objects to be maintained, AI must also be trained specifically. This training is called "machine learning", and the object to be learned is called "model".In the training process, how to find the relationship between feature quantities and actual states--such as the relationship between sound decibels and frequency bands and motor states--and the method to find this relationship is called "machine learning engine".
(2) Machine learning engine
Regarding machine learning engines, if we talk about humans, reading thousands of books and traveling thousands of miles are different learning engines.How does a computer predict the unknown from the known, based on experience or reasoning? This is the problem that machine learning engines need to solve.As a PLC engineer, you don't need to consider this problem.Experts in the field of AI have developed several learning engines. Cloud service providers provide machine learning frameworks with different learning engines, and automation manufacturers have already made the interfaces with these cloud machine learning frameworks.PLC engineers only need to implement these interfaces on the PLC according to the instructions, and can dock with the cloud learning framework. After training, they can get the standard machine learning model file, and finally run this file on the PLC.
(3) Edge computing and cloud computing
For automation equipment, the scenario that needs to be faced is: if there are hundreds of motors in a factory, controlled by dozens of controllers, and there is also a dedicated computer for predictive maintenance.Each controller only collects data and transmits it to the predictive maintenance computer through the network. The latter runs an artificial intelligence algorithm to diagnose the status of all motors and transmits the diagnosis results to each controller through the network.This situation is called 'centralized computing'.If this predictive maintenance computer is not in the factory, but is located on a virtual machine on the Internet, users do not need to know whether the virtual machine is in Shenzhen or Shanghai when using it, nor do they need to know its working principle, learning engine, or how it reaches conclusions. As long as they are connected to the Internet and run the local software as required to send and receive data, users can know the "health status" of all motors in the factory at any time.This is called "cloud" computing.Whether it is centralized computing or cloud computing, the data and results of computing need to be transmitted through the network. The former is through the intranet and the latter is through the Internet. If the computing is placed on the local controller, it is called "edge computing" - the so-called edge is just that compared with the intranet or the Internet, the automation equipment belongs to the bottom layer and is at the edge of the network.So the IT world calls the computing running on the controller "edge computing".In the AT industry, the controller has always been the core, because for Filebus, field actuators, and sensors, the controller is the brain and heart, not at all marginal.As for edge computing and cloud computing, I think it needs to be considered as appropriate for automation equipment.
1.2 times of Beckhoff's AI products
(1) Does Beifu have a edge computing controller?
Customers often ask "Does Beifu have a controller for edge computing?" At this time, I want to say: I have a controller for edge computing. Do you have an algorithm for edge computing?Often, customers will say, "I don't have an algorithm, do you have one?" Then I ask, "What do you want to calculate?" This is the fundamental question: in the field of industrial control, there are countless things that need to be calculated, and Beckhoff provides some of them, while the vast majority are algorithms written by OEM equipment factories or specialized industry experts and software companies for specific objects.Beifu's software products can be used in four aspects of edge computing: data collection, data storage, computing services and display operations.See Annex: 1a TwinCAT edge computing Product.pdf
(2) Edge computing and Machine Learning
Will edge computing necessarily use machine learning?Not necessarily.If the calculation process can be expressed in a certain mathematical formula, machine learning is not needed, such as calculating power based on voltage and current, analyzing harmonics, and judging the quality of the power grid.If edge computing only stores and preprocesses some signals that need to be uploaded, it does not require machine learning.The above calculation was implemented on Bev controller many years ago, when the concept of edge computing was not yet born.Despite the hype of edge computing, this concept is meaningless for Bev PLC - in addition to undertaking PLC and NC tasks, TwinCAT originally provides a variety of plug-ins for data acquisition, storage, IoT communication and display, which can also run various third-party operations.As long as the algorithm is running under Windows, it can be run on Beckhoff controllers.If you have the C++ source code of the algorithm, you can even package it into a TwinCAT COM component that runs on the TwinCAT real-time core.Of course, if the algorithm has been encapsulated into the PLC Open standard library, it can be directly integrated into the PLC program.In other words, this part of the operation has always been there, but now it has a trendy name.Searching for "edge computing" on the Internet is mostly discussed by the IT industry.In the AT world, what can edge computing be used for? At present, it seems that the most reliable foothold is "predictive maintenance", but the focus of predictive maintenance is not "edge computing" but AI technology and machine learning.German engineers disdain to talk about the concept of edge computing, but they are more willing to promote the software product TwinCAT Machine Learning, which they have spent a lot of time and are proud of.One of the application scenarios of machine learning is predictive maintenance. OMRON's AI controller has only made three predictive maintenance models - cylinder, screw and belt, but the market promotion is very successful.In contrast, talking about machine learning in the automation community is a bit too highbrow, as there are ready-to-use function blocks, even if there are only three, which sounds much easier than building and training models by yourself.But for software engineers with strong R&D capabilities, they can build and train models themselves, which opens up endless possibilities and makes the "playability" several levels higher.Whether to teach people how to fish or just give them fish, European and Japanese automation manufacturers have taken different routes in AI applications, which is also a consistent difference between European and Japanese products.
1.3 Assumptions about machine learning
The current background is that there are a group of young, highly educated engineers who are proficient in algorithms and programming in the TwinCAT 3 user community, and are willing to deeply understand or have already mastered certain AI concepts. They are easily able to become fans of TwinCAT Machine Learning.Given the openness and mature software architecture of TwinCAT, it is expected that the application scenarios of TwinCAT Machine Learning include but are not limited to the following possibilities:
(1) Independent software companies train typical process models
Independent small software companies can develop models for predictive maintenance of cylinders, screw rods, belts, and other components similar to ORMON through TwinCAT Machine Learning and sell them on the market.
(2) Equipment with self-learning function
Traditional process parameters are a set of formulas developed by industry process engineers through years of experience.If the machine has self-learning capabilities, it may greatly shorten the 'groping' time.Equipment manufacturers who master this technology will have a significant competitive advantage in the industry.
(3) Design of virtual sensors
This is an application in the promotional materials of TwinCAT Machinge Learning.If the software supplier trains the virtual sensor under specific conditions to achieve the same performance as the physical sensor, the physical sensor can be removed and replaced with the virtual sensor.In the following example, the speed of the fan directly affects the pressure at the measurement point, but the exact correlation requires "learning". Once a model that matches the pressure sensor response is learned, the pressure can be calculated by measuring the fan speed in the future.
If you are a system integrator, you need to buy 100 pressure sensors and 100 pressure measurement modules for 100 pressure measurements. With TwinCAT Machine Learning, you only need to train 100 sets of parameters for one model.If the fan speed is controlled by frequency or voltage conversion (usually this is a linear relationship), you can directly read the current output frequency or voltage from the controller to calculate the pressure at the measurement point.Of course, this is a very simple correlation, just an example for easy understanding.In practical applications, it may be much more complex, but TwinCAT Machine Learning provides such a possibility, a new way of solving problems.
1.4 Introduction to TwinCAT Machine Learning
The following content is from Beckhoff's official promotional materials
1.4.1 Three links of machine learning
All machine learning requires the cyclic execution of these three steps: data collection, training, and running.
For TwinCAT Machine Learning, different products are required in each step.However, the most important step, "ML Training", is not executed on the TwinCAT controller, but is completed using third-party learning frameworks and services on the "cloud".Therefore, the data collected by the TwinCAT controller must be sent to the cloud, and the trained model must be deployed to the TwinCAT controller
(1) Data collection for machine learning
a) Machine learning relies on data b) Beckhoff products that need to be used: TC3 ScopeTC3 DB ServerTC3 Data AgentTC3 Analysis Loggerc) Which product to use depends on whether the application requires long-term data collection, access to the machine's source code, sampling rate, and data volume.
(2) Training of machine learning
a) There are many different ML frameworks, most of which are based on python and are open source.They have been used commercially, for example, Matlab® b) Examples of deep learning frameworks include: Tensor Flow (Google), Tensor Flow (Google) Keras (Front-end for Tensor Flow, CNTK, ..) PyTorch (Facebook) MxNet (AWS) CNTK (Microsoft) MATLAB DeepLearning Toolbox (MathWorks) c) Examples of using classic ML tool frameworks include: Python SciKit MATLAB Machine Learning Toolbox
(3) Operation of machine learning
After the training phase is complete, the output result is a standard ONNX file.To execute this file in the TwinCAT real-time core, there is no need to connect to the cloud.Alternatively, for the same model, it is possible to train only once and obtain the desired ONNX file for use in TwinCAT.
a) The standard TcCOM component can reference the ML model in the real-time kernel to provide direct access to EtherCAT slaves, actuators, and sensors from PLCs, C++, or automatic loop calls. b) Support for ONNX allows the definition of model input and output characteristics to be loaded at startup or during operation. This is a standard ML file format with broad application prospects.c) It can handle multiple tasks without blocking, with the same TcCOM output.d) Based on PC control, scalable performance requirements: x86 CPU and 64-bit operating system.A MLP learning model with 10k weights can be used multiple times in a sub-millisecond task. Note: ONNX (Open Neural Network Exchange), a standard for representing deep learning models, is an AI middleware created by Facebook that enables models to be transferred between different frameworks.
1.5 TwinCAT machine learning products
When it comes to machine learning products, it mainly refers to TwinCAT products involved in the machine training and machine operation stages, because the software used in the data acquisition stage is generic old products, such as Scope, Database Server, etc., which are not specifically developed for machine learning.Depending on the model reasoning framework selected for the "machine learning cloud service provider", users need to choose one of two options: TF380x for machine learning model reasoning of traditional models, and TF381x for neural network model reasoning.
(1) TF380x: TC3 Machine Learning Inference Engine
The traditional machine learning model inference, such as SVM (support vector machine), is a generalized linear classifier that performs binary classification on data using supervised learning.PCA (principal component analysis) is a widely used data compression algorithm. k-means clustering algorithm is an iterative clustering algorithm.
(2) TF381x: TC3 Neural Network Inference Engine
The reasoning of neural networks, such as MLP (Multi-Layer Perception), is a forward-looking artificial neural network that maps a set of input vectors to a set of output vectors.CNN (Convolutional Neural Network), a type of feedforward neural network that includes convolutional calculations and has a deep structure, is one of the representative algorithms of deep learning.LSTM (Long Short-Term Memory) is a long short-term memory network, a type of time-cycle neural network, suitable for processing and predicting important events with relatively long intervals and delays in time series.