1 Introduction

Additive manufacturing (AM) is now considered by many industries as an alternative to conventional techniques due to its ability to generate complex components in less time [1]. AM, as its name implies, employs a layered approach to material deposition, culminating in the creation of a three-dimensional object. Amongst the available AM techniques, material extrusion, or as it is more commonly known fused filament fabrication (FFF), is the most popular method for producing plastic parts due to its lower printing cost and ease of handling [2, 3]. However, the mechanical properties of FFF printed components do not compare favourably to those produced by conventional subtractive manufacturing [4] and this limits their use in high strength applications [5]. One of the key reasons for the inferior mechanical performance of FFF parts is the presence of voids between extruded paths caused by the local deviation or offset of the actual printed path from the ideal path [6, 7]. One such study has identified correlation between voids and effective modulus of printed parts. As voids increase, effective modulus decreases [8]. Direct correlation between deviation of print paths and mechanical performance has not yet been established. Although many previous studies have suggested print path deviation as the cause of these voids, no attempt has been made to characterise these deviations.

To characterise the deviation in the print path, insights may be taken from the field of continuous fibre composites, where such deviations are well explored [9,10,11]. Deviation in a continuous fibre composite is determined by two features, i.e. fibre tow centroid and width. Deviation in the centroid is referred to as waviness and deviation in the width is known as wrinkling [12, 13] (Fig. 1). The deviation in these two features along the length of the fibre cause micro-cracks in the matrix material and can degrade the strength of a composite structure [14]. On correlating the deviation in a FFF print path to the deviation in a fibre of a conventional composite, it can be proposed that the variation in centroid (waviness) and width (wrinkling) of the print path contributes to the formation of voids in the printed path (Fig. 1c), resulting in inferior mechanical performance. Deviation in 3D printed paths is defined as the difference between the actual filament print path and the ideal value that was sent to the printer by the user (in this case using G-code).

Fig. 1
figure 1

Deviation in a centroid (waviness), b width (wrinkling) along the length of fibres in a composite material, c wrinkling and waviness in PLA print path causing voids

It is proposed that the deviation in centroid and width of 3D printed paths comprises two elements: systematic deviation, which is defined as the mean deviation from the ideal, along a print path, across a sample, and stochastic deviation, which is random deviation within a single specimen. Adding these two elements to the ideal value gives the actual value of deviation [11]. Several studies used these deviation elements to regenerate a statistically meaningful virtual model for textile composites [15,16,17]. In [14], the stochastic and systematic deviations of the fibre tows in the textile composite were characterised by two statistical parameters: the root mean square deviation, which describes the spread of values around the mean, and a correlation length that expresses the distance at which these deviations persist. These studies used Markov chain Monte Carlo [18] approach to regenerate unique but statistically representative virtual geometries of the textile composite. These virtual geometries can then be used for structural analysis [19], probabilistic modelling [20] and topology optimisation.

To obtain these elements of deviation for FFF parts, dimensional data need to be extracted from images of the printed paths. As there has only been limited research to characterise FFF print paths, extraction techniques used for continuous fibre composites are adopted in this study. Several processes are available to determine the deviation in a fibre [21,22,23,24,25]. According to [26], the features of a fibre were extracted by first segmenting an image into square domains, each domain was then processed to separate the fibre from the image background. This was followed by detecting the features of the region covered by fibre in each domain. These processes can be automated and carried out at a much faster rate with the help of available software such as ImageJ [25]. Here, the microscopic or SEM image undergoes binarization such that the fibres are seen as white regions with a black background. This image is then divided into small segments and the white regions in each segment are analysed to determine features such as area, diameter and centroid [22, 23].

The studies above are presented for continuous fibre composites; however to date, no such investigation has been made for FFF printed components. Research into FFF so far has primarily been focused on the effects of FFF printing parameters [27] such as bed temperature [28], nozzle temperature [29], layer height [30], feed rate [31] and print speed [32, 33] on the mechanical performance of the printed specimen. Some studies have also shown SEM and optical microscopic images of the FFF printed path [34, 35], but none have attempted to characterise the microstructural deviation in the printed specimen with respect to these printing parameters.

In this study, a methodology is presented to characterise the deviation in print paths of FFF 3D printed PLA parts, including an investigation into the effect of the key printing parameters of speed and geometry. This methodology provides a step-by-step process that includes printing paths on a detachable print bed, capturing digital microscopic images, image processing and acquisition of deviation data. A range of geometric shapes are characterised including straight paths, 45°, 90° and 135° corners, and curves with varying radius, at different printing speeds.

The proposed methodology presents a novel approach to quantitatively assess print quality, opening up opportunities for printer maintenance scheduling and further considered for improvements in printer performance and design. This research will yield valuable deviation data, enabling the construction of statistically representative virtual models of 3D printed components, which can be used for probabilistic stress analysis under required loading conditions. These virtual models also offer potential for accurate and meaningful topology optimisation of printed components, ultimately leading to improved mechanical performance and cost reduction.

2 Methodology

2.1 Printer setup

The printer used for this study is a Geeetech A20T (Fig. 2a). Polylactic acid (PLA) is used as the printing material due to its popularity, widespread availability, biodegradable nature and ease of use [36]. Print paths were created using G-code, which gives direct control over print position, speed and temperature. Three stepper motors are used to move the print head in the X, Y and Z directions in minimum increments of 0.1 mm [37]. One motor is connected to the print bed to provide movement in the Y-direction and the other two motors move the print head in the X- and Z-directions, respectively. A detachable glass plate is set-up on top of the existing fixed print bed, which can be removed for microscopic analysis of the printed path. To ensure precise and repeatable positioning of the glass plate, an acrylic angle plate with securing clips is attached to the existing print bed. Optical microscopy of the printed paths is performed using an Alicona Infinitefocus microscope at 5X magnification, which gives a resolution of 410 nm [38, 39]

Fig. 2
figure 2

a Geeetech A20T printer and b detachable glass plate setup on existing print bed

To ensure a consistent reference origin for printing, three points are marked on the glass plate at a measured distance from the printer’s origin. The coordinates of these points are (60, 60), (60,120) and (120, 60) (see Fig. 2b). Before printing, the print head is instructed to travel to these three locations and checks are made to ensure the nozzle is positioned accurately. These points also act as a secondary coordinate system to provide a reference to all print paths after the glass bed is detached from the printer and help to align the glass bed in the microscope.

The microscopic image acquired in the previous step is then processed automatically using imageJ macros. Here, an image is converted into binary format (Fig. 3) through an auto thresholding method. Next, the print path is segmented into small domains of 0.1 mm length, which is the minimum distance the print head can move for this printer. The centroid and width of the print path within each segment are measured and analysed for different geometric features (i.e. straight paths, corners at 90°, 45° and 135°, and circles of 2, 4, 6 and 8 mm radius).

Fig. 3
figure 3

Binarification of microscopic image followed by segmentation into domains

2.2 Image processing and characterisation

The deviation in the printed path is characterised as the distance between the actual print path and the ideal or user-specified path. In previous research on continuous fibre composites, characterisation of deviation in fibre tow paths is based on how far each individual fibre tow deviates from the mean position of all fibre tows [11]. However, in the case of AM, the component is manufactured based on known ideal print paths specified by the user.

The total deviation is separated into systematic and stochastic deviation elements. The actual deviation (\({\varvec{\varepsilon}}\)) from the ideal path at any point is expressed as the sum of the mean systematic (\(\overline{{\varvec{\rho}} }\)) and stochastic deviation (\({\varvec{\sigma}}\)) (Eq. 1). Suppose there are N specimens in the sample dataset and each specimen has n number of data points, then the ith data point along the length of the jth specimen is given by \(({\varvec{i}},{\varvec{j}})\) and the coordinates at data points are given by \(\{{{\varvec{P}}}^{\left({\varvec{i}},{\varvec{j}}\right)}, {\varvec{i}}=\mathrm{1,2},\dots {\varvec{n}} \, and \, {\varvec{j}}=\mathrm{1,2},\dots {\varvec{N}}\}\). The coordinate P indicates the deviation normal to the direction of the print path. For instance, straight paths are printed along the x-direction; therefore, the coordinate P is the y-coordinate. Similarly, 90° paths are printed along the y-direction; therefore, P represents the x-coordinate. The systematic deviation (\({{\varvec{\rho}}}_{{\varvec{i}}}\)) at the ith data point is determined by the mean of N = 5 printed path coordinates at that data point \({{\varvec{P}}}^{({\varvec{i}},{\varvec{m}}{\varvec{e}}{\varvec{a}}{\varvec{n}})}\). The mean of systematic deviations for n number of data points is the mean systematic deviation (\(\overline{{\varvec{\rho}} }\)). It is a representation of the printer’s average capability to follow a user defined print path (see Fig. 4) and is given by:

$${\varvec{\varepsilon}}=\boldsymbol{ }\overline{{\varvec{\rho}} }+{\varvec{\sigma}},$$
(1)

where

$${{\varvec{\rho}}}_{{\varvec{i}}}={{\varvec{P}}}^{({\varvec{i}},{\varvec{m}}{\varvec{e}}{\varvec{a}}{\varvec{n}})}=\frac{\sum_{{\varvec{j}}=1}^{{\varvec{N}}}{{\varvec{P}}}^{({\varvec{i}},{\varvec{j}})}}{{\varvec{N}}}$$
(2)

and

Fig. 4
figure 4

a Deviation of the mean of the printed paths from the ideal path, b deviation of the printed path from the mean

$$\overline{{\varvec{\rho}} }=\frac{{{\varvec{\rho}}}_{1}+{{\varvec{\rho}}}_{2}+\cdots {{\varvec{\rho}}}_{{\varvec{n}}}}{{\varvec{n}}}.$$
(3)

The stochastic deviation (\({\varvec{\sigma}}\)) is characterised as the root mean square deviation (RMSD) of the difference between actual and systematic coordinates at any point \({{\varvec{\delta}}}^{({\varvec{i}},{\varvec{j}})}\). These deviations are squared and summed over total number of data points (\({{\varvec{N}}}_{{\varvec{e}}{\varvec{x}}{\varvec{p}}}={\varvec{N}}\boldsymbol{*}{\varvec{n}}\)):

$${\varvec{\sigma}}=\sqrt{\frac{\sum_{{\varvec{i}}=1}^{{\varvec{n}}}\sum_{{\varvec{j}}=1}^{{\varvec{N}}}{\left({{\varvec{\delta}}}^{({\varvec{i}},{\varvec{j}})}\right)}^{2}}{{{\varvec{N}}}_{{\varvec{e}}{\varvec{x}}{\varvec{p}}}}},$$
(4)

where

$${{\varvec{\delta}}}^{({\varvec{i}},{\varvec{j}})}=\left({{\varvec{P}}}^{({\varvec{i}},{\varvec{j}})}-{{\varvec{\rho}}}_{{\varvec{i}}}\right).$$
(5)

To fully characterise the nature of the stochastic deviation, a correlation length is calculated using Pearson’s correlation coefficient. This is the distance over which correlations between neighbouring points persist. Pearson’s correlation coefficient is given by:

$${\varvec{C}}\left({\varvec{k}}\right)=\frac{\boldsymbol{\Sigma }{{\varvec{\delta}}}^{({\varvec{i}},{\varvec{j}})}{{\varvec{\delta}}}^{({\varvec{i}}+{\varvec{k}},{\varvec{j}})}/{\varvec{N}}{{\varvec{N}}}_{{\varvec{e}}{\varvec{x}}{\varvec{p}}}}{{\left({\varvec{\sigma}}\right)}^{2}},$$
(6)

where \({\varvec{N}}{{\varvec{N}}}_{{\varvec{e}}{\varvec{x}}{\varvec{p}}}\) is the number of pairs of data points \(\{({\varvec{i}},{\varvec{j}})\), \(({\varvec{i}}+{\varvec{k}},{\varvec{j}})\)} for all specimens in the sample data set. The correlation is calculated at increasing increments of k. As the distance between two points along the print path increases, the correlation between them decreases. The separation distance k’ at which C(k’) equals zero is defined as the correlation length. This implies that the position of the print path at the ith data point has no influence on the position of the print path at the (i + k’)th data point.

2.3 Print settings

Research into printer settings has determined bed temperature, layer height, flow rate, nozzle temperature and print speed as major factors affecting the quality of print. Layer height is directly proportional to the error in the printed part dimensions, i.e. the lower the layer height, the lower the size of error in X, Y and Z dimensions of the printed specimen. However, a lower layer height implies a longer printing time. A layer height of 0.14 mm is suggested as a compromise between print time and accuracy with an average error size of 6% [30]. Ideal flow rate values range from 80 to 100% of the theoretical requirement. If the value is below 80%, insufficient material is extruded and exceeding 100% by increasing extrusion value in G-code results in visible surface defects [31]. Hence, in this study, the flow rate is maintained at 100%. Higher nozzle temperature improves adhesion between adjacent deposited filaments and reduces voids in the same layer as well as between layers of the printed part. However, too high a nozzle temperature can cause creep effects and dimensional errors [29]. Therefore, the temperature is set at the manufacturer’s recommended value of 180 °C. In the case of print speeds, different printers have different speed ranges. Some studies have found that a part printed at the lower end of the speed range possess higher tensile and flexural strength [32, 33, 40, 41] and others found that printing at the higher end of speed range provides higher Young’s modulus to the part [32, 33, 40, 41]. Hence, an ideal value of print speed is still unknown. Therefore, a range of speed is taken in this study.

To determine the print speed range, straight paths were initially printed at different speeds at a regular increment of 5 mm/s from 15 mm/s up to 40 mm/s. The paths printed at 15 mm/s showed a significant amount of deviation from the ideal path as shown in Fig. 5a rendering any meaningful print geometry inaccurate. The path printed at 40 mm/s showed insufficient flow of material during printing and produced a sinusoidal print width that would introduce significant voids as shown in Fig. 5b. This phenomenon is not as apparent at low speeds. The large deviations at 15 mm/s could be due to the reaction force applied on the nozzle by the extruded PLA, which causes the nozzle to deflect significantly from the ideal path [42]. At the higher speeds, the nozzle spends less time at any given instance, and therefore does not experience significant reaction forces. However, too high a speed requires more material to melt in a shorter time, causing under extrusion. Therefore, the speed values selected for this study are 20, 25, 30 and 35 mm/s, as paths printed at these speeds showed less deviation from the ideal path and printed well with sufficient flow of material.

Fig. 5
figure 5

a Large deviation of printed path from ideal path when printed at 15 mm/s, and b insufficient flow of material whilst printing path at 40 mm/s

3 Results and discussion

3.1 Deviation in centroid of straight paths

The results for straight paths are summarised in Table 1. Five specimens are printed at each print speed and mean centroid and mean width of these five specimens is shown in Fig. 6a and b. It can be observed that both mean systematic and stochastic deviations are smaller in straight paths printed at higher speeds. Whilst printing path at high speeds, the semi-molten material coming out of nozzle is stretched [42]. This stretching tends to straighten the path, lowering its deviations. The correlation length is in a narrow range of 56.5 to 61.3 mm. Correlations tend to remain consistently high until a rapid decrease at around 50 mm between points. This trend is observed for all geometric features. No significant trend is observed for correlation lengths relative to print speed. This is true for all geometric features tested in this study.

Table 1 Mean systematic and stochastic deviation in straight paths
Fig. 6
figure 6

a Microscopic image of printed straight path, b deviation in mean centroid at different speeds, and c mean width values at different speed

3.2 Deviation in centroid of angled corners of 45°, 90° and 135°

Deviation results for paths containing angled corners are presented with respect to the distance from the junction point. For corner paths, the nozzle moves in a straight path until it reaches the junction point (c.f. microscope images in Fig. 7a) where the path then turns at the desired angle. Three regions can be identified by direct observation of the print paths (Fig. 7b). Region A represents the straight path before the corner. Region B represents the corner at the junction point. It is the location of peak systematic deviation, which is due to the printed path being rounded and cutting the corner of the ideal path. This happens because the material does not adhere to the print bed properly at the junction point and is then pulled to create a rounded corner. The third region (C) represents the path after the corner where the print path becomes straight again. The mean systematic deviation and stochastic deviation of regions B and C for each geometric shape are tabulated in Table 2.

Fig. 7
figure 7

a Microscopic images for 45°, 90° and 135° curved paths, b mean centroid deviations and c mean width along print paths at different print speeds

Table 2 Mean systematic and stochastic deviation in 45°, 135° and 90° corner paths

The correlation length of region B is not calculated due to its small length. The size of region B is selected by observing the spike in values. In region C, both systematic and stochastic deviations gradually attain consistent values. However, there is a clear shift in actual printed paths from the ideal path in region C. This is due to the nozzle’s deviation from the designated junction point, which then remains consistent for rest of the print path. It is also noted that the mean systematic deviation increases, and stochastic deviation decreases at higher speeds in region C (Table 2). This indicates that the nozzle has deviated more from the designated path but there is less random deviation within five specimens at higher speeds.

Correlation lengths are smaller for corner paths, compared to straight paths. This is due to the change in direction of the nozzle at the junction point whilst printing corner paths. The change in direction causes irregular deposition of material and due to this, the position of each data point is more random and less correlated.

3.3 Deviation in centroid of curved paths

The results for curved paths are presented in Fig. 8. Prints follow a sinusoidal path around the ideal radius. Since values of systematic deviation vary from positive to negative depending on the position around the curve, the mean of these deviations cancels out to approximately zero and is not presented here.

Fig. 8
figure 8

a Microscopic image of printed curved paths, deviation in centroid radius and mean width at different speeds for radii of b, c 2 mm, d, e 4 mm, f, g 6 mm and h, i 8 mm

For curved paths, the stochastic deviation increases as speed increases, and this is evident in all printed radii, as shown in Table 3. At higher speeds, the print paths do not have enough time to adhere to the print bed [43]. This leads to varying adhesion along the print path resulting in randomness (stochastic deviation). Additionally, studies also show that vibration of the nozzle increases at higher speeds [44]. For curved paths, the nozzle is continuously changing direction causing the printed material to get pulled from the print bed if not adhered properly. Correlation lengths for all radii range from 1.3 to 1.8 radians. This means the length in mm increases proportionally with increasing radius suggesting that the correlation between points is determined by their relative position around the curve. It is expected the correlation length would approach the values observed for straight paths as the radii increase.

Table 3 Stochastic deviation and correlation length in curved paths

3.4 Deviation in the width of printed paths

For the width of printed paths, a systematic (mean) width can be measured, but cannot be compared to an ideal value as print path width is not specified by the user. Stochastic deviations for all geometric features are presented in Table 4. Figures 6, 7 and 8 show the deviation in width along the length of print paths printed at different print speeds.

Table 4 Stochastic deviation and correlation lengths for the width of printed paths

For straight paths, the deviation in width increases with speed. This could be due to vibration of the extruder unit at higher speed or could be due to a higher flow rate of material causing discrepancies in the width.

In 45° and 90° corner paths, region B remains unaffected by speed whereas deviation of widths in region C decreases with speed. Whilst printing these corner paths, the nozzle takes a micro pause at the junction point whilst material continues to flow out. This leads to an accumulation of material as shown by a spike in width values in Fig. 7c. At higher speed, the accumulated material is stretched which keeps the width more consistent. Hence, the deviation decreases with speed.

In the case of 135° corner paths, the nozzle continues to move in the same direction and does not take a micro pause, and hence no material is accumulated. This is evident in Fig. 7c as no spike is observed at the junction point, unlike the 90°/45° paths. Since no material is accumulated, 135° corner paths are suspected to be similar to straight paths.

For curves, deviation in width decreases with speed. This trend is expected due to the nature of printing curves, which form a polygon with many short sides. Here, the nozzle is constantly changing direction with a micro pause for each side of the polygon. At slower speeds, this results in accumulation of material that manifests as variability in the width of the printed path.

No significant trend is observed in the correlation length of width. However, the correlation length in width of the straight path is significantly higher than other corner paths as observed with print centroids. Therefore, the same explanation is valid here, i.e., interruption of the nozzle’s direction creates disturbance in the flow of material, affecting its correlation between data points. In the case of curves, no significant variation in correlation values is observed with respect to radius or speed. It lies between 5.3 radians and 6.28 radians.

4 Conclusion

A methodology is presented to characterise the variability and accuracy of FFF printed paths of varying geometry. As might be expected, the systematic deviation was found to be smallest for straight paths and increased with the severity of the geometric feature, with 45° corners exhibiting the largest deviation. Both systematic and stochastic deviation were found to be higher at the junction point of the corner paths as compared to rest of the path. Curved paths are shown to have a periodic sinusoidal path that is centred around the user-specified radius. Correlation lengths for straight sections are several times longer when compared to other geometric features. Based on the geometry of the path, it is easy to categorise the quality of the printed path, as both systematic and stochastic deviation values demonstrate clear distinctions amongst different path geometries. Regarding print speed, straight paths printed at higher speeds exhibit the least deviation, whilst no significant trend is observed with respect to speed in the remaining paths. It is worth noting that the range of valid print speeds examined in this study may differ for each printer model.

The methodology outlined in this study can be used to provide a quantitative comparison of the quality of different printers, and the effect of different materials and print settings. This approach can be used as part of a toolkit to guide maintenance schedules and aid in the diagnosis of root causes of voids present within a part. The statistical data obtained from the methodology outlined here can be utilised to regenerate unique virtual models with representative statistical properties. These virtual models could be further utilised to analyse the mechanical behaviour of printed parts under loading conditions to provide probabilistic models of failure including a study of extreme cases and outliers. This has the potential to lead to more meaningful optimised print geometries based upon experimentally observed phenomena, offering improved mechanical performance, reduced weight, cost and print time.