CHARACTERIZATION AND APPLICATIONS OF

ELECTRICALLY-CONDUCTIVE FILAMENT IN

by

PRATIK DILIP DESAI, B.S.E.E.

A THESIS

Submitted to

The Department of Engineering

Colorado State University-Pueblo

In partial fulfillment of the requirements for the degree of Master of Science

CERTIFICATION OF ACCEPTANCE

This thesis

presented in partial fulfillment of

the requirements for the degree of

Master of Science

has been accepted by the

Program of Mechatronics Engineering

Colorado State University – Pueblo

APPROVED:

Dr. Nebojsa I. Jaksic, Ph.D., P.E., Committee Chair Date

Dr. Jude L. DePalma, Ph.D., Committee Member Date

Dr. Bahaa I. Kazem, Ansaf, Ph.D., Committee Member Date

Master’s Candidate Pratik D. Desai, B.S.E.E.

Date of Thesis Presentation December 15, 2016

Pratik D. Desai for the degree of Master of Science in Engineering with emphasis in

Mechatronics, presented on December 15th, 2016 at Colorado State University-Pueblo

Title:

Characterization and Applications of Electrically-Conductive Filament in 3D Printing

Abstract approved:

Professor Nebojsa I. Jaksic, Ph.D., P.E., Advisor

Abstract

Three dimensional printing (3D printing) a form of has been conceived by Charles W. Hull in 1986. As design patents pertaining to expensive commercial 3D printers expire, more affordable 3D printers are emerging. One particular 3D printing technology that has become very popular is Fused Filament Fabrication (FFF). The widespread acceptance of FFF printers has boosted the demand for new types of filaments with different properties. Filament composites can provide 3D prints with additional functionality. There is a need to characterize new filaments and to develop novel applications that will further push the boundaries of this technology. This research explores the use and characterization of electrically-conductive

Carbon Black plastic composite filament in conjunction with desktop FFF printers. Electrically- conductive graphene plastic composite is also characterized based on these results. Resistors, capacitors, and inductors are designed, created, and characterized. Based on these findings, capacitive touch and flexure sensors are designed, implemented, and characterized. A small musical keyboard is designed and built to showcase the use of readily available conductive filament in low cost 3D printers. Finally, 3D printing process best practices and improvements are detailed, and additional recommendations are made.

Table of Contents

Abstract ...... iii Table of Contents ...... iv List of Figures ...... vii List of Tables ...... x Acknowledgements ...... xi Abbreviations ...... xii Chapter I Introduction ...... 1 1.1 Motivation ...... 2 1.2 Research Goals...... 2 1.3 Structure of Thesis ...... 3 Chapter II Background and Literature Review ...... 5 2.1 Short History of 3D Printing ...... 5 2.2 Expiration of Key Patents ...... 6 2.3 Previous Research ...... 8 2.3.1 3D Electronics Printers ...... 8 2.3.2 3D Printed Circuits and Applications ...... 10 Chapter III Research Methodology ...... 12 3.1 Standards and Terminology for Additive Manufacturing ...... 12 3.1.1 Additive Manufacturing Terminology ...... 13 3.1.2 Current AM Standards ...... 15 3.1.3 ASTM D4496 – 13...... 15 3.2 Equipment ...... 18 3.2.1 Replicator 2X Experimental 3D Printer ...... 18 3.2.2 Replicator 2X Improvements ...... 20 3.2.3 2X Printing Process ...... 22 3.2.4 FFF Printer Filaments ...... 22 3.2.5 Measuring Instruments...... 23 3.2.6 PSoC® ...... 23 3.2.7 CapSense® ...... 24

iv Chapter IV Characterization of Passive Elements ...... 27 4.1 Resistor ...... 28 4.1.1 Design of Resistor Testbeds...... 28 4.1.2 Resistance Versus X-Axis Expansion ...... 30 4.1.3 Resistance Versus Y-Axis Expansion ...... 36 4.1.4 Resistance Versus Z-Axis Expansion (Linear) ...... 42 4.1.5 Resistance Versus Z-Axis Expansion (Geometric)...... 45 4.2 Capacitor ...... 49 4.2.1 Capacitance Versus X-Axis Expansion ...... 55 4.2.2 Capacitance Versus Y-Axis Expansion ...... 59 4.2.3 Capacitance Versus Z-Axis Expansion (Number of Plates) ...... 63 4.3 Inductor ...... 69 Chapter V Design and Implementation of Sensors ...... 78 5.1 Capacitive Touch ...... 78 5.1.1 Sensor Design ...... 78 5.1.2 Sensor Test Application ...... 82 5.1.3 Capacitive Sensor Test Results ...... 84 5.2 Flexure Sensor ...... 88 5.2.1 Sensor Design ...... 88 5.2.2 Test Apparatus ...... 89 5.2.3 Flexure Sensor Test Results ...... 90 Chapter VI Application – Musical Keyboard ...... 93 6.1 Five Keys ...... 93 6.1.1 Keyboard Design ...... 93 6.1.2 Keyboard Application ...... 97 6.2 Full Octave ...... 99 6.2.1 Keyboard Design ...... 99 6.2.2 Keyboard Application ...... 103 Chapter VII Conclusions & Future Work ...... 105 References ...... 108 Appendix A Capacitive Sensor Test Application ...... 113

v Appendix A.1 Main.c ...... 113 Appendix A.2 CapSense Configurations ...... 115 Appendix A.3 Capacitive Sensor Ground Plane Drawings ...... 118 Appendix B Music Keyboard – Five Key ...... 121 Appendix B.1 Conductive Layer Drawings ...... 121 Appendix B.2 Five Key PSoC Application – Top Level Design ...... 123 Appendix B.3 Five Key PSoC Application – Pin Assignments ...... 124 Appendix B.4 Five Key PSoC Application – CapSense Configuration ...... 124 Appendix B.5 Five Key PSoC Application – Main.c ...... 125 Appendix C Music Keyboard – Octave ...... 129 Appendix C.1 Conductive Layer Drawings ...... 129 Appendix C.2 Octave Keyboard PSoC Application – Top Level Design ...... 131 Appendix C.3 Octave Keyboard PSoC Application – Configs.h ...... 132 Appendix C.4 Octave Keyboard PSoC Application – Main.c ...... 133 Appendix C.5 Octave Keyboard PSoC Application – Sound.h ...... 142 Appendix C.6 Octave Keyboard PSoC Application – Sound.c ...... 145

vi List of Figures

Figure 1: MakerBot Replicator 2X Experimental 3D printer ...... 18 Figure 2: MakerBot 2X standard dual extruder ...... 19 Figure 3: Standard 2X test print ...... 20 Figure 4: Improved 2X test print ...... 21 Figure 5: Standard Test Platform ...... 27 Figure 6: Resistor Test Sample Design (mm) ...... 29 Figure 7: MakerBot Desktop layout - Resistance vs. X-Axis expansion testbed ...... 30 Figure 8: MakerBot Desktop Slicing Preview - X-Axis Expansion Testbed ...... 32 Figure 9: 3D Print - X-Axis Expansion Testbed ...... 32 Figure 10: Resistance vs. Width of Resistive Element (Conductive PLA) ...... 34 Figure 11: Resistivity vs. Width of Resistive Element (Conductive PLA) ...... 35 Figure 12: MakerBot Desktop layout - Resistance vs. Y-Axis expansion testbed ...... 36 Figure 13: MakerBot Desktop software - purge wall to improve start of extruder ...... 37 Figure 14: Resistance vs. Length of Resistive Element (Conductive PLA) ...... 38 Figure 15: Resistivity vs. length of resistive element (C. PLA) ...... 39 Figure 16: MakerBot Desktop layout - Resistance vs. Z-Axis (linear) expansion testbed ...... 42 Figure 17: Resistance vs. height of resistive element (Linear) (C. PLA) ...... 43 Figure 18: Resistivity vs. height of resistive element (Linear) (C. PLA) ...... 44 Figure 19: MakerBot Desktop layout - resistance vs. Z-Axis (geometric) expansion testbed ..... 45 Figure 20: Resistance vs. Height of Resistive Element (Geometric) (C. PLA) ...... 47 Figure 21: Resistivity vs. height of resistive element (Geometric) (C. PLA)...... 48 Figure 22: Parallel plate capacitor ...... 50 Figure 23: Multi-plate capacitor ...... 52 Figure 24: Initial design of multi-plate capacitor ...... 53 Figure 25: Capacitor short due to lateral separation of 0.6 mm...... 53 Figure 26: Eliminate electrical short - Increase terminal lateral spacing ...... 55 Figure 27: Eliminate electrical short - Add non-conductive PLA barrier ...... 55 Figure 28: MakerBot Desktop layout - capacitance vs. X-Axis expansion testbed ...... 56 Figure 29: Capacitance vs. width of conductive plate (conductive PLA) ...... 57

vii Figure 30: Dielectric constant vs. conductive plate width (conductive PLA) ...... 59 Figure 31: MakerBot Desktop layout - Capacitance vs. Y-Axis expansion testbed ...... 60 Figure 32: Capacitance vs. Length of Conductive Plate (Conductive PLA) ...... 61 Figure 33: Dielectric constant vs. Conductive Plate Length (Conductive PLA) ...... 63 Figure 34: MakerBot Desktop layout - capacitance vs. Z-Axis expansion (No. Plates) testbed .. 64 Figure 35: Z-Axis expansion testbed with exposed terminal plates ...... 65 Figure 36: Capacitance vs. number of conductive plates (conductive PLA) ...... 66 Figure 37: Dielectric constant vs. number of conductive plates (conductive PLA) ...... 67 Figure 38: Physical parameters of an inductor ...... 69 Figure 39: Inductor conductive coil (10.5 turn, 10.0 mm inner diameter) – front view ...... 71 Figure 40: Inductor conductive core (10.5 turn, 10.0 mm inner diameter) - Isometric view ...... 72 Figure 41: Inductor insulating support block ...... 73 Figure 42: MakerBot Desktop layout, print preview, 3D print - Inductor (10.5 turns, 10.0 mm inner diameter) ...... 74 Figure 43: Inductor conductive core and 3D print with ferrite (10.5 turn, 22.0 mm inner diameter) ...... 75 Figure 44: 3D printed inductor with ferrite (10.5 turns, 22.0 mm inner diameter) ...... 76 Figure 45: Approximation of inductor (10.5 turns, 24.0 mm inner diameter) ...... 77 Figure 46: Electrical connection socket evaluation ...... 79 Figure 47: Standardized capacitive sensor pad design ...... 81 Figure 48: Capacitive sensor test application - Top level design ...... 82 Figure 49: Capacitive sensor test application - Pin assignments ...... 83 Figure 50: Capacitive sensor test sample one - 3mm lateral spacing ...... 85 Figure 51: Capacitive sensor test sample two - 2mm lateral spacing ...... 85 Figure 52: Capacitive sensor test sample three - 1mm lateral spacing ...... 85 Figure 53: Capacitive sensor test sample four - 2mm lateral spacing with GND backplane ...... 86 Figure 54: Capacitive sensor test sample five - 2mm lateral spacing with GND hatch ...... 86 Figure 55: Flexure sensor - conductive circuit trace design (mm) ...... 88 Figure 56: MakerBot Desktop layout and 3D print - Flexure sensor ...... 89 Figure 57: Flexure sensor testing apparatus...... 90 Figure 58: Flexure sensor - Resistance vs. deflection...... 91

viii Figure 59: Music keyboard - Five Key - Conductive layer ...... 95 Figure 60: MakerBot Desktop layout - Music keyboard - Five Keys ...... 96 Figure 61: Fully assembled music keyboard - Five keys ...... 97 Figure 62: Minimize electrical shorts - conductive circuits Z-axis lift ...... 99 Figure 63: Minimize electrical shorts – Conductive Z-axis lift – 3D print ...... 100 Figure 64: Music keyboard - Octave - 3D print layers ...... 101 Figure 65: MakerBot Desktop layout - Octave keyboard ...... 102 Figure 66: Fully assembled octave keyboard ...... 103

ix List of Tables

Table 1: Resistor sample test data - X-Axis expansion ...... 33 Table 2: Resistivity of sample test data - X-Axis expansion ...... 34 Table 3: Resistor sample test data - Y-Axis expansion ...... 38 Table 4: Resistivity of sample test data - Y-Axis expansion ...... 39 Table 5: Reheated resistor sample test data – Y-Axis expansion ...... 41 Table 6: Reheated sample resistivity - Y-Axis expansion ...... 41 Table 7: Resistor sample test data - Z-Axis (linear) expansion ...... 43 Table 8: Resistivity of sample test data - Z-Axis expansion (Linear) (C. PLA) ...... 44 Table 9: Resistor sample test data - Z-Axis (geometric) expansion ...... 46 Table 10: Resistivity of sample test data - Z-Axis expansion (Geometric) (C. PLA) ...... 47 Table 11: Capacitor sample test data - X-Axis expansion ...... 56 Table 12: Dielectric constant of sample data - X-Axis expansion ...... 58 Table 13: Dielectric constant data statistics - X-Axis expansion ...... 58 Table 14: Capacitor sample test data - Y-Axis expansion ...... 60 Table 15: Dielectric constant data - Y-Axis expansion ...... 62 Table 16: Dielectric constant data statistics - Y-axis expansion ...... 62 Table 17: Capacitor sample test data - Z-Axis expansion (no. plates) (C. PLA) ...... 65 Table 18: Dielectric constant data - Z-Axis expansion (no. plates) (C. PLA) ...... 67 Table 19: Dielectric constant statistics for capacitor with no. plates 4, 6, 8, and 10 - Z-axis expansion ...... 68 Table 20: Capacitive sensor test results ...... 87 Table 21: Flexure sensor test results ...... 91

x Acknowledgements

I would like to express my sincere gratitude to all the following people who helped me make this work a success, and help fulfil my ambition of achieving my masters.

To my advisor Dr. Neb Jaksic. His continual support, guidance, and teaching throughout my degree, along with his assistance and contributions to my research have been invaluable. To my thesis committee members Dr. DePalma and Dr. Ansaf, for their patience and guidance towards my work. To Mr. Paul Wallace, for all his help, in particular towards mechanical fabrication. To faculty members, for imparting their knowledge which has greatly aided my research. To faculty admin staff for their support, and guidance on rules and regulations.

To my sister and her family, for providing me with a home, and their undivided support in all aspects of my life, without whom I would not have been able to pursue my masters. To my parents and grandma, for their moral guidance and unhindered belief in me.

To my dear friend Anais, for her support and encouragements through the tough times.

To Mrs. Annie Williams, for keeping me in check with immigration requirements, and moral support. To Ms. Heidi Laino, for her encouragements and countless meals during lunch. To the staff at the Center of International Programs (CIP) office, for many interesting conversations during my lunch breaks.

Finally, to everyone else who have been a part of my life in these past few years.

xi Abbreviations

2D Two Dimension

3D Three Dimension

AM Additive Manufacturing

CAD Computer Aided Design

CAM Computer Aided Manufacturing

DC Direct Current

FFF Fused Filament Fabrication

PCB

SLA Stereolithographic Apparatus

UV Ultraviolet Light Spectrum

xii Chapter I

Introduction

We currently live in a society that expects technological iterations of devices in a relatively short period of time. Fast-paced consumer market trends force manufacturers to integrate new technologies and to improve product specifications while at the same time reducing product life cycle environmental impact and maintaining competitive costs. Due to these factors, manufacturers are seeking out technology and processes that can minimize their time to market and reduce overall costs by optimizing all aspects of production. These requirements on manufacturing during the past few decades have fueled developments in rapid prototyping technology and related processes.

Rapid prototyping, commonly known as three dimensional (3D) printing, a form of additive manufacturing (AM), builds objects using a layer by layer process. Since its inception by Charles W. Hull [1], it was created to reduce the turnaround time for designers, from inception to finished prototype. The development phase of a product usually includes multiple design iterations. Prior to 3D printing, designers had to wait many weeks to receive a prototype from the fabrication facility. While 3D printing does not offer the benefit of the economy of scale of traditional manufacturing methods, it is accepted as a preferred method for production of functional prototypes and small batches.

The overall objective of this research is to further the field of 3D printing, in particular the use of 3D printers to embed electronics within end user applications. This, in part, is achieved by characterizing newly available electrically conductive filament (filament for use in

Fused Filament Fabrication (FFF) 3D printers). This goal is achieved by designing passive electrical components resistors, capacitors, and inductors, followed by sensors and applications.

1 1.1 Motivation

3D printing is an additive manufacturing process and as such reduces waste. Availability of biodegradable plastic filaments for FFF printers, coupled with AM processes, is paving a new era for manufacturing and sustainability. Most commonly used processes to create printed circuit boards (PCB) make use of composite materials that cannot be easily recycled. As such, printing usable circuits using biodegradable electrically conductive filament offers a benefit to the user and the environment. Being able to 3D print electrical circuits allows designers to better integrate electrical components within physical objects with a focus on usability and ergonomics, ultimately resulting in a better product, and increase in product usage and lifespan. With the recent demand for 3D printers and 3D printed objects, there is a window of opportunity to embed electrical circuits within end user applications.

1.2 Research Goals

In the early stages, the 3D printing industry concentrated their efforts to make this technology viable for industrial use. The uptake of AM in aviation, vehicle, and medical industries, provided the necessary resources to refine this technology. Now, this technology is seeing widespread use in the consumer market. Increase in global acceptance for 3D printers in our homes is further lowering the cost of ownership. This is attracting new users and widening the possible uses for this technology.

In the past few years, some new research has focused on the use of electrically- conductive material for use in 3D printers to create electrical circuits. The purpose has been to embed electrical circuits into 3D printed objects.

2 There is significant research on conductive materials. However, these materials are not easily accessible. Electrically-conductive plastic composite filament based on carbon black and graphene is available in consumer grade FFF 3D printers. There is a need to characterize these materials to better understand how to use them in FFF 3D printers. There is a need for this research, so that these materials can be better utilized to provide end user application, thus aiding in further acceptance of 3D printers.

1.3 Structure of Thesis

This thesis is divided into the following chapters; Introduction, Background and

Literature Review, Research Methodology, Characterization of Passive Elements, Design and

Implementation of Sensors, Application – Musical Keyboard, and finally, Conclusions & Future

Work.

Chapter two, Background and Literature Review, addresses the basic definitions and terminology used during the analysis phase of the thesis. It analyses the current research, to identify knowledge gaps that this thesis may address.

Chapter three, Research Methodology, outlines current standards and terminology related to AM. It reviews current applicable standards and defines the experimental process, along with the collected data that will be used for further analysis. This section also provides details into the equipment used in this thesis.

Chapter four, Characterization of Passive Elements, is the foundation of this thesis. This chapter details the design phase for the electrical passive elements; resistors, capacitors, and inductors. This is followed by test results and analysis of data, providing the necessary characterization map for the passive elements.

3 Chapter five, Design and Implementation of Sensors, details the design and characterization phases of sensors. A capacitive touch and flexure sensors are designed and tested for their functionality and performance.

Chapter six, Application – Musical Keyboard, showcases the design, development, and implementation of an end-user application in the form of a musical keyboard. This is a novel approach, creating a functional music keyboard, with 3D printed touch sensors, and plug and play electronics.

Finally, chapter seven, Conclusions & Future Work, summarizes the findings of this research and recommends further research that can stem from this thesis.

4 Chapter II

Background and Literature Review

In this chapter, the history of 3D printing is explored which provides the baseline context of the importance of 3D printing technology in manufacturing today. This is followed by an outline of the expiration of key patents, widely considered a key factor in the rise of current low cost FFF 3D printers. Then, a general overview of current 3D printing technology is provided.

Finally, current research material is evaluated to ascertain any gaps in the knowledge for the use of electrically conductive material/filaments in 3D printing.

2.1 Short History of 3D Printing

Prior to 3D printing, automated manufacturing predominately made use of computer numerical control (CNC) based machines. Since the invention of 3D printing by Charles Hull in

1986, 3D printing industry has flourished with innovative new processes.

Scott Crump invented Fused Filament Fabrication (FFF) in 1989, and went on to form the company Stratasys. Also in 1989, Carl Deckard invented Selective Laser Sintering (SLS), making use of a targeted radiation source to sinter particles together. In 2000, MPC Technologies took SLS a stage further and introduced (SLM). Dr. Bowyer created the

RepRap project in 2004, and self-replicating 3D printer. In 2007, the 3D printing industry had its first system launched for under $10,000. RepRap showcased their first commercially available 3D printer in 2009, based on the RepRap kit form. In 2012, alternate were launched at the entry level marker, B9Creator (DLP technology) and

Form-1 (). In 2014, the launch of Micro 3D printer at $349 is considered to be

5 the first affordable 3D printer. Mattel launched their first consumer level 3D printer in 2016 at

$299. Finally, in 2016 HP launched their first multi-jet fusion technology based 3D printer.

2.2 Expiration of Key Patents

The inventors of 3D printing processes were quick to realize the benefits of this technology for commercial and industrial use. Patent protected processes quickly emerged into the market in the form of 3D printers for commercial use. An entire industry formed around rapid prototyping, where key companies had the largest commercial market share. However, this growth of the commercial sector stifled the consumer market. The cost of ownership of 3D printers in the 1990’s, and early 2000’s was relatively high, negating widespread consumer acceptance. It was not until the expiration of key patents that allowed commercial 3D printers to be re-purposed for the consumer market.

In 1986, Charles Hull was issued the first patent related to 3D printing, U.S. Patent

4,575,330, for his invention Stereolithographic Apparatus (SLA) [2]. This patent was dubbed

“original U.S. stereolithography patent,” and has since expired. Hull’s motivation behind the

SLA 3D printer was to find a method to quickly produce prototypes in plastic [1]. Prior to the invention of the SLA 3D printer, a physical part took weeks to produce after a design iteration was completed. Designs usually required multiple stages of prototypes, making the whole process costly and time consuming. Hull then co-founded 3D Systems, which in 1987 launched their first commercially available SLA printer, the SLA-1. The invention of the SLA-1, and subsequent 3D printers allowed designers to dramatically cut down the design and development time and costs.

6 In the next few years after 1986, multiple U.S. patents were filed that further added to the

Stereolithographic process. In 1990, Hull was issued U.S. Patent 4,929,402, “Method for production of three-dimensional objects by stereolithography” [3]. In 1991, Hull et al. was issued

U.S Patent 4,999,143, “Methods and apparatus for production of three-dimensional objects by stereolithography” [4]. Finally in 1992, Almquist et al was issued U.S Patent 5,174,931,

“Method of and apparatus for making a three-dimensional product by stereolithography” [5].

These patents have since expired and are considered to be important contributors to the 3D printing technology.

While Hull was developing the SLA 3D printer, other rapid prototyping technologies were being explored that now fall under the umbrella of 3D printing. Carl Deckard, in 1989 was issued U.S patent 5,597,589, for the invention of Selective Laser Sintering (SLS) [6]. This patent was a continuation or divisional application of previously approved patents U.S. Patent

5,376,580, U.S. Patent 5,132,143, and U.S. Patent 4,863,538.

However, many consider the expiration of U.S Patent 5,121,329, “Apparatus and method for creating three-dimensional objects,” and patents related to FFF as key to the steep growth of consumer grade 3D printers [7], [8].

7 2.3 Previous Research

This section includes a summary of published research in the field of 3D printed electronics.

2.3.1 3D Electronics Printers

In past few years, there has been a considerable research and development of 3D printers engineered for printing electronics. The resulting 3D printers make use of various types of conductive materials, hardware, and software to produce prototype and production level electronic circuits.

A recent entry into the 3D electronics printer market is from the Voxel8 team led by Dr.

Jennifer A. Lewis [9], [10]. According to the article, Voxel8 has created “the world’s first multi- material 3D electronics printer”, the Voxel8’s Developer's Kit 3D Printer or Voxel8 DK for short. The Voxel8 DK has two independent extruders that use PLA filament and silver based conductive ink [11]. The printer uses material extrusion based AM technique, using PLA to create 3D shapes, and silver conductive ink to make electrical interconnects. A bespoke software,

Project Wire, has been created in collaboration with Autodesk, allowing users to place standard circuit components and make electrical connections in 3D space [12]. The slicing software creates specific instructions for Voxel8 DK, which halts the printing process at specific layers of the print, allowing user to place components. This printer is still in the design phase, and only a select few companies, research institutes, and universities have access to a Voxel8 DK kit. This printer has the advantage of being able to embed commercially available components within the

3D space of a design. It also provides a complete ecosystem of hardware, software, and the materials needed for 3D printed electronics. However, it is still in the design phase and thus the

8 retail price as well as the availability is unknown. Furthermore, due to the process of halting and manually inserting components during the printing process, user intervention is required. This is in stark contrast to current 3D printers, where the user starts the printing process, and comes back to a finished print. The use of silver particles in the conductive ink has the advantage of being highly conductive. However, the conductive ink is proprietary and thus subject to availability and monopoly. Patented formulation allows the ink to dry at room temperature, requiring the user to purchase this ink for the intended functionality of the printer. With the availability of many types of extrusion filaments from various vendors, a proprietary extrusion material is a disadvantage.

Nano Dimension’s DragonFly 2020 3D printer uses inkjet deposition, also known as material jetting AM, to produce multilayer printed circuit boards (PCBs) [13], [14]. The printer makes use of their in-house developed AgCite™ line of silver nanoparticle based inks to print the conductive layers [15], [16]. This allows Nano Dimension to formulate the ink to optimize for their customer requirements such as conductivity, adhesion, and flexibility. The printer makes use of in-house developed dielectric inks to print out non-conductive dielectric layers. This allows the printer to print out multiple layers of conductive tracks, which are insulated and held in place using the dielectric inks. This printer has the advantage of printing multilayered circuits on demand for prototyping purposes. The 3D printing process allows the user to freely pick the size of PCB to print on the printer, unlike traditional PCB manufacturing methods. The flexible property of the conductive and dielectric inks open up possibilities for wearable electronics.

However, this printer has some disadvantages. It is firmly aimed at the professional PCB designer market, and along with commercialized hardware, software, and inks, limits access for the average consumer due to its cost. Furthermore, unlike the Voxel8 DK, the DragonFly 2020

9 does not provide the ability to embed electronics. The 3D printed PCBs produced from the

DragonFly 2020, require the user to populate PCBs with components via traditional soldering methods.

2.3.2 3D Printed Circuits and Applications

Leigh et al. [17] formulate a conductive composite they term

‘carbomorph’, and use it in a low cost material extrusion 3D printer to create functional objects.

The carbomorph is created using Carbon Black (CB) as a filler to provide conductivity, and is mixed with polycaprolactone (PCL) which provides a printable thermoplastic matrix for the composite. A low-cost FFF printer, Bits from Bytes BFB 3000 is used for creating the 3D prints.

It is a multi-extruder printer, that can print standalone and embedded sensors [18]. To test the resistivity of carbomorph, 5 mm cubes are printed and tested for both in-plane and perpendicular to the printed layers. Silver based conductive paint is applied to opposite sides of the cube to minimize contact resistance. The resulting resistivity is 9.0±1.0 Ω-cm, and 12.0±1.0 Ω-cm for in- plane and perpendicular to the layers, respectively. Two 3D printed sensors have been demonstrated, a flex sensor and a capacitive button sensor. The carbomorph material is shown to exhibit piezoresistive behavior, forming the basis of the flex sensor. The capacitive sensor makes use of the Arduino platform and a capacitive sensing software library (CapSense) created by Paul

Badger. The sensors have integrated sockets for banana plug based electrical wires. This allows sensors to be connected to other circuit elements such as an Arduino controller board. A 3D printed ‘smart’ vessel is also created that can detect and measure quantity of liquid.

The authors have demonstrated that consumer grade low-cost 3D printers can be used to produce functional objects, furthering the usefulness of FFF printers. This creates opportunities

10 for the average consumer to print out functional designs that can be made freely available on hosting websites such as [19]. Their work has shown resistivity values for a 3D printed 5 mm cubed block. However, further research is required to investigate if resistivity is maintained with changes of the block size in the x, y, and z directions. With the use of a conductive and dielectric filament, the electronic passive components (resistor, capacitor, and inductor) can be explored. It is worth noting that the authors have created a capacitance based sensor, however the sensed capacitance values are relative and not absolute.

Carbomorph uses PCL and has the advantage of being biodegradable for ecological sustainability. However, carbomorph filament has not been commercialized and as such is not available to the public. To make functional 3D printing more accessible for consumers, a readily available conductive filament is required. At the time of this writing, the two most popular used as filaments for FFF printers are Acrylonitrile Butadiene Styrene (ABS), and

Polylactic acid (PLA). Just like PCL, PLA has the advantage of being biodegradable and there are conductive filaments currently available in PLA.

ProtoPlant offers Proto-pasta conductive PLA that uses CB as the conductive material

[20]. It offers volume resistivity for in-plane and perpendicular to the layers, of 30 Ω-cm and 115

Ω-cm respectively. Black Magic 3D offers conductive graphene filament that uses graphene as the conductive material [21]. Black Magic 3D claims a volume resistivity of 0.6 Ω-cm. This is significantly lower than that of conductive PLA from Proto-pasta. However, for either material it is not clear what testing methods and equipment is used to calculate their respective resistivity.

11 Chapter III

Research Methodology

This chapter details the experimental methods and processes used to effectively characterize passive elements and sensors. Where possible, a clear set of guidelines have been extracted from current standards. These guidelines form the basis for the experimental process, data collection, and evaluation undertaken in this work.

The equipment used in this thesis is also described in this chapter. The 3D printing process is explained from initial Computer Aided Design (CAD) through to the finished print from the 3D printer. Measurement related equipment is listed along with their specifications.

3.1 Standards and Terminology for Additive Manufacturing

In any engineering related process, the use of global standards promotes efficient development of technology while minimizing duplication of effort. However, during the early stages of technological development in AM, there was a lack of standards. This was due to the novel technology and as such low acceptance in industry.

In 2009, the American Section of the International Association for Testing Materials

(ASTM), formed committee F42 on additive manufacturing technologies [22], [23]. The purpose of this committee was to produce standards on terminology, design, processes, and testing. Soon after their formation, the committee completed the Terminology Standard.

In October 2011, the International Organization for Standards (ISO) and ASTM decided to combine their efforts on AM, by forming a collaboration between the ISO Technical

Committee 261 and ATSM International Committee F42. In 2013, the joint committee published

ISO/ASTM 52900:2013 “Additive manufacturing — General principles — Terminology”. This

12 new standard superseded ASTM F2792-12a titled “Standard Terminology for Additive

Manufacturing Technologies”.

3.1.1 Additive Manufacturing Terminology

According to the standard ISO/ASTM 52900:2015, there are seven families of additive manufacturing listed in the terminology section [24]. The following section gives a brief description of the categorized family members.

3.1.1.1 Vat Polymerization

A selective exposure to light via laser or projection cures a vat of liquid photopolymer resin. This induces polymerization in the resin exposed to light creating a solid part. Due to the vat of liquid resin, the build platform is lifted upwards along the z-axis as each new layer is created.

3.1.1.2 Powder Bed Fusion (PBF)

A bed of powder is selectively fused (melted) using a heat source from a laser or electron beam. The powder that has not been fused acts as the support for subsequent layers. Once the print is completed, any unfused powder can be recycled with some form of filtering to remove any fused powder.

3.1.1.3 Binder Jetting

A bed of powder is selectively fused with the application of a binder in the form of a liquid bonding agent. This process is similar to PBF, where un-fused powder acts as the support

13 for the new layers. Metallic and ceramic powdered parts can be processed further in a furnace to improve structural strength.

3.1.1.4 Material Jetting

Minute droplets of material are selectively deposited to form each layer of the part.

Materials commonly used are photo-curable resins which are solidified using an ultraviolet light

(UV), and thermally molten materials which once deposited solidify at room temperature.

3.1.1.5 Sheet Lamination

Sheets of material are stacked on top of each other to form layers. Various types of adhesives and chemical bonding agents are used to fuse layers. Unwanted areas of the sheet are cut every layer, to be easily separated in post processing of completed print.

3.1.1.6 Material Extrusion

Material in the form of small pellets, or a contiguous uniform line is extruded through a nozzle to form layers of the printed object. Each new layer physically bonds to the previous layer without the use of bonding agents. This process is known as Fused Filament Fabrication (FFF).

3.1.1.7 Directed Energy Deposition (DED)

Using a directed energy source such as a laser, a molten pool is selectively created on top of previous layers, to which a wire or powder is fed forming new layers.

14 3.1.2 Current AM Standards

The joint efforts from ISO/TC261 and ASTM F42 hope to fast track industry wide acceptance of AM. This is very encouraging for those who are already utilizing AM processes, as many new standards have already been published by the joint committee pertaining to AM.

However, there still exist gaps in the standards portfolio, related to measurement and analysis of electrical resistance, capacitance, and inductance of 3D printed objects. This is understandable as the use of AM for producing electrical components is relatively new and as such not standardized. Thus, for the purpose of this thesis, current industry standards are considered to extract a process for effective characterization of 3D printed passive components.

3.1.3 ASTM D4496 – 13

The standard ASTM D4496 – 13 titled “Standard Test Method for D-C Resistance or

Conductance of Moderately Conductive Materials”, is an industrial standard used for measuring direct current (DC) resistance of resistive materials [25]. The appended ‘-13’ indicates 2013 as the year of last approval, and as such the standard will be referred to as D4496 from now on. The standard describes a test method that can be used to attain accurate resistance measurements. As such, this standard is evaluated to form a set of procedures to be used for attaining resistance data from the 3D printed test samples.

The scope section of the D4496 states that the test method is applicable to all material that have a volume resistivity in the range of 1 to 107 Ω-cm. The manufacture of conductive PLA states the volume resistivity of 3D printed parts from conductive PLA are roughly in the range of

30-150 Ω-cm [20]. The manufacturer of graphene PLA states the volume resistivity of solid piece of material at 0.6 Ω-cm, which falls below the minimum volume resistivity requirement for

15 the application of D4496 [21]. However, it is well know that material extrusion 3D printers produce parts that are internally nonhomogeneous. As such, the volume resistivity of graphene

PLA will be higher than the stated 0.6 Ω-cm, once printed using a material extrusion 3D printer.

Thus, it is assumed that 3D printed parts using conductive PLA and graphene PLA will fall within the range of volume resistivity as defined by D4496.

The scope section in D4496 also states that the test method is designed to be used in standard conditions of 23°C and 50% humidity. However, it adds that the principle of using the listed method can be applied in higher and lower temperatures and at different humidity levels.

For the duration of this thesis, all 3D printed test samples will be kept in the 3D printing lab within the department. Due to central air conditioning, the lab is temperature and humidity controlled.

3.1.3.1 Test Procedure

The procedure section in D4496 lists the steps for recording measurements on test samples. An additional step is added as the first step,

1. Randomize the order of testing the samples to minimize the effects of non-

controllable factors.

2. Conduct all measurement using an electrification time of less than 1 minute. This

time should be long enough to attain a steady state value in the measurement device.

Electrification time and the applied voltage has to be kept to a minimum, to avoid any

undue heating of the test sample

3. Test a minimum of five samples for each direction of measurement. For each passive

element, five test samples will be printed for each X, Y, and Z axis.

16 4. Take the measurement for the test sample and record each observed measurement in a

table.

5. Calculate the volume resistivity of the test sample by using equation 3.1.

퐴 휌 = 푅 (3.1) 푣 푣 푡

Where,

휌푣 = Volume resistivity (Ω-cm)

푅푣 = Measured volume resistance (Ω)

퐴 = Cross-sectional area of test sample between electrodes (cm2)

푡 = The distance between the electrodes (cm)

3.1.3.2 Reporting Measured Data

Following the test procedure as outlined in the previous section, test data needs to be analyzed to provide a conclusive result. The report section of D4496 lists the required data that should be reported in order to conduct further analysis. The required data is listed as follows:

a. Full identification of the material tested

b. The average and standard deviation of the calculated resistivities shall be listed as the

resistivity of the test sample

c. The median and the range (high and low) of the calculated resistivities

d. List of any deviations from the prescribed test conditions

e. Notification if any conductive paint was used

17 3.2 Equipment

This section lists and describes the notable equipment used to perform this research.

Where necessary, changes or modifications made to equipment are described and justified.

3.2.1 Replicator 2X Experimental 3D Printer

A MakerBot® Replicator 2X Experimental 3D printer (2X) is exclusively used for all 3D prints created in this thesis [26]. The 2X is a dual extruder 3D printer which can extrude two filaments during a single print cycle. This provides a means to create electrical circuits on top, or within an insulating material extruded by the second extruder.

The 2X was introduced by MakerBot in September of 2012 at a cost of $2500, along with a single extruder 3D printer the Replicator 2. Figure 1 shows the 2X.

Figure 1: MakerBot Replicator 2X Experimental 3D printer

18 On the front panel of the 2X there is a Liquid Crystal Display (LCD) and a direction pad, which provides the Human Machine Interface (HMI). Just behind the HMI is a Secure Digital

(SD) memory card slot. This is used for transferring design print files to the printer. The inside cavity of the printer is referred to as the build chamber. Within the build chamber resides the heated build platform. Kapton® tape is applied to the build surface, which improves the adhesion and release of printed objects.

Figure 2: MakerBot 2X standard dual extruder

Figure 2 shows dual extruders of the 2X. Filament enters at the top of the extruder assembly via plastic hollow guide tubes, passes through the heater core and is extruded via the nozzles underneath shown in the right image. Towards the rear of each extruder there is a stepper motor driving a micro-toothed pinion wheel to feed and retract filament. Towards the front are fans coupled to heatsinks, keeping the extruder assembly from overheating due to the heater cores. This is important as overheating of the extruder assembly will cause filament to prematurely soften, making the extrusion process inconsistent.

19 3.2.2 Replicator 2X Improvements

MakerBot 2X is designed to print with ABS plastic. However, conductive filament used in this work is based on PLA. Furthermore, it was important to characterize the print quality of the 2X, the repeatability of the printing process, and to improve reliability.

To adapt the 2X to print with PLA, the heated build platform is set to 70° C. This temperature along with the Kapton tape, provided the best result for printing the first layer of objects. Extruders are set to 230° C. A dust filter is added with an inserted sponge lightly coated with Canola cooking oil [27], [28]. This provides additional lubrication for the PLA filament as it enters the heating core. This modification dramatically reduced the occurrence of extruder clogs.

The next step was to optimize the print quality of the 2X. Only changes that can be replicated by others are implemented. To gauge the current print quality of the printer, a standardized test was sourced on Thingiverse [29]. Figure 3 shows the standardized test, and the

3D print created with standard 2X. Prior to the print, 2X was calibrated as suggested by

MakerBot.

Figure 3: Standard 2X test print

20 The first improvement to the 2X is an extruder drive block upgrade [30]. The upgrades were printed using standard ABS filament, which replaced the standard extruder parts. ABS was used instead of PLA, due to a higher glass temperature of ABS, required to resist heat deformation from the heating core. This upgrade helped to improve the consistency of prints due to reduced slippage of the stepper motor pinion gear. The next improvement to the 2X was the addition of filament cooling fans [31]. This modification attaches two additional cooling fans

[32], one for each extruder, actively cooling extruded molten filament. Figure 4 shows 3D prints of the standardized test, before (top) and after (bottom) making improvements to the 2X.

Figure 4: Improved 2X test print

21 3.2.3 MakerBot 2X Printing Process

The process starts with a CAD model of the part to be 3D printed. Any commercial or non-commercial software that can output a .STL file of the designed part can be used. Then the

.STL file is imported into the so called “slicing” software. The overall purpose of the slicing software is to convert CAD design models, into a sequence of printing instructions that are understood by the 3D printer. These instructions are usually in the form of G-code, a language usually associated with computer aided manufacturing (CAM) machine tools. The slicing software, virtually slices the imported CAD design model, into layers along the vertical (z-axis) with predefined thickness. For each layer, point to point G-code instructions are generated, guiding the extruder from the end of the previous layer, printing the current layer, and linking to the next layer. Any slicing software can be used that can produce the appropriate file used by the

MakerBot 2X. The software used for this thesis is the MakerBot Desktop software. This software is chosen as it is made freely available by the manufacturer and has ongoing customer support.

Through the development phases of this thesis, various MakerBot Desktop software releases have been used as the software automatically updates when updates are made available by the manufacturer. At the time of this writing the current release is Version 3.9.2.1357.

3.2.4 FFF Printer Filaments

Two filaments have been utilized for this research, a Carbon Black (CB) based conductive PLA [20] and a graphene based PLA [21] with measured resistivity of 3.41 Ω-cm and

0.43 Ω-cm, respectively.

22 3.2.5 Measuring Instruments

In this work the following measurement instruments were used.

 Fluke 73 multi-meter (used to measure the resistance of created elements)

 DE-6000 handheld LCR meter (used to measure resistance, capacitance, and inductance

of 3D printed elements)

 Tektronix TPS 2014 oscilloscope (used to measure voltages and signals in application

circuits and sensors)

3.2.6 PSoC®

A Programmable System-on-Chip (PSoC) is a mixed signal controller, designed and manufactured by Cypress Semiconductor [33]. A PSoC is used as a controller for capacitive touch sensing in Section 5.1, and for the musical keyboard application in Section Chapter VI. A

PSoC combines a microcontroller, an array of configurable digital and analog circuit elements, and programmable general purpose input output (GPIO) pins. Analog blocks consist of configurable operational amplifiers and comparators. Digital circuit blocks consist of

Programmable Logic Devices (PLD), and are called Universal Digital Blocks (UDBs). UDBs can be configured to create simple digital logic circuits, or more complex logic blocks such as timers, counters, decoders and other microcontroller related peripherals. The programmable nature of the PSoC allows the user to route internal functions to any GPIO pin. These features provide a level of flexibility that cannot be attained by simple microcontroller platforms.

Integration of external digital and analog circuits is possible, thereby reducing power consumption, overall size, and cost of the system. This type of controller will maximize the level

23 of integration, allowing creation of higher quality 3D printed functional objects as compared to the Arduino platform [17].

Cypress Semiconductor provides multiple PSoC platforms. Each PSoC platform integrates unique set of hardware and firmware resources, giving the designer a choice to select one that meets their specific needs. The PSoC platform used in this thesis is the PSoC 5lp. A development kit CY8CKIT-059 consisting of a PSoC 5lp device was purchased from Cypress

Semiconductor [34]. This family of PSoC integrates a 32-bit ARM® Cortex®-M3 series microcontroller. The development board is populated with a PSoC 5lp CY8C5888LTI-LP097 device [35]. This development board has been selected due to the flexibility of the PSoC, the low retail price of $10.00, the small physical size for better integration, and a free software development toolchain, and our previous positive experience with this board [36].

3.2.7 CapSense®

Cypress Semiconductor has created a capacitive touch sensing technology named

CapSense [37]. This technology, based on hardware, computer software, and controller firmware, is made available on the PSoC line of controllers. As such, CapSense is available on the CY8CKIT-059 development board, and is utilized for sensing capacitive touch in this thesis.

Capacitive sensors are contactless sensors which detect a change in capacitance, when in presence of an electrical conductor or charge carrier such as a human finger [38]. This family of sensors have been used in industry to measure human interface, humidity, fluid levels, displacement, and proximity. The use of capacitive sensors for human-to-machine interface

(HMI) is common due to the popularity of mobile devices.

24 Compared to mechanical input devices, capacitive sensors offer many advantages. A major drawback of using mechanical input devices such as switches, has been their long term reliability due to mechanical wear. Mechanical reliability can be improved, with better materials and construction techniques. However, this can further increase cost of these devices. Capacitive sensors do not rely on moving parts, therefore offer better reliability at lower costs. They can be created on PCBs, thereby reducing bill of materials (BOM) and assembly costs. However, capacitive sensors are susceptible to false triggering due to electromagnetic interference.

CapSense works by monitoring the capacitance of controller GPIO pins assigned as sensors. A sensor requires only one GPIO pin. For each sensor pin (x), total capacitance can be modelled as a lumped capacitor (Cx). A dielectric layer is required to cover each sensor, creating a touch surface. A charge body such as a human finger acts like a parallel grounded conductive plane. When a finger touches the sensor, a parallel plate capacitor is formed, whose capacitance is given by equation 3.2 [39]:

휀 휀 퐴 퐶 = 0 푟 (3.2) 퐹 퐷

Where,

퐶퐹 = Sensor capacitance affected by finger touch (F)

-1 휀0 = Permittivity of free space (Fm )

휀푟 = Dielectric constant of overlay

퐴 = Finger and sensor overlap area (m2)

퐷 = Overlay thickness (m)

A sensor has some parasitic capacitance (Cp) even without the presence of a human finger. This is in part created due to internal parasitic capacitance from the CapSense module,

25 and due to the coupling of sensor electric field to other surrounding charge bodies. As such, Cp and CF are parallel to each other as they both are connected to the sensor and ground. Cp has a nominal range of 6 pF to 15 pF, but can be as high as 45 pF. CF has a nominal range of 0.1 pF to

0.4 pF. When tuning the CapSense module, Cp should be kept to a minimum for best performance.

26 Chapter IV

Characterization of Passive Elements

In this chapter, the electrical passive elements (resistors, capacitors, and inductors) are designed and characterized. For each element, the key parameter is analyzed in X, Y, and Z axis with reference to the MakerBot 2X build platform. It is important to note that the data gathered from the experimental process should have a real world application. In an end-user application,

3D printed electrical circuits are created and embedded within the final product. As such, the analysis of gathered data from 3D printed isolated elements cannot be easily applied to a consumer application. To provide application driven data, elements are printed on testing platforms, which are referred to as testbeds.

Figure 5: Standard Test Platform

Testbeds consist of a base as shown in Figure 5, created using standard PLA filament.

The base provides a repeatable platform on top of which elements can be arranged for testing.

Standard PLA is used to create the base thus providing structural rigidity, as well as an insulating platform for electrical isolation between passive elements. From preliminary tests, a base thickness of 1 mm was selected for optimal rigidity while minimizing the amount of PLA used.

27 The length and width of the base is adjusted for each testbed to effectively accommodate all the test samples.

4.1 Resistor

This section describes the design and implementation of resistor testbeds. For each testbed, the gathered data is presented and analyzed.

Manufacturers of conductive and graphene PLA list resistivity of their material for a given volume of uniform density. The uniform density of the material is critical to give resistance values with low tolerances. However, due to the 3D printing process, a uniform structure is not produced. 3D prints can vary in the levels of adhesion between layers along the

Z-axis, as well as have internal air gaps within the printed structure. Furthermore, the extruded filament can be non-uniform and incur breaks during extrusion caused by various factors. These inconsistencies during the 3D printing process can result in variations in the volume resistance

(푹풗) achieved by a 3D printed resistor. This variation caused by FFF printing technology needs to be characterized, so that designers can effectively implement resistive circuit elements in their designs.

4.1.1 Design of Resistor Testbeds

The 3D printing process opens up the possibility for the use of various 3D shapes to create resistive elements in an end-user application. This ability allows designers to optimize their designs for better ergonomics and usability, rather than be restricted by the need to embed two dimensional (2D) printed circuit boards (PCB). This undoubtedly is a key benefit of using

3D printers to create resistive elements. However, it is beyond the scope of this thesis to

28 effectively characterize multiple geometric shapes that can form resistive elements, for variances in all axes of the MakerBot 2X.

As such, a cuboid shape is selected to form the resistor sample to fully characterize the effects on resistance from an individual axis. The cuboid shape allows for the width, length, and height to be changed which in turn corresponds to the X, Y, and Z axis of the MakerBot 2X build chamber. Figure 6 shows the resistor test sample design. This design is created in Autodesk

Inventor® CAD software. The test sample consists of a resistive cuboid element with two electrode contact pads placed at either end.

Figure 6: Resistor Test Sample Design (mm)

To integrate 3D printed circuits with external components such as LEDs, a suitable contact point has to be provided. The 3D printed contact point should provide sufficient rigidity to secure external components while minimizing contact resistance. Due to the resistive property of the conductive filament, contact resistance plays a significant role in determining the final volume resistance (푅푣) of the test sample. It is for these reasons that contact pads are added to

29 the test sample. Each contact pad is a cylinder of 5 mm in diameter, having the same thickness as the resistive cuboid. On the top surface of the contact pad, silver based conductive paint is applied to minimize the contact resistance. The contact pad once covered with conductive paint, provides a uniform resistive area when performing resistance measurements.

4.1.2 Resistance Versus X-Axis Expansion

To characterize the change in volume resistance (푅푣) of conductive PLA along the X- axis, the following testbed shown in Figure 7 is created in MakerBot Desktop software. The width of each resistor sample along the x-axis is increased in 0.4 mm increments, starting from

0.8 mm and ending with 2.4 mm. In all resistor samples, the cross-sectional height is kept constant at 1.0 mm, along with a constant length of 30.0 mm.

Y X

Figure 7: MakerBot Desktop layout - Resistance vs. X-Axis expansion testbed

As test specimens are placed closer to each other, the likelyhood of electrical shorts between them increases. These shorts occur during the printing phase of non-conductive layers due to the extruder leaking small amounts of conductive filament. The leaked conductive

30 filament is smeared on to the non-conductive gaps inbetween the conductive test specimens. This smearing effect dramatically increases the likelyhood of shorts when the spacing is set to 2.0 mm or less. As such, a minimum spacing of 5.0 mm is provided between resistor test specimens.

A redundant resistor sample whose value is not measured, is placed towards the right most position along the x-axis. During initial print testing on MakerBot 2X, it was observed that once the non-conductive testbed was printed, the conductive PLA extruder had inconsistent starts when extruding the first few centimeters of filament. It was also observed that while printing the first conductive layer, the right most resistor sample’s first layer was printed first. Due to these combined effects, the right most resistor produced inconsistent resistance data. Therefore, an additional resistor is placed in the right most position along the x-axis on the test plate, and rejected during data collection.

Figure 8 shows the testbed preview from the slicing process on the MakerBot Desktop software. It is worth noting that the slicer creates a single shell wall around the perimeter of the resistor test samples. Due to the first sample’s resistive element having a width of 0.8 mm, the slicer simply creates a single shell wall without infill. However, as the width of resistive element increase for subsequent test samples, the slicer adds infill for any gaps created in between the single shell wall. This is a process variation and may result in a change in volume resistivity (휌푣).

31

Figure 8: MakerBot Desktop Slicing Preview - X-Axis Expansion Testbed

Five sets of x-axis expansion resistor testbeds were 3D printed from which a sample is shown in Figure 9. The conductive paint is omitted for the sixth resistor test sample as it is rejected.

Figure 9: 3D Print - X-Axis Expansion Testbed

32 Table 1 contains volume resistance (푅푣) data collected during the test procedure as outlined in section 3.1.3. The table also shows the calculated mean 푅̅̅푣̅ and standard deviation

(S.D.) for each of the tested widths. The final column calculates the standard deviation as a percentage (S.D. %) of the mean. As the conductor width increases the standard deviation decreases. This, at first, seems to indicate an improvement in the process, resulting in better precision in resistance as the width of the resistive element increases. However, the standard deviation percentage takes into account the decrease in mean as width increases.

Table 1: Resistor sample test data - X-Axis expansion

Sample Resistance Data – X-Axis Expansion (Ω) Width Print Print Print Print Print Mean S.D. S.D. % (mm) 1 2 3 4 5 0.8 1443 1534 1567 1574 1566 1537 55 3.56 1.2 1155 1296 1273 1271 1273 1254 56 4.47 1.6 909 1007 1006 1039 1009 994 49 4.98 2.0 816 835 829 870 829 836 20 2.43 2.4 711 745 734 764 735 738 19 2.61

In Figure 10 the resistance data for each print is plotted against the width of the resistive elements. As per expectation, the resistance is decreasing with the increase in the width of the resistive element. However, the visual indication of reduction in variance as width increases should be ignored, as previously explained.

33 Resistance versus Width of Resistive Element Conductive PLA ( Height 1.0 mm and Length 30.0 mm )

Print 1 Print 2 Print 3 Print 4 Print 5

2000 )

Ω 1500 1000

500 Resistance ( Resistance 0 0.8 1.2 1.6 2.0 2.4 Width (mm)

Figure 10: Resistance vs. Width of Resistive Element (Conductive PLA)

Table 2 shows the calculated volume resistivity (휌푣). The mean volume resistance 푅̅̅푣̅ calculated in Table 1 is used as the volume resistance for the corresponding sample widths. In an ideal resistor, the volume resistivity should not change irrespective of changes in width of the conductor. However, as Table 2 shows, the volume resistivity is increasing with the width of the resistive element.

Table 2: Resistivity of sample test data - X-Axis expansion

Sample Resistivity Data – X-Axis Expansion Length Resistivity Width Resistance Height Area (A) (t) (R.(A/t)) (cm) Mean (Ω) (cm) (cm²) (cm) (Ω-cm) 0.08 1537 0.10 3.00 0.008 4.098 0.12 1254 0.10 3.00 0.012 5.014 0.16 994 0.10 3.00 0.016 5.301 0.20 836 0.10 3.00 0.020 5.572 0.24 738 0.10 3.00 0.024 5.902

34 The volume resistivity (휌푣) has been plotted in Figure 11. There is a significant jump in volume resisitivity with an increases in width from 0.8 mm to 1.2 mm. This increase in resistivity is expected due to the addition of infill within the resistive element when width is 1.2 mm or greater. At the width of 0.8 mm, the resisitive element consists only of two outer shell layers. There is only a single filament to filament bond running along the y-axis, along the length of the resistive element. The lack of infill produces a resistive element with minimum amount of gaps, as well as reduces the filament to filament bonds, reducing overall resistivity.

The addition of infill for resistive element of widths 1.2 mm and above increases resistivity. This is due to significant increase in filament to filament bonds as the direction of subsequent layers of infill are rotated 90° with respect to each other. This creates weak filament to filament bonds and as such increases resistivity.

Resistivity versus Width of Resistive Element Conductive PLA ( Height 1.0 mm and Length 30.0 mm )

Resistivity (Ω-cm) 6.0

5.5

cm)

- Ω 5.0

4.5 Resistivity ( Resistivity

4.0 0.06 0.11 0.16 0.21 0.26 Width (cm)

Figure 11: Resistivity vs. Width of Resistive Element (Conductive PLA)

35 This characteristic of 3D printed resistors can be used as a design parameter when creating resistors using 3D printers. The resistance can be controlled in part by changes in infill directions and number of shell layers.

4.1.3 Resistance Versus Y-Axis Expansion

To characterize the change in resistance of conductive PLA along the Y-axis, the following testbed is created in MakerBot Desktop software as shown in Figure 12. The testbed has five resistor test samples, incrementing 1 cm in size along the Y-axis. The left most test sample along the X-axis is 3 cm in length, with the rightmost set to 7 cm.

Y X

Figure 12: MakerBot Desktop layout - Resistance vs. Y-Axis expansion testbed

In all resistor test samples, the cross-sectional height and width is kept constant at 0.1 cm and 0.08 cm, respectively. The height is set to 0.1 cm as it is evenly divisible by the layer height of 0.02 cm, as set in the MakerBot Desktop slicing parameters. Likewise, the cross-sectional width of resistors is set to 0.08 cm as it is evenly divisible by the extruder nozzle diameter of

0.04 cm. It is important to keep these parameters evenly divisible by their minimum alowable set

36 values, to reduce any bias effects caused from different slicing software. Furthermore, the cross- sectional height and width of resistors is kept to a minimum while producing a strong structural resistor that can widhstand normal wear and tear during the testing phase.

This testbed omits the use of the redudandant resistor used in the previous testbed due to inconsistent extruder start. MakerBot Desktop slicing software offers a feature called purge wall which creates a wall of filament on the perimeter of the printed object. Figure 13 shows a preview of the sliced testbed prior to printing with a purge wall. Prior to printing of any layer of the testbed, the purge wall layer is printed first. This eliminates the inconsistent extruder starts as the extruders get pre-charged with material. The purge wall also provides a barrier to trap unwated filament that may leak from the extruders.

Figure 13: MakerBot Desktop software - purge wall to improve start of extruder

Table 3 shows the resistance data collected from the testbed. As expected, the average resistance increases with the increase in length of the resistive element. The standard deviation for all the tested lengths is within 4 % of the mean. This data is plotted in Figure 14, giving a

37 visual indication of the spread of the data. We expect to see a linear increase in resistance for every 1 cm increase in length. However, the plot shows that at the length of 5 cm, the overal resistance is slightly less than what is expected.

Table 3: Resistor sample test data - Y-Axis expansion

Sample Resistance Data – Y-Axis Expansion (Ω) Length Print Print Print Print Print Mean S.D. S.D. % (cm) 1 2 3 4 5 3.0 1430 1473 1356 1400 1340 1400 54 3.87 4.0 1810 1850 1807 1850 1788 1821 28 1.53 5.0 2169 2153 2158 2153 2234 2173 35 1.59 6.0 2900 2792 2710 2798 2786 2797 68 2.42 7.0 3690 3520 3570 3540 3420 3548 97 2.74

Resistance versus Length of Resistive Element Conductive PLA ( Width 0.08 cm and Height 0.1 cm )

Print 1 Print 2 Print 3 Print 4 Print 5 4000 3500

) 3000 Ω 2500 2000 1500

Resistance ( Resistance 1000 500 0 3.0 4.0 5.0 6.0 7.0 Length (cm)

Figure 14: Resistance vs. Length of Resistive Element (Conductive PLA)

38 To further analyze the data, resistivity of the resistor samples is calculated as shown in

Table 4. The calculated means, as shown in Table 3, are used as volume resistances for their respective lengths. The calculated resistivities are plotted in Figure 15.

Table 4: Resistivity of sample test data - Y-Axis expansion

Sample Resistivity Data – Y-Axis Expansion Resistivity Length Resistance Width Height Area (A) (R.(A/t)) (cm) Mean (Ω) (cm) (cm) (cm²) (Ω-cm) 3.0 1400 0.08 0.10 0.008 3.733 4.0 1821 0.08 0.10 0.008 3.642 5.0 2173 0.08 0.10 0.008 3.477 6.0 2797 0.08 0.10 0.008 3.730 7.0 3548 0.08 0.10 0.008 4.055

Resistivity versus Length of Resistive Element Conductive PLA ( Width 0.8 mm and Height 1.0 mm )

Resistivity (Ω-cm) 4.1

4.0 cm)

- 3.9 Ω 3.8 3.7 3.6

Resistivity ( Resistivity 3.5 3.4 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 Length (cm)

Figure 15: Resistivity vs. length of resistive element (C. PLA)

39 The plot in Figure 15 shows a dip in resistivity of 3.477 Ω-cm for sample length of 5 cm, placed in the center of the testbed. The adjacent samples of lengths 4 cm and 6 cm, have a higher resistivity of 3.642 Ω-cm and 3.730 Ω-cm, respectively, while the outer samples of length 3 cm and 7 cm, exhibit the highest levels of resistivity at 3.733 Ω-cm and 4.055 Ω-cm, respectively.

This interesting behavior of resistivity can be explained as follows. The MakerBot

Desktop slicing software slices the testbed and produces a set of instructions that are optimized for the path the extruder takes. Once the insulating platform is printed, the first layer of the right most resistor sample is printed. In this case the resistor sample with the length of 7 cm. This is followed by printing of first layers of resistor samples of length 6 cm, 5 cm, 4 cm, and finally 3 cm. For the second conductive layer, the 3 cm resistor sample is printed first, followed by 4 cm,

5 cm and so forth. The process then repeats itself. This however creates an inconsistency for the time intervals between subsequent conductive layers printed for each resistor sample. The different time intervals allow for inconsistent cooling of the previously extruded conductive layer, therefore, affecting the quality of adhesion for the subsequent conductive layer. The 5 cm resistor sample, due to its central position has the most consistent time intervals between additional conductive layers, whereas the outer resistor samples have two different time intervals, the shortest as well as the longest. Thus, the 5 cm resistor sample has the lowest volume resistivity.

To test the assumption of inconsistent time intervals between additions of conductive layers as the cause to inconsistent resistivity data, all the testbeds are reheated in an oven at a temperature to 90° C for 10 minutes. This is done so that all the layers are heated past the glass temperature of the material and allowed to solidify.

40 Table 5 shows the data collected after the samples were reheated. The resistance in all samples has been reduced when compared to the prior data shown in Table 3. It is worth noting that the spread in the data has increased as shown in the S.D. % column.

Table 6 shows the resulting resistivities calculated from the resistance data. Due to a reduction in resistance data, the calculated resistivities for the samples is also reduced when compared to the prior data shown in Table 4. However, we fail to see uniform resistivity values across all samples.

Table 5: Reheated resistor sample test data – Y-Axis expansion

Reheated Sample Resistance Data (Ω) Length Print Print Print Print Print Mean S.D. S.D. % (cm) 1 2 3 4 5 3.0 808 735 665 646 657 702 69 9.78 4.0 1061 941 900 886 928 943 69 7.36 5.0 1321 1154 1132 1125 1233 1193 83 6.99 6.0 1761 1515 1455 1466 1630 1565 129 8.27 7.0 2202 1917 1868 1898 1990 1975 135 6.82

Table 6: Reheated sample resistivity - Y-Axis expansion

Reheated Sample Resistivity Data – Y-Axis Expansion Resistivity Length Resistance Width Height Area (A) (R.(A/t)) (cm) Mean (Ω) (cm) (cm) (cm²) (Ω-cm) 3.0 702 0.08 0.10 0.008 1.873 4.0 943 0.08 0.10 0.008 1.886 5.0 1193 0.08 0.10 0.008 1.909 6.0 1565 0.08 0.10 0.008 2.087 7.0 1975 0.08 0.10 0.008 2.257

41 4.1.4 Resistance Versus Z-Axis Expansion (Linear)

To characterize the change in resistance of conductive PLA along the Z-axis, two testbeds are created. The first testbed, decribed in this section, linearly increments height of resistor samples arcoss the z-axis. The second testbed increments the height geometrically, using a common multiple of two. The two testbeds have been devised to provide additional data for the

Z-axis, as any changes in the height of resistor sample results in different number of conductive

PLA layers. This, layer to layer, bond is relatively weak and as such could vary the resulting resistance significantly. Figure 16 shows the layout of the testbed as created on MakerBot

Desktop software.

Z

Y X

Figure 16: MakerBot Desktop layout - Resistance vs. Z-Axis (linear) expansion testbed

The height of resistor samples from left to right along the x-axis, is increased from 0.1 cm to 0.5 cm in 0.1 cm increments. The resistive element width and length are kept constant at 0.08 cm and 0.30 cm, respectively. These values are selected to create at least one sample resistor that will overlap all the testbeds. In this case it is the leftmost resistor sample with the height of 0.1 cm. Table 7 contains the test data collected from the 3D printed samples of the testbed.

42 Table 7: Resistor sample test data - Z-Axis (linear) expansion

Sample Resistance Data – Z-Axis (Linear) Expansion (Ω)

Height Print Print Print Print Print Mean S.D. S.D % (mm) 1 2 3 4 5 1 1400 1396 1399 1354 1364 1383 22 1.58 2 742 765 750 766 741 753 12 1.61 3 509 531 540 527 536 529 12 2.27 4 402 409 421 415 410 411 7 1.72 5 329 339 341 329 328 333 6 1.88

As per expectation, Table 7 shows a gradual decrease in the average resistance as the resistor sample height is increased. The standard deviation as a percentage of the mean for all resistor samples is less than 2.5 %.

Resistance vs. Height of Resistive Element (Linear) Conductive PLA ( Width 0.8 mm and Length 30.0 mm )

Print 1 Print 2 Print 3 Print 4 Print 5 1600 1400

) 1200 Ω 1000 800 600

Resistance ( Resistance 400 200 0 1.0 2.0 3.0 4.0 5.0 Height (mm)

Figure 17: Resistance vs. height of resistive element (Linear) (C. PLA)

43 Table 8: Resistivity of sample test data - Z-Axis expansion (Linear) (C. PLA)

Sample Resistivity Data – Z-Axis Expansion (Linear) Length Resistivity Height Resistance Width Area (t) (R.(A/t)) (cm) Mean (Ω) (cm) (A) (cm²) (cm) (Ω-cm) 0.1 1383 0.08 3.00 0.008 3.687 0.2 753 0.08 3.00 0.016 4.015 0.3 529 0.08 3.00 0.024 4.229 0.4 411 0.08 3.00 0.032 4.388 0.5 333 0.08 3.00 0.040 4.443

The resistivity of all the resistor sample heights is calculated and shown in Table 8. The mean resistance calculated in the resistance data table has been used as the overall resistance of the respective resistor sample height. The resistivity data, plotted in Figure 18, shows a steady increase in resistivity as the height of the resistor sample is increased.

Resistivity versus Height of Resistive Element (Linear) Conductive PLA ( Width 0.08 cm and Length 3.0 cm )

Resistivity Linear (Resistivity (R.(A/t)) (R.(A/t)) (Ω-cm) (Ω-cm))

4.5

cm)

- Ω 4.0

3.5 y = 1.8848x + 3.5869 Resistivity ( Resistivity 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 Height (cm)

Figure 18: Resistivity vs. height of resistive element (Linear) (C. PLA)

44 This is to be expected, as the height of the contact pads increases with the increase in resistive element height. This adds to the overall resistance and thus increases the overall volume resistivity of the resistor sample. It can be argued that this is not a true representation of the resistance of the resistive element. However, practical use of 3D printed resistors is within circuits containing other 3D printed elements, along with external electronic components. The contact pads allow for a standardized mechanism to integrate 3D printed resistors in 3D printed applications.

4.1.5 Resistance Versus Z-Axis Expansion (Geometric)

This section uses a geometric expansion of the height of resistor samples, to investigate if the trend discovered in the previous section holds true for a larger change in height along the Z- axis expansion.

Z

Y X

Figure 19: MakerBot Desktop layout - resistance vs. Z-Axis (geometric) expansion testbed

45 As in the Section 4.1.4, the width and length of all resistive elements have been kept constant at 0.08 cm and 3.00 cm respectively. In this testbed however, the height of resistor samples is incremented geometrically with a common ratio of two. The resistor samples from left to right along the x-axis, have heights set at 0.1 cm, 0.2 cm, 0.4 cm, 0.8 cm, and 1.6 cm respectively. The contact pads are set to the same height as the resistive element.

Table 9 contains the test data collected from the 3D printed samples of the testbed. The average resistance decreases with the increase in height of the resistor samples. This is an expected result as the increase in height allows for a larger cross-sectional area of the resistive element, thus reducing volume resistivity as per equation 3.1. The table also shows that the standard deviation as a percentage of the mean is below 2.5 % for all resistor samples.

Table 9: Resistor sample test data - Z-Axis (geometric) expansion

Sample Resistance Data – Z-Axis (Geometric) Expansion (Ω)

Height Print 1 Print 2 Print 3 Print 4 Print 5 Mean S.D. S.D % (cm) 0.1 1272 1333 1305 1284 1300 1299 23 1.78 0.2 714 751 739 723 727 731 14 1.97 0.4 402 421 404 397 400 405 9 2.33 0.8 229 237 227 225 224 228 5 2.27 1.6 157 159 153 153 153 155 3 1.82

The resistor sample data is plotted in Figure 20. The data points for each of the tested resistor heights is tightly grouped. The plotted data forms an exponential decay curve. This is expected due to the diminishing reduction in resistance with doubling of resistor sample height.

46 Resistance vs. Height of Resistive Element (Geometric) Conductive PLA ( Width 0.08 cm and Length 3.0 cm )

Print 1 Print 2 Print 3 Print 4 Print 5

1500

) Ω 1000

500 Resistance ( Resistance

0 0.1 0.2 0.4 0.8 1.6 Height (cm)

Figure 20: Resistance vs. Height of Resistive Element (Geometric) (C. PLA)

Table 10 shows the calculated resistivities for the tested sample resistor heights. The mean resistance data from Table 9 is used as the final resistance for the corresponding sample heights. The data shows a steady increase in resistivity.

Table 10: Resistivity of sample test data - Z-Axis expansion (Geometric) (C. PLA)

Sample Resistivity Data – Z-Axis Expansion (Geometric) Resistivity Height Resistance Width Length Area (R.(A/t)) (cm) Mean (Ω) (cm) (t) (cm) (A) (cm²) (Ω-cm) 0.1 1299 0.08 3.00 0.008 3.463 0.2 731 0.08 3.00 0.016 3.898 0.4 405 0.08 3.00 0.032 4.318 0.8 228 0.08 3.00 0.064 4.873 1.6 155 0.08 3.00 0.128 6.613

47 The resistivity data is plotted in Figure 21. Here we can see more clearly, a linear progression of resistivity with the geometric increase in resistor sample height. A line of best fit is created, giving us the relationship between resistivity and resistor sample height with equation

4.1.

휌푣 = (1.9961 ∗ ℎ) + 3.3954 (4.1)

Where,

휌푣 = Volume resistivity (Ω-cm)

ℎ = Height of resistor (cm)

Resistivity versus Height of Resistive Element (Geo.) Conductive PLA ( Width 0.8 mm and Length 30.0 mm )

Resistivity Linear (Resistivity (R.(A/t)) (R.(A/t)) (Ω-cm) (Ω-cm)) 7.0

cm) 6.0

- Ω 5.0

4.0 y = 1.9961x + 3.3954 Resistivity ( Resistivity 3.0 0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 Height (cm)

Figure 21: Resistivity vs. height of resistive element (Geometric) (C. PLA)

48 The results from Z-axis expansion show a clear relationship of increasing resistivity as the height of the resistor sample is increased. There is an inflection point in the plotted data at about 0.55 cm in height, after which point the graph shows a small rise in the gradient between height and resistivity. The line of best fit for the linear expansion shown in Figure 18, has a gradient of 1.8848. This is lower than the gradient for the geometric expansion of 1.9961, as the linear data only covers the range 0.1 to 0.5 cm, which is prior to the inflection point of 0.55 cm in height. Therefore the linear data plot does not take into account resistivity data past 0.5 cm in height shown in the geometric expansion, which is past the inflection point and therefore exhibits a slightly higher resistivity for a given height. Thus, the data characterized for the geometric expansion is a better representation of Z-axis expansion of the 3D printed resistor samples, and can be used when creating 3D printed resistors with a height of more than 1.0 mm.

4.2 Capacitor

This section describes the design, implementation, and analysis of 3D printed capacitors.

The design phase for a 3D printed capacitor is crucial for maximizing the capacitance for a given volume of space. The design also plays a crucial role in the reproducibility of functional capacitors. Furthermore, a well-designed capacitor can reduce variability in capacitance, thus achieving lower tolerances. This allows for a 3D printed capacitor to meet requirements placed by complex electrical circuits.

The first stage of the design process is to build a functional capacitor. This is important as it provides a benchmark for subsequent design improvements. A simple capacitor topology is selected in the form of a parallel plate capacitor and is shown in Figure 22. It consists of two

49 conductive plates separated by a dielectric layer. Energy is stored when a potential difference is applied to the conductive plates.

Figure 22: Parallel plate capacitor

The capacitance of a parallel plate capacitor is given by equation 4.2. According to this equation, increase in capacitance is proportional to conductive plate area, and inversely proportional to separation distance between the plates. The capacitance is also proportional to the relative permittivity of the dielectric material.

퐴 퐶 = 휀 푘. (4.2) 0 푑

Where,

퐶 = Capacitance (F)

−12 -1 휀0 = Permittivity of vacuum (electric constant) 8.854187 × 10 F.m

푘 = Relative permittivity (dielectric constant)

퐴 = Area of conductive plate (m2)

푑 = Separation between conductive plates (m)

50 For the purpose of this thesis, the conductive plates are formed using conductive PLA, and non-conductive PLA is used for the dielectric layers. An air gap can be used to form the dielectric. However, it has a dielectric constant close to 1.0, which is much lower than the dielectric constant of 3.8 for PLA [40]. Therefore using non-conductive PLA as the dielectric will maximize the achievable capacitance. For the 3D printed capacitor samples a dielectric constant less than 3.8 is expected. This is due to the non-homogenous structure of 3D prints, creating small pockets of air and lowering the overall dielectric constant.

The selection of non-conductive PLA as the dielectric leaves surface area (A) and separation distance (d) as optimization factors to increase the overall capacitance. There is a limitation on the minimum separation distance that can be achieved. The MakerBot 2X has a minimum layer height of 0.01 cm along the z-axis. For the x and y axis the minimum printable thickness is 0.04 cm, determined by the extruder nozzle diameter. This limits the minimum dielectric thickness to a best case of 0.01 cm. As such, to increase capacitance of a 3D printed capacitor, the surface area of conductive plates has to be increased. Due to these reasons a multi- plate capacitor is considered (shown in Figure 23). Using this topology, a capacitor is optimized for the 3D build volume space of the MakerBot 2X. Once the conductive plate area is maximized for 2D space, multiple plates can be stacked on top of each other to further increase the capacitance in 3D space. This techniques still limits the overall capacitance of a 3D printed capacitor. Commercially available capacitors achieve ultra-low separation distance, and make use of materials with high dielectric constants. This produces capacitors with large capacitance density per volume.

51

Figure 23: Multi-plate capacitor

The multi-plate capacitor shown in Figure 23 uses four conductive plates with three dielectric layers. This topology produces three identical capacitors using four conductive plates

(n) of surface area (A), and separating distance (d). The capacitance of a multi-plate capacitor is determined by equation 4.3.

퐴 퐶 = (푛 − 1) (휀 푘 ) (4.3) 0 푑

Figure 24 shows the initial design layout of a multi-plate capacitor testbed in MakerBot

Desktop software. The capacitor is built on a standard test platform as described at the beginning of the chapter. There are two terminals, each formed with five conductive plates (grey). The separation between plates is filled with non-conductive PLA (red), as used for the standard test platform. Conductive plates have a thickness of 0.06 cm, also a constant separation of 0.06 cm is kept between plates throughout this design.

52 Conductive

Non -Conductive

Figure 24: Initial design of multi-plate capacitor

This initial design failed to produce a functional capacitor due to electrical shorting of the terminals. An inspection during the printing process revealed that lateral shorts were being formed between ends of a conductive plate of one terminal with the adjacent stem of the other terminal. This is highlighted as number 1 in green in Figure 25.

1

2

Figure 25: Capacitor short due to lateral separation of 0.6 mm

The initial design also exhibited vertical electrical short between the terminals highlighted as number 2 in blue in Figure 25. This short occurs on the sides of the capacitor during the printing process. Small strings of conductive filament from the conductive PLA

53 extruder were being deposited on the sides, thus creating resistive shorts between the terminals.

These strings were also the cause of the lateral shorts. To alleviate the problem of leaking extruder, the default filament retract distance of 1.3 mm was incrementally increased. This setting retracts the filament for the set amount of distance from the extruder, after the extruder has finished printing. This should stop the filament from extruding due to latent pressure in the extruder. Increasing the retract distance did reduce the number of resistive shorts, but did not entirely eliminate them. Setting a retract distance of 3.5 mm and above created a new problem in the form of the extruder jamming. Therefore the final retract distance was set to 3.0 mm.

To eliminate the electrical shorts, two techniques are employed that reduce the opportunity for the shorts to occur. Figure 26 shows the first technique of increasing the lateral spacing between the terminals. In this figure the dielectric block has been removed for illustration purposes. The spacing between the terminals is incrementally increased from the previously set value of 0.06 cm. At a spacing of 0.36 cm there were no noticeable lateral shorts occurring. An additional 0.04 cm is added for further confidence, giving a final lateral spacing of

0.4 cm between the terminals. This increase in spacing between the terminals reduces the capacitance of this topology, as the conductive plate overlap is reduced. However, as 3D printing technology improves, the lateral spacing can be further reduced.

For the elimination of the vertical shorts, Figure 27 shows the use of an expanded dielectric block to act as an insulating barrier for the exposed sides of the capacitor. In Figure 27 the dielectric block is expanded by 0.64 cm, to provide a barrier of 0.32 cm per side. Any conductive strings from the extruder are deposited on the outer surface of the barrier, shielding the conductive plates. The barrier is further optimized by limiting the expansion to 0.16 cm,

54 giving a 0.08 cm barrier wall per side. A reduction of the volume in the side wall reduces printing time, as well as the amount of non-conductive PLA used.

Figure 26: Eliminate electrical short - Figure 27: Eliminate electrical short - Add Increase terminal lateral spacing non-conductive PLA barrier

4.2.1 Capacitance Versus X-Axis Expansion

This section describes the characterization of change in capacitance with an expansion of the capacitor plate width along the x-axis. Figure 28 shows the testbed layout created in

MakerBot Desktop software. This testbed uses parallel plate capacitor topology consisting of two conductive plates. There are five capacitor samples with varying conductive plate width. The first sample on the left with respect to the x-axis has a plate width of 0.52 cm. Subsequent sample plate widths are incremented by 0.52 cm. This results in capacitors of plate width 0.52 cm, 1.04 cm, 1.56 cm, 2.08 cm, and 2.60 cm from left to right respectively. The plate width, and incremental increase of 0.52 cm is chosen as it is evenly divisible by the extruder nozzle width of

0.04 cm. A constant vertical separation distance (d) of 0.06 cm is maintained between the two terminals along the z-axis. A constant plate length of 3.00 cm is selected for both terminals. Due to the added lateral separation of 0.40 cm, the final capacitor plate length is 2.60 cm. This length

55 provides sufficient plate area with the selected widths for significant capacitance change between samples for characterization.

Z

Y X

Figure 28: MakerBot Desktop layout - capacitance vs. X-Axis expansion testbed

The capacitance data gathered from five 3D printed samples is shown in Table 11. As expected, there is a linear increase in the average capacitance as the sample plate width is increased. This can be observed in the plot shown in Figure 29. There is a linear increase of roughly 6.3 pF between consecutive samples. The standard deviation as a percentage of the mean for all samples are all within 3%, showing good repeatability of the produced capacitors.

Table 11: Capacitor sample test data - X-Axis expansion

Sample Capacitance Data – X-Axis Expansion (pF) Width Print Print Print Print Print Mean S.D. S.D. % (cm) 1 2 3 4 5 0.52 6.5 6.4 6.7 6.4 6.8 6.56 0.18 2.77 1.04 12.8 12.7 13.1 12.7 12.6 12.78 0.19 1.51 1.56 19.1 19.1 19.0 18.9 19.1 19.04 0.09 0.47 2.08 24.9 25.0 24.6 24.7 25.1 24.86 0.21 0.83 2.60 32.0 31.5 31.0 31.1 32.6 31.64 0.67 2.10

56 Capacitance Change versus Plate Width Conductive PLA - 2 Conductive Plates ( Seperation 0.06 cm and Length 2.60 cm )

Print 1 Print 2 Print 3 Print 4 Print 5 35

) 30 pF 25 20 15

10 Capacitance ( Capacitance 5 0.5 1.0 1.6 2.1 2.6 Plate Width (cm)

Figure 29: Capacitance vs. width of conductive plate (conductive PLA) Table 12 shows the calculated dielectric constant for capacitor samples using equation

4.4, created from rearranging equation 4.2. For each sample plate width, the averaged capacitance data from Table 11 is used for calculating the dielectric constant.

퐶. 푑 푘 = (4.4) 휀0. 퐴

All samples exhibit a dielectric constant of less than 3.8. Figure 30 shows a plot of the data. There is no discernable trend. Variationa in the data can be attributed to variations in the

3D printing process.

57 Table 12: Dielectric constant of sample data - X-Axis expansion

Sample Dielectric Constant Data – X-Axis Expansion Plate Width Capacitance Separation Dielectric Length Area (m²) (m) Mean (F) (d) (m) Constant (k) (m) 0.0052 6.56E-12 0.0260 0.000135 6.0E-04 3.29 0.0104 1.28E-11 0.0260 0.000270 6.0E-04 3.20 0.0156 1.90E-11 0.0260 0.000406 6.0E-04 3.18 0.0208 2.49E-11 0.0260 0.000541 6.0E-04 3.12 0.0260 3.16E-11 0.0260 0.000676 6.0E-04 3.17

Table 13 shows descriptive statistics for the dielectric constant data. The calculated standard deviation of 0.06, and the standard deviation percentage of 1.97 %, show minimal spread in the data. From the gathered data for the x-axis expansion, the calculated dielectric constant has a mean of 3.19, and a standard deviation of 0.06.

Table 13: Dielectric constant data statistics - X-Axis expansion Dielectric

Constant (k) Min 3.12 Max 3.29 Mean 3.19 S.D 0.06 S.D. % 1.97

58 Dielectric Constant versus Plate Width Conductive PLA - 2 Conductive Plates ( Seperation 0.06 cm and Plate Length 2.60 cm )

Dielectric Constant (k) 3.30

3.25

3.20

3.15 Dielectric Constant (k) Constant Dielectric

3.10 0.000 0.005 0.010 0.015 0.020 0.025 0.030 Plate Width (m)

Figure 30: Dielectric constant vs. conductive plate width (conductive PLA)

4.2.2 Capacitance Versus Y-Axis Expansion

This section characterizes the change in capacitance with an expansion of capacitor plate length along the y-axis. A suitable testbed is created and shown in Figure 31. The testbed consists of five multi-plate capacitor samples, with varying conductive plate lengths. Multi-plate capacitor topology is employed to yield a higher change in capacitance value for a given change in capacitor plate length. Separation distance and plate thickness of 0.06 cm is kept constant between all samples, as well as the plate width of 0.52 cm. The capacitor samples from left to right in Figure 31, have plate length of 3.0 cm, 4.0 cm, 5.0 cm, 6.0 cm, and 7.0 cm. However, due to 0.4 cm of later separation between the terminals, the plate overlap is reduced. The final plate lengths are 2.6 cm, 3.6 cm, 4.6 cm, 5.6 cm, and 6.6 cm.

59 Z

Y X

Figure 31: MakerBot Desktop layout - Capacitance vs. Y-Axis expansion testbed

Table 14 shows the capacitance data collected from five printed copies of the testbed.

The standard deviation percentage of the mean for all samples are all within 3 %. The data shows good correlation with minimal spread. As expected there is a linear increase in the average capacitance with an increase in sample plate length. This is shown in the plot in Figure 32. There is an average increase of 7.5 pF between each successive sample.

Table 14: Capacitor sample test data - Y-Axis expansion Sample Capacitance Data – Y-Axis Expansion (pF) Length Print Print Print Print Print Mean S.D. S.D. % (cm) 1 2 3 4 5 2.6 21.7 21.5 20.3 20.7 20.5 20.94 0.62 2.97 3.6 28.9 28.8 28.3 29.0 28.1 28.62 0.40 1.38 4.6 36.1 36.0 35.7 36.0 35.7 35.90 0.19 0.52 5.6 43.1 42.6 42.7 43.1 42.3 42.76 0.34 0.80 6.6 51.7 50.8 51.2 51.6 49.7 51.00 0.81 1.59

60 Capacitance Change versus Plate Length Conductive PLA - 4 Conductive Plates ( Seperation 0.06 cm and Plate Width 0.52 cm )

Print 1 Print 2 Print 3 Print 4 Print 5 55

) 50

pF 45 40 35 30 Capacitance ( Capacitance 25 20 2.6 3.6 4.6 5.6 6.6 Conductive Plate Length (cm)

Figure 32: Capacitance vs. Length of Conductive Plate (Conductive PLA) Table 15 shows the calculated dielectric constants for all the sample capacitor lengths. To calculate the dielectric constant for a multi-plate capacitor, equation 4.3 is rearranged to form equation 4.5 as follows,

퐶. 푑 푘 = (4.5) 휀0퐴(푛 − 1)

The capacitors in this testbed consist of four conductive plates, resulting in the formation of three capacitors. Thus, to calculate the dielectric constant, the averaged capacitance values for each sample length is divided by three. Figure 33 shows a plot of the dielectric constant data versus the capacitor samples lengths. Overall the plot shows a decrease in the dielectric constant with an increase in the sample plate length. Capacitors of plate length of 5.6 cm exhibit the lowest dielectric constant of 3.32.

61 Table 15: Dielectric constant data - Y-Axis expansion

Sample Dielectric Constant Data – Y-Axis Expansion

(m)

e Width e Width

(d) (m) (d)

Mean (F)

Dielectric Dielectric

Area(m²)

Capacitors

Length (m) Length

Number of Number

Separation Separation

Plat

Capacitance Capacitance

Constant (k) Constant 0.0260 2.09E-11 3 0.0052 1.35E-04 6.0E-04 3.50 0.0360 2.86E-11 3 0.0052 1.87E-04 6.0E-04 3.45 0.0460 3.59E-11 3 0.0052 2.39E-04 6.0E-04 3.39 0.0560 4.28E-11 3 0.0052 2.91E-04 6.0E-04 3.32 0.0660 5.10E-11 3 0.0052 3.43E-04 6.0E-04 3.36

Table 16 shows the statistical calculations for the dielectric constant data. The standard deviation as a percentage of the mean of 2.15 % shows us that the data has a tight grouping. As per expectation the averaged dielectric constant of 3.40 is below the previously mentioned maximum value of 3.8. It is worth noting that the dielectric constant of 3.40 is higher than 3.19, calculated from the testbed data for the x-axis expansion. This can be attributed to the change in capacitor topology from a parallel plate, to a multi-plate capacitor.

Table 16: Dielectric constant data statistics - Y-axis expansion

Dielectric Constant (k)

Min 3.32 Max 3.50 Mean 3.40 S.D 0.07 S.D. % 2.15

62 Dielectric Constant versus Plate Length Conductive PLA - 4 Conductive Plates ( Seperation 0.06 cm and Plate Width 0.52 cm )

Dielectric Constant (k) 3.6

3.5

3.5

3.4

3.4 Dielectric Constant (k) Constant Dielectric

3.3 0.020 0.025 0.030 0.035 0.040 0.045 0.050 0.055 0.060 0.065 0.070 Conductive Plate Length (m)

Figure 33: Dielectric constant vs. Conductive Plate Length (Conductive PLA)

4.2.3 Capacitance Versus Z-Axis Expansion (Number of Plates)

In this section, the change in capacitance is characterized with respect to the z-axis. This is achieved by varying the number of conductive plates. This approach is used instead of varying the thickness of conductive plate and the dielectric (separation distance). As the minimum achievable separation distance of 0.6 mm has already been determined, increasing the separation distance along with the plate thickness will result in reduction of capacitance per unit volume.

Figure 34 shows the testbed layout with five capacitor samples of varying number of plates. For all samples, separation distance and plate thickness is kept constant at 0.06 cm, along with plate width of 0.52 cm and plate length of 3.0 cm. The final plate length is reduced to 2.6 cm due to the lateral separation distance of 0.4 cm added between the terminals. The capacitor samples, as seen from left to right, vary in number of plates from 2, 4, 6, 8, and 10.

63 Z

Y X

Figure 34: MakerBot Desktop layout - capacitance vs. Z-Axis expansion (No. Plates) testbed

In Figure 35 the conductive plates of capacitor samples are exposed by removing the dielectric blocks. The removal of the dielectric blocks is for illustration purposes only showing how the terminal plates are interleaved to form the sample capacitors. It is worth noting that the testbed makes use of both the parallel plate, and multi-plate capacitor topologies. The first sample capacitor with two conductive plates forms the only parallel plate capacitor, the rest forming multi-plate capacitors. Both capacitor topologies are implemented in this testbed to provide a comparison link in the data collected from the x-axis and y-axis expansion. The first capacitor sample consisting of two conductive plates from this testbed is directly comparable with the first sample on the x-axis expansion testbed, shown in Figure 28. Likewise, the second capacitor sample is directly comparable with the first sample from the y-axis expansion testbed shown in Figure 31.

64

Figure 35: Z-Axis expansion testbed with exposed terminal plates

Table 17 shows the capacitance data collected from five printed samples of the testbed.

Figure 36 shows a linear increase in capacitance with respect to the number of plates. According to the multi-plate capacitance equation 4.3, there is a linear increase in the number of formed capacitors. As all other capacitance affecting parameters are kept constant throughout all the samples, this will result in a linear increase in capacitance. For all samples, there is minimal spread in the data as shown by the standard deviation percentage of the mean.

Table 17: Capacitor sample test data - Z-Axis expansion (no. plates) (C. PLA)

Sample Capacitance Data – Y-Axis Expansion (pF) No. of Print Print Print Print Print Mean S.D. S.D. % Plate 1 2 3 4 5 2 6.6 6.2 6.3 6.4 6.6 6.42 0.18 2.79 4 20.0 19.7 20.3 20.1 20.4 20.10 0.27 1.36 6 33.3 32.6 33.5 33.7 34.0 33.42 0.53 1.57 8 47.3 46.2 48.1 47.9 47.4 47.38 0.74 1.56 10 62.3 60.6 63.9 61.3 61.7 61.96 1.25 2.01

65 Capacitance Change versus Number of Plates Conductive PLA - Seperation 0.06 cm ( Plate Width 0.52 cm, Plate Length 2.60 cm )

Print 1 Print 2 Print 3 Print 4 Print 5

80 )

pF 60 40 20

Capacitance ( Capacitance 0 2 4 6 8 10 Number of Conductive Plates

Figure 36: Capacitance vs. number of conductive plates (conductive PLA)

Table 18 shows the calculated dielectric constant data for all samples. There is a significant jump in the dielectric constant between the first and the second sample capacitor, consisting of two and four plates respectively. This is easily seen in the plot of the data shown in

Figure 37. The dielectric constants for samples consisting of 4, 6, 8, and 10 plates are better grouped with each other.

The dielectric constant of 3.22 of the first sample correlates well with the average dielectric constant of 3.19 (Table 13) calculated for the x-axis expansion testbed. The value of

3.22 is also within the limits of min and max values from the x-axis testbed data at 3.12 and 3.29 respectively. As such the data point of the first sample is omitted in the statistical calculations as shown in Table 19. The data point for the first sample served the purpose of validating this testbed with the x-axis expansion.

66 Table 18: Dielectric constant data - Z-Axis expansion (no. plates) (C. PLA)

Sample Dielectric Constant Data – Z-Axis Expansion

s

(k)

(m) (m) (m)

(m²)

Area(A)

Mean (F)

Dielectric Dielectric

Capacitors

Number of Number

Plate Width Plate Width

Capacitance Capacitance

Constant

Plate Length Length Plate

No. of Plateof No.

Separation (d) (d) Separation 2 6.42E-12 1 0.0260 0.0052 1.35E-04 6.0E-04 3.22 4 2.01E-11 3 0.0260 0.0052 1.35E-04 6.0E-04 3.36 6 3.34E-11 5 0.0260 0.0052 1.35E-04 6.0E-04 3.35 8 4.74E-11 7 0.0260 0.0052 1.35E-04 6.0E-04 3.39 10 6.20E-11 9 0.0260 0.0052 1.35E-04 6.0E-04 3.45

Dielectric Constant versus Number of Plates Conductive PLA - Seperation 0.06 cm ( Plate Width 0.52 mm, Plate Length 2.60 cm )

Dielectric Constant (k) 3.50 3.45 3.40 3.35 3.30

3.25 Dielectric Constant (k) Constant Dielectric 3.20 2 4 6 8 10 Number of Conductive Plates

Figure 37: Dielectric constant vs. number of conductive plates (conductive PLA)

Table 19 shows the statistical calculations for capacitor samples with 4, 6, 8, and 10 conductive plates. The data has a standard deviation of 0.05, and as a percentage of the mean of

1.80 %. This shows that the data has a low scatter and the effects from random process variables

67 are minimized. The averaged dielectric constant of 3.39 is closely matched with the calculated value of 3.40, from the y-axis testbed data. Therefore it is concluded that the two tested capacitor topologies, parallel plate and multi-plate capacitors, have a significant effect on the dielectric constant and thus the resulting capacitance achieved. The expansion of the x, y, and z axis have had no significant effect on the achievable dielectric constant for PLA.

Table 19: Dielectric constant statistics for capacitor with no. plates 4, 6, 8, and 10 - Z-axis expansion

Dielectric Constant (k)

Min 3.35 Max 3.45 Mean 3.39 S.D 0.05 S.D. % 1.80

68 4.3 Inductor

This section describes the design, implementation, and analysis of 3D printed inductors.

An inductor is a coil of electrically conductive wire that can store energy in the form of a magnetic field [41]. Inductance is a property of a coil of wire that opposes a change in flow of electric current through it. When an electric current flows through a single coil of wire it forms an electromagnetic field around the wire. When multiple coils are stacked close to each other, their individual magnetic fields are combined to form a stronger magnetic field.

푁푢푚푏푒푟 표푓 푡푢푟푛푠 (푁)

퐶푟표푠푠 − 푠푒푐푡𝑖표푛푎푙 푎푟푒푎 (퐴) 퐿푒푛푔푡ℎ (푙)

Figure 38: Physical parameters of an inductor

Figure 38 shows a simplified depiction of an inductor, specifically an air-core inductor.

The inductance of an air-core inductor is given by equation 4.6. This shows that inductance of a coil is proportional to the number of turns, permeability of the core material, cross-sectional area, and inversely proportional to the length.

69 푁2휇퐴 퐿 = (4.6) 푙

Where,

L = Inductance (henries,H)

N = Number of coil turns

µ = Permeability (Hm-1) (air = 1.2566 * 10-6 Hm-1)

A = Cross-sectional area (m2)

l = Length of the coil (m)

An air-core inductor topology is selected to create a 3D printed inductor. An inductor with a ferrite core will increase the inductance when compared to an air-core, due to the higher permeability of the ferrite. However, the MakerBot 2X printer only has two extruder nozzles which are required for the conductive and non-conductive PLA. Due to the lack of a third extruder, it is not possible to add a ferro-magnetic PLA filament during 3D printing. For future work, 3D printers with additional extruders can be used to print with ferro-magnetic materials.

The resistive property of conductive PLA has been ideal for creating resistors. When used for creating capacitors, due to the large cross-sectional area of the conductive plates, the resistance is minimized. However, when used for creating the conductive coil of an inductor, the resistive property of conductive PLA poses a problem. The flow of electric current through the coil of an inductor generates a magnetic field, which in turn defines the inductance of an inductor. As such, the resistance of the coil in a 3D printed inductor has to be kept as low as possible to maximize the flow of current through it.

70 To reduce the overall resistance of a 3D printed coil with conductive PLA, the cross- sectional area of the conductor can be increased, and overall length of conductor reduced.

However, increasing the cross-sectional area of the conductor reduces the number of coils that can be formed within a given length of coil as shown in Figure 38, thus, reducing the inductance of the coil as per equation 4.6. Furthermore, reducing the length of the conductor to form the coil, reduces the number of turns that can be achieved for a given cross-sectional area of the coil.

This also has the net effect of reducing the inductance of the coil.

All CAD models in this section are created using the SOLIDWORKS® computer program. Figure 39 and Figure 40 show the initial design for a 3D printed inductor coil. The conductor is created using a rectangular cross-section. This type of cross-section is utilized to maximize the cross-sectional area of the conductor, as compared to the typical circular cross- section of a metallic conductor. This should aid in minimizing the overall resistance of the coil and thus maximize the current flow. The cross-section has a height and length of 1.0 mm and 5.0 mm, respectively.

Figure 39: Inductor conductive coil (10.5 turn, 10.0 mm inner diameter) – front view

71 The coil has 10.5 turns with a pitch of 2.0 mm, giving it an axial coil length of 21.0 mm.

The inner diameter of the coil and the created air-core is 10.0 mm. To create contact points for testing purposes, as well as circuit integration, additional length of conductor is extended from the endpoints of the coil as shown in Figure 40. This does increase the overall resistance, however these contact points are required for circuit integration. The 2.0 mm pitch of the coil creates a spacing of 1.0 mm between each turn. This spacing is required for a 3D printed coil to eliminate short circuit between each turn. Commercially available inductors make use of thin insulated metallic wire that allow for tightly packed turns without shorting. With ever progressing hybrid 3D printing technology, future work can utilize inkjet nozzles to apply thin coats of insulating material to tightly pack 3D printed turns on top of each other.

Figure 40: Inductor conductive core (10.5 turn, 10.0 mm inner diameter) - Isometric view

72 Figure 41 shows the insulating support block created for the inductor core. The support block insulates adjacent turns, and provides physical support during the 3D printing process.

This is a solid block, and has not been extruded cut to provide the channels for the conductive coil. Removal of necessary material in the insulating support structure takes place in the

MakerBot Desktop software during the slicing process. Where there is a spacial conflict between objects assigned to the left and right extruder, the right extruder is given precedence. In the conflict zone, the slicer removes necessary material from the object assigned to the left extruder, making space for the object assigned to the right extruder. This functionality of the slicer greatly improves productivity during the design phase, as spacial negatives do not have to be manually created.

Figure 41: Inductor insulating support block

Figure 42 shows the MakerBot Desktop layout, print preview, and 3D print of the inductor. In the layout, while observing the air-core we can see the slicer has resolved the spacial conflict between the conductive core and the support block. The print preview shows the use of a purge wall to improve multi material print quality, and eliminate potential shorts from extruder leaks. The print preview also shows the slicer utilizing a staircase type approximation to 3D print

73 the conductive coil. This is not ideal as it will further increase the resistance of the coil.

However, this is a limitation of 3D print technology due to a finite print height. The 3D print shows the addition of conductive paste on the contact pads post printing.

Figure 42: MakerBot Desktop layout, print preview, 3D print - Inductor (10.5 turns, 10.0 mm inner diameter)

The printed inductor was tested using the DE-6000 handheld LCR meter. The meter can measure down to 0.001 µH. However, the meter failed to register an inductance measurement at all test frequencies of the meter. The coil resistance is measured at 5.79 kΩ, which is a very high for an inductor. This severely limits the flow of current though the coil for a given voltage, thus reducing the magnetic field. Furthermore, the meter uses a test signal level of 0.5 Vrms. To

74 improve the performance of the 3D printed inductor, the coil resistance has to be reduced many orders of magnitude. This is not possible with either use of conductive PLA or graphene based

PLA. The conductive material needs to be highly conductive like some silver based inks.

To provide a significant boost in the inductance of a 3D printed inductor, while using conductive PLA, a ferrite core is utilized in the following design. The ferrite core is placed inside the air cavity of the inductor post printing. This is an effort to create a semi 3D printed inductor with a measurable inductance value. Figure 43 shows a modified version of the previous coil design. In this design the inner diameter of the coil has been increased to 22.0 mm to accommodate the ferrite core material.

Figure 43: Inductor conductive core and 3D print with ferrite (10.5 turn, 22.0 mm inner diameter)

Figure 44 shows the 3D printed inductor with an embedded ferrite core. The coil resistance is measured at 13.64 kΩ. This is an increase from the previous coil design. This is to be expected as an increase in core diameter causes an increase in length of coil, thus increasing

75 the coil resistance. The 3D printed inductor with the ferrite core did not register an inductance reading on the LCR for all test frequencies of the meter.

Figure 44: 3D printed inductor with ferrite (10.5 turns, 22.0 mm inner diameter)

Previous experiments have shown that using the MakerBot 2X with conductive PLA, a physical structure resembling an inductor can be 3D printed. However, due to the relatively high resistivity of currently available conductive filaments, it is not possible to produce a functional inductor. Therefore, for further work, a hybrid printer is proposed that can utilize conductive materials such as silver based conductive paste. Such a printer, when loaded with conductive and non-conductive PLA and silver based paste, will be able to print all the passive components. This hybrid printer can be further improved with the addition of thin insulating material to improve capacitance as well as inductance. Further research in material science needs to be conducted to determine how these different materials can be extruded and bond well to each other.

Figure 45 shows an inductor made from conductive wire, which is an approximation of the previous inductor coil. This inductor is created to validate the functionality of our design, with the use of a conductive material such as copper. The inductor was tested using the LRC meter at a test frequency of 1.0 kHz. Without the ferrite core, with half of the ferrite core, and

76 with the whole ferrite core, the inductor produced 2.0 µH, 4.7 µH, and 5.9 µH respectively. This result validates the functionality of the coil design for a 3D printable inductor, with the availability of better conductive extrudable filaments.

Figure 45: Approximation of inductor (10.5 turns, 24.0 mm inner diameter)

In this chapter, the three passive electrical elements are designed and characterized with respect to 3D printing variables (x, y, z directions, and slicing parameters). 3D printed resistors have shown rising trends in resistivity for the x, and z-axis expansion, and a trough shaped curve for the y-axis expansion. 3D printed capacitors have shown no discernable trends for the dielectric constant for the x, y, and z-axis expansions. The capacitance dielectric constant data has a standard deviation as a percentage of the mean of less than 2.5 %. The inductance of 3D printed inductors could not be measured using lab test equipment. The inductor coil design is validated using an approximated physical model. To successfully create passive electrical elements using 3D printers, the conventional element designs were modified.

77 Chapter V

Design and Implementation of Sensors

This chapter details the design, implementation, and testing of sensors. Two types of sensors are developed; capacitive touch sensor, and flexure sensor. For each sensor, a detailed description of the design stage is provided, followed by the 3D printing stage, and testing of sensor functionality.

5.1 Capacitive Touch

The capacitive touch sensors implemented in this section make use of PSoC and

CapSense technology by Cypress Semiconductor, described in section 3.2.6 and 3.2.7 respectively. The 3D printed sensors are designed in SolidWorks CAD software suite, and the software application is designed in PSoC Creator 3.3 CP1 version 3.3.0.410.

The purpose of this section is to evaluate the performance of 3D printed capacitive sensors used as human finger touch interface. To do this effectively, first a standardized design is required that is suitable for sensing touch gestures. This includes the sensor design as well as a standardized test that can be used to evaluate the sensors with minimal bias. Second, a standardized software application is required to test the physical design of the sensor, and eliminate bias from software settings.

5.1.1 Sensor Design

In the previous section, the passive elements have been characterized using a Fluke 73 multi-meter, and a DE-6000 handheld LCR meter. Taking measurements with both of these instruments required the use of handheld probes. This is an appropriate method for testing

78 passive components, however, a handheld probe approach is not reliable for use with capacitive touch sensors. Any charge body such as a hand in the vicinity of a capacitive touch sensor can affect the measured response from it. The 3D space in which a sensor is affected by an external charge body is dependent upon various factors such as physical design of the sensor or sensitivity of the controller. As such, a method is required that can interface with the PSoC development board and the printed sensors, in isolation of external charge bodies.

A solderless prototyping breadboard (breadboard) is selected for securing the development board [42]. The breadboard has the required pin spacing of 2.54 mm, matching that of the PSoC development board. To remove the need to use handheld probes for interfacing the sensor with the development board, electrical jumper wires have been selected [43]. This allows for a practical connection with the development board on the breadboard. However, a suitable connection socket is required on the sensor as well. The connection socket on the sensor has to provide a reliable electrical contact between the probe and the sensor, and has to be structurally stable. Shown in Figure 46 is a testbed designed to evaluate the connection socket hole, shape, and size. The cylindrical sockets have an outer diameter of 5 mm, with an internal hole diameter ranging from 0.4 mm to 2.4 mm, in 0.4 mm increments. The cubic sockets have 5 mm side length with internal cubic hole side length ranging from 0.4 mm to 2.4 mm, in 0.4 mm increments.

Figure 46: Electrical connection socket evaluation

79 The 3D printed testbed showed that the cylindrical hole provided the most secure connection with the male connector on the jumper wire. Furthermore, an internal hole size of 1.2 mm is the most suitable.

The next important task is the physical design of the sensor. The CapSense design guide provided from Cypress Semiconductor makes the following key recommendations [37]. First, to maximize a button sensor performance, the surface area of the sensor pad and the touching finger should be equal. Second, an electrical ground layer should surround the sensor pad to reduce signal noise. Finally, sensor performance is maximized with the highest signal to noise ratio

(SNR).

Due to the popularity of mobile devices, there has been a considerable research done on optimizing the performance of touch interfaces [44]–[48]. These studies as part of the research have carried out human trials to ascertain ideal contact size for human touch interfaces. One study showed that a contact patch of 8.30 mm by 15.11 mm provided a desirable hit rate of 99 %

[46]. To aid their developers, a study conducted by Microsoft collected large samples in their lab to measure the contact area size created by human finger touch [49]. The Microsoft study showed that the average contact size created from an index finger was 9.4 mm by 8.8 mm.

However, in the same study it was also shown that the largest contact area is 30 mm by 30 mm.

All these study show that there is no ideal size for a contact area. There are considerable variations in the contact area due to finger size, the resting angle, and the pressure exerted by the user. The purpose of this work is to evaluate the performance of the 3D printed sensors whose design is based on industry recommendations. As such, based on CapSense design guide and evaluation of relevant research, a circular sensor pad of 15 mm in diameter is selected. The design guide also recommends a series resistance of around 560 Ω between the sensor pad and

80 the PSoC 5lp pin. To accommodate this, a resistor is designed between the sensor pad and the connection socket. Using resistor characterization results collected for conductive PLA in section

4.1.2, a cross section of height 1 mm and width of 2.4 mm is selected. The associated volume resistivity for this cross section was calculated to be 5.902 Ω-cm. The resistor length is set to 20 mm. Using equation 3.1, and manipulating it to calculate the volume resistance we get the following,

퐴 휌 = 푅 (5.1) 푣 푣 푡

푡휌푣 (5.2) ∴ 푅 = 푣 퐴

2 ∗ 5.902 (5.3) ∴ 푅 = 푣 0.1 ∗ 0.24

∴ 푅푣 = 492 Ω (5.4)

Figure 47 shows the final sensor pad design based on the previously determined design parameters. Finally, the performance of the sensor is tested in relation to the surrounding electrical ground layer. To provide a touch stimulus for the 3D printed sensors, a steel cylindrical rod of 15 mm in diameter is used and is referred to as the test subject.

Figure 47: Standardized capacitive sensor pad design

81 5.1.2 Sensor Test Application

To create a PSoC 5lp firmware application, PSoC Creator (Creator) software requires the use of the C programming language (C code), and a block based visual programming language.

An application is created, first by adding the required visual programming blocks in the

TopDesign.cysch (top level design) file of Creator. This is followed by compiling the project files for the first time. This allows Creator to auto-generate application programming interface

(API) in C code, and hardware description language (HDL) code; associated with the visual programming blocks. Finally, the user can add C code constructs to utilize auto-generated APIs, or create standalone C code subroutines, for a combined effort to manipulate the PSoC 5lp controller as required. Figure 48 shows the top level design of the sensor test application.

Figure 48: Capacitive sensor test application - Top level design

82 The top level design contains visual programming blocks for the CapSense module, inter- integrated circuit (I2C) communication module, and various GPIO pins. The CapSense module implements a single button capacitive touch interface. The I2C module allows the development board to communicate with the host computer, allowing the capture of runtime data. Finally,

GPIO pins are assigned to I2C P12[1:0], CapSense P0[6], input switch SW1 P2[2], and an output light emitting diode (LED) LED_1 P2[1]. Figure 49 shows the final pin assignments for the test application. CapSense design is further optimized by considering the internal analog routing of

PSoC 5lp. According to application notes AN58304 and AN58827, PSoC 5lp GPIO ports P[0:7],

P3[0:7], and P4[0:7], have a slight analog performance advantage [50], [51].

Figure 49: Capacitive sensor test application - Pin assignments

Appendix A.1 contains the main.c code created for the test application. As a general overview, the code initializes various entities including the CapSense module, followed by an endless loop of sending out CapSense data back to the host computer via the I2C communication bus.

Shown in Appendix A.2 are the CapSense module settings used to perform tests for all capacitive touch sensors. Design procedures determined in the CapSense design guide were followed to optimize the CapSense settings for the test subject.

83 5.1.3 Capacitive Sensor Test Results

Five ground plane variations for the capacitive sensor have been tested. For all test samples a top surface dielectric layer of 0.1 mm has been added. This provides a suitable touch surface for the test subject. The first three test samples test the effects of reducing the lateral spacing between the ground plane and the sensor pad with 3.0 mm, 2.0 mm, and 1.0 mm. For these samples the ground plane is of the same thickness as the sensor pad at 1.0 mm, and in the same plane. The fourth sample maintains a 2.0 mm lateral spacing between the sensor pad and the ground plane. However, in this sample the ground plane fully surrounds the bottom of the sensor pad, effectively, encasing it on all three sides apart from the top surface. The fifth sample once again maintains a 2.0 mm lateral spacing between the sensor pad and the ground plane.

However, in this case a hatch pattern is given to the ground plane as recommended by the

CapSense design guide. This will challenge the 3D printer due to a more intricate design, and further increase the print time. However, it allows the evaluation of a 3D printed capacitive sensor with recommended industrial designs. In all figures of capacitive sensors, the MakerBot

Desktop layout has been altered for the purpose of illustration. Namely, the top 0.1 mm dielectric layer is removed to reveal the underlying sensor topology. Without this alteration only the connection sockets are visible. In Figure 53 the entire testbed dielectric block is removed, leaving behind the conductive layers. The GND plane is switched to non-conductive PLA to visually differentiate the sensor pad from the GND plane. The 3D prints do reveal the underlying sensor topology due to the translucently of the non-conductive PLA.

Figure 50, Figure 51, and Figure 52 show 3D printed capacitive touch sensors with decreasing GND plane and sensor pad lateral spacing. Sensors with a lateral spacing of 3 mm and 2 mm printed without error. However, a lateral spacing of 1 mm between the GND plane and

84 sensor pad created an electrical short between them. This has been caused by smearing of small amounts of conductive filament during the printing of non-conductive layers. A future study can look into optimizing design of the extruder nozzle to stop any filament leaks when extruder is not being used.

Figure 50: Capacitive sensor test sample one - 3mm lateral spacing

Figure 51: Capacitive sensor test sample two - 2mm lateral spacing

3D printed sample failed due to internal

electrical short between the sensor pad and

the ground plane.

Figure 52: Capacitive sensor test sample three - 1mm lateral spacing

85 Sensors shown in Figure 53 and Figure 54 printed without error. However, it is worth noting the print quality of the sensor with the GND hatch pattern. The hatch pattern created quality issues during printing. During the printing of each layer of the sensor, there was significant amount of smearing of conductive PLA on the surface. The smearing effect from the conducive PLA extruder limits the level of complexity that can be achieved for functional designs.

Figure 53: Capacitive sensor test sample four - 2mm lateral spacing with GND backplane

Figure 54: Capacitive sensor test sample five - 2mm lateral spacing with GND hatch

Table 20 shows capacitive sensor test results. All tests are performed at the same location. This is important as a change in location may result in changes to external noise levels.

Two isolated tests are conducted for each sensor, one with an active GND plane and one without.

The final column shows the change in SNR value between two tests. Test sample three is not

86 tested due to an internal short. As per CapSense design guide a minimum SNR value of 5 is required for capacitive touch sensing applications. All tested samples passed.

With the highest SNR value of 50, sample test 2 outperforms them all. This is followed by sample test 1. Thus a lateral spacing of 2 mm achieves a better SNR value as compared to 1 mm. During the test of sample test 4, the sensor data from the CapSense was saturated prior to the placement of the test subject. The GND backplane underneath the sensor pad increases the parasitic capacitance (Cp) of the sensor. As such the CapSense configurations that maximized the range for the previous two test samples was saturated when used to test sample test 4. Upon discovering this, the CapSense module was reconfigured to provide universal settings that can be used for all the sensors. However, this effort failed due to a large difference in Cp between the test samples. Therefore the test conducted for test sample 4 is with configuration settings that maximizes the sensor range. To achieve this the IDAC value is changed from 30 to 40. All other settings are kept the same as shown in Appendix A.2. The GND hatch sensor design did not perform as well as the solid GND plane. It is worth noting that the sensor with GND backplane has the smallest change of SNR value from the two tests. It is possible that the GND backplane is passively shielding the sensor pad from external noise.

Table 20: Capacitive sensor test results

Signal to Noise Ratio (SNR)

GND plane GND Plane Sample Test Change in SNR Active Disabled 1 45 30 15 2 50 35 15 3 Not Tested Not Tested Not Tested 4 33 24 9 5 42 28 14

87 5.2 Flexure Sensor

Previous research has demonstrated piezoresistive property of electrically-conductive filament. In this section we implement a flexure sensor based on strain gauge design, and characterize its response to specific changes in deflection.

5.2.1 Sensor Design

Figure 55 shows the conductive circuit trace, designed using the principles of a strain gauge foil. In this configuration, a single conductive trace runs from one connection socket to the other, where most of its length is kept in-line with the axis in which the sensor will deform due to a deflection. This maximizes the change in resistance of the conductive trace due to the piezoresistive property of conductive PLA.

Figure 55: Flexure sensor - conductive circuit trace design (mm)

88 The conductive circuit trace is added on top of a testbed as shown in Figure 56. This testbed serves the purpose of mechanically fixing the design of the conductive circuit trace and providing mechanical design elements required for testing purposes. This sensor is utilized as a cantilever, where the connection socket side is firmly fixed and the opposite side is deflected along the z-axis. Two cubic blocks are placed on the testbed, which allows for repeatable alignments in the testing apparatus. At the deflected end of the sensor are two cut-outs that allow to securely fasten a string for controlled deflections.

Z Y

X

Figure 56: MakerBot Desktop layout and 3D print - Flexure sensor

5.2.2 Test Apparatus

Figure 57 shows the testing apparatus for the flexure sensor. A physically secured test structure is used for mounting all test equipment and sensor under test, to provide a stable vibration free test platform. The sensor under test correctly positioned using the alignment blocks, and secured to the test apparatus using a screw down metal clamp. A dial indicator is positioned at the side of the sensor to be deflected. Finally, a flexible string is looped around the cut-outs, with the other end securely fastened to a screw turnbuckle used for making fine adjustements in deflection along the z-axis. The type of string is not critical as the dial indicator shows the deflection at all times, and any movement in the string can be corrected prior to taking

89 measurements. Electrical jumper wires are inserted in the connection sockets of the sensor as well as to a multi-meter for measuring the resistance of the sensor.

Figure 57: Flexure sensor testing apparatus

5.2.3 Flexure Sensor Test Results

Table 21 shows the flexure sensor test reults. Five samples of the flexure sensor were 3D printed. Conductive silver paint was applied to all the connection sockets of the samples, and all samples were tested in the same session to minimize effects from enviormental changes. The order in which the sensors were tested was randomized from the 3D printed order.

The data shows a consistant linear relationship between the change in deflection and the measured resistance. This is better shown in Figure 58, a plot of resistance data for all sensors against deflection. For each sample data, a line of best fit is added using a plot tool in Microsoft

Excel. The gradient of the line for the top four sample data is very closely spread, with a minimum value of 0.1903 and maximum of 0.2333.

90 Table 21: Flexure sensor test results

Sample Strain Gauge Deflection vs. Resistance (KΩ) Deflection (cm) Print 1 Print 2 Print 3 Print 4 Print 5 0.0000 82.1 75.8 86.8 85.0 88.4 0.1016 82.3 75.5 87.1 85.2 88.6 0.2032 82.5 75.6 87.3 85.3 88.8 0.3048 82.7 75.8 87.6 85.5 89.1 0.4064 83.7 76.0 87.8 85.7 89.3 0.5080 83.9 76.2 88.1 85.9 89.6 0.6096 83.3 76.4 88.3 86.1 89.8 0.7112 83.5 76.6 88.5 86.3 90.0 0.8128 83.7 76.8 88.7 86.5 90.2 0.9144 83.9 76.9 88.9 86.7 90.5

Flexure sensor - Resistance versus Deflection 91 y = 0.2333x + 88.147 89 Print 1 y = 0.2333x + 86.627

87 Print 2 )

Ω 85 y = 0.1903x + 84.773 Print 3 K Print 4 83 y = 0.2x + 82.06 Print 5

81 Linear (Print 1) Resistance ( Resistance 79 Linear (Print 2) Linear (Print 3) 77 y = 0.1576x + 75.293 Linear (Print 4) 75 Linear (Print 5) 0.00 0.10 0.20 0.30 0.41 0.51 0.61 0.71 0.81 0.91 Deflection (cm)

Figure 58: Flexure sensor - Resistance vs. deflection

91 All the sensor samples have a different starting resistance. This offset can be compensated in a calibration process prior to the use of the sensor. This is a standard procedure in industrial applications of such sensors. The sensors need to be pre-loaded with some deflection before they start to exhibit a change in resistance. During testing the force of the return spring of the dial indicator, and the resulting deflection was enough to pre-load the sensor.

In summary, this chapter has demonstrated two types of sensor, namely the capacitive touch sensor and the flexure sensor. The capacitive touch sensor is characterised using industry recommended hardware and software design. It was shown that SNR is improved for human finger touch applications, with a reduction in the lateral seperation between the ground plane and the sensor. It was also shown that industry recommended hatch pattern ground plane design, has a lower SNR performance as compared to a solid ground plane design. Finally, increasing the ground plane shielding of the sensor pad is shown to reduce SNR due to the increase in the parasitic capacitance Cp of the sensor. A flexure sensor has been created using industrial principles of a strain gauge. The sensor has shown near linear resistive response to deflection.

The un-loaded starting resistance of the samples is subject to variation due to the 3D printing process. However, this offset can be compensated using a calibration process.

92 Chapter VI

Application – Musical Keyboard

This chapter describes the design and development of a small musical keyboard application. The musical keyboard requires the use of resistive and capacitive elements. A high level of integration is demonstrated by embedding the PSoC 5lp development board in the 3D printed application.

6.1 Five Keys

A simpler keyboard with five keys is considered in this section. This will act as the platform to optimize design features before tackling a full octave keyboard.

6.1.1 Keyboard Design

A simple keyboard application requires multiple capacitive sensors to function as music keys, a transducer (speaker) to output music notes, and PSoC 5lp development board to act as the controller. The capacitive sensors require routing to the relevant GPIO on the development board with a series resistance. Ideally a speaker requires routing to the GPIO pins with minimal series resistance to maximize the transfer of power. However, due to the resistive property of conductive PLA, there will be an impedance mismatch when coupled to a standard 4 Ω or 8 Ω coil speaker. Furthermore, any significant electrical current will be the cause of high power dissipation through the conductive PLA. This must be avoided as the effects of temperature on conductive PLA have not been analyzed. As such, a piezo electric transducer is selected to act as a speaker. This speaker has a relatively high impedance load, therefore a better match to a resistive source.

93 In Section 5.1 results from the tests showed that the use of an active GND layer improved the SNR value of the capacitive sensors. However, the GND layer required a substantial surface area around the sensor pad. For a musical keyboard layout this is not practical. A better GND layer is required.

The keyboard layout requires appropriate connection sockets to secure the development board, and provide a reliable electrical connection. In Sections 5.1 and 5.2, sensors were electrically connected to test equipment via electrical jumper wires. The sockets had a diameter of 5 mm. However a diameter of 5 mm is too large to cope with 2.54 mm pin spacing of the development board. The connection sockets can be reduced in diameter, at the expense of reduced structural rigidity and electrical conductivity.

Figure 59 shows the final layout of the conductive layer. Appendix B.1 shows the

SolidWorks annotated drawings of the conductive layer. Some of the key design features of this layout are the connection socket, multi-output speaker path, and the ground layer surrounding the capacitive sensors.

A new connection socket has been designed for this layout. The diameter has been reduced to 4 mm. This allows for a 3D printable socket while maintaining the socket hole.

Further reduction in diameter resulted in printing inconsistency for the inner hole, as well as structural weaknesses. To compensate for the loss in structural rigidity and conductivity, a bridging chamfer is added between the side of the socket and the conductive track. A disadvantage of this method is that it only allows the use of alternate pins on the development board.

To maximize the output from the speaker, five conductive paths are combined at the output pin of the speaker. Each path is connected to a separate GPIO pin. This layout goes

94 against conventional wisdom, as electrically combining output pins can result in shorting the power rails. However, due to their resistive paths there is no direct shorting of pins. Furthermore, this topology acts as a low pass filter due to the series resistance, coupled with the piezo electric speaker acting as a shunt capacitor to ground. Thus, the pulse width modulation (PWM) square wave generated music notes receive some audible smoothing. However, this layout is not ideal as the conductive path resistance from each pin to the speaker is not balanced. This is discussed in the application section. Speaker Output Paths

C D E F G

Active Ground Layer

Figure 59: Music keyboard - Five Key - Conductive layer

95 Finally, a ground layer is added on the outskirts of the block of capacitive sensor keys.

This choice is made due to practical reasons, as adding a ground layer in between keys increases likelihood of shorting the sensors to ground. The shorting can be eliminated by increasing the spacing between the keys. However, this results in a compromised design for keyboard playability.

Figure 60 shows the MakerBot Desktop layout for the keyboard. The top dielectric layer of 0.1 mm is removed for a better illustration of the layout. It is worth noting that the keyboard layout is such on the build plate, so that the line of connection sockets is perpendicular to the in- line extruders. This further reduces the likelihood of shorts between adjacent circuit paths.

Figure 60: MakerBot Desktop layout - Music keyboard - Five Keys

Figure 61 shows the fully assembled keyboard. The development board is populated with single in line (SIL) header pins, and attached to the 3D printed keyboard along with the speaker.

The keyboard print contains some conductive PLA smearing near the connection sockets. This

96 can lead to shorts when designing the full octave keyboard, due to a higher density of circuit paths.

Figure 61: Fully assembled music keyboard - Five keys

6.1.2 Keyboard Application

Appendix B.2 shows the top level design for the application. The application uses a

CapSense module, five PWM modules, I2C communication module, synthesized internal logic gates, and GPIO pins. The pin assignments for the application are listed in Appendix B.3. The

CapSense module has the same configuration as the capacitive sensor test application shown in

Appendix A.2, apart from what is shown in Appendix B.4. The main.c file is listed in Appendix

B.5.

The keyboard application makes use of five PWM modules, to output a square wave with the frequency of the music note assigned to it. The first iteration of the application, sent PWM outputs to the five speaker output paths highlighted in Figure 59. However, during testing of the

97 software on a 3D printed keyboard, due to signal path variations the audible levels of notes were inconsistent. This was due to resistance variations of the signal paths. To resolve this issue,

PWM outputs are internally combined using a multi-input AND logic gate, and sent out to a single GPIO pin with the shortest conductive path to the speaker connection socket. It is worth noting that the output from a stopped PWM is a logic LOW level. Internal NOT logic gates are used to invert the outputs from the PWMs. Without the logic inversion of PWM outputs, a single stopped PWM would force the AND gate to output a logic LOW level. Thus, the AND gate will not effectively combine and pass through outputs from active PWMs. Due to the use of an AND logic gate for combining the outputs from PWMs, conventional 50% PWM duty cycle does not effectively combine multiple audio notes. During the off period of the PWM output with the lowest note frequency, the AND gate is held LOW and does not pass through the higher note frequencies. As the duty cycle of PWMs is decreased below 50 %, resulting in an increase past

50 % after the NOT gates, the input from the lowest note frequency to the AND gate is held

HIGH for a longer duration. The audio notes are combined more effectively and can produce musical chords. However, this desired effect is at the expense of a lowered audio output level.

The current release of application makes use of a 2.5 % PWM duty cycle, producing a 97.5 % duty cycle after the NOT gates and input to the AND gate.

Once powered up, the application initializes all the internal modules. It then executes an infinite software loop where it checks all the capacitive sensors, for any active sensors the relevant PWM modules are activated, all other PWM modules are deactivated.

98 6.2 Full Octave

A full octave keyboard is designed, implemented, and demonstrated in this section.

Design challenges due to the increase in the number of music keys and related conductive circuit paths are addressed.

6.2.1 Keyboard Design

A full octave musical keyboard consists of twelve keys, out of which seven represent the natural notes, while the other five represent sharp notes. In Section 6.1, the 3D printed keyboard showed significant smearing of conductive PLA in-between the connection sockets. This did not result in any electrical shorts between any conductive circuit paths of the five key keyboard.

However, with the increase in the number of keys required for a full octave keyboard, the likelihood of electrical shorts increases with circuit density.

The unwanted smearing of conductive PLA is caused due to non-conductive PLA in between the conductive PLA circuit paths acting as a bridge. To remove this bridge, adjacent circuit paths need to be lifted along the Z-axis to create an air channel in between them. To evaluate this solution, Figure 62 shows a testbed created with two rows of connection sockets placed to fit a PSoC 5lp development board populated with SIL header pins.

Figure 62: Minimize electrical shorts - conductive circuits Z-axis lift

99 The conductive connection sockets are raised by 0.4 mm using a layer of non-conductive

PLA, better illustrated with the connection sockets lifted in the right image. It is worth noting that the design of the non-conductive lifting layer, should extend the cross-sectional design of the bottom layer of the lifted conductive layer.

Figure 63 shows the 3D print of the testbed. All connection sockets printed without any electrical shorting occurring between them. Furthermore, the overall print quality has been improved, with smearing of conductive PLA minimized. The right image shows a PSoC 5lp development board inserted into the testbed. The connection socket design, with the Z-axis lift of conductive layer provide sufficient improvement in 3D print quality allowing the use of alternate pins while maintaining electrical isolation.

Figure 63: Minimize electrical shorts – Conductive Z-axis lift – 3D print

Figure 64 shows an exploded view of the 3D print layers of the octave keyboard.

Appendix C.1 shows the annotated drawings. The non-conductive layers are shown in two colors red and yellow, consisting of 0.4 mm high base keyboard base layer, and a 0.4 mm high lift layer to raise the conductive circuits in the Z-axis respectively. The conductive layer is shown in dark grey, consisting of the sensor pads and the speaker output path. The speaker output path combines the output from four GPIO pins to maximized power delivery to the speaker. In this keyboard the ground layer has been omitted. The primary reason for the removal of the ground

100 layer is due to the increase in complexity of the required design, due to reduction in the space between the keys. Furthermore, as shown in Section 5.1, the sensor performance without an active ground plane is still well above the minimum required SNR of 5 as recommended in the

CapSense design document.

Speaker Output Path Non – Conductive Layers

# C # D # F # G A#

C D E F G A B Conductive Layer

Figure 64: Music keyboard - Octave - 3D print layers

101 Figure 65 shows the MakerBot Desktop layout for the octave keyboard. The keyboard 3D print layers as shown in Figure 64 are stacked on top of each other. Finally, an additional top insulating layer is added on top of the conductive layer using a copy of the lift layer.

Figure 65: MakerBot Desktop layout - Octave keyboard

Figure 66 shows the 3D printed keyboard, assembled with the PSoC 5lp development board and a piezoelectric speaker. The final print shows minimal signs of smearing from the conductive PLA extruder, an improvement over the five key keyboard shown in the previous

Section 6.1.

102

Figure 66: Fully assembled octave keyboard

6.2.2 Keyboard Application

The top level design for the octave keyboard is shown in Appendix C.2. The source code is shown in Appendix C.3 to Appendix C.6. The keyboard application makes use of five PWMs for music note frequency generation. However, unlike in the five key keyboard application where PWMs are permanently assigned to specific music notes, in this application there is dynamic allocation of the PWM resource.

103 With a press of a music key, the first available PWM module is assigned to that note. The

PWM module is configured with the note frequency and the duty cycle ratio, and then it is activated. Additional simultaneous key presses take up more PWM modules, until all five modules are in use. Once all the PWM modules are assigned, further key presses do not get assigned a PWM module, and must wait for an assigned PWM module to become available.

When an assigned music key is released, the associated PWM is released and is made available for future use.

At any time the user can press and release pushbutton switch SW1 to cycle between octaves C4 to C7 in the C major scale. Once set to C7 octave, an additional press and release of

SW1 sets the octave back to C4. Only these octaves have been implemented in the application, as the piezoelectric speaker works best for these frequencies. More octaves can be easily added to the application for a speaker with a wider frequency response.

In summary, the five key and the full octave keyboard have been demonstrated as functional 3D printed applications. Design and techniques were developed to further improve 3D print quality for a successful integration of multiple capacitive touch sensors, the PSoC 5lp development board and the output speaker. The functionality of both keyboards has been demonstrated once they were fully assembled and programmed with the latest release of firmware.

104 Chapter VII

Conclusions & Future Work

In this thesis, evidence is presented to show that electrical passive components such as resistors, and capacitors can be printed to within 5 % tolerance using low cost desktop FFF 3D printers in conjunction with electrically-conductive composite filament. A scalable design model for the passive components is developed. An increasing trend in resistivity is shown for the x and z-axis expansion, occurring due to less than ideal infill pattern and layer to layer bonds in relation to electrical conduction. Resistivity data from the y-axis expansion showed unexpected variations which were further analyzed by reheating the test samples to create a uniform resistivity distribution. This resulted in an overall reduction in resistivity for all samples.

However, this reheating did not produce a uniform distribution in resistivity. 3D printed inductors were unsuccessful as their inductance could not be measured using lab test equipment.

Further work needs to be done by using an electrically-conductive filament with considerably lower resistivity than conductive (CB) and graphene PLA.

It is shown that 3D printed sensors perform comparable to industry standards.

Piezoresistive behavior of conductive PLA is combined with the design principles from strain gauges, to demonstrate near linear response in the change in resistance to sensor deflection.

Capacitive sensors have been designed with the required embedded series resistor element, and tested for varying ground plane performance. A simple solid ground plane design is shown to outperform industry recommended hatch ground plane design.

Finally, design and techniques have been developed to embed a commercially available development controller board, into a functional 3D printed application with active capacitive sensors. A small musical keyboard application is designed in two stages. A small five key design

105 followed by a full octave design. The full octave design utilizes design refinements made during the development of the five key version. The 3D print quality is further improved by lifting the conductive layer up in the z-axis. This allows for utilization of a larger number of GPIO pins on the development board which are needed for the additional capacitive touch sensors. Both keyboard versions demonstrate a high level of integration with embedded sensors, controller board, and an output speaker.

This work has also shown limitations of current low cost desktop FFF 3D printing technology related to functional 3D printed parts. Future work in material science could create filaments with a high level of conductivity, and still be usable with currently available filament in low cost FFF 3D printers. 3D printing hardware can also be further improved to minimize, if not eliminate, any smearing of filament from extruders. 3D printing software is needed, to be designed for functional 3D printing. Currently, freely available slicing programs are optimized for reducing printing times, and maximizing structural properties of 3D printed objects.

However, a slicing software is needed that allows the user to optimize 3D printed objects for improved properties related to structural and/or functional characteristics. A better equipped slicing software for example should allow the user to pick the order in which the layers of resistor elements are printed allowing to minimize large variations in the time intervals between additional conductive layers. There is also a need for a freely available CAD design software with the ability to design electrical circuits with inbuilt components. In this thesis, the CAD design work for the music keyboard application took a great deal of effort to design all the circuit paths. For the software to automatically route the required PCB traces, the conventional PCB design tools require users to pick and place electronic components and add circuit schematic defining inter-component electrical connections. A similar approach is required for creating

106 functional 3D prints where standardized passive components can be picked and placed by the user. With a definition of circuit paths, the CAD tool can then create conductive pathways in 3D space within the application.

107 References

[1] C. W. Hull, “The Birth of 3D Printing IRI Achievement Award Address,” Res. Technol. Manag., vol. 58, no. 6, pp. 25–29, 2015.

[2] C. W. Hull, “Apparatus for production of three-dimensional objects by stereolithography,” U.S. Patent 4 575 330, 1986.

[3] C. W. Hull, “Method for production of three-dimensional objects by stereolithography,” U.S. Patent 4 929 402, 1990.

[4] C. W. Hull and C. W. Lewis, “Methods and apparatus for production of three-dimensional objects by stereolithography,” U.S. Patent 4 999 143, 1991.

[5] T. A. Almquist, B. Modrek, P. F. Jacobs, C. W. Lewis, M. A. Lewis, and A. Liran, “Method of and apparatus for making a three-dimensional product by stereolithography,” U.S. Patent 5 174 931, 1992.

[6] C. Deckard, “Apparatus for producing parts by selective sintering,” U.S. Patent 5 597 589, 1997.

[7] J. Hornick and A. Bhushan, “More 3D Printing Patents Are Expiring Soon: Here’s a Roundup.” [Online]. Available: https://3dprintingindustry.com/news/more-3d-printing- patents-are-expiring-soon-heres-a-roundup-96561/. [Accessed: 11-Jan-2016].

[8] J. Hornick and D. Roland, “Many 3D Printing Patents Are Expiring Soon: Here’s A Round Up & Overview of Them.” [Online]. Available: https://3dprintingindustry.com/news/many-3d-printing-patents-expiring-soon-heres- round-overview-21708/. [Accessed: 11-Jan-2016].

[9] “VOXEL8 DEBUTS 3D ELECTRONICS PRINTER.,” CAD/CAM Update, vol. 27, no. 2. Worldwide Videotex, pp. 5–7, Feb-2015.

[10] “Our Team — Voxel8.” [Online]. Available: http://www.voxel8.com/new-page/. [Accessed: 12-Aug-2016].

[11] “Developer's Kit Platform Overview – Voxel8 Support Center.” [Online]. Available: http://support.voxel8.co/hc/en-us/articles/207469773-Developer-s-Kit- Platform-Overview. [Accessed: 12-Aug-2016].

[12] “Autodesk and Voxel8 to make 3D Printed Electronics a reality | Spark - an open platform for connecting the 3D Printing ecosystem,” 2015. [Online]. Available: https://spark.autodesk.com/blog/autodesk-and-voxel8-make-3d-printed-electronics-reality. [Accessed: 12-Aug-2016].

[13] Nano Dimension Ltd., “Nano Dimension Puts 3D Printed Electronics in the Spotlight at SOLIDWORKS World 2016 | Business Wire,” Business Wire (English), 2016. [Online].

108 Available: http://www.businesswire.com/news/home/20160201005647/en/Nano- Dimension-Puts-3D-Printed-Electronics-Spotlight. [Accessed: 12-Aug-2016].

[14] Nano Dimension Ltd., “DragonFly 2020 | Nano Dimension | The World’s First 3D PCB Printer,” 2016. [Online]. Available: http://www.nano-di.com/3d-printer. [Accessed: 12- Aug-2016].

[15] Nano Dimension Ltd., “Nanoparticle Conductive & Dielectric Inks | Nano Dimension.” [Online]. Available: http://www.nano-di.com/conductive-inks. [Accessed: 12-Aug-2016].

[16] Nano Dimension Ltd., “Nano Dimension Introduces AgCiteTM; Highly Conductive Silver Nanoparticle Inks for Printed Electronics | Business Wire,” Business Wire (English), 2015. [Online]. Available: http://www.businesswire.com/news/home/20151021005118/en/Nano-Dimension- Introduces-AgCiteTM-Highly-Conductive-Silver. [Accessed: 12-Aug-2016].

[17] S. J. Leigh, R. J. Bradley, C. P. Purssell, D. R. Billson, and D. A. Hutchins, “A Simple, Low-Cost Conductive Composite Material for 3D Printing of Electronic Sensors,” PLoS One, vol. 7, no. 11, p. e49365, Nov. 2012.

[18] J. L. Flatley, “Bits from Bytes’ new 3D printer extrudes with the best of ’em.” [Online]. Available: https://www.engadget.com/2010/04/13/bits-from-bytes-new-3d-printer- extrudes-with-the-best-of-em/. [Accessed: 12-Sep-2016].

[19] Thingiverse.com, “Thingiverse - Digital Designs for Physical Objects.” [Online]. Available: http://www.thingiverse.com/. [Accessed: 12-Sep-2016].

[20] ProtoPlant, “Conductive PLA; ProtoPlant, makers of Proto-pasta.” [Online]. Available: https://www.proto-pasta.com/pages/conductive-pla#CCmade. [Accessed: 12-Sep-2016].

[21] Graphene 3D Lab Inc., “Conductive Graphene 3D Printing PLA Filament.” [Online]. Available: http://www.blackmagic3d.com/Conductive-p/grphn-175.htm. [Accessed: 12- Sep-2016].

[22] T. Wohlers and T. Gornet, “Wohlers Report 2014: 3d Printing and Additive Manufacturing State of the Industry Annual Worldwide Progress Report,” Wohlers Assoc., 2014.

[23] “Committee F42 on Additive Manufacturing Technologies.” [Online]. Available: https://www.astm.org/COMMITTEE/F42.htm. [Accessed: 01-Jan-2016].

[24] “ISO / ASTM52900-15, Standard Terminology for Additive Manufacturing - General Principles - Terminology.” ASTM International.

[25] “ASTM D4496-13, Standard Test Method for D-C Resistance or Conductance of Moderately Conductive Materials.” ASTM International.

109 [26] MakerBot, “Shop Replicator 2X Experimental 3D Printer | MakerBot.” [Online]. Available: https://store.makerbot.com/printers/replicator2x/. [Accessed: 12-Nov-2016].

[27] C. Bean, “Thoughts of a Plebeian: Printing with PLA on a Makerbot 2X,” 2013. [Online]. Available: http://thoughtsofaplebeian.blogspot.com/2013/10/printing-with-pla-on- makerbot-2x.html. [Accessed: 12-Nov-2016].

[28] ppyromann, “Threaded Filament Dust Filter - Universal by ppyromann - Thingiverse,” 2013. [Online]. Available: http://www.thingiverse.com/thing:153807. [Accessed: 12-Nov- 2016].

[29] MAKE, “Make: 2015 3D Printer Shoot Out Test Models by MAKE - Thingiverse,” 2014. [Online]. Available: http://www.thingiverse.com/thing:533472. [Accessed: 12-Nov-2016].

[30] rmcniff, “Replicator 2X Extruder Drive Block Upgrade by rmcniff - Thingiverse,” 2014. [Online]. Available: http://www.thingiverse.com/thing:222667. [Accessed: 12-Nov-2016].

[31] BalticCopters, “Makerbot Replicator 2x Filament Fan Upgrade by BalticCopters - Thingiverse,” 2014. [Online]. Available: http://www.thingiverse.com/thing:239108. [Accessed: 12-Nov-2016].

[32] MakerBot, “Extruder Cooling Fan for MakerBot Replicator 2/2X.” [Online]. Available: https://store.makerbot.com/parts-accessories/cooling-fan-makerbot-replicator-2/. [Accessed: 12-Nov-2016].

[33] Cypress Semiconductor, “32-bit ARM® Cortex®-M PSoC® | Cypress Semiconductor,” 2016. [Online]. Available: http://www.cypress.com/products/32-bit-arm-cortex-m-psoc. [Accessed: 12-Oct-2016].

[34] Cypress Semiconductor, “CY8CKIT-059 PSoC® 5LP Prototyping Kit With Onboard Programmer and Debugger | Cypress Semiconductor,” 2016. [Online]. Available: http://www.cypress.com/documentation/development-kitsboards/cy8ckit-059-psoc-5lp- prototyping-kit-onboard-programmer-and. [Accessed: 12-Oct-2016].

[35] Cypress Semiconductor, “CY8C5888LTI-LP097 | Cypress Semiconductor,” 2016. [Online]. Available: http://www.cypress.com/part/cy8c5888lti-lp097. [Accessed: 12-Oct- 2016].

[36] N. Jaksic, J. DePalma, P. Desai, and R. Van Deest, “3D-Printed Smart Lamp Workshop,” 2015 ASEE Annual Conference and Exhibition, Seattle, WA, June 14 – 17, 2015.

[37] Cypress Semiconductor, “AN64846 - Getting Started with CapSense | Cypress Semiconductor,” 2016. [Online]. Available: http://www.cypress.com/documentation/application-notes/an64846-getting-started- capsense?source=search&cat=technical_documents. [Accessed: 12-Oct-2016].

[38] S. Pratt, “Capacitance Sensors for Human Interfaces to Electronic Equipment | Analog Devices,” 2006. [Online]. Available: http://www.analog.com/en/analog-

110 dialogue/articles/capacitance-sensors-for-human-interfaces-to-electronics.html. [Accessed: 12-Oct-2016].

[39] Cypress Semiconductor, “AN75400 - PSoC® 3 and PSoC® 5LP CapSense® Design Guide | Cypress Semiconductor,” 2016. [Online]. Available: http://www.cypress.com/documentation/application-notes/an75400-psoc-3-and-psoc-5lp- capsense-design-guide?source=search&cat=technical_documents. [Accessed: 12-Oct- 2016].

[40] T. Nakagawa, T. Nakiri, R. Hosoya, and Y. Tajitsu, “Electrical Properties of Biodegradable Film,” IEEE Trans. Ind. Appl., vol. 40, no. 4, pp. 1020– 1024, 2004.

[41] T. L. Floyd, Principles of electric circuits, 5th ed. Upper Saddle River, N.J : Prentice Hall, 1997.

[42] SparkFun Electronics, “Breadboard - Full-Size (Bare) - PRT-12615 - SparkFun Electronics.” [Online]. Available: https://www.sparkfun.com/products/12615. [Accessed: 12-Dec-2016].

[43] SparkFun Electronics, “Jumper Wires Premium 6" M/M - 20 AWG (10 Pack) - PRT-11709 - SparkFun Electronics.” [Online]. Available: https://www.sparkfun.com/products/11709. [Accessed: 12-Dec-2016].

[44] H. Benko, A. D. Wilson, and P. Baudisch, “Precise Selection Techniques for Multi-touch Screens,” in Proceedings of the SIGCHI Conference on Human Factors in Computing Systems, 2006, pp. 1263–1272.

[45] S. Radhakrishnan, Y. Lin, I. Zeid, and S. Kamarthi, “Finger-based multitouch interface for performing 3D CAD operations,” Int. J. Hum. Comput. Stud., vol. 71, no. 3, pp. 261–275, 2013.

[46] E. S. Jung and Y. Im, “Touchable area: An empirical study on design approach considering perception size and touch input behavior,” Int. J. Ind. Ergon., vol. 49, pp. 21– 30, 2015.

[47] Y. Im, T. Kim, and E. S. Jung, “Investigation of Icon Design and Touchable Area for Effective Smart Phone Controls,” Hum. Factors Ergon. Manuf. Serv. Ind., vol. 25, no. 2, pp. 251–267, Mar. 2015.

[48] C. Travis and P. Murano, “A comparative study of the usability of touch-based and mouse-based interaction,” Int. J. Pervasive Comput. Commun., vol. 10, no. 1, pp. 115– 134, Apr. 2014.

[49] Microsoft, “Contact area size - Windows 10 hardware dev,” 2013. [Online]. Available: https://msdn.microsoft.com/en-us/library/windows/hardware/dn672264(v=vs.85).aspx. [Accessed: 12-Dec-2016].

111 [50] Cypress Semiconductor, “AN58304 - PSoC® 3 and PSoC 5LP – Pin Selection for Analog Designs | Cypress Semiconductor,” 2015. [Online]. Available: http://www.cypress.com/documentation/application-notes/an58304-psoc-3-and-psoc-5lp- pin-selection-analog-designs?source=search&keywords=AN58304. [Accessed: 01-Jan- 2016].

[51] Cypress Semiconductor, “AN58827 - PSoC® 3 and PSoC 5LP Internal Analog Routing Considerations | Cypress Semiconductor,” 2015. [Online]. Available: http://www.cypress.com/documentation/application-notes/an58827-psoc-3-and-psoc-5lp- internal-analog-routing-considerations?source=search&keywords=AN58827. [Accessed: 01-Jan-2016].

112 Appendix A Capacitive Sensor Test Application

Appendix A.1 Main.c

/**************************************************************************** **************************************************************************** * Project :- Capacitive Sensor Test Application * Class :- Master Thesis Research * Advisors :- Dr. N. Jaksic, Dr. J. DePalma, and Dr. B. Ansaf * Creator :- Pratik Desai * * File :- Main.c * * About :- This is an application created as part of the master thesis * research of CHARACTERIZATION AND APPLICATIONS OF ELECTRICALLY * CONDUCTIVE FILAMENT IN 3D PRINTING. * * This application is used for evaluating 3D printed capacitive * touch sensors. * **************************************************************************** */

#include

/**************************************************************************** * Function Name: main ***************************************************************************** * * Summary: * Main function performs following functions: * 1. Enable global interrupts. * 2. Initialize CapSense CSD and EzI2C Start the sensor scanning loop. * 3. Process scanning results and communicates with Tuner GUI. * * Parameters: * None * * Return: * None * ****************************************************************************/ void Sensors_Ena_Buttons(void); int main() { /* Local Variables */ uint16 pressedState = 0x00; uint16 sw1State = 0x00;

/* Enable global interrupts */ CyGlobalIntEnable;

/* Initialize CapSense CSD and EzI2C Start the sensor scanning loop */

113 CapSense_CSD_TunerStart(); CapSense_CSD_Start();

/* Check SW1 (Active Low) - if pressed > launch Tuner GUI */ sw1State = SW1_Read();

CapSense_CSD_InitializeAllBaselines();

while(1u) { /* Process scanning results and communicates with Tuner GUI */ if( sw1State != 0x00 ) CapSense_CSD_TunerComm();

/* Update Sensor UUT baseline */ CapSense_CSD_UpdateEnabledBaselines();

/* Start scanning all enabled sensors */ CapSense_CSD_ScanEnabledWidgets();

/* Wait for scanning to complete */ while(CapSense_CSD_IsBusy() != 0) { }

/* Toggle LED @2.1 if Sensor UUT is active */ if( CapSense_CSD_CheckIsWidgetActive(CapSense_CSD_SENSOR_UUT__BTN)) { if( pressedState == 0x00) { LED_1_Write(!LED_1_Read()); pressedState = 0x01; } } else pressedState = 0x00; } } void Sensors_InitSensors(void) { /* Initialization Code */

/* Start CSD proximity sensor */ CapSense_CSD_Start();

/* Enable and Sensor UUT */ Sensors_Ena_Buttons();

/* Initialize baseline for Sensor UUT */ CapSense_CSD_InitializeAllBaselines();

/* Update Sensor UUT baseline */ CapSense_CSD_UpdateEnabledBaselines();

/* Start scanning all enabled sensors */

114 CapSense_CSD_ScanEnabledWidgets();

/* Wait for scanning to complete */ while(CapSense_CSD_IsBusy() != 0) { }

} void Sensors_Ena_Buttons(void) { CapSense_CSD_EnableWidget(CapSense_CSD_SENSOR_SENSOR_UUT__BTN); }

/* [] END OF FILE */

Appendix A.2 CapSense Configurations

115

116

117 Appendix A.3 Capacitive Sensor Ground Plane Drawings

118

119

120 Appendix B Music Keyboard – Five Key

Appendix B.1 Conductive Layer Drawings

121

122 Appendix B.2 Five Key PSoC Application – Top Level Design

123 Appendix B.3 Five Key PSoC Application – Pin Assignments

Appendix B.4 Five Key PSoC Application – CapSense Configuration

124 Appendix B.5 Five Key PSoC Application – Main.c

/**************************************************************************** **************************************************************************** * Project :- Music Keyboard - 5 Keys * Class :- Master Thesis Research * Advisors :- Dr. N. Jaksic, Dr. J. DePalma, and Dr. B. Ansaf * Creator :- Pratik Desai * * File :- Main.c * * About :- This is an application created as part of the master thesis * research of CHARACTERIZATION AND APPLICATIONS OF ELECTRICALLY * CONDUCTIVE FILAMENT IN 3D PRINTING. * * This application is used in conjunction with the 3D printed * 5 Key Music Keyboard. * **************************************************************************** */

#include

/**************************************************************************** * Function Name: main ***************************************************************************** * * Summary: * Main function performs following functions: * 1. Enable global interrupts. * 2. Initialize CapSense CSD, EzI2C Start, all PWM blocks, * and start the sensor scanning loop. * 3. Process scanning results and communicates with Tuner GUI * if requested by user during reset. * 4. Toggle sound on and off during runtime if requested by user. * 5. If sensor is active activate the associated PWM block. * 6. If sensor is not active, disable associated PWM block. * * Parameters: * None * * Return: * None * ****************************************************************************/ #define BUZZ_PWM_CLOCK_FRQ (100000) // Hz int main() { /* Local Variables */ uint16 pressedState = 0x00; uint16 sw1ResetState = 0x00; uint16 sw1State = 0x01; uint16 sw1Pressed = 0x00; uint16 musicKeyPressed = 0x00;

125 uint16 pwmBuzzFreq[] = { 524, 588, 660, 698, 784}; // c5 d5 e5 f5 g5 uint16 pwmBuzzCmpDiv = 40; uint16 countLed = 0; uint16 countBuzz = 0; uint16 lengthLedArray = 10; uint16 lengthBuzzArray = 5; uint16 sliderRange = 100; uint16 sliderOffset = 2; uint16 sliderVal = sliderRange + sliderOffset;

/* Enable global interrupts */ CyGlobalIntEnable;

/* Initialize CapSense CSD and EzI2C Start the sensor scanning loop */ CapSense_CSD_TunerStart(); CapSense_CSD_Start();

/* Initialize the PWM blocks and turn them off immediately */ buzzPWM_1_Start(); buzzPWM_1_Stop(); buzzPWM_2_Start(); buzzPWM_2_Stop(); buzzPWM_3_Start(); buzzPWM_3_Stop(); buzzPWM_4_Start(); buzzPWM_4_Stop(); buzzPWM_5_Start(); buzzPWM_5_Stop();

Led_1_Write( sw1State );

/* Check SW1 (Active Low) - if pressed > launch Tuner GUI */ sw1ResetState = SW1_Read();

CapSense_CSD_InitializeAllBaselines();

while(1u) { /* To use the Tuner GUI - Press and hold SW1 P2.2, while pressing the reset button. Then launch the GUI in TopDesign */ if( sw1ResetState == 0x00 ) CapSense_CSD_TunerComm();

/* Press SW1 during runtime mode to toggle the sound output on or off */ if(!SW1_Read()) { if(sw1Pressed == 0x00) { sw1State = !sw1State;

126 Led_1_Write( sw1State ); sw1Pressed = 0x01; } } else sw1Pressed = 0x00;

/* Perform initial proximity read to set max and min */ CapSense_CSD_UpdateEnabledBaselines(); /* Start scanning all enabled sensors */ CapSense_CSD_ScanEnabledWidgets(); /* Wait for scanning to complete */ while(CapSense_CSD_IsBusy() != 0) { }

/* Check if each button is pressed and sound the appropriate * buzzer tone. Else turn off the buzzer */

if( CapSense_CSD_CheckIsWidgetActive( CapSense_CSD_BTN_C__BTN ) && sw1State != 0x00 ) { buzzPWM_1_WritePeriod( BUZZ_PWM_CLOCK_FRQ / pwmBuzzFreq[0] ); buzzPWM_1_WriteCompare( BUZZ_PWM_CLOCK_FRQ / ( pwmBuzzFreq[0] * pwmBuzzCmpDiv) ); buzzPWM_1_Enable(); } else buzzPWM_1_Stop();

if( CapSense_CSD_CheckIsWidgetActive( CapSense_CSD_BTN_D__BTN ) && sw1State != 0x00 ) { buzzPWM_2_WritePeriod( BUZZ_PWM_CLOCK_FRQ / pwmBuzzFreq[1] ); buzzPWM_2_WriteCompare( BUZZ_PWM_CLOCK_FRQ / ( pwmBuzzFreq[1] * pwmBuzzCmpDiv) ); buzzPWM_2_Enable(); } else buzzPWM_2_Stop();

if( CapSense_CSD_CheckIsWidgetActive( CapSense_CSD_BTN_E__BTN ) && sw1State != 0x00 ) { buzzPWM_3_WritePeriod( BUZZ_PWM_CLOCK_FRQ / pwmBuzzFreq[2] ); buzzPWM_3_WriteCompare( BUZZ_PWM_CLOCK_FRQ / ( pwmBuzzFreq[2] * pwmBuzzCmpDiv) ); buzzPWM_3_Enable(); } else buzzPWM_3_Stop();

127

if( CapSense_CSD_CheckIsWidgetActive( CapSense_CSD_BTN_F__BTN ) && sw1State != 0x00 ) { buzzPWM_4_WritePeriod( BUZZ_PWM_CLOCK_FRQ / pwmBuzzFreq[3] ); buzzPWM_4_WriteCompare( BUZZ_PWM_CLOCK_FRQ / ( pwmBuzzFreq[3] * pwmBuzzCmpDiv) ); buzzPWM_4_Enable(); } else buzzPWM_4_Stop();

if( CapSense_CSD_CheckIsWidgetActive( CapSense_CSD_BTN_G__BTN ) && sw1State != 0x00 ) { buzzPWM_5_WritePeriod( BUZZ_PWM_CLOCK_FRQ / pwmBuzzFreq[4] ); buzzPWM_5_WriteCompare( BUZZ_PWM_CLOCK_FRQ / ( pwmBuzzFreq[4] * pwmBuzzCmpDiv) ); buzzPWM_5_Enable(); } else buzzPWM_5_Stop(); } } void Sensors_InitSensors(void) { /* Initialize CapSense */ CapSense_CSD_Start();

/* Initialize all sensor baselines */ CapSense_CSD_InitializeAllBaselines();

/* Update all sensor baselines */ CapSense_CSD_UpdateEnabledBaselines();

/* Start scanning all enabled sensors */ CapSense_CSD_ScanEnabledWidgets();

/* Wait for scanning to complete */ while(CapSense_CSD_IsBusy() != 0) { } }

/* [] END OF FILE */

128 Appendix C Music Keyboard – Octave

Appendix C.1 Conductive Layer Drawings

129

130 Appendix C.2 Octave Keyboard PSoC Application – Top Level Design

131 Appendix C.3 Octave Keyboard PSoC Application – Configs.h

/**************************************************************************** **************************************************************************** * Project :- 3D Printed Octave Music Keyboard * Class :- Master Thesis Research Application * Advisors :- Dr. N. Jaksic, Dr. J. DePalma, and Dr. B. Ansaf * Creator :- Pratik Desai * * File :- Configs.h * * About :- This is an application created as part of the master thesis * research of Characterization and Applications of conductive * filament in 3D Printing. * ***************************************************************************/

#if !defined CONFIGS_H #define CONFIGS_H

/* Common include files */ #include #include

/* Type definitions */ typedef unsigned int errCode;

/* Common definitions */ #define LOW (0u) #define HIGH (1u)

/* Capsense definitions */ #define CAPSENSE_LAUNCH_TUNER_FIRST (true) #define CAPSENSE_INIT_DELAY (100) /* milliseconds */ #define CAPSENSE_PROX_NOISE (10) #define CAPSENSE_BTN_NOISE (10) #define CAPSENSE_BTN_PRESSED_INTV (500) /* milliseconds */ #define CAPSENSE_BOTH_PRESSED_INTV (500) /* milliseconds */ #define CAPSENSE_MODE_HELD_TIMEOUT (10000) /* milliseconds */ #define CAPSENSE_BASE_RESET_INTV (1500) /* milliseconds */

/* Sound definitions */ #define BUZZ_PWM_CLOCK_FRQ (100000)// Hz #define MASTER_PWM_CLK_FRQ (50000) // Hz #define BUZZ_PWM_CLK_DIV (15) // counts #define SOUND_DFLT_PRESSED_MILLIS (0) #define SOUND_PWM_PERIOD_OFFSET (1) // counts #define SOUND_PWM_OFF (0) #define SOUND_OCTAVE_4_MSTR_FRQ (1) #define SOUND_OCTAVE_5_MSTR_FRQ (2) #define SOUND_OCTAVE_6_MSTR_FRQ (4) #define SOUND_OCTAVE_7_MSTR_FRQ (8)

/* State machine definitions */ #define STATE_MACHINE_TIME_INTV (5) /* milliseconds */

132 #define STATE_MACHINE_STOP_TIME (10000) /* milliseconds */

/* Error codes */ #define OK_ERROR (0)

/* Debug Definitions - Define these to activate debug data */ #undef DEBUG_MAIN_SENSORS #undef DEBUG_SENSORS_LOWPASS #undef DEBUG_SENSORS_STATE

#endif

/* [] END OF FILE */

Appendix C.4 Octave Keyboard PSoC Application – Main.c

/**************************************************************************** **************************************************************************** * Project :- 3D Printed Octave Music Keyboard * Class :- Master Thesis Research Application * Advisors :- Dr. N. Jaksic, Dr. J. DePalma, and Dr. B. Ansaf * Creator :- Pratik Desai * * File :- Main.c * * About :- This is an application created as part of the master thesis research of Characterization and Applications of conductive filament in 3D Printing.

>>> Feature Implementation

v303 -> Reduced the number of output PWMs to 5. -> Added token based request system for pressed keys to request for any available PWMs to play the note. -> Improved the robustness of the Master pin pulse detection at the slave pin. -> Configured Slave pin as both, a digital input and, analog input. Digital input is configured with a pull down resistor and set to 0. -> A PGA is added to the Slave pin to amplify the signal at the slave pin for threshold detection. A comparator is added to the output of the PGA to detect pulses from the master pin. -> Slave pin interrupt has been removed and attached to the output from the comparator. -> This version of code needs a lot of clean up. It is left in this state so that previous implemetation of the master -> slave detection can be seen.

v302 -> Added Files

133 > sound.c and sound.h - For all tone generation. -> Added octaves C4, C5, C6 and C7. -> For master and slave functionality > Added PWM_Master to generate master pulses > Added Slave_Pin for master pulse detection

v301 -> Added configs.h - To add general settings -> CapSense configs CapSense_Config_Test_Key12_v100.xml imported -> These configs are optimised for a faster scan time. -> Current scan time for all buttons at ~4.6 ms. -> All notes on the C-5 octave calibrated with an oscilloscope.

>>> Further Improvements

-> Concatenate the keyboard > Implement a sysTick clock for better program control. > Add one wire master slave feature to auto adjust octaves. > Add more octave frequencies

-> Further improvement can be made by splitting up the buttons into two groups to utilize the dual CapSense resource. Potentially halving the scan time.

****************************************************************************/

#include #include #include "configs.h" #include "sound.h"

/**************************************************************************** * Global Variables ***************************************************************************/ volatile uint32_t Millis = 0; // Number of millis elasped volatile int64_t CompMillis = 0; // Octave setting on master volatile uint32_t PrevCompMillis = 0; // Octave setting on master volatile int64_t PrevMillisArray[] = {0, 0, 0, 0, 0}; volatile uint16_t MillisArrayIndx = 0; volatile enumOctave PrevValidOctave = E_OCTAVE_4; volatile uint16_t ValidMasterCount = 0; volatile bool ValidMaster = false;

/**************************************************************************** * Global Definitions ***************************************************************************/ #define CR 0x0D #define LF 0x0A

/* Used to insert a carriage return and line feed */ #define NewLine() UART_1_UartPutChar(CR); UART_1_UartPutChar(LF);

134 /**************************************************************************** * Function Prototypes ***************************************************************************/ void initModules (void); void initCapSense (void);

/**************************************************************************** * ISR Prototypes ***************************************************************************/ CY_ISR_PROTO( TickISR ); CY_ISR_PROTO( ComparatorISR );

/**************************************************************************** * ISR Functions ***************************************************************************/ CY_ISR( TickISR ) { /* Clear the interrupt flags */ Tick_Timer_ReadStatusRegister(); isr_Tick_ClearPending();

/* Increment the millis counter */ Millis++; }

CY_ISR( ComparatorISR ) { /* Clear the interrupt flags */ isr_Comparator_ClearPending();

/* Calculate the duration */ CompMillis = (int64_t)(Millis - PrevCompMillis); PrevCompMillis = Millis;

MillisArrayIndx = MillisArrayIndx % 5; MillisArrayIndx++;

/* Check duration matches previous valid master octave */ int32_t duration = Sound_getMasterDuration( PrevValidOctave ); int64_t millisDiff = CompMillis - duration; millisDiff = CompMillis - (int64_t)(duration); millisDiff = (int32_t)(CompMillis) - duration; millisDiff = (int64_t)(CompMillis - duration);

PrevMillisArray[MillisArrayIndx] = (int32_t)millisDiff;

if( CompMillis == Sound_getMasterDuration( PrevValidOctave ) ) { ValidMasterCount++;

/* Check if valid count has been reached */ ValidMaster = true; } else

135 { /* Reset the valid master and pulse count */ ValidMaster = false; ValidMasterCount = 0;

/* Check if duration matches other octave master durations */ enumOctave octave = E_OCTAVE_4; for( ; octave < E_OCTAVE_TOTAL; octave++ ) { if( CompMillis == Sound_getMasterDuration( octave ) ) { PrevValidOctave = octave; ValidMasterCount++; break; } } } }

/**************************************************************************** * Function Name: main ***************************************************************************** * * Summary: * Main function performs following functions: * 1. Enable global interrupts. * 2. Initialize CapSense CSD, EzI2C Start, all PWM blocks, * and start the sensor scanning loop. * 3. Process scanning results and communicates with Tuner GUI * if requested by user during reset. * 4. Increment C octave by 1, from C4 - C7 and back to C4 * when SW1 is pressed. * 5. If sensor is actived request a PWM token. When all 5 PWM tokens have * been allocated the Sound_requestPWM() returns E_PWM_NONE. * 6. If sensor is not active relsease PWN token. * * Parameters: * None * * Return: * None * ****************************************************************************/ int main() { /* Local Variables */ uint16_t pressedState = 0x00; uint16_t sw1ResetState = 0x00; uint16_t sw1State = 0x01; uint16_t sw1Pressed = 0x00; uint16_t musicKeyPressed = 0x00;

uint16_t masterPwmFrq[] = {1, 2, 4, 8}; // Hz uint16_t masterFrqIndx = 0; uint16_t masterDetected = false;

136 enumOctave octaveIndx = 0; uint16_t countLed = 0; uint16_t countBuzz = 0; uint32_t previousMillis = 0; uint32_t prevLedMillis = 0; /* milliseconds */

/* Enable global interrupts */ CyGlobalIntEnable;

/* Initialize all modules */ initModules();

/* Store SW1 state (Active Low) */ sw1ResetState = SW1_Read();

/* Main forever loop */ while(1u) { /* Launch Tuner if set in configs.h */ if(sw1ResetState != CAPSENSE_LAUNCH_TUNER_FIRST) { CapSense_CSD_TunerComm(); }

if(SW1_Read() == false) // SW1 is active low { if(sw1Pressed == false) { if( masterFrqIndx >= (( sizeof(masterPwmFrq) / sizeof(uint16_t) ) - 1 )) { masterFrqIndx = masterFrqIndx % ( (sizeof(masterPwmFrq) / sizeof(uint16_t)) - 1); } else { masterFrqIndx++; }

if( octaveIndx >= 3 ) { octaveIndx = octaveIndx % 3 ; } else octaveIndx++;

/* Set the master PWM frequency */ PWM_Master_WritePeriod((MASTER_PWM_CLK_FRQ / masterPwmFrq[masterFrqIndx]) - SOUND_PWM_PERIOD_OFFSET); PWM_Master_WriteCompare((MASTER_PWM_CLK_FRQ / (masterPwmFrq[masterFrqIndx] * 2)) - SOUND_PWM_PERIOD_OFFSET);

sw1Pressed = true;

137 masterDetected = false; }

} else { sw1Pressed = 0x00; }

/* Check if correct time has been detected by slave millis */ static uint16_t duration = 0;

/* clearing interrupt in main due to potential lockup */ isr_Comparator_ClearPending();

/* Check if valid master has been detected */ if(ValidMaster == true) { /* Set a latch for LED to indicate state of master */ masterDetected = true;

/* Match current octave to master if max octave */ if(PrevValidOctave >= E_OCTAVE_7) { duration = Sound_getMasterDuration( E_OCTAVE_7 ); octaveIndx = E_OCTAVE_7; } else { /* Set current octave to master + 1 */ octaveIndx = PrevValidOctave + 1; duration = Sound_getMasterDuration(octaveIndx); } }

if(masterDetected != true) { duration = 1000 / masterPwmFrq[masterFrqIndx]; }

if(Millis - prevLedMillis >= duration) { Led_1_Write(!Led_1_Read()); prevLedMillis = Millis; }

/* Start scanning all enabled sensors */ CapSense_CSD_ScanEnabledWidgets();

/* Wait for scanning to complete */ while(CapSense_CSD_IsBusy() != 0) { }

/* Update sensor baselines */ CapSense_CSD_UpdateEnabledBaselines();

138 /* Check if each button is pressed and sound the appropriate buzzer tone. Else turn off the buzzer */ static enumPwmKey pwmKey_C = E_PWM_NONE, pwmKey_Cs = E_PWM_NONE, pwmKey_D = E_PWM_NONE, pwmKey_Ds = E_PWM_NONE, pwmKey_E = E_PWM_NONE, pwmKey_F = E_PWM_NONE, pwmKey_Fs = E_PWM_NONE, pwmKey_G = E_PWM_NONE, pwmKey_Gs = E_PWM_NONE, pwmKey_A = E_PWM_NONE, pwmKey_As = E_PWM_NONE, pwmKey_B = E_PWM_NONE; if( CapSense_CSD_CheckIsWidgetActive( CapSense_CSD_BTN_C__BTN ) && sw1State != 0x00 ) { pwmKey_C = Sound_requestPwm( pwmKey_C, octaveIndx, E_NOTE_C ); } else pwmKey_C = Sound_releasePwm( pwmKey_C );

if( CapSense_CSD_CheckIsWidgetActive( CapSense_CSD_BTN_CS__BTN ) && sw1State != 0x00 ) { pwmKey_Cs = Sound_requestPwm( pwmKey_Cs, octaveIndx, E_NOTE_CS ); } else pwmKey_Cs = Sound_releasePwm( pwmKey_Cs );

if( CapSense_CSD_CheckIsWidgetActive( CapSense_CSD_BTN_D__BTN ) && sw1State != 0x00 ) { pwmKey_D = Sound_requestPwm( pwmKey_D, octaveIndx, E_NOTE_D ); } else pwmKey_D = Sound_releasePwm( pwmKey_D );

if( CapSense_CSD_CheckIsWidgetActive( CapSense_CSD_BTN_DS__BTN ) && sw1State != 0x00 ) { pwmKey_Ds = Sound_requestPwm( pwmKey_Ds, octaveIndx, E_NOTE_DS ); } else pwmKey_Ds = Sound_releasePwm( pwmKey_Ds );

if( CapSense_CSD_CheckIsWidgetActive( CapSense_CSD_BTN_E__BTN ) && sw1State != 0x00 ) { pwmKey_E = Sound_requestPwm( pwmKey_E, octaveIndx, E_NOTE_E ); }

139 else pwmKey_E = Sound_releasePwm( pwmKey_E );

if( CapSense_CSD_CheckIsWidgetActive( CapSense_CSD_BTN_F__BTN ) && sw1State != 0x00 ) { pwmKey_F = Sound_requestPwm( pwmKey_F, octaveIndx, E_NOTE_F ); } else pwmKey_F = Sound_releasePwm( pwmKey_F );

if( CapSense_CSD_CheckIsWidgetActive( CapSense_CSD_BTN_FS__BTN ) && sw1State != 0x00 ) { pwmKey_Fs = Sound_requestPwm( pwmKey_Fs, octaveIndx, E_NOTE_FS ); } else pwmKey_Fs = Sound_releasePwm( pwmKey_Fs );

if( CapSense_CSD_CheckIsWidgetActive( CapSense_CSD_BTN_G__BTN ) && sw1State != 0x00 ) { pwmKey_G = Sound_requestPwm( pwmKey_G, octaveIndx, E_NOTE_G ); } else pwmKey_G = Sound_releasePwm( pwmKey_G );

if( CapSense_CSD_CheckIsWidgetActive( CapSense_CSD_BTN_GS__BTN ) && sw1State != 0x00 ) { pwmKey_Gs = Sound_requestPwm( pwmKey_Gs, octaveIndx, E_NOTE_GS ); } else pwmKey_Gs = Sound_releasePwm( pwmKey_Gs );

if( CapSense_CSD_CheckIsWidgetActive( CapSense_CSD_BTN_A__BTN ) && sw1State != 0x00 ) { pwmKey_A = Sound_requestPwm( pwmKey_A, octaveIndx, E_NOTE_A ); } else pwmKey_A = Sound_releasePwm( pwmKey_A );

if( CapSense_CSD_CheckIsWidgetActive( CapSense_CSD_BTN_AS__BTN ) && sw1State != 0x00 ) { pwmKey_As = Sound_requestPwm( pwmKey_As, octaveIndx, E_NOTE_AS ); } else pwmKey_As = Sound_releasePwm( pwmKey_As );

140

if( CapSense_CSD_CheckIsWidgetActive( CapSense_CSD_BTN_B__BTN ) && sw1State != 0x00 ) { pwmKey_B = Sound_requestPwm( pwmKey_B, octaveIndx, E_NOTE_B ); } else pwmKey_B = Sound_releasePwm( pwmKey_B ); } }

/**************************************************************************** * Initialize All Modules ***************************************************************************/ void initModules(void) { /* Start the millis timer */ isr_Tick_ClearPending(); Tick_Timer_Start(); isr_Tick_StartEx( TickISR );

/* Initialize CapSense CSD and EzI2C Start the sensor scanning loop */ CapSense_CSD_TunerStart();

/* Start CapSense */ initCapSense();

/* Initialize the octave structure */ Sound_initOctaves();

/* Initialize the Pwm structure */ Sound_initPwm();

/* Start the master output */ PWM_Master_Start();

/* Start PGA and comparator */ PGA_Start(); PGA_SetGain(PGA_GAIN_04);

COMP_Start(); CyDelay(500); // some delay for PGA and comparator to startup

/* Initialize the slave pin */ isr_Comparator_ClearPending(); isr_Comparator_StartEx( ComparatorISR );

} void initCapSense(void) { /* Start CapSense module */ CapSense_CSD_Start();

/* Small delay to allow module to start */ CyDelay(100);

141 /* Initialize baselines for all sensors */ CapSense_CSD_InitializeAllBaselines();

/* Start scanning all enabled sensors */ CapSense_CSD_ScanEnabledWidgets();

/* Wait for scanning to complete */ while(CapSense_CSD_IsBusy() != 0) { }

/* Update sensor baselines */ CapSense_CSD_UpdateEnabledBaselines(); }

/* [] END OF FILE */

Appendix C.5 Octave Keyboard PSoC Application – Sound.h

/**************************************************************************** **************************************************************************** * Project :- 3D Printed Octave Music Keyboard * Class :- Master Thesis Research Application * Advisors :- Dr. N. Jaksic, Dr. J. DePalma, and Dr. B. Ansaf * Creator :- Pratik Desai * * File :- Sound.h * * About :- This is an application created as part of the master thesis * research of Characterization and Applications of conductive * filament in 3D Printing. * ***************************************************************************/ #include #include "configs.h"

#if !defined SOUND_H #define CONFIGS_H /**************************************************************************** * Global Definitions ***************************************************************************/ #define NO_TONE 0 #define C_Full_4 262 #define C_Sharp_4 277 #define D_Full_4 294 #define D_Sharp_4 311 #define E_Full_4 330 #define F_Full_4 349 #define F_Sharp_4 370 #define G_Full_4 392 #define G_Sharp_4 415 #define A_Full_4 440 #define A_Sharp_4 466

142 #define B_Full_4 494 #define C_Full_5 523 #define C_Sharp_5 554 #define D_Full_5 587 #define D_Sharp_5 622 #define E_Full_5 659 #define F_Full_5 698 #define F_Sharp_5 740 #define G_Full_5 784 #define G_Sharp_5 831 #define A_Full_5 880 #define A_Sharp_5 932 #define B_Full_5 988 #define C_Full_6 1047 #define C_Sharp_6 1109 #define D_Full_6 1175 #define D_Sharp_6 1245 #define E_Full_6 1319 #define F_Full_6 1397 #define F_Sharp_6 1480 #define G_Full_6 1568 #define G_Sharp_6 1661 #define A_Full_6 1760 #define A_Sharp_6 1865 #define B_Full_6 1976 #define C_Full_7 2093 #define C_Sharp_7 2217 #define D_Full_7 2349 #define D_Sharp_7 2489 #define E_Full_7 2637 #define F_Full_7 2794 #define F_Sharp_7 2960 #define G_Full_7 3136 #define G_Sharp_7 3322 #define A_Full_7 3520 #define A_Sharp_7 3729 #define B_Full_7 3951

/**************************************************************************** * Global Variables ***************************************************************************/ typedef enum { E_NOTE_C = 0, E_NOTE_CS, E_NOTE_D, E_NOTE_DS, E_NOTE_E, E_NOTE_F, E_NOTE_FS, E_NOTE_G, E_NOTE_GS, E_NOTE_A, E_NOTE_AS, E_NOTE_B, E_NOTE_TOTAL } enumNote;

143 typedef enum { E_OCTAVE_4 = 0, E_OCTAVE_5, E_OCTAVE_6, E_OCTAVE_7, E_OCTAVE_TOTAL } enumOctave; typedef enum { E_PWM_KEY_0 = 0, E_PWM_KEY_1, E_PWM_KEY_2, E_PWM_KEY_3, E_PWM_KEY_4, E_PWM_TOTAL, E_PWM_NONE } enumPwmKey; typedef struct { uint16_t frequency; uint16_t pwmPeriod; uint16_t pwmDivider; uint16_t pwmCompare; uint32_t pressedMillis; } note; typedef struct { note note[E_NOTE_TOTAL]; uint16_t masterFreq; uint16_t masterDuration; } octave; typedef struct { uint16_t pwmKey; bool isFree; void (*writePeriod)(uint16_t); void (*writeCompare)(uint16_t); void (*enable)(); void (*start)(); void (*stop)(); } pwm;

/**************************************************************************** * Function Prototypes ***************************************************************************/ void Sound_initOctaves ( void ); void Sound_initPwm ( void ); bool Sound_isMasterActive ( void ); uint16_t Sound_getMasterOctave ( uint32_t period ); uint16_t Sound_getMasterDuration ( enumOctave octave ); uint16_t Sound_getFrequency (enumOctave octave, enumNote note); uint16_t Sound_getPwmPeriod (enumOctave octave, enumNote note); uint16_t Sound_getPwmDivisor (enumOctave octave, enumNote note); uint16_t Sound_getPwmCompare (enumOctave octave, enumNote note); enumPwmKey Sound_requestPwm (enumPwmKey reqKey,

144 enumOctave octave, enumNote note); enumPwmKey Sound_releasePwm ( enumPwmKey key );

#endif

/* [] END OF FILE */

Appendix C.6 Octave Keyboard PSoC Application – Sound.c

/**************************************************************************** **************************************************************************** * Project :- 3D Printed Music Keyboard - 12 Key * Class :- Master Thesis Research Application * Advisors :- Dr. N. Jaksic, Dr. J. DePalma, and Dr. B. Ansaf * Creator :- Pratik Desai * * File :- Sound.c * * About :- This is an application created as part of the master thesis research of Characterization and Applications of conductive filament in 3D Printing.

***************************************************************************/ #include "sound.h"

/**************************************************************************** * Global Variables ***************************************************************************/ static octave Octave[E_OCTAVE_TOTAL]; static pwm Pwm[ E_PWM_TOTAL ] = { { E_PWM_KEY_0, true, buzzPWM_0_WritePeriod, buzzPWM_0_WriteCompare, buzzPWM_0_Enable, buzzPWM_0_Start, buzzPWM_0_Stop },

{ E_PWM_KEY_1, true, buzzPWM_1_WritePeriod, buzzPWM_1_WriteCompare, buzzPWM_1_Enable, buzzPWM_1_Start, buzzPWM_1_Stop },

145 { E_PWM_KEY_2, true, buzzPWM_2_WritePeriod, buzzPWM_2_WriteCompare, buzzPWM_2_Enable, buzzPWM_2_Start, buzzPWM_2_Stop },

{ E_PWM_KEY_3, true, buzzPWM_3_WritePeriod, buzzPWM_3_WriteCompare, buzzPWM_3_Enable, buzzPWM_3_Start, buzzPWM_3_Stop },

{ E_PWM_KEY_4, true, buzzPWM_4_WritePeriod, buzzPWM_4_WriteCompare, buzzPWM_4_Enable, buzzPWM_4_Start, buzzPWM_4_Stop }, }; static const uint16_t Octave_Freq[E_OCTAVE_TOTAL][E_NOTE_TOTAL] = {

{ C_Full_4, C_Sharp_4, D_Full_4, D_Sharp_4, E_Full_4, F_Full_4, F_Sharp_4, G_Full_4, G_Sharp_4, A_Full_4, A_Sharp_4, B_Full_4 },

{ C_Full_5, C_Sharp_5, D_Full_5, D_Sharp_5, E_Full_5, F_Full_5, F_Sharp_5, G_Full_5, G_Sharp_5, A_Full_5, A_Sharp_5, B_Full_5 },

{ C_Full_6, C_Sharp_6, D_Full_6, D_Sharp_6, E_Full_6, F_Full_6, F_Sharp_6, G_Full_6, G_Sharp_6, A_Full_6, A_Sharp_6, B_Full_6 },

{ C_Full_7, C_Sharp_7, D_Full_7, D_Sharp_7, E_Full_7, F_Full_7,

146 F_Sharp_7, G_Full_7, G_Sharp_7, A_Full_7, A_Sharp_7, B_Full_7 } }; static const uint16_t Octave_Master_Freq[E_OCTAVE_TOTAL] = { SOUND_OCTAVE_4_MSTR_FRQ, SOUND_OCTAVE_5_MSTR_FRQ, SOUND_OCTAVE_6_MSTR_FRQ, SOUND_OCTAVE_7_MSTR_FRQ, };

/**************************************************************************** * Function Prototypes ***************************************************************************/

/**************************************************************************** * Function Name: Sound_initOctave ***************************************************************************** * * Summary: * The octave setup function does the following: * 1. Initializes the octave structure array. * * Parameters: * None * * Return: * None * ****************************************************************************/ void Sound_initOctaves( void ) { enumOctave octave = E_OCTAVE_4; enumNote note = E_NOTE_C; uint16_t pwmPeriod;

/* Initialize the note frequencies, period */ for( octave = E_OCTAVE_4; octave < E_OCTAVE_TOTAL; octave++ ) { for( note = E_NOTE_C; note < E_NOTE_TOTAL; note++ ) { pwmPeriod = ( (BUZZ_PWM_CLOCK_FRQ / Octave_Freq[octave][note]) - SOUND_PWM_PERIOD_OFFSET); Octave[octave].note[note].frequency = Octave_Freq[octave][note]; Octave[octave].note[note].pwmPeriod = pwmPeriod; Octave[octave].note[note].pwmDivider = BUZZ_PWM_CLK_DIV; Octave[octave].note[note].pwmCompare = pwmPeriod / BUZZ_PWM_CLK_DIV; Octave[octave].note[note].pressedMillis = SOUND_DFLT_PRESSED_MILLIS; }

/* initialize the master frequencies for each octave */ Octave[octave].masterFreq = Octave_Master_Freq[octave]; Octave[octave].masterDuration = 1000 / Octave_Master_Freq[octave];

147 } }

/**************************************************************************** * Function Name: Sound_initPwm ***************************************************************************** * * Summary: * Initializes all defined PWMs in struct Pwm * * Parameters: * None * * Return: * None * ****************************************************************************/ void Sound_initPwm( void ) { enumPwmKey key;

/* Initialize all PWMs */ for( key = E_PWM_KEY_0; key < E_PWM_TOTAL; key++ ) { Pwm[key].start(); Pwm[key].stop(); } }

/**************************************************************************** * Function Name: Sound_isMasterActive ***************************************************************************** * * Summary: * Checks if there is a master keyboard connected * * Parameters: * None * * Return: * bool * ****************************************************************************/ bool Sound_isMasterActive( void ) { extern volatile bool ValidMaster; bool state = false;

state = ValidMaster; ValidMaster = false; return state; }

/**************************************************************************** * Function Name: Sound_getMasterOctave

148 ***************************************************************************** * * Summary: * Returns the current octave set on the master * * Parameters: * uint32_t period * * Return: * bool * ****************************************************************************/ uint16_t Sound_getMasterOctave( uint32_t period ) { enumOctave octave;

for( octave = E_OCTAVE_4; octave < E_OCTAVE_TOTAL; octave++) { uint16_t checkPeriod = 1000 / (octave + 1); if(period == checkPeriod) break; } //return (1000 / (octave + 1)); return octave; }

/**************************************************************************** * Function Name: Sound_getMasterDuration ***************************************************************************** * * Summary: * Returns the duration of the pulse from the master for a given octave * * Parameters: * enumOctave octave * * Return: * bool * ****************************************************************************/ uint16_t Sound_getMasterDuration( enumOctave octave ) { return Octave[octave].masterDuration; }

/**************************************************************************** * Function Name: Sound_getFrequency() ***************************************************************************** * * Summary: * Request the note frequency: * * Parameters: * uint16_t octave -> The octave number * uint16_t note -> The note *

149 * Return: * uint16_t frequency * ****************************************************************************/ uint16_t Sound_getFrequency (enumOctave octave, enumNote note) { return Octave[octave].note[note].frequency; }

/**************************************************************************** * Function Name: Sound_getPwmPeriod() ***************************************************************************** * * Summary: * Request the value for PWM period to generate note frequency: * * Parameters: * uint16_t octave -> The octave number * uint16_t note -> The note * * Return: * uint16_t pwmPeriod * ****************************************************************************/ uint16_t Sound_getPwmPeriod (enumOctave octave, enumNote note) { return Octave[octave].note[note].pwmPeriod; }

/**************************************************************************** * Function Name: Sound_getPwmDivisor() ***************************************************************************** * * Summary: * Request the value for the PWM compare value divisor: * * Parameters: * uint16_t octave -> The octave number * uint16_t note -> The note * * Return: * uint16_t pwmDivisor * ****************************************************************************/ uint16_t Sound_getPwmDivisor (enumOctave octave, enumNote note) { return Octave[octave].note[note].pwmDivider; }

/**************************************************************************** * Function Name: Sound_getCompare() ***************************************************************************** * * Summary:

150 * Request the pwm compare register value: * * Parameters: * uint16_t octave -> The octave number * uint16_t note -> The note * * Return: * uint16_t pwmCompare * ****************************************************************************/ uint16_t Sound_getPwmCompare(enumOctave octave, enumNote note) { return Octave[octave].note[note].pwmCompare; }

/**************************************************************************** * Function Name: Sound_requestPwm() ***************************************************************************** * * Summary: * Request the use of a PWM to play a note: * * Parameters: * uint16_t octave -> The octave number * uint16_t note -> The note * * Return: * enumPwmKey pwmKey * ****************************************************************************/ enumPwmKey Sound_requestPwm(enumPwmKey reqKey, enumOctave octave, enumNote note) { enumPwmKey pwmKey = E_PWM_NONE; // pwm key holder enumPwmKey key; // pwm struct index

/* Return key if already assigned */ if( reqKey != E_PWM_NONE ) { return reqKey; }

for( key = E_PWM_KEY_0; key < E_PWM_TOTAL; key++ ) { /* Find a free PWM */ if( Pwm[key].isFree == true ) { pwmKey = Pwm[key].pwmKey; Pwm[key].writePeriod( Octave[octave].note[note].pwmPeriod ); Pwm[key].writeCompare( Octave[octave].note[note].pwmCompare ); Pwm[key].enable(); Pwm[key].isFree = false; break; } }

151 return pwmKey; }

/**************************************************************************** * Function Name: Sound_releasePwm() ***************************************************************************** * * Summary: * Release the PWM after playing a note: * * Parameters: * enumPwmKey key -> The pwm key index * * Return: * enumPwmKey pwmKey * ****************************************************************************/ enumPwmKey Sound_releasePwm( enumPwmKey key ) { if( key!= E_PWM_NONE ) { Pwm[key].stop(); Pwm[key].isFree = true; key = E_PWM_NONE; }

return key; } /* [] END OF FILE */

152