Closed-Loop Control of 3D Printers via Web Services Felix W. Baumann1 and Dieter Roller1 University of Stuttgart, Stuttgart BW 70569, Germany, felix.baumann@informatik.uni-stuttgart.de Abstract. In this work, we present a method to directly control an ex- isting 3D printer with a retrofittable device and communication to and from an online service. The control is exerted utilizing calls to a RESTful API that provides functionality for an online 3D printing service. The di- rect control of the hardware aims to alleviate problems with the printing process and a fine grained control for a high-quality printed object. The system relies on online data acquisition for which this work provides an implementation based on previous work and extended to a custom made sensor node. Keywords: 3D Printing, Additive Manufacturing, Online Service, Hard- ware Control 1 Introduction 3D printing or synonymously Additive Manufacturing (AM) describes the cre- ation of physical objects from digital models [9]. The creation of the objects is tool-free and based on the geometrical information from the digital models. 3D printed objects are created using a range of different technologies and ma- terials [12, 15]. For consumer-grade 3D printers the material commonly used is either Acrylonitrile butadiene styrene (ABS) or polylactic acid (PLA), both are thermoplastics, that are heated above the glass transition temperature, so that the plastic is soft and extrudable. The heated thermoplastic is extruded through a nozzle onto the print-bed or a previous layer of the object, where it solidifies by cooling. This technology is called Fused Deposition Modeling (FDM) or Fused Filament Fabrication (FFF) [7]. With this technology, as with most other tech- nologies, the object is created in a layer-wise fashion, with the material being deposited at specific places that are defined in the machine code. Other tech- nologies include the sintering of metal powder (Direct Laser Sintering) using a laser beam for the creation of metal or ceramic objects. 3D printers for the con- sumer market are open-loop controlled which means that there is no feedback within the machine on the current operating status. This lack of direct control can lead to errors and misprints caused by external or internal factors. As an example, vibration from the machine itself or from external sources, can cause the object to detach, causing a failed print. In an error scenario, the 3D printer is occupied for the duration of the 3D print, without producing the requested O. Kopp, J. Lenhard, C. Pautasso (Eds.): 9th ZEUS Workshop, ZEUS 2017, Lugano, Switzerland, 13-14 February 2017, published at http://ceur-ws.org/ Closed-Loop Control of 3D Printers via WebServices 45 resulting object, thus blocking the 3D printer itself and wasting material, both the filament and the 3D printer internal components that are specified as usable for a limited and specific amoutn of time. A number of error states are char- acterised by a build up phase where the fault is not permanent but will be if unadjusted. With this research we include sensors for vibration and acoustics in order to detect such faulty states early. The system we propose is backed by an online 3D printing service, based on previously published works, that features a RESTful API. It is elaborated on the timing requirements as well as required latency for the early detection of faulty states, and the adaption and correction of machine instructions. This work is describing the service requirements for an extension of a service to extend and interface with real-world devices, thus forming a Cyber-physical system (CPS). The scope of this work is to define the requirements and architectural decisions for such a CPS to control an existing 3D printer via an external, remote service in a closed-loop control manner. Fur- thermore, this proposed system is not limited to 3D printing but can be utilised in the remote monitoring and control of other hardware, such as CNC or milling machines, where sensorial output can be acquired and the control is possible through computerised systems. Remote monitoring and control capabilities are also integral concepts for Industry 4.0 scenerios. In the current state, no internal models of the 3D printing process exist for this work. The intention is to com- pensate for errors that are resulting from exessive vibration of the 3D printer, thus allowing for better quality results and reduced power motors thus saving money and extending the service life time of 3D printers. 2 Related Work The work by Lotrakul et al. [10] explores the possibility of state and fault detec- tion in AM utilizing acoustic emissions. The authors were able to both detect filament supply loss and nozzle clogging in their experiment. The information available through acoustic analysis is further presented in the work by Song et al. [11] where the authors describe a side-channel attack on the intellectual property during the printing process. In contrast to the proposed closed-loop system by Weiss in his master the- sis [13] and the corresponding article [14] where the control is directly interfacing with the motor control, this system will not alter the motor control but will in- terface through the exposed firmware of the 3D printer that accepts machine commands through a USB-serial interface. The necessity for an improved pro- cess supervision and control is presented in the work by Blandon et al. [6]. In this work the authors presented a list of potential challenges and problems that can occur during the 3D printing process. The authors Faes et al. [8] present an alternative monitoring strategy for AM utilizing laser scanning. Their work is focussed on the monitoring of process properties, whereas the following work by Xiong et al. [16] is focussed on the control strategy. 46 Felix Baumann et al. In Xiong et al. [16] the authors present a closed-loop control system for wire and arc AM (WAAM), based on an artificial neural network. Existing proposals for direct-control of 3D printing hardware is focused on the direct integration of closed-loop control systems within the 3D printer, re- spectively the firmware. The system proposed in this work, on the other hand, utilises an external service for the control component. This externalisation brings benefits such as flexibility and extensibility at the drawback of latency and the strict requirement of availability of or connectability to remote components. 3 Proposal The system described within this work is based on three components: 1. Sensor Node 2. 3D Printer Adaptor and 3. Printing Service. The sensor nodes are based on custom built PCBs (Printed circuit board) with a STM32F072C81 MCU (Microcontroller unit), a MPU92502 IMU (Inertial measurement unit) and a SPU0410HR5H-PB3 microphone. The sensor nodes are extensions to previous works presented in [2, 4]. The algorithms for the analysis and evaluation of the sensor data is implemented in the cloud printing service, presented in [1, 5], as a service component that is exposed through the service API and offers RESTful endpoints to the internet. See Figure 1 for the communication flow between the individual components during printing. In this figure, the adaptor and the PrintingService are divided by the Internet, and the User is also divided by the Internet from the PrintingService. The SensorNode is directly attached to a 3D printer and acquires data throughout the 3D printing process. A configurable number of SensorNodes is attached to and controlled by a computer system titled Adaptor which communicates with the 3D printer and the PrintingService. The PrintingService is equipped with a model of the expected behaviour of the 3D printing process against which the acquired sensor data is checked. These models are specific to a 3D printer and are to be generated through observation or simulation. Preliminary calculations on the speed and latency requirements are based on the experiment conducted in Baumann et al. [3]. In this experiment, 121 specimens were printed using an FDM 3D printer (Makerbot Replicator 2X ) and the executions were captured and analysed. The objects are of different shape and size. From the actual printing time, it was found that the average movements involving the X-axis were 7.25 per second and 8.57 per second for the Y-axis. The average distance travelled by the printhead involving the X- axis is 23.42 mms and 21.95 mm/s for movements involving the Y-axis. From these numbers, it can be calculated that the average time for any instruction involving the X-axis is 0.16 s and 0.14 s respectively. In order to provide rapid interaction with the printing process the lower number of 0.14 s is the hard limit 1 http://www.st.com/en/microcontrollers/stm32f072c8.html 2 https://www.invensense.com/products/motion-tracking/9-axis/mpu-9250/ 3 http://www.knowles.com/eng/content/download/5754/91789/version/3/file/ SPU0410HR5H-PB+revH.PDF Closed-Loop Control of 3D Printers via WebServices 47 Fig. 1. Component Communication Flow User PrintingService Adaptor 3DPrinter SensorNode Start print Instruct for print start Issue start command (Machine code for object) Issue start command for data acquisition loop Submit sensor readings Process and evaluate sensor data against internal model Update on process opt [onFault] Issue corrective machine code instruction Issue warning to user opt [onPersistanceOfFault:] Instruct abort command Issue abort command Inform on abort Inform on completion Instruct halt on data collection Inform on completion status Update status in which the sensor data acquisition, data transmission, analysis, correction and instruction re-transmission must occur, i. e., one round-trip. This is estimated so that only one instruction will be performed without correction thus limiting potential damage and increasing the chance to recover or compensate. With an assumed sensor data acquisition frequency of 400 Hz the data trans- mission must occur in bundles of less than 56 measurements to stay under the hard threshold given above. As the transmission in bundles versus single data transmission is a tradeoff between latency and transmission volume the following bundle sizes are tested: 10, 20, 30 and 40 measurements per data submission. An experiment is conducted in two locations for two application scenarios. The first scenario is the deployment within a university and the second is the deploy- ment with a customer connected to the Internet using a DSL (Digital Subscriber Line) connection. From preliminary experiments a clear discrepancy between the latency of these two locations is evident, see Table 1. In the following Table 1, the latency to a number of Internet hosts is listed. Hosts A through C are on the local network α and hosts D through F on the local network β. The roundtrip time listed is achieved for ICMP requests to the respective hosts and used to demonstrate the potential problems for the proposed service, based on the available Internet connection. The hosts tested 48 Felix Baumann et al. are selected arbitrarilly and can be regarded as prototypical connections to and from universities, inter-corporation connection, local and overseas connections. Table 1. Roundtrip Times in ms from Locations Connected to the Internet using a DSL and a 10G Ethernet connection DSL/Network α 10/100 GE/Network β Host rtt rtt min avg max min avg max heise.de 19.975 20.665 21.692 4.335 4.455 4.691 uni-stuttgart.de 31.235 31.912 32.759 0.343 0.396 0.436 fh-esslingen.de 31.75 32.34 33.116 0.734 0.877 1.083 kit.edu 41.003 42.113 51.259 2.563 2.711 4.425 Host A 1.324 1.545 1.930 Host B 4.081 5.134 14.389 Host C 2.100 2.725 5.171 1und1.de 19.974 20.42 21.281 3.831 3.868 3.901 acm.org 106.608 108.572 117.772 84.561 84.959 87.13 Host D 0.189 0.229 0.314 Host E 0.130 0.251 0.400 Host F 0.221 0.353 0.559 mashup.inf.unisi.ch 24.107 25.033 77.941 6.874 7.022 7.210 Average 29.0459 10.5121 The required data rates vary for the sensornode configurations and the amount of sensornodes. Exemplary it can be defined, that the throughput must at least be sufficient to stream from three sensornodes with three sensors each (acceler- ation, temperature, gyroscope) at a data acquisition rate of 400 Hz per sensor. For this scenario, the raw data to be transported is 49.2 Kib/s, as the accelera- tion and gyroscope report data on three axis each and each sensor value is of 16 bit size. This throughput is calculated without protocol overhead and assumed package loss. 4 Benefits and Drawbacks With the proposed system, the extension of the closed-loop control capability on new 3D printers is enabled without the requirement to change the firmware of the respective 3D printer or the alterations in hardware besides the addition of the sensornodes. Different 3D printing mode models can be implemented in the service and selected by the user as per his requirement. The modes can differ in the fault tolerance or achievable 3D print quality. As a drawback of the proposed system, the constant and uninterupted Internet connectivity is stated. This connection must be capable to provide high-throughput and low latency as per the requirements stated. These requirements can vary for sensornode configurations. Closed-Loop Control of 3D Printers via WebServices 49 5 Conclusion This work analyses the time available for each component respective transmis- sion sequence of information so that the hard threshold is not exceeded. With this approach provided, it is possible to provide closed-loop control of existing 3D printers, by the utilisation of a remote service. Potential benefits, such as ex- tensibility and flexibility for the addition of new 3D printers, is discussed as well as the drawbacks of requiring constant and uninterupted Internet connectitvity. The work presented in this paper is still in progress and requires the extended implementation and evaluation of the proposed service and adaptor to generate the required models of the 3D printing process per individual 3D printer. References 1. Baumann, F., Eichhoff, J., Roller, D.: Collaborative Cloud Printing Service, pp. 77–85. Springer International Publishing (2016), http://dx.doi.org/10.1007/ 978-3-319-46771-9_10 2. Baumann, F., Schön, M., Eichhoff, J., Roller, D.: Concept Development of a Sensor Array for 3D Printer. In: Procedia CIRP, 3rd ICRM 2016 International Conference on Ramp-Up Management. vol. 51, pp. 24–31 (2016), http://dx.doi.org/10. 1016/j.procir.2016.05.041 3. Baumann, F., Straßer, S., Roller, D.: Free complexity in additive manufacturing?! a study in fused deposition modeling. 3D-Printed Materials and Systems (2017), in preparation 4. Baumann, F.W., Eichhoff, J.R., Roller, D., Schön, M.: Sensors on 3D Printers for Cloud Printing Service. In: Proceedings of the 2016 International Conference on Advanced Material Science and Mechanical Engineering (March 2016), http: //www.amsme2016.org/sub.htm 5. Baumann, F.W., Kopp, O., Roller, D.: Abstract api for 3d printing hardware and software resources. International Journal of Advanced Manufacturing Technology (2016), submitted - Under Review 6. Blandon, S., Amaya, J.C., Rojas, A.J.: Development of a 3d printer and a super- vision system towards the improvement of physical properties and surface finish of the printed parts. In: 2015 IEEE 2nd Colombian Conference on Automatic Control (CCAC). pp. 1–7 (10 2015), http://dx.doi.org/10.1109/CCAC.2015.7345179 7. Bonten, C.: Kunststofftechnik. Carl Hanser Verlag GmbH & Co. KG (2014), http: //www.hanser-fachbuch.de/buch/Kunststofftechnik/9783446440937 8. Faes, M., Abbeloos, W., Vogeler, F., Valkenaers, H., Coppens, K., Goedemé, T., Ferraris, E.: Process monitoring of extrusion based 3d printing via laser scanning. In: Proceedings of the International Conference on Polymers and Moulds Innova- tions (PMI). vol. 6, pp. 363–367 (2014), https://lirias.kuleuven.be/handle/ 123456789/451935 9. Gibson, I., Rosen, D., Stucker, B.: Additive Manufacturing Technologies - 3D Print- ing, Rapid Prototyping, and Direct Digital Manufacturing. Springer New York, 2 edn. (2015), http://dx.doi.org/10.1007/978-1-4939-2113-3 10. Lotrakul, P., San-Um, W., Takahashi, M.: The Monitoring of Three-Dimensional Printer Filament Feeding Process Using an Acoustic Emission Sensor, pp. 499–511. Springer Singapore, Singapore (2017), http://dx.doi.org/10.1007/ 978-981-10-0471-1_34 50 Felix Baumann et al. 11. Song, C., Lin, F., Ba, Z., Ren, K., Zhou, C., Xu, W.: My Smartphone Knows What You Print: Exploring Smartphone-based Side-channel Attacks Against 3D Print- ers. In: Proceedings of the 2016 ACM SIGSAC Conference on Computer and Com- munications Security. pp. 895–907. CCS ’16, ACM, New York, NY, USA (2016), http://dx.doi.org/10.1145/2976749.2978300 12. Turner, B.N., Strong, R., Gold, S.A.: A review of melt extrusion additive man- ufacturing processes: I. Process design and modeling. Rapid Prototyping Journal 20(3), 192–204 (2014), http://dx.doi.org/10.1108/RPJ-01-2013-0012 13. Weiss, B.: Closed-Loop Control of a 3D Printer Gantry. Master’s thesis, University of Washington (10 2014), http://hdl.handle.net/1773/26048 14. Weiss, B., Storti, D.W., Ganter, M.A.: Low-cost closed-loop control of a 3d printer gantry. Rapid Prototyping Journal 21(5), 482–490 (2015), http://dx.doi.org/ 10.1108/RPJ-09-2014-0108 15. Wong, K.V., Hernandez, A.: A review of additive manufacturing. ISRN Mechanical Engineering 2012, 1–10 (2012), http://dx.doi.org/10.5402/2012/208760 16. Xiong, J., Yin, Z., Zhang, W.: Closed-loop control of variable layer width for thin- walled parts in wire and arc additive manufacturing. Journal of Materials Process- ing Technology 233, 100–106 (2016), http://dx.doi.org/10.1016/j.jmatprotec. 2016.02.021