Abstract
Direct Ink Writing, an extrusion-based 3D printing technique, has attracted growing interest due to its ability to process a broad range of materials and integrate multifunctional printheads with features such as shape-changing nozzles, in-situ curing, material switching, and material mixing. Despite these advancements, incorporating auxiliary controls into Geometry Code (G-Code), the standard programming language for these printers, remains challenging. G-Code’s line-by-line execution requires auxiliary control commands to interrupt the print path motion, causing defects in the printed structure. We propose a generalizable time-based synchronization approach called Time Code (T-Code), which decouples auxiliary control from G-Code, enabling uninterrupted print path enrichment. We demonstrate the method’s effectiveness with both high-end and affordable 3D printers by fabricating functional gradients and parallelizing printhead auxiliary devices for mass customization. Our method reduces defects, enhances print speed, and minimizes the mechanical burden on 3D printers, enabling the rapid creation of complex multimaterial structures.
Similar content being viewed by others
Introduction
Additive manufacturing (AM), or three-dimensional (3D) printing provides design freedoms that are not feasible using conventional manufacturing techniques, enabling the production of multifunctional and hierarchically complex structures for a variety of industries, ranging from aerospace and construction to consumer goods and healthcare1,2,3,4,5. Specifically, direct ink writing (DIW)—a material extrusion 3D printing technique—has gained attention due to it’s ability to process a broad range of organic and inorganic materials, both individually and concurrently5,6,7,8,9,10,11,12,13. DIW can be further enhanced by multifunctional 3D printheads that enable, among others, multimaterial switching14, mixing4,15,16,17,18,19,20, in-situ curing21,22, and rotational co-extrusion with sub-voxel resolution23,24. This versatility facilitates diverse applications, such as architected materials, integrated electronics, optics, soft robotics, and vascularized tissue23,25,26,27,28.
Despite these advancements, there has been little to no change in Geometry Code or G-Code, which remains the most common programming language used to control the print path of extrusion-based 3D printers29. G-Code was originally introduced for computer numerical control (CNC) machines in the 1950s, long before the first AM machines30, and although it efficiently manages motion, it does not easily adapt to include integrated auxiliary controls, such as pressure boxes, UV lights, and stepper motors. This limitation stems from the line-by-line execution of G-Code, requiring the printer to decelerate and stop at each new line, leading to over-extrusion defects. In simple, single-material DIW setups, these stops and defects only occur at directional changes in the print path; however, if additional path functionalization, such as material switching, is desired, auxiliary commands must be inserted as new lines in the G-Code, causing frequent interruptions and defects along the print path as demonstrated in Fig. 1a–d. This requirement is particularly problematic with designs necessitating frequent changes, such as continuous compositional4,17,20,31 and shape gradients32,33,34.
a Exemplary multimaterial lattice structure displaying defects due to G-Code interruptions from material switching commands, with arrows pointing to defects occurring before the interface due to dead volume in the nozzle and delayed execution of the pressure boxes. b Schematic of a single filament with multiple auxiliary commands along its length. c G-Code interruptions lead to discontinuity and frequent stops in the velocity profile of the 3D printer. d These interruptions result in over-extrusion defects, which become more pronounced at reduced accelerations. e, f Comparison of total print times as a function of the number of auxiliary actions at e various velocities (acceleration = 1000 mm/s2) and f various accelerations (velocity = 20 mm/s); assuming a linear velocity profile for the 3D printer, the graphs show the print time comparison between conventional G-Code and the time-sync solution, or T-Code which g decouples the auxiliary commands from the printer’s motion, ensuring an uninterrupted velocity profile and h a reduction in defects regardless of acceleration. i The exemplary multimaterial lattice printed using the T-Code method demonstrates a reduction in defects. Scale bars = 5 mm. Source data provided as a Source data file.
To address the defects associated with G-Code interruptions due to directional changes, many commercial fused filament fabrication (FFF) printers utilize a method known as linear advance. This technique predicts pressure buildup in the nozzle and adjusts the extrusion rate during deceleration35. Although linear advance has led to improvements in print quality, its effectiveness is limited by the need for pressure prediction values to be calibrated experimentally, as they depend on material properties and print speed. In addition, linear advance, which is designed for volumetric-driven extrusion of thermoplastics, does not account for time-dependent material properties, such as thixotropy and pot-life36,37, which are common in viscoelastic materials used in DIW. Further, linear advance is not directly adaptable to pressure-driven systems used in DIW applications that require rapid flow rate control beyond what is achievable using volumetric extrusion.
In addition to defects, frequent interruptions to the print path can lead to significant increases in print time due to the finite acceleration capabilities of the 3D printer; this concern intensifies as researchers pursue ever-higher resolutions. For instance, at voxel-level resolution, where an action is required at every travel distance equal to the nozzle diameter, the total print time can increase up to six times for a nozzle diameter of 0.1 mm (Fig. 1e, f). In addition, highly functionalized print paths often require multiple commands to be sent simultaneously or consecutively. Using conventional G-Code, this becomes a significant issue as the commands have to be executed line-by-line before printhead movement can continue (Supplementary Fig. 1).
Although printer accessories and systems addressing specific functions, such as linear advance for defect control and filament splicing for multimaterial FFF, do exist, they cater to niche needs and specific conditions, such as material type and 3D printer brand38,39. These systems are not generalizable for the broad range of auxiliary controls required to accommodate the growing complexity of 3D printheads needed for creating multimaterial and multifunctional objects. To sustain the growing potential of DIW, it is necessary to advance how complex print paths are executed, both to reduce defects and to enable frequent and independent control of auxiliary devices without increasing print time, part file size, or imposing additional mechanical stresses on the 3D printer.
Here, we propose a generalizable method that separates control of auxiliary devices from G-Code using a time-based synchronization approach (Fig. 1g), which we refer to as Time Code, or T-Code. This method effectively decouples print path motion from on-the-fly in-situ functionalization, thereby reducing interruptions to the print path and enhancing print speed without compromising the precision, accuracy, or complexity of 3D-printed structures (Fig. 1h, i and Supplementary Movie 1). The reported method holds far-reaching potential, as we demonstrate by its application in creating functional gradients for both energy absorption and optics and in the parallelization of multiple auxiliary devices for mass customization.
Results
Time Code-based 3D printing
To implement time-based synchronization, the commands for the auxiliary devices are decoupled from the G-Code print path and controlled via a custom Python script (Fig. 2a). First, a conventional G-Code, which contains the desired locations of the auxiliary commands, is imported into Python. The script identifies and differentiates the G-Code motion commands (e.g., “G0” and “G1”) from auxiliary commands, categorizing them into two distinct groups while ensuring proper alignment and parallelization of the commands. Once decoupled, the script consolidates the interrupted G-Code movements into a continuous, uninterrupted print path. For example, if a print path includes an auxiliary command every 2 mm over a 10 mm distance in the x-direction, the script consolidates the five separate “G1 X2” commands into one continuous “G1 X10” path. The uninterrupted G-Code is then formatted and transferred for execution by the 3D printer. An exemplary comparison between interrupted conventional G-Code and uninterrupted G-Code generated via T-Code is provided in Supplementary Fig. 2. Subsequently, using the defined print speed and acceleration, the velocity profile of the 3D printer is generated. The timestamps for the auxiliary commands are then calculated by mapping their locations onto the velocity profile. These timestamps are formatted into a list, ready for execution by the Python script. Once the uninterrupted G-Code (Output 1) and the auxiliary timestamps (Output 2) are generated, the script awaits a start ping from the 3D printer to initiate synchronization.
a Process of decoupling and synchronizing auxiliary commands with G-Code. b, c Impact of resynchronization on print accuracy. The red circles in b represent locations of resync pings. d Common velocity profiles (top) used to illustrate differences in 3D-printed parts (bottom). 'Bang-bang motion' demonstrates how short moves that do not reach full velocity are managed in the velocity profile estimation. The red dashed line indicates the desired print velocity. e Comparisons of structures printed using a custom high-performance gantry-stage (Aerotech) and an affordable desktop 3D printer (Hyrel). f Complex, multimaterial image of the Hopkins blue jay printed using T-Code. Blue Jay Athletics logo courtesy of Johns Hopkins University. Source data provided as a Source data file.
Depending on the specific requirements of the 3D printer, the connection between the 3D printer and Python can be established through various methods. We have successfully used both physical and virtual RS-232 connections, TCP/IP networking, and voltage signals. In our demonstrations, the 3D printer control software and Python are run on the same computer but this is not a requirement. A schematic of the software/hardware connections can be found in Supplementary Fig. 3. Regardless of the setup, there is a finite delay between sending the start ping from the 3D printer and its reception by Python. This delay is dependent on both hardware and software, so it is crucial to determine time delay during initial setup. We achieved this by sending a series of equally timed pings from the 3D printer and recording when Python receives them; the average difference between the ideal intervals and the actual times between consecutively received pings is calculated and used to adjust the synchronization of the systems (Supplementary Fig. 4).
During initial tests of the system, we observed an increasing synchronization mismatch during prints, likely due to the cumulative small yet unavoidable deviations in both the mechanical motion of the 3D printer and the execution of the Python script. In an exemplary multimaterial print measuring 30 mm by 40 mm, the error approximately doubled at the interface between the black and white materials over the course of the print (Fig. 2b, c). To maintain synchronization, we introduced resync pings from the G-Code to Python to readjust the timing of command executions. To minimize the interruptions and defects that these resyncs might cause in the print path, they are strategically placed at points where direction changes already necessitate stops in the print path and require very little processing time (Supplementary Fig. 5). Any remaining deviations in auxiliary command execution can largely be attributed to errors and delays from the auxiliary devices’ processing and execution of the commands (Fig. 2b, c), as evidenced by comparable results when controlling pressure boxes directly via the G-Code (Supplementary Fig. 6).
In addition to maintaining synchronization, the precise definition of the printer’s velocity profile as it accelerates or decelerates, which is often unknown or imprecise, is crucial in system development. Because the most common 3D printer velocity profiles, linear, half-sine, and s-curve profiles, are relatively similar in shape, we approximate the profile in the Python script to be linear. This simplification is independent of print direction and extends to short “bang-bang” motions—movements that do not reach full speed within the defined line segment. To assess the accuracy of this simplification, we compared the linear velocity profile used in the Python script to other common 3D printer velocity profiles using a custom high-precision gantry stage (Fig. 2d). At a print speed of 15 mm/s and an acceleration of 1000 mm/s2, no significant differences were observed in the printed parts among these profiles (Fig. 2di–iii). In addition, using the linear velocity mode, we verified the time-based solution at various speeds (5–25 mm/s) and accelerations (200–1000 mm/s2; Supplementary Fig. 7). These results indicate that T-Code can be effectively used as a generalizable and low-cost solution for a variety of 3D printers, even those with unknown velocity profiles. For increased precision, the Python script can be customized to define specific velocity profiles.
To further verify the generalizability of the code, we compared different geometries printed on the custom gantry stage to those printed on an affordable desktop printer. The custom gantry can reach accelerations of over 1000 mm/s2, while the recommended acceleration for the desktop printer is limited to 700 mm/s2. Without the time-based synchronization, the acceleration discrepancies between the two printers are more pronounced (as evidenced in Fig. 1d); however, with only minor adjustments, the T-Code approach yields comparable results for circular, linear, and 3D print paths, independent of print direction, despite smaller accelerations (Fig. 2e, f).
Time Code-based fabrication of functional objects
To further demonstrate the efficacy of time-based synchronization, we fabricated various structures that are infeasible with conventional G-Code path planning. Structures that particularly benefit from T-Code are those requiring frequent modulation of functionality along the print path, such as filament diameter, composition, and UV-curing intensity—critical for printing functional gradients.
Functionally graded structural materials, known for their strength-to-weight ratio and energy absorption, are prevalent in many natural systems, such as bone40 and bamboo41. Inspired by these natural systems, there has been recent interest in using AM to create architected lattices and structures that are functionally graded both geometrically and compositionally to enhance properties such as stiffness, strength, energy absorption, and fracture toughness17,20,27,40,42,43,44,45. Beyond mechanical improvements, functional gradients find utility in a variety of applications such as radio frequency (RF) devices46, optics4, and drug delivery47.
Filament diameter gradients
One method of creating functional gradients via 3D printing is through the use of filament geometry, such as variations in width, height, and shape, which can be achieved by varying the nozzle diameter32,33,34 or speed to indirectly manipulate flow rate45,48,49,50. Both methods require discretizing the print path into short segments, leading to defects, increased print times, large file sizes, and stuttering due to the printer’s physical limitations. T-Code addresses these issues by enabling a continuous print path, effectively overcoming the limitations associated with traditional methods. To demonstrate gradient filaments, we varied the flow rate by adjusting the applied extrusion pressure in a fixed diameter nozzle, printing at a constant speed. Compared to using G-Code alone, T-Code achieves a seamless change in filament cross-section—both in width and height (Fig. 3a–d).
a, b Comparison between filaments using conventional G-Code and the T-Code method for diameter increases every 10 mm: a top view of filament width and b side view of filament height. c, d Comparisons for filament diameter increase every 1 mm: c top view of filament width and d side view of filament height. e, f Print path and printed structure comparison; a traditional, fixed diameter nozzle requires a significantly more complex print path (generated via Prusa slicer) and produces poorer results compared to T-Code-based control of a pressure-controlled variable filament width. g, h Similarly, a constant diameter nozzle requires a complex print path and still fails to infill a solid layer or volume completely. i, j The variable filament can also produce triangles and infill sharp corners. m Layer height deviations from ideal, based on the cross-sectional cuts seen in (k, l). n Porosity, outer contour, and total error from the ideal shape of each printed structure in (e–j). Scale bars = 5 mm except for zoom-ins (i and ii) in (a–d), which are 1 mm. Source data provided as a Source data file.
A direct and recent use case for varying filament width is variable contour infill, which is typically used in FFF to optimize speed and infill accuracy49,50. Specifically, variable contour infill addresses limitations of traditional slicers designed for fixed nozzle diameters which optimize the print path for outer shapes at the expense of inner regions, resulting in large gaps, porosity, or contour errors due to binary over- or under-extrusion decisions. Unlike the currently available methods, the pressure-driven T-Code method can achieve variable contour infill without the need to discretize the print path or change the speed. As compared to structures printed using a fixed filament diameter (Fig. 3e–l and Supplementary Fig. 9), T-Code with variable width infill significantly improves part accuracy (Fig. 3m, n), simplifies the print path, and reduces print time, for example, by reducing the number of contours required to infill a space (Fig. 3e–h and Supplementary Movie 2). In addition, this method effectively fills gaps at sharp direction changes, such as those seen in triangular print paths (Fig. 3i, j), and maintains a more consistent layer height (Fig. 3k–n).
In addition to enabling fully dense parts, gradient filaments enabled by T-Code can facilitate discrete parts with localized infill densities (Fig. 4a and Supplementary Fig. 10). Similarly to solid parts, producing similar structures using conventional methods would require either multiple tool passes or frequent adjustments in the print speed, both of which result in extended print times and defects, such as stair-stepping artifacts and over-extrusion. The smooth density transitions in the T-Code structures can enhance and customize the structures’ overall mechanical and optical behavior. For example, graded filaments have been shown to enhance energy absorption and fracture mechanics in cellular structures17,42. Figure 4b shows different filament or strut designs, including fully graded, partially graded, and constant width struts. In bending-dominated lattices containing constant width struts, failure often occurs along a shear band at the nodes due to stress concentrations51. Using T-Code to integrate different strut types into a lattice made from brittle epoxy, we demonstrate that nodal failure can be significantly reduced without altering the overall relative density, thus substantially improving virtually all mechanical properties, such as elastic modulus (+50%), ultimate strength (+30%), and toughness (+212%; Fig. 4c–e). This improvement is due to the reinforcement of the nodes, leading to greater energy absorption and increased resilience to fracture, as evidenced by failure patterns diverging from the shear band and the foam-like behavior of lattices with graded struts (Fig. 4f and Supplementary Movie 3).
a Functionally graded struts for variable infill density. b Different filament or strut designs for graded lattice structures enabled by T-Code. c Epoxy lattices (30 mm × 30 mm × 10 mm) printed with and without graded struts, and d their relative densities. Error bars represent the standard deviation for n ≥ 3 independent replicates. e Stress-strain curve of the lattices subjected to a compressive load. Shaded error bands represent the standard deviation for n ≥ 3 independent replicates. f Progression of damage in the different lattices. g Stress-strain curves of lattices for increasing relative densities. h Effect of relative density on Young’s modulus, i ultimate compressive strength, and j energy absorption up to 61% strain (the average onset densification strain; Supplementary Fig. 11). Source data provided as a Source data file.
Specifically, the graded lattice displays elastic-brittle foam behavior, which is characterized by three distinct phases in the stress-strain curves: (1) linear elasticity (bending), (2) a plateau (brittle crushing), and (3) densification52. These phases are clearly evident in the curves of the gradient lattices across all relative densities (Fig. 4g), resulting in consistently higher stiffness and ultimate compressive strength as compared to their non-graded counterparts (Fig. 4h, i). Due to the expected nodal failure, the non-graded lattices do not exhibit densification; instead, their failure strain significantly decreases with increasing relative density. This results in substantially higher energy absorption values in the graded lattices for relative densities above 0.28 (Fig. 4j). Fabricating such graded lattices with conventional G-Code would be virtually impossible.
Compositional gradients
In addition to geometric gradients, T-Code can also be applied to create compositional gradients, such as bioinspired interfaces17,31, stiffness gradients20, and gradient index glass4. Previous research has shown the use of print speed manipulation for gradient filaments; however, this method only alters the overall volume/flow rate and cannot be used to manipulate the ratios of the materials on-the-fly48. Traditional active and passive material mixing nozzles facilitate functionality but require significant mixing volumes inside the printhead15,53; this prevents voxel-level resolution and causes substantial delays, making these nozzles infeasible for high-resolution AM. To overcome this limitation, we utilize printheads designed for material switching14,54; however, instead of switching entirely, we coextrude materials concurrently at varying ratios (Fig. 5a, b). In combination with the T-Code approach, this enables rapid voxel composition changes while maintaining a constant print speed. To maintain a constant flow rate, and thus a constant cross-sectional area, each material must be precisely controlled, considering additional factors like ink aging (Fig. 5c, d). To visualize the voxel-level compositional control, we use coextrusion to achieve optical color blending (Supplementary Fig. 12), akin to the techniques used for LED displays, textile weaving, and pointillism art, where adjacent colors create the illusion or perception of color mixing55,56. To demonstrate this, we 3D-printed filaments with various discrete red and blue ratios, transitioning from red, through their blended color purple, to blue (Fig. 5e–g). Using T-Code, a simple print path (Supplementary Fig. 13) can achieve continuous color gradients (Fig. 5h and Supplementary Movie 4), discrete color changes (Fig. 5i and Supplementary Movie 5), or a combination of discrete and continuous color changes (Fig. 5j and Supplementary Movie 6.
a Two “modes” for the switching nozzle: single material switching (top) and coextrusion (bottom). b Switching nozzle used for tests and demonstrations. c The relationship between pressure and flow rate using the single extrusion mode at different stages of SE1700's pot life. Error bars represent the standard deviation for n = 5 independent measurements. d Validation of the pressure-flow rate-ratio model using coextrusion; the ideal flow rate matches a print speed of 10 mm/s for a 1 mm diameter filament. Error bars represent the standard deviation for n = 6 independent measurements. e Coextrusion within single filaments to (f) verify that the desired range of ratios and widths can be achieved. g Cross-sectional cut of filaments showing that the filaments' overall shape and dimensions are maintained. h Example of continuous color gradient printed with coextrusion, where the zoom-out shows the 'illusion' of mixing. i Example of 3 discrete color changes (blue, yellow, and green) created using only 2 color inputs (blue and yellow). j Example of discrete and continuous gradients used to print a complex image of Einstein65. Scale bars (e–h) = 5 mm; scale bars (i, j) = 10 mm. Source data provided as a Source data file.
In DIW, materials with similar non-Newtonian rheological properties are generally best for coextrusion, but differences, such as viscosity, can be managed by adjusting hardware and nozzle design. For instance, applied pressure can be tailored to each material, and nozzle channel lengths can be varied to modify flow resistance and mitigate backflow14. Ensuring the yield stress of each material is sufficient to maintain its shape after extrusion and support subsequent layers is crucial, though in-situ curing, such as with UV light, can enable the use of low-viscosity or low-yield stress materials. T-Code’s generalizability allows adaptation for additional auxiliary controls, enabling the printing of diverse materials.
A limitation of this coextrusion method is its directional dependence on the printhead orientation relative to its motion during material deposition—i.e., the mixed ratio must always be visible from the top plane limiting the directions the nozzle is able to travel. To address directionality issues arising from the fixed nozzle orientation, a rotational coextrusion nozzle24,57 could be used. Directionality can also be addressed using concurrent modulation of core and shell diameters in a “core-shell” filament to maintain a constant outer diameter27. As demonstrated in Supplementary Fig. 14, T-Code can enable continuously and instantly changing ratios in core-shell architecture to create voxel-level gradients. In the future, these switching and mixing concepts can be extended towards material mixing at a molecular level for mechanical, electrical, or biomedical applications, for example, via diffusion.
Scalability and parallelization for mass customization
Beyond functional gradients, decoupling geometric from functional control in the printhead via T-Code can substantially enhance the scalability of 3D printing and enable mass customization. This advancement is facilitated by integrating multiple printheads into a single 3D printer or gantry stage, with each printhead moving in-sync but performing distinctly different tasks at any given location, such as toggling extrusion or switching between materials. Ultrafast switching nozzles support this capability, enabling voxel-level resolution and a parallel scanning strategy for printing parts, rather than completing each material island individually before moving to the next one14.
While conventional G-Code-based control strategies can offer print parallelization, they require every printhead to stop each time an action is needed in one of the structures, a frequency that exponentially increases with the number of printheads or parts. In contrast, T-Code allows each printhead to operate independently. This synchronization further accelerates fabrication by dividing a large structure into n smaller sections, each printed by a separate printhead, effectively reducing the overall printing time by a factor of n.
To demonstrate the parallelization of a single object print, we divided a 180 mm × 180 mm landscape image into three 180 mm × 60 mm sections, printing them simultaneously (Fig. 6a–g and Supplementary Movie 7). With conventional G-Code, each print path stoppage and its resulting defect would propagate into the other sections, as seen in Fig. 6d. In this example, 98% of the color switches across all sections of the print occur uniquely or not at the same time/location as a color switch in another section (Supplementary Fig. 15), resulting in three total defects for the majority of individual switches. In addition, sending consecutive commands via G-Code leads to longer interruptions to the print path (Supplementary Fig. 1). Thus, the defects would be about three times larger even if all the switches occur at the same locations. Our time-based solution enables seamless material switching across all sections, resulting in a 180 mm × 180 mm print that takes one-third the time compared to using a single nozzle method. This approach can extend beyond the 2D image presented here, enabling rapid fabrication of large 3D structures.
a Schematic of the parallel printing process used to print a b 180 pixel × 180 pixel image divided into three 180 pixel × 60 pixel segments to be printed in parallel. Each pixel translates to a 1 mm feature size. c Material switches occurring in one exemplary trace across each section A, B, and C. d The total number of material switches occurring across all print paths and the resulting propagation of defects if using conventional G-Code. e Schematic of the print path used for all nozzles during the parallel print. f Progression of the prints over time, showing each section being printed simultaneously using the T-Code method. g Final printed image. h Schematic of parallel printing process used for discrete 3D shape printing. i Renderings of the three discrete 3D shapes to be printed in parallel by following the same overall print path. j The print path for the first layer of the three structures. k Schematic and l printing of layers 1, 10, and 20. m Final 3D structures. Source data provided as a Source data file.
Similarly, parallelization can be used for mass customization of disparate structures. By aligning three different objects—such as a hollow half-sphere, a triangular prism, and a block cube pyramid—onto the same print path (Supplementary Fig. 16), they can be printed simultaneously (Fig. 6h–m and Supplementary Movie 8). Although beyond the scope of this project, to maximize the benefits of this method, the print path should be optimized beyond the basic cubic path used here, aiming to minimize the total non-extrusion moves. Structures with overall similar shapes and sizes but varying internal material arrangements, such as lattice structures with different density layouts seen in Fig. 4, Supplementary Fig. 18, and Supplementary Movie 9, naturally maximize the time benefits of parallelization, as they involve no unnecessary non-extrusion moves. Parallelization in printing discrete structures has potential applications in the rapid prototyping of several design concepts at once as well as in the mass customization of biomechanical devices, such as orthotics, where only slight differences are needed between different patient requirements.
Discussion
We have developed a generalizable method called T-Code for improved print path functionalization to decouple auxiliary device controls from G-Code motion planning. The continuous print path enabled by T-Code improves overall print performance, including accuracy, precision, and speed, without altering the 3D printer’s hardware or software. In addition, T-Code allows affordable desktop printers the ability to produce structures comparable in quality to high-end alternatives. To demonstrate the method’s potential, we showcased seamless control of functional gradients for improved infill, energy absorption, and optics, as well as print path parallelization for scalability and mass customization.
T-Code is particularly advantageous for pressure-driven systems due to their quick flow rate control but works universally across all applications, materials, and extruder types compatible with conventional G-Code. This includes DIW and FFF, high-viscosity inks58,59, volumetric extruders, which offer precise flow rate control but slow reaction speeds typically unsuitable for multimaterial printing, and even CNC milling machines and lathes. By combining appropriate printheads, auxiliary hardware (e.g., pressure boxes, UV lights, volumetric extruders), and material design, T-Code can be adapted to print a wide range of functional materials, enabling a single-system approach for fabricating multifunctional structures such as structural batteries60,61, shape-changing structures62, and soft robotics and wearables with integrated electronics63.
Current speed and resolution limits in our demonstrations are primarily due to external hardware and software constraints. Most commercial pressure dispensers are limited to 1–5 Hz switching frequencies, and communication with auxiliary devices is often unpredictable due to task scheduling protocols. To address these limitations, future work will integrate solenoid valves to increase multimaterial switching to 50 Hz or more14. We also envision T-Code integration into real-time operating systems or offloading timing-critical tasks to dedicated hardware, such as microcontrollers, for more efficient auxiliary device communication. With advancements in printhead, material, and part design, T-Code has broad potential for fabricating scalable, multifunctional structures across a variety of applications such as biological, electrical, optical, and mechanical.
Methods
Materials
All samples, unless otherwise specified, were printed with silicone inks containing SE 1700 base and catalyst (Dow Corning) at a 10:1 weight ratio, colored with 1% w/w pigment (Silc-Pig, Smooth-On). The inks were mixed for 2 minutes at 2000 rpm in a speed mixer (DAC 300-100 Pro, Flacktek). The stiff epoxy used to fabricate the black gradient lattices in 4c–j was composed of EPON 828 (Hexion), Epikure 3230 (Hexion), fumed silica (M5, CAB-O-SIL), and pigment (Silc-Pig) at a 100:35:14.5:0.5 weight ratio. The epoxy ink was prepared through speed mixing (DAC 300-100 Pro, Flacktek) under vacuum at 800 rpm for 90 s, 1600 rpm for 90 s, and 2000 rpm for 120 s.
Ink rheology
The rheological behavior of the ink (Supplementary Fig. 20) was characterized with a compact modular rheometer (MCR 302, Anton Parr). Measurements were performed at 20 °C using a 25 mm diameter parallel-plate geometry with a gap of 0.5 mm. Apparent viscosity was measured by shear-rate sweeps between 0.01 s−1 and 100 s−1. The storage and loss moduli were determined using oscillatory amplitude sweeps at shear strains between 0.01% and 100% with an angular frequency of 10 rad/s. Samples were tested within 20 min of mixing.
Multimaterial printhead fabrication
The switching nozzle printheads were fabricated with an LCD Resin 3D Printer (Sonic mini 8K, Phrozen) using either Aqua Gray 8K Resin (Phrozen) or Simple Clear Resin (Siraya Tech). After printing, the nozzles were cleaned with isopropyl alcohol and dried with compressed air to remove uncured resin from the channels. A schematic of the switching nozzle can be found in Supplementary Fig. 19.
Printing process
The ink-filled syringe barrels were connected to the nozzles and mounted on 3-axis motion gantry stages (Aerotech or Engine SR, Hyrel). Printer motion was controlled via G-Code using A3200 or Automation1 (Aerotech) or Repetrel (Hyrel) motion controller software. Inks were extruded using pressure pumps (Ultimus V, Nordson EFD) and gated by pneumatic solenoid valves (VQD1151-5MO, SMC) controlled with 0-24 V digital relays (WAGO). For conventional G-Code demonstrations, the pressure boxes and valves were controlled within the G-Code using A3200, Automation1, or Repetrel software. For T-Code, the pressure boxes and valves were synchronized with the print motion using the custom T-Code Python script described above. The motion control software and T-Code Python script were connected via virtual RS-232 connections or TCP/IP networking. Unless otherwise specified, all structures were printed on the Aerotech gantry stage at accelerations of 1000 mm/s2. All structures were printed at room temperature within 3 h of material mixing. After printing, the samples were cured in an oven for 24 h at a constant temperature of 100 °C.
G-Code was generated in three ways: (1) manually, (2) via a custom Python script that projects multicolor bitmap files onto a parallel-rastering print path, and (3) via the Prusa slicer. To project the 3D parallel print structures (hollow dome, triangular prism, and cube pyramid) onto parallel-rastering print paths, the structures were first modeled in SolidWorks, converted to .stl files, and sliced into 2D images using 3D Slicer, an open-source 3D visualization software. For multimaterial and gradient prints, the switching location/pressure change location was determined by an offset variable to account for dead volume in the nozzle and command delays.
Single material samples, including gradient diameter samples in Figs. 3 and 4, were printed using 20 GA (Nordson EFD) nozzles unless otherwise specified. All multimaterial structures were printed using switching nozzles with a 1 mm outlet diameter. The blue single filament samples in Fig. 1d and h were printed at speeds of 20 mm/s and a pressure of 20 psi. The blue and black multimaterial lattices comparing conventional G-Code (Fig. 1a) and T-Code (Fig. 1) were printed at speeds of 10 mm/s, accelerations of 200 mm/s2, and pressures of 25 psi. The black and white resync comparison samples (Fig. 2b) were printed at speeds of 15 mm/s and pressures of 35 psi. The blue and white checkerboard cubes comparing different velocity profiles (Fig. 2di–iii) were printed at 10 mm/s using pressures of 25 psi. The Hyrel and Aerotech comparison structures (Fig. 2e) were printed using speeds of 10 mm/s and pressures of 25 psi; the Hyrel samples were printed at the recommended acceleration of 700 mm/s2, while the Aerotech samples were printed at 1000 mm/s2. The Hopkins blue jay (Fig. 2f) was printed at 5 mm/s using pressures of 20 psi.
The gradient filament diameter samples in Figs. 3 and 4 were printed using a fixed nozzle diameter (20 GA, Nordson EFD) at constant print speed; the flow rate was altered by adjusting the extrusion pressure applied. When decreasing flow rates and thus lower pressure inputs are desired, the pressure build-up in the nozzle is released by toggling the solenoid valves off and on quickly. The white increasing diameter filament gradients (Fig. 3a–d) were printed at a speed of 15 mm/s at increasing pressures of 25–55 psi. The constant width and variable infill structures (Figs. 3f–j and 4a, b), were printed at speeds of 5 mm/s; the gradient diameter samples were printed at pressures of 18–30 psi (pressure change increments every 1 mm), and constant filament width samples were printed at 18 psi. The epoxy lattice structures (Fig. 4c) were printed at speeds of 10 mm/s; the non-graded cellular structures were printed at 40 psi, and the graded structures were printed at 30–45 psi, with a pressure change occurring every 0.5 mm.
The coextruded compositional gradients (Fig. 5) were printed at speeds of 10 mm/s (linearly graded sample) and 5 mm/s (cube illusion and Einstein) using pressures of 5–25 psi and 5–20 psi, respectively; the appropriate pressure ratios for each material were found using the experimentally determined relationship between flow rate and pressure shown in Fig. 5c and discussed more below.
The parallel print mountain scene (Fig. 6a–g) was printed at a speed of 5 mm/s using pressures of 20 psi. The parallel printed discrete 3D shapes (Fig. 6h–m) were printed using 18 GA nozzles (Nordson EFD) at speeds of 10 mm/s at a starting pressure of 25 psi; the pressures were increased by 0.1 psi every layer to account for increasing viscosity as the ink aged (see Supplementary Fig. 17).
Coextrusion pressure ratio determination
To maintain a constant cross-sectional area of the filament, the relationship between pressure and flow rate of SE1700 through the switching nozzle was experimentally determined by extruding a single material through a 1 mm diameter switching nozzle at various pressures. A curve was fitted to the data using a non-linear least squares optimization function in Python. Due to factors such as nozzle channel geometry (Supplementary Fig. 19), thixotropy, and material pot life, it is challenging to directly apply existing flow models, like the Herschel-Bulkley model64, to determine the flow rate-pressure relationship. Therefore, the fitted curve presented in Fig. 5c is used for interpolation of the measured data to determine the appropriate pressure values for specific color ratios. The flow rate-pressure relationship is verified through the coextrusion of red and blue dyed SE1700 aged 0.5–1 h (Fig. 5d). Assuming a cylindrically extruded filament with radius r and speed v, the ideal flow rate is given by:
Figure 5e–g further verifies that appropriate color ratios can be achieved while maintaining a relatively constant filament diameter. Errors in the ratios and widths of the filaments are likely due to the flow rate’s dependence on factors that change over time, such as thixotropy and pot life. Although these factors are important, addressing them was beyond the scope of this project.
Print characterization
The accuracy and precision of the 2D samples used to validate the T-Code method were assessed by scanning the samples’ surface at 3200 dpi (Epson) and using Photoshop (Adobe) to remove dust and reduce glare from the curved surface of the filaments. A custom Python script was used to determine the location and color of each pixel and compare them across samples and to the ideal structure. Supplementary Fig. 8 provides an example of how the porosity and contour error for the variable contour infill samples (Fig. 3) were determined.
Mechanical tests of the functionally graded lattices in Fig. 4 were performed on an electromechanical testing system (Criterion, MTS) using a 50 kN load cell. The samples were tested under compression at a rate of 0.25 mm/s. The energy absorption for gradient lattice structures was calculated by computing the area under the stress-strain (σ–ϵ) curve up to the average onset of densification strain (ϵd) (Supplementary Fig. 11) as given by:
Data availability
Source data are provided with this paper.
Code availability
T-Code is available at https://github.com/JHU-Mueller-Lab/Time-Code-for-Multifunctional-3D-Printhead-Controls.
References
Hui, Y. et al. Three-dimensional printing of soft hydrogel electronics. Nat. Electron. 5, 893–903 (2022).
Zhang, P. et al. Integrated 3D printing of flexible electroluminescent devices and soft robots. Nat. Commun. 13, 4775 (2022).
Zhou, N., Liu, C., Lewis, J. A. & Ham, D. Gigahertz electromagnetic structures via direct ink writing for radio-frequency oscillator and transmitter applications. Adv. Mater. 29, 1605198 (2017).
Dylla-Spears, R. et al. 3D printed gradient index glass optics. Sci. Adv. 6, eabc7429 (2020).
Xin, S. et al. Generalizing hydrogel microparticles into a new class of bioinks for extrusion bioprinting. Sci. Adv. 7, eabk3087 (2021).
Saadi, M. et al. Direct ink writing: a 3D printing technology for diverse materials. Adv. Mater. 34, 2108855 (2022).
Zhao, S. et al. Additive manufacturing of silica aerogels. Nature 584, 387–392 (2020).
Kim, F. et al. Direct ink writing of three-dimensional thermoelectric microarchitectures. Nat. Electron. 4, 579–587 (2021).
Gantenbein, S. et al. Three-dimensional printing of mycelium hydrogels into living complex materials. Nat. Mater. 22, 128–134 (2023).
Wan, X., Luo, L., Liu, Y. & Leng, J. Direct ink writing based 4D printing of materials and their applications. Adv. Sci. 7, 2001000 (2020).
Tagliaferri, S., Panagiotopoulos, A. & Mattevi, C. Direct ink writing of energy materials. Mater. Adv. 2, 540–563 (2021).
Shahzad, A. & Lazoglu, I. Direct ink writing (DIW) of structural and functional ceramics: recent achievements and future challenges. Compos. Part B: Eng. 225, 109249 (2021).
Qian, F. et al. Direct writing of tunable living inks for bioprocess intensification. Nano Lett. 19, 5829–5835 (2019).
Skylar-Scott, M. A., Mueller, J., Visser, C. W. & Lewis, J. A. Voxelated soft matter via multimaterial multinozzle 3D printing. Nature 575, 330–335 (2019).
Ober, T. J., Foresti, D. & Lewis, J. A. Active mixing of complex fluids at the microscale. Proc. Natl Acad. Sci. USA 112, 12293–12298 (2015).
Ortega, J. M. et al. Active mixing of disparate inks for multimaterial 3D printing. Adv. Mater. Technol. 4, 1800717 (2019).
Kokkinis, D., Bouville, F. & Studart, A. R. 3D printing of materials with tunable failure via bioinspired mechanical gradients. Adv. Mater. 30, 1705808 (2018).
Ceballos-González, C. F. et al. Plug-and-play multimaterial chaotic printing/bioprinting to produce radial and axial micropatterns in hydrogel filaments. Adv. Mater. Technol. 8, 2202208 (2023).
Zeng, M. et al. High-throughput printing of combinatorial materials from aerosols. Nature 617, 292–298 (2023).
Giachini, P. et al. Additive manufacturing of cellulose-based materials with continuous, multidirectional stiffness gradients. Sci. Adv. 6, eaay0929 (2020).
Skylar-Scott, M. A., Gunasekaran, S. & Lewis, J. A. Laser-assisted direct ink writing of planar and 3D metal architectures. Proc. Natl Acad. Sci. USA 113, 6137–6142 (2016).
Kotikian, A. et al. Innervated, self-sensing liquid crystal elastomer actuators with closed loop control. Adv. Mater. 33, 2101814 (2021).
Raney, J. R. et al. Rotational 3d printing of damage-tolerant composites with programmable mechanics. Proc. Natl Acad. Sci. USA 115, 1198–1203 (2018).
Larson, N. M. et al. Rotational multimaterial printing of filaments with subvoxel control. Nature 613, 682–688 (2023).
Franchin, G., Wahl, L. & Colombo, P. Direct ink writing of ceramic matrix composite structures. J. Am. Ceram. Soc. 100, 4397–4401 (2017).
Rocha, V. G., Saiz, E., Tirichenko, I. S. & García-Tuñón, E. Direct ink writing advances in multi-material structures for a sustainable future. J. Mater. Chem. A 8, 15646–15657 (2020).
Mueller, J., Raney, J. R., Shea, K. & Lewis, J. A. Architected lattices with high stiffness and toughness via multicore–shell 3D printing. Adv. Mater. 30, 1705001 (2018).
Ren, J. et al. Multicore–shell direct ink writing of coaxial transmission lines. ACS Appl. Eng. Mater. 2, 67–75 (2024).
Kumar, A., Kumar, P., Mittal, R. K. & Singh, H. Printing file formats for additive manufacturing technologies. In Advances in Additive Manufacturing 87–102 (2023).
Smid, P. CNC Programming Handbook: A Comprehensive Guide to Practical CNC Programming (Industrial Press Inc., 2003).
Saldívar, M. et al. Bioinspired rational design of bi-material 3D printed soft-hard interfaces. Nat. Commun. 14, 7919 (2023).
Lao, W., Li, M. & Tjahjowidodo, T. Variable-geometry nozzle for surface quality enhancement in 3D concrete printing. Addit. Manuf. 37, 101638 (2021).
Xu, J. et al. Volume-forming 3d concrete printing using a variable-size square nozzle. Autom. Constr. 104, 95–106 (2019).
Kang, S.W. and Mueller, J. Multiscale 3D printing via active nozzle size and shape control. Science Advances 10, eadn7772 (2024).
Tronvoll, S. A., Popp, S., Elverum, C. W. & Welo, T. Investigating pressure advance algorithms for filament-based melt extrusion additive manufacturing: theory, practice and simulations. Rapid Prototyp. J. 25, 830–839 (2019).
Rau, D. A., Williams, C. B. & Bortner, M. J. Rheology and printability: A survey of critical relationships for direct ink write materials design. Prog. Mater. Sci. 140, 101188 (2023).
Cipriani, C. E., Shu, Y., Pentzer, E. B. & Benjamin, C. C. Viscoelastic and thixotropic characterization of paraffin/photopolymer composites for extrusion-based printing. Phys. Fluids 34, 093106 (2022).
Kwon, N., Deshpande, H., Hasan, M. K., Darnal, A. & Kim, J. Multi-ttach: techniques to enhance multi-material attachments in low-cost FDM 3D printing. In Proceedings of the 6th Annual ACM Symposium on Computational Fabrication, 1–16 (2021).
Ahn, S.-J., Lee, H. & Cho, K.-J. 3D printing with a 3D printed digital material filament for programming functional gradients. Nat. Commun. 15, 3605 (2024).
Han, C. et al. Continuous functionally graded porous titanium scaffolds manufactured by selective laser melting for bone implants. J. Mech. Behav. Biomed. Mater. 80, 119–127 (2018).
Tan, T. et al. Mechanical properties of functionally graded hierarchical bamboo structures. Acta Biomater. 7, 3796–3803 (2011).
Niknam, H. & Akbarzadeh, A. Graded lattice structures: simultaneous enhancement in stiffness and energy absorption. Mater. Des. 196, 109129 (2020).
Mueller, J. & Shea, K. Stepwise graded struts for maximizing energy absorption in lattices. Extrem. Mech. Lett. 25, 7–15 (2018).
Mueller, J., Raney, J. R., Kochmann, D. M. & Shea, K. Stiffness-independent toughening of beams through coaxial interfaces. Adv. Sci. 5, 1800728 (2018).
Houriet, C. et al. 3d printing of flow-inspired anisotropic patterns with liquid crystalline polymers. Adv. Mater. 36, 2307444 (2024).
Duncan, B. et al. Low-loss graded dielectrics via active mixing of nanocomposite inks during 3d printing. Adv. Mater. Technol. 8, 2201496 (2023).
Haring, A. P., Tong, Y., Halper, J. & Johnson, B. N. Programming of multicomponent temporal release profiles in 3d printed polypills via core–shell, multilayer, and gradient concentration profiles. Adv. Healthc. Mater. 7, 1800213 (2018).
Qu, H. et al. Gradient matters via filament diameter-adjustable 3d printing. Nat. Commun. 15, 2930 (2024).
Hornus, S. et al. Variable-width contouring for additive manufacturing. ACM Trans. Graph. (TOG) 39, 131–1 (2020).
Kuipers, T., Doubrovski, E. L., Wu, J. & Wang, C. C. A framework for adaptive width control of dense contour-parallel toolpaths in fused deposition modeling. Comput. Aided Des. 128, 102907 (2020).
Bai, L. et al. Configuration optimization design of Ti6Al4V lattice structure formed by SLM. Materials 11, 1856 (2018).
Ashby, M. F. & Gibson, L. J. Cellular solids: structure and properties. Press Syndicate of the University of Cambridge 175–231 (1997).
Therriault, D., White, S. R. & Lewis, J. A. Chaotic mixing in three-dimensional microvascular networks fabricated by direct-write assembly. Nat. Mater. 2, 265–271 (2003).
Hardin, J. O., Ober, T. J., Valentine, A. D. & Lewis, J. A. Microfluidic printheads for multimaterial 3d printing of viscoelastic inks. Adv. Mater. 27, 3279–3284 (2015).
Wu, Y.-C., Tsai, Y.-T., Lin, W.-C. & Li, W.-H. Generating pointillism paintings based on seurat’s color composition. In Computer Graphics Forum, Vol. 32, 153–162 (Wiley Online Library, 2013).
Chae, Y. The color appearance shifts of woven fabrics induced by the optical blending of colored yarns. Text. Res. J. 90, 395–409 (2020).
Compton, B. G. & Lewis, J. A. Dd-printing of lightweight cellular composites. Adv. Mater. 26, 5930–5935 (2014).
Wei, P. et al. Go with the flow: Rheological requirements for direct ink write printability. J. Appl. Phys. 134, 100701 (2023).
Das, A., Gilmer, E. L., Biria, S. & Bortner, M. J. Importance of polymer rheology on material extrusion additive manufacturing: correlating process physics to print properties. ACS Appl. Polym. Mater. 3, 1218–1249 (2021).
Zeng, L. et al. Recent progresses of 3D printing technologies for structural energy storage devices. Mater. Today Nano 12, 100094 (2020).
Ji, D., Zheng, H., Zhang, H., Liu, W. & Ding, J. Coaxial 3D-printing constructing all-in-one fibrous lithium-, sodium-, and zinc-ion batteries. Chem. Eng. J. 433, 133815 (2022).
Boley, J. W. et al. Shape-shifting structured lattices via multimaterial 4D printing. Proc. Natl Acad. Sci. USA 116, 20856–20862 (2019).
Guo, M., Li, Q., Gao, B. & He, B. One-step 3D printed intelligent silk fibroin artificial skin with built-in electronics and microfluidics. Analyst 146, 5934–5941 (2021).
Zheng, Q., Xie, B., Xu, Z. & Wu, H. A systematic printability study of direct ink writing towards high-resolution rapid manufacturing. Int. J. Extrem. Manuf. 5, 035002 (2023).
Lee-Sean Huang, Flickr. Albert Einstein. https://www.flickr.com/photos/leesean/15430375227. This work is licensed under the Creative Commons Attribution-ShareAlike (CC BY-SA 2.0). To view a copy of this license, visit https://creativecommons.org/licenses/by-sa/2.0/. (2014).
Acknowledgements
We gratefully acknowledge funding from the Jean-Jacques and Felicia Lopez-Loreta Foundation for Academic Excellence. Research was sponsored by the Army Research Laboratory and was accomplished under Cooperative Agreement Number W911NF-23-2-0062. The views and conclusions contained in this document are those of the authors and should not be interpreted as representing the official policies, either expressed or implied, of the Army Research Laboratory or the U.S. Government. The U.S. Government is authorized to reproduce and distribute reprints for Government purposes notwithstanding any copyright notation herein. We thank A.J. Schepers for assistance with code debugging and helpful network connectivity discussions.
Author information
Authors and Affiliations
Contributions
S.P. and J.M. designed the research. S.P. performed the research and analyzed the data. S.P. and J.M. prepared the manuscript.
Corresponding author
Ethics declarations
Competing interests
S.P. declares no competing interests. J.M. is a co-founder and shareholder at Mooji Meats Inc.
Peer review
Peer review information
Nature Communications thanks Lihua Lu, Devin Roach and the other, anonymous, reviewer for their contribution to the peer review of this work. A peer review file is available.
Additional information
Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Supplementary information
Source data
Rights and permissions
Open Access This article is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License, which permits any non-commercial use, sharing, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if you modified the licensed material. You do not have permission under this licence to share adapted material derived from this article or parts of it. The images or other third party material in this article are included in the article’s Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
About this article
Cite this article
Propst, S., Mueller, J. Time Code for multifunctional 3D printhead controls. Nat Commun 16, 1035 (2025). https://doi.org/10.1038/s41467-025-56140-1
Received:
Accepted:
Published:
Version of record:
DOI: https://doi.org/10.1038/s41467-025-56140-1
This article is cited by
-
Additive Manufacturing for Nanogenerators: Fundamental Mechanisms, Recent Advancements, and Future Prospects
Nano-Micro Letters (2026)
-
Multimaterial extrusion 3D printing printheads
Nature Reviews Materials (2025)
-
Non-planar additive manufacturing with hydrogels: a review of flow control and toolpath strategies
npj Soft Matter (2025)








