# PLC as the Main Controller for Additive Manufacturing Machines

Marcosiris Oliveira Pessoa, Gerson Silva, Paulo Eigi Miyagi, Ahmad Barari, Marcos Tsuzuki

► To cite this version:

Marcosiris Oliveira Pessoa, Gerson Silva, Paulo Eigi Miyagi, Ahmad Barari, Marcos Tsuzuki. PLC as the Main Controller for Additive Manufacturing Machines. 13th Doctoral Conference on Computing, Electrical and Industrial Systems (DoCEIS), Jun 2022, Caparica, Portugal. pp.217-224, 10.1007/978-3-031-07520-9_20. [https://inria.hal.science/hal-04308397](https://inria.hal.science/hal-04308397)

HAL Id: hal-04308397

https://inria.hal.science/hal-04308397v1

Submitted on 27 Nov 2023

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons CC BY 4.0 - Attribution - International License
<figure><img src="image_2.png" /></figure>

ifip

International Federation for Information Processing

This document is the original author manuscript of a paper submitted to an IFIP
conference proceedings or other IFIP publication by Springer Nature. As such, there
may be some differences in the official published version of the paper. Such
differences, if any, are usually due to reformatting during preparation for publication or
minor corrections made by the author(s) during final proofreading of the publication
manuscript.
# PLC as the Main Controller for Additive
Manufacturing Machines

Gerson Fabio da Silva ¹, Marcosiris Amorim de Oliveira Pessoa ¹,
Paulo Eigi Miyagi ¹, Ahmad Barari ² and Marcos Sales Guerra Tsuzuki ¹

¹ Department of Mechatronics and Mechanical Systems Engineering,
Escola Politécnica da Universidade de São Paulo, Av. Prof. Mello Moraes, 2231
CEP 05508-030 – São Paulo – SP – Brasil

² Department of Mechanical and Manufacturing Engineering, Ontario Tech University, 2000
Simcoe Street North, Oshawa, Ontario L1G 0C5, Canada

{gerson.fabio, marcosiris, pemiyagi, mtsuzuki}@usp.br
ahmad.barari@ontariotechu.ca

**Abstract.** Additive manufacturing (AM) is the process of manufacturing a physical object, layer by layer, from a 3D digital model. Despite the advantages of using this technology, its adoption, especially by users with fewer resources, is still limited by the high cost of machines, raw materials, and the complexity of the process. To make this technology more accessible, increasing the cost-effectiveness of the machines, this work analyzes the feasibility of using a single programmable logic controller (PLC) as the main controller of an additive manufacturing machine, as an alternative to the CNC and PLC structure used in most of the applications of this type. Through a PLC programming structure, it was possible to load an instruction file in G code generated by a market slicer program, convert it into axis position commands, and verify that the deposition trajectory was executed.

**Keywords:** Additive manufacturing, Fused filament fabrication, Wire arc additive manufacturing, Direct energy deposition, PLC, Position axis control, industry 4.0.

## 1 Introduction

Additive manufacturing is a building process that consists of producing parts from a 3D digital model, progressively adding thin layers of raw material [1-4]. There are seven types of technologies that employ the concept of additive manufacturing [4], and among them are material extrusion (MEX), which is the process in which the material is selectively dispensed through a nozzle or orifice, and directed energy deposition (DED), where a source of thermal energy is used to fuse the material, melting it as it is deposited [5,6]. In both processes, the layer deposition trajectory is controlled by mechatronic systems that can be machines equipped with dedicated boards or with a computerized numerical controller (CNC) that, from a sequence of commands, provides simultaneous control of machine axes, resulting in the trajectory in a three-dimensional Cartesian plane [7]. This system approach has been widely
adopted on machines utilized in conventional production processes for a long time. Another device typically used with CNC is the programmable logic controller (PLC).

PLC is a universal microprocessor-based device designed to control the operation of various machines, devices, or process lines. Its cyclic program memory circuit is a characteristic that distinguishes it from other computer-based controllers [8, 9]. With the advancement of technology, PLCs began to integrate axis positioning control functionality through sophisticated control loops, making it possible to create applications that involve more flexible motion control. Furthermore, they have a high degree of connectivity with other devices, being able to use different communication protocols, allowing their use in automation and modularized control systems capable of making data available through a local or global network, making them a fundamental device for the implementation of the concept of industry 4.0 in industries [10].

This work analyzes the feasibility of using PLC as an alternative to CNC to generate and control the trajectory of the layer deposition in an additive manufacturing machine, MEX or DED type, and, in an integrated way, to control all the intrinsic aspects of the process. This work is organized as follows: Section 2 relates this work with the context of technological innovation for digitalization and virtualization; Section 3 presents the necessary system hardware and software architecture to make the tests; Section 4 presents the methodology used in the tests, and the last section discusses the results and the future research directions.

## 2 Contribution to Technological Innovation for Digitalization and Virtualization

The entire additive manufacturing process, whether for the construction of a simple prototype or a part with highly complex geometry, necessarily starts from the part's digital model. It is not possible to think of additive manufacturing without digitalization. Another critical point is that the processes are complex. They require a high degree of knowledge as there are an infinity of parameters to be adjusted to produce the part correctly, which demands time and cost in its development. Therefore, virtualization tools, such as the digital twin that allows manufacturers to make more accurate predictions, rational decisions, and informed plans [11-13], are being increasingly used to validate production parameters, thus reducing the time and costs associated with a trial-and-error process in the physical process. The use of the PLC as a single controller of an additive manufacturing machine allows, in addition to greater flexibility and modularization of the application, the integration and virtualization of the entire manufacturing process; they are the fundamentals of Industry 4.0 [14-16]. In addition, the constant growth of competitiveness in the market has led industries to a continuous process of adaptation to remain competitive. Despite additive manufacturing being a disruptive technology that has caused a paradigm shift in production processes, its access is still restricted to large companies, partly due to the high costs of implementing this technology and partly due to the shortage of skilled labor. Using the machine approach with a single PLC as a controller reduces machine costs, allowing the generalization of the application, its
development, and sharing, making it increasingly possible for smaller companies to digitize their processes and maintain a competitive position in the market.

## 3 System Architecture

The additive manufacturing process consists of well-defined steps and is common to all technologies used. The first step is to model the part produced using computer-aided design CAD software [17], thus generating a 3D digital file. Typically, additive manufacturing machine builders provide the manufacturing process parameterization software that slices the model and generates another file with a sequence of instructions encoded in a language known as G-code [18], specifying how the movement of the machine axes should be to perform the layer deposition trajectory. After its production, the part will be removed and can go through a post-processing process, which can be the removal of building support, a heat treatment, or a polishing. Finally, the part is inspected for verification of its geometric characteristics. Computerized Numerical Control can easily interpret the instructions from a G-code file as it is a native language for it. However, to use this file in a PLC, a whole programming structure must be developed. The structure proposed (see Fig. 1) must be able to load the file, check its consistency, interpret it, and convert the instructions into axis movement commands.

<figure><img src="image_3.png" /><figcaption>Fig. 1. System architecture proposed of a PLC as a controller for additive manufacturing machines.</figcaption></figure>

Another important point is that the CNC is natively capable of converting a positioning instruction in the Cartesian plane, such as linear interpolation, into coordinated and synchronous movements of electric motors. In other words, it is enough to configure the type of kinematics that will be used, and the CNC cyclically calculates what the movement in revolutions per minute of the electric motors connected to each axis should be for the interpolation to be performed. The entire
transform calculation must be carried out through the user program if the used PLC
does not have this functionality integrated into its system.

**3.1 Hardware**

To use a PLC as a controller of an additive manufacturing machine, hardware and software architecture will be presented. For the hardware architecture, the PLC needs to have a communication interface (ethernet, OPC UA, etc.) that allows loading the file in G-code from an external device (personal computer via local or global network) to a memory area and that allows it to be accessed by the user program that is running. It can also be checked the possibility of using a physical port such as USB or SD card to transfer the file to the PLC's internal memory. Another characteristic that the PLC must have is the ability to establish a closed control loop with the drive unit, responsible for moving the axes motors, through well-defined communication protocols. For the positioning control loop to be as precise as possible, it is essential that the PLC supports an isochronous real-time (IRT) communication protocol with the drive system [19].

**3.2 Software**

As PLCs do not have a system architecture prepared for reading and executing G-
code language instructions, all steps, from reading the file to the commands for the
axes, must be developed via a user program. For the tests carried out, a modularized
structure was adopted for the user program, with specific functions for each step of
the application process. The language used for the program development is the
structured control Language (SCL), which is a high-level textual programming
language based on PASCAL and conforms to DIN EN-61131-3 (IEC 61131-3).

**LoadFile** The G-code file generated by the slicer must be loaded into a memory area of the PLC. The LoadFile function should allow this file to be loaded, access its content, and sequentially fill a buffer of instructions. Each instruction line in the file, also known as instruction blocks, defines the characteristics of the point's trajectory in a three-dimensional Cartesian plane, such as the final coordinate of the trajectory, velocity, and acceleration. In addition, other commands can be configured to perform some functions on the machine, such as activating the laser and turning on the vacuum pump. Each of these commands must have its respective logic implemented in the user program.

**InstructionBuffer** This part of the architecture refers to the memory area where each command line will be stored. An array of type String can be used to store the instructions. G-code files for additive manufacturing applications usually have thousands of instruction lines. Each line corresponds to a small path that makes up the layer profile and that makes up a set of many layers that will form the final part. Therefore, it becomes prohibitive to try to use a fixed size of memory to store all the instruction lines of the G-code file. A buffer must be created with a reasonable
number of elements. Each instruction that has already been executed must be removed
from the buffer to make room for a new.

**Conversion** The biggest challenge of this application is the conversion of instructions in string format for the positioning commands intrinsic to the PLC firmware. First, we must interpret each command line in the instruction buffer and identify which PLC command the instruction refers to. Then this command must be inserted into a sequential list of commands that the PLC executes and monitors. Once command execution begins, there must be mechanisms in the system that allow monitoring this execution to determine when the following command can be executed or if there was a problem and the movement had to be stopped.

**Path Commands Buffer** Refers to the memory area where motion commands interpreted by the conversion function will be stored and executed sequentially (FIFO).

**Axes Movement Commands** The movement commands stored in the command buffer will be sequentially executed, and the movement state monitored in this function. The library used for axis control functions, such as axis enable, reference, absolute positioning, linear interpolation, etc., is based on PCLopen Motion Control Function blocks standardization that standardizes application libraries for a wide variety of different PLCs [20].

**Kinematic Model** This structure item refers to the mathematical model that represents the kinematics of the machine. It is responsible for receiving the axes positioning and movement commands based on a three-dimensional Cartesian system and converting them into movements of the electric motors so that the specified trajectory is performed because of the coordinated and synchronized movement of the set of engines. Some PLCs come with this model integrated into their system (see Fig. 2); it is ready and is only necessary to configure the desired mechanical system. Otherwise, it must be implemented via a user program, which can considerably increase the complexity of the application.

<figure><img src="image_4.png" /><figcaption>Fig. 2. Siemens PLC S7 1500T integrated Roller Picker 3D kinematic model.</figcaption></figure>
## 4 Method

To verify the feasibility of using PLC as the central controller of an additive manufacturing machine, a Siemens S7 1500T PLC will be used together with TIA Portal V17, an engineering platform for the configuration and parameterization of devices and software development for automation systems. For the application simulation, the software S7-PLCSim Advanced 4.0 will be used, which allows the simulation of the PLC programs in a virtual controller. For the software structure, a library available for this specific PLC model and developed primarily for machine tools will be used, with some adaptation, to carry out the tests.

The first step in the process is to digitally model the part to be produced. A digital model of a piece made available as an open source was chosen. The extension of the model file is of type stl, which is an extension widely used in additive manufacturing processes and has the representation of the surface of the digital model in a mesh of small triangles [21].

As a slicer, the Ultimaker Cura software was used, which is also an open-source project. In this software, the digital model file was loaded and, with the basic parameter settings, the file with the instructions in G-code was generated [22]. The file was transferred from the PC to the nonvolatile PLC memory accessing the internal PLC web server through the Ethernet protocol.

The S7-1500T PLC series uses the concept of "technology objects" (TO) in motion control and industrial automation applications (see Fig.3). TOs are programming units that create an interface between the various elements of the machine and the user program. They are independent objects with their own parameters. For an additive manufacturing machine based on a Cartesian system application, synchronous axis technology objects were created and configured with respect to the synchronized axes of the plane, X, Y, and Z, and connected to the kinematic model technology object.

A library available for applications that use this type of PLC with machine tools will be used for control software, which should be adapted to work as an additive manufacturing application. In addition, relevant logic must be implemented with respect to other intrinsic functions of this application.

<figure><img src="image_5.png" /><figcaption>Fig. 3. Axes and kinematic model technology objects configuration.</figcaption></figure>
# 5 Results and Conclusion

The proposed structure was commissioned and tested entirely in a virtualized way through the PLCSIM Advanced software that creates an instance of a virtual network card on the PC, allowing the TIA Portal development software to connect to the controller's virtual CPU through an IP address. The PLC's internal webserver was enabled and accessed via a web browser to load the G-code file into the PLC's virtual non-volatile memory.

The first observation is regarding the available memory size for storing the G-code file on the PLC, which must be sufficient to store large files. The file generated by the slicer needed to be manipulated. Some commands generated by the slicer software, Ultimaker Cura 3D, were removed or ignored when interpreting the code by the library functions because they were not applicable to a DED or FFF industrial additive manufacturing application. The positioning commands described by the G-code program were all interpreted and executed by the application, resulting in the expected trajectory of each layer. Through the trace tool integrated into the Tia Portal V17 platform and real-time position monitoring of the X, Y, and Z axes, it was possible to confirm the coordinated movement of the axes of the mechanical model faithfully representing the instructions generated by the slicer. Therefore, we conclude that the proposed software and hardware structure can be used to control the axes of an additive manufacturing machine.

As future work, a specific additive manufacturing application library will be developed in order to leverage the PLC programming flexibility, its hardware connectivity, and its integration capacity with both IIoT and cloud systems, which means a library that allows the machine to connect to a computing edge device, which can process the g code conversion algorithm saving PLC processor resources, and to connect directly to a cloud platform to share data generated from the process. A digital twin will also be implemented to interact with the application to enhance the tests, provide a better understanding of the axis's dynamics, and to make possible the integration and tests of new functionalities.

**Acknowledgments.** The authors would like to thank the Brazilian governmental agencies CAPES, CNPq and FAPESP, and Siemens Infraestrutura e Indústria for their partial support of this work.

# References

1. A. C. Brown and D. De Beer, "Development of a stereolithography (stl) slicing and g-code generation algorithm for an entry level 3-d printer," in 2013 Africon, pp. 1-5, IEEE, 2013.

2. T. DebRoy, H. L. Wei, J. S. Zuback, T. Mukherjee, J. W. Elmer, J. O. Milewski, A. M. Beese, A. Wilson-Heid, A. De, and W. Zhang, "Additive manufacturing of metallic components - process, structure and properties," Progress in Materials Science, vol. 92, pp. 112-224, 2018.
3. J. Oliveira, T. Santos, and R. Miranda, "Revisiting fundamental welding concepts to improve additive manufacturing: from theory to practice," *Progress in Materials Science*, vol. 107, p. 100590, 2020.

4. C. Wang, X. Tan, S. Tor, and C. Lim, "Machine learning in additive manufacturing: State-of-the-art and perspectives," *Additive Manufacturing*, vol. 36, p. 101538, 2020.

5. J. Gardan, "Additive manufacturing technologies: state of the art and trends," *International Journal of Production Research*, vol. 54, no. 10, pp. 3118-3132, 2016.

6. A. Standard et al., "Standard terminology for additive manufacturing technologies," *ASTM International F2792-12a*, 2012.

7. T. K. Nguyen, L. X. Phung, and N.-T. Bui, "Novel integration of capp in a gcode generation module using macro programming for cnc application," *Machines*, vol. 8, no. 4, p. 61, 2020.

8. A. Rullan, "Programmable logic controllers versus personal computers for process control," *Computers & industrial engineering*, vol. 33, no. 1-2, pp. 421-424, 1997.

9. M. M. Barkalov A., Titarenko L., "Priogrammable logic controllers," *Foundations of Embedded Systems. Studies in Systems, Decision and Control*, vol. 195, pp. 145-162, 2019.

10. J. Langmann and L. F. Rojas-Pena, "A plc as an industry 4.0 component," in 201613th International Conference on Remote Engineering and Virtual Instrumentation (REV), pp. 10-15, 2016.

11. A. Fuller, Z. Fan, C. Day, and C. Barlow, "Digital twin: Enabling technologies, challenges and open research," *IEEE access*, vol. 8, pp. 108952-108971, 2020.

12. F. Tao, H. Zhang, A. Liu, and A. Y. Nee, "Digital twin in industry: State-of-the-art," *IEEE Transactions on Industrial Informatics*, vol. 15, no. 4, pp. 2405-2415, 2018.

13. Y. Wei, T. Hu, Y. Wang, S. Wei, and W. Luo, "Implementation strategy of physical entity for manufacturing system digital twin," *Robotics and Computer Integrated Manufacturing*, vol. 73, p. 102259, 2022.

14. G. Culot, G. Orzes, M. Sartor, and G. Nassimbeni, "The future of manufacturing: A delphi-based scenario analysis on industry 4.0," *Technological forecasting and social change*, vol. 157, p. 120092, 2020.

15. A. Jandyal, I. Chaturvedi, I. Wazir, A. Raina, and M. I. U. Haq, "3d printing-a review of processes, materials and applications in industry 4.0," *Sustainable Operations and Computers*, vol. 3, pp. 33-42, 2022.

16. E. Oztemel and S. Gursev, "Literature review of industry 4.0 and related technologies," *Journal of Intelligent Manufacturing*, vol. 31, no. 1, pp. 127-182, 2020.

17. M. Iqbal and M. S. Hashmi, "Design and analysis of a virtual factory layout," *Journal of Materials Processing Technology*, vol. 118, no. 1-3, pp. 403-410, 2001.

18. H. S. Shin, H. I. Lee, and E. S. Jang, "An effective data structure for a 3d printing slicer api," in *2016 IEEE International Conference on Consumer Electronics-Asia (ICCE-Asia)*, pp. 1-4, IEEE, 2016.

19. G. Berardinelli, N. H. Mahmood, I. Rodriguez, and P. Mogensen, "Beyond 5g ireless irt for industry 4.0: Design principles and spectrum aspects," in *2018 IEEE Globecom Workshops (GC Wkshps)*, pp. 1-6, IEEE, 2018.

20. J. Contreras, J. Rubio, and A. Martínez, "Plc based control of robots using plcopen motion control specifications," in *Advances in Automation and Robotics Research (H. A. Moreno, I. G. Carrera, R. A. Ramírez-Mendoza, J. Baca, and I. A. Banfield, eds.), (Cham)*, pp. 109-120, Springer International Publishing, 2022.

21. M. Szilási-Nagy and G. Matyasi, "Analysis of stl files," *Mathematical and computer modelling*, vol. 38, no. 7-9, pp. 945-960, 2003.

22. M. Wüthrich, M. Gubser, W. J. Elspass, and C. Jaeger, "A novel slicing strategy to print overhangs without support material," *Applied Sciences*, vol. 11, no. 18, p. 8760, 2021.