top of page
  • Writer's picturePaxton Shantz

TwinCAT Machine Learning Helps 3D Printers Work Smarter

Improving part quality, throughput, reliability and more is possible by implementing ML technologies integrated into the machine control environment

3D printer creates metal part

Additive manufacturing applications require significantly more control than traditional subtractive manufacturing. Although both processes usually rely on G-code for the motion control, there is great sophistication required to consistently make quality parts with additive machines. These machines must also be much more repeatable with as little operator intervention as possible. In fact, many additive manufacturing machines only require the user to select the G-code and hit “Start” – though sometimes that’s automated, too. Either way, the prevailing wisdom is: The less operator intervention, the less downtime on the 3D printer.


But this leaves machine builder OEMs and equipment end users with a conundrum. If the machine doesn’t run perfectly, all of the time, a part could be wasted. To prevent this, OEMs need new ways to guarantee part quality throughout the process and help machines adapt to unexpected conditions even while printing. Machine vision is one solution that offers benefits and, when fully integrated, can help the printer make changes based on observed conditions.


An even more proactive approach involves using machine learning (ML) directly in the machine control environment. The machine controller can leverage trained neural networks to anticipate and mitigate problems before they occur. ML can also help machines run more efficiently to reduce time in production, raw materials waste, wear and tear on parts, and energy consumption.


Additive manufacturing machine building an industrial component
Machine learning can accomplish a range of optimizations that benefit additive manufacturing equipment.

But what are actual use cases for ML in additive manufacturing? How does it work? And is ML always the right answer? Let’s answer these questions, first exploring the differences between ML solutions.


Different approaches to machine learning


To begin, ML, is a subset of the broader world of artificial intelligence (AI). The most common ML technologies in the industry exist at the enterprise or cloud level. These collect data on the factory floor, send the data to a separate environment for processing and then make updates to the machine control later. This strategy can help identify process improvements asynchronously.


Solving problems that need immediate attention during printing requires a different approach. Fully integrated ML technologies reside in the machine control environment. Not only does this simplify implementation, but it also enables real-time responses in the control logic based on the ML inference.


TwinCAT Machine Learning software, for example, uses the same engineering and runtime environments for everything from PLC and motion control to machine vision and IoT, providing a true end-to-end automation platform. This provides significant advantages in real-world production scenarios.


ML use cases for additive manufacturing


Nearly all industrial machinery presents some opportunities for optimization through ML. With motion control systems, for example, trained neural networks could tweak motion profiles to boost energy efficiency, eliminate vibration that can harm products, optimize robot kinematics or reduce mechanical wear on components, extending time between maintenance and even the lifecycle of the equipment. Additive manufacturing machines can benefit from these general optimizations, too.



Industry-specific use cases focus more on the specific material being extruded. By using ML to change flow and deposition rates on the fly, among other variables, machines can achieve higher part quality in the fastest time possible. Much of this involves accounting for heat in the process. The further a machine gets into printing, the more risk that heat fluctuations will impact how the material reacts.


While many plastics cool rather quickly, heat tends to linger with architected materials in construction projects. The residual heat could lead to unwanted compacting if concrete is unable to cool and solidify as quickly in upper layers, for example. A similar problem often occurs with 3D printing metals since this often involves melting the specific metal with a laser during deposition. On the reverse side, if the material is not deposited at a hot enough temperature, it may not bond properly.


This is where ML comes in. An integrated system can draw directly from tools like machine vision and profilometers during the process and even the G-code and controller cycle data. ML inferences could read in various parameters and then change the dynamics of the machine in microseconds to ensure greater quality and uniformity. As a result, the process would create less waste, both in terms of time and materials.


How integrated ML works

Diagram of the three steps of TwinCAT Machine Learning: data collection, ML training and ML runtime in a continuous loop
With TwinCAT Machine Learning, optimization is a virtuous cycle that leads to enhanced machine operation and part quality.

Success in machine learning depends on the data. The first step is collecting a wealth of data and labeling good and bad prints from the specific application. Many Beckhoff solutions – e.g. Database Server, Analytics Logger or TwinCAT Scope – assist with collecting the necessary data. However, detailed knowledge of the machine and process is mandatory to determine which data sets are truly valuable.


An ML framework must then process the data. The Beckhoff approach allows for use of well known and widely used ML training frameworks, including MATLAB®, PyTorch, TensorFlow, SAS, etc. Properly processing the data with existing toolboxes or libraries, modeling suitable ML algorithms and constant evaluation will lead to a trained ML model that’s prepared for the specific requirements of its application.


When deploying the trained ML model in TwinCAT 3, the Open Neural Network Exchange (ONNX) file format, an industry standard, provides the bridge to real-time use. Training the model requires significant processing power, often with GPUs, but the trained ML inference can run on the CPU of a standard Industrial PC (IPC) from Beckhoff. Three inference engines are available from Beckhoff:

  • TwinCAT 3 Machine Learning Inference Engine enables classic ML algorithms, such as support vector machine (SVM), principal component analysis (PCA) and several others.

  • TwinCAT 3 Neural Network Inference Engine supports deep learning and neural networks, such as multilayer perceptrons (MLPs) and convolutional neural networks (CNNs).

  • TwinCAT Machine Learning Server provides a near real-time inference engine with greater flexibility to meet the growing requirements of complex ML or deep learning applications utilizing parallel CPUs or variety of GPU hardware.

Situated in the machine control environment, the inference has access to all synchronous data and fieldbus nodes. This allows it to make predictions based on the model, leading to better outcomes.


This approach also leads to a virtuous cycle of improvement. The controller can collect data and send it to a central PC with GPUs or up to the cloud. Using the data from one or more 3D printers, the model can be retrained on a regular basis. The refined ML inference can then be automatically deployed back to the IPCs on the machine, even taking effect on the next cycle. This helps ensure that a machine won’t run for several hours just to mess up a part in the last few minutes. And this approach is only possible with a fully integrated solution, like TwinCAT Machine Learning.



Are there alternatives to AI for smaller projects?


In some cases, training and running an ML inference may seem excessive. But engineers may still want to optimize their additive manufacturing machines with advanced algorithms. Fortunately, the open TwinCAT automation platform allows engineers to create custom algorithms in C, C++, JavaScript, etc. It also incorporates tools like MATLAB/Simulink, which enable simple implementation of simulation to enhance machine operation.


Sometimes the 3D printing and other applications require complicated algorithms that are difficult to write. MATLAB/Simulink can empower engineers with an advanced toolbox of preconfigured objects to design the algorithms more graphically. As such, you can create algorithms to solve problems and then implement the machine control using the MATLAB/Simulink target for TwinCAT. One example might be a powerful and complex temperature controller specific to advanced additive process. These tools can refine control processes to a certain degree, but the next step beyond those algorithms is a full ML implementation.


Careful evaluation will show whether an application is a good fit for ML. The decision largely depends on what data you can collect and label, and whether the machine and its mechanics can truly make changes on the fly to improve quality. However, don’t be afraid to get started on an ML project ‒ for additive manufacturing and beyond, designing industrial equipment to include deep learning is not a far-off concept. ML is here now, and like a 3D printer putting down layer upon layer, it continues to grow with each new success.


Interested in implementing AI technologies in industrial automation? Download our technical whitepaper on the topic below to learn more.



 

Paxton Shantz is the Digital Manufacturing Industry Manager for Beckhoff Automation LLC.

bottom of page